kconfig: Add LSMOD=file to override the lsmod for localmodconfig
[safe/jmp/linux-2.6] / scripts / kconfig / Makefile
1 # ===========================================================================
2 # Kernel configuration targets
3 # These targets are used from top-level makefile
4
5 PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \
6         localmodconfig localyesconfig
7
8 ifdef KBUILD_KCONFIG
9 Kconfig := $(KBUILD_KCONFIG)
10 else
11 Kconfig := arch/$(SRCARCH)/Kconfig
12 endif
13
14 xconfig: $(obj)/qconf
15         $< $(Kconfig)
16
17 gconfig: $(obj)/gconf
18         $< $(Kconfig)
19
20 menuconfig: $(obj)/mconf
21         $< $(Kconfig)
22
23 config: $(obj)/conf
24         $< $(Kconfig)
25
26 oldconfig: $(obj)/conf
27         $< -o $(Kconfig)
28
29 silentoldconfig: $(obj)/conf
30         $(Q)mkdir -p include/generated
31         $< -s $(Kconfig)
32
33 # if no path is given, then use src directory to find file
34 ifdef LSMOD
35 LSMOD_F = $(shell if [ `basename $(LSMOD)` == $(LSMOD) ]; then \
36                 echo $(objtree)/$(LSMOD);                       \
37         else                                                    \
38                 echo $(LSMOD);                                  \
39         fi)
40 endif
41
42 localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
43         $(Q)mkdir -p include/generated
44         $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
45         $(Q)if [ -f .config ]; then                             \
46                         cmp -s .tmp.config .config ||           \
47                         (mv -f .config .config.old.1;           \
48                          mv -f .tmp.config .config;             \
49                          $(obj)/conf -s $(Kconfig);             \
50                          mv -f .config.old.1 .config.old)       \
51         else                                                    \
52                         mv -f .tmp.config .config;              \
53                         $(obj)/conf -s $(Kconfig);              \
54         fi
55         $(Q)rm -f .tmp.config
56
57 localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
58         $(Q)mkdir -p include/generated
59         $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
60         $(Q)sed -i s/=m/=y/ .tmp.config
61         $(Q)if [ -f .config ]; then                             \
62                         cmp -s .tmp.config .config ||           \
63                         (mv -f .config .config.old.1;           \
64                          mv -f .tmp.config .config;             \
65                          $(obj)/conf -s $(Kconfig);             \
66                          mv -f .config.old.1 .config.old)       \
67         else                                                    \
68                         mv -f .tmp.config .config;              \
69                         $(obj)/conf -s $(Kconfig);              \
70         fi
71         $(Q)rm -f .tmp.config
72
73 # Create new linux.pot file
74 # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
75 # The symlink is used to repair a deficiency in arch/um
76 update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
77         $(Q)echo "  GEN config"
78         $(Q)xgettext --default-domain=linux              \
79             --add-comments --keyword=_ --keyword=N_      \
80             --from-code=UTF-8                            \
81             --files-from=scripts/kconfig/POTFILES.in     \
82             --output $(obj)/config.pot
83         $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
84         $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch
85         $(Q)(for i in `ls arch/*/Kconfig`;               \
86             do                                           \
87                 echo "  GEN $$i";                        \
88                 $(obj)/kxgettext $$i                     \
89                      >> $(obj)/config.pot;               \
90             done )
91         $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
92             --output $(obj)/linux.pot
93         $(Q)rm -f arch/um/Kconfig.arch
94         $(Q)rm -f $(obj)/config.pot
95
96 PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
97
98 randconfig: $(obj)/conf
99         $< -r $(Kconfig)
100
101 allyesconfig: $(obj)/conf
102         $< -y $(Kconfig)
103
104 allnoconfig: $(obj)/conf
105         $< -n $(Kconfig)
106
107 allmodconfig: $(obj)/conf
108         $< -m $(Kconfig)
109
110 defconfig: $(obj)/conf
111 ifeq ($(KBUILD_DEFCONFIG),)
112         $< -d $(Kconfig)
113 else
114         @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
115         $(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
116 endif
117
118 %_defconfig: $(obj)/conf
119         $(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig)
120
121 # Help text used by make help
122 help:
123         @echo  '  config          - Update current config utilising a line-oriented program'
124         @echo  '  menuconfig      - Update current config utilising a menu based program'
125         @echo  '  xconfig         - Update current config utilising a QT based front-end'
126         @echo  '  gconfig         - Update current config utilising a GTK based front-end'
127         @echo  '  oldconfig       - Update current config utilising a provided .config as base'
128         @echo  '  localmodconfig  - Update current config disabling modules not loaded'
129         @echo  '  localyesconfig  - Update current config converting local mods to core'
130         @echo  '  silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
131         @echo  '  randconfig      - New config with random answer to all options'
132         @echo  '  defconfig       - New config with default answer to all options'
133         @echo  '  allmodconfig    - New config selecting modules when possible'
134         @echo  '  allyesconfig    - New config where all options are accepted with yes'
135         @echo  '  allnoconfig     - New config where all options are answered with no'
136
137 # lxdialog stuff
138 check-lxdialog  := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
139
140 # Use recursively expanded variables so we do not call gcc unless
141 # we really need to do so. (Do not call gcc as part of make mrproper)
142 HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
143 HOST_LOADLIBES   = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
144
145 HOST_EXTRACFLAGS += -DLOCALE
146
147
148 # ===========================================================================
149 # Shared Makefile for the various kconfig executables:
150 # conf:   Used for defconfig, oldconfig and related targets
151 # mconf:  Used for the menuconfig target
152 #         Utilizes the lxdialog package
153 # qconf:  Used for the xconfig target
154 #         Based on QT which needs to be installed to compile it
155 # gconf:  Used for the gconfig target
156 #         Based on GTK which needs to be installed to compile it
157 # object files used by all kconfig flavours
158
159 lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
160 lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
161
162 conf-objs       := conf.o  zconf.tab.o
163 mconf-objs      := mconf.o zconf.tab.o $(lxdialog)
164 kxgettext-objs  := kxgettext.o zconf.tab.o
165
166 hostprogs-y := conf qconf gconf kxgettext
167
168 ifeq ($(MAKECMDGOALS),menuconfig)
169         hostprogs-y += mconf
170 endif
171
172 ifeq ($(MAKECMDGOALS),xconfig)
173         qconf-target := 1
174 endif
175 ifeq ($(MAKECMDGOALS),gconfig)
176         gconf-target := 1
177 endif
178
179
180 ifeq ($(qconf-target),1)
181 qconf-cxxobjs   := qconf.o
182 qconf-objs      := kconfig_load.o zconf.tab.o
183 endif
184
185 ifeq ($(gconf-target),1)
186 gconf-objs      := gconf.o kconfig_load.o zconf.tab.o
187 endif
188
189 clean-files     := lkc_defs.h qconf.moc .tmp_qtcheck \
190                    .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
191 clean-files     += mconf qconf gconf
192 clean-files     += config.pot linux.pot
193
194 # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
195 PHONY += $(obj)/dochecklxdialog
196 $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
197 $(obj)/dochecklxdialog:
198         $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES)
199
200 always := dochecklxdialog
201
202 # Add environment specific flags
203 HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
204
205 # generated files seem to need this to find local include files
206 HOSTCFLAGS_lex.zconf.o  := -I$(src)
207 HOSTCFLAGS_zconf.tab.o  := -I$(src)
208
209 HOSTLOADLIBES_qconf     = $(KC_QT_LIBS) -ldl
210 HOSTCXXFLAGS_qconf.o    = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
211
212 HOSTLOADLIBES_gconf     = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
213 HOSTCFLAGS_gconf.o      = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
214                           -D LKC_DIRECT_LINK
215
216 $(obj)/qconf.o: $(obj)/.tmp_qtcheck
217
218 ifeq ($(qconf-target),1)
219 $(obj)/.tmp_qtcheck: $(src)/Makefile
220 -include $(obj)/.tmp_qtcheck
221
222 # QT needs some extra effort...
223 $(obj)/.tmp_qtcheck:
224         @set -e; echo "  CHECK   qt"; dir=""; pkg=""; \
225         pkg-config --exists qt 2> /dev/null && pkg=qt; \
226         pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
227         if [ -n "$$pkg" ]; then \
228           cflags="\$$(shell pkg-config $$pkg --cflags)"; \
229           libs="\$$(shell pkg-config $$pkg --libs)"; \
230           moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
231           dir="$$(pkg-config $$pkg --variable=prefix)"; \
232         else \
233           for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
234             if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
235           done; \
236           if [ -z "$$dir" ]; then \
237             echo "*"; \
238             echo "* Unable to find the QT3 installation. Please make sure that"; \
239             echo "* the QT3 development package is correctly installed and"; \
240             echo "* either install pkg-config or set the QTDIR environment"; \
241             echo "* variable to the correct location."; \
242             echo "*"; \
243             false; \
244           fi; \
245           libpath=$$dir/lib; lib=qt; osdir=""; \
246           $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
247             osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
248           test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
249           test -f $$libpath/libqt-mt.so && lib=qt-mt; \
250           cflags="-I$$dir/include"; \
251           libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
252           moc="$$dir/bin/moc"; \
253         fi; \
254         if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
255           echo "*"; \
256           echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
257           echo "*"; \
258           moc="/usr/bin/moc"; \
259         fi; \
260         echo "KC_QT_CFLAGS=$$cflags" > $@; \
261         echo "KC_QT_LIBS=$$libs" >> $@; \
262         echo "KC_QT_MOC=$$moc" >> $@
263 endif
264
265 $(obj)/gconf.o: $(obj)/.tmp_gtkcheck
266
267 ifeq ($(gconf-target),1)
268 -include $(obj)/.tmp_gtkcheck
269
270 # GTK needs some extra effort, too...
271 $(obj)/.tmp_gtkcheck:
272         @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then               \
273                 if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then                  \
274                         touch $@;                                                               \
275                 else                                                                    \
276                         echo "*";                                                       \
277                         echo "* GTK+ is present but version >= 2.0.0 is required.";     \
278                         echo "*";                                                       \
279                         false;                                                          \
280                 fi                                                                      \
281         else                                                                            \
282                 echo "*";                                                               \
283                 echo "* Unable to find the GTK+ installation. Please make sure that";   \
284                 echo "* the GTK+ 2.0 development package is correctly installed...";    \
285                 echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0.";                 \
286                 echo "*";                                                               \
287                 false;                                                                  \
288         fi
289 endif
290
291 $(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c
292
293 $(obj)/kconfig_load.o: $(obj)/lkc_defs.h
294
295 $(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h
296
297 $(obj)/gconf.o: $(obj)/lkc_defs.h
298
299 $(obj)/%.moc: $(src)/%.h
300         $(KC_QT_MOC) -i $< -o $@
301
302 $(obj)/lkc_defs.h: $(src)/lkc_proto.h
303         sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
304
305 # Extract gconf menu items for I18N support
306 $(obj)/gconf.glade.h: $(obj)/gconf.glade
307         intltool-extract --type=gettext/glade $(obj)/gconf.glade
308
309 ###
310 # The following requires flex/bison/gperf
311 # By default we use the _shipped versions, uncomment the following line if
312 # you are modifying the flex/bison src.
313 # LKC_GENPARSER := 1
314
315 ifdef LKC_GENPARSER
316
317 $(obj)/zconf.tab.c: $(src)/zconf.y
318 $(obj)/lex.zconf.c: $(src)/zconf.l
319 $(obj)/zconf.hash.c: $(src)/zconf.gperf
320
321 %.tab.c: %.y
322         bison -l -b $* -p $(notdir $*) $<
323         cp $@ $@_shipped
324
325 lex.%.c: %.l
326         flex -L -P$(notdir $*) -o$@ $<
327         cp $@ $@_shipped
328
329 %.hash.c: %.gperf
330         gperf < $< > $@
331         cp $@ $@_shipped
332
333 endif