Build system overhauled to use Kbuild (XCC)
[akaros.git] / 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
6
7 ifdef KBUILD_KCONFIG
8 Kconfig := $(KBUILD_KCONFIG)
9 else
10 Kconfig := Kconfig
11 endif
12
13 xconfig: $(obj)/qconf
14         $< $(Kconfig)
15
16 gconfig: $(obj)/gconf
17         $< $(Kconfig)
18
19 menuconfig: $(obj)/mconf
20         $< $(Kconfig)
21
22 config: $(obj)/conf
23         $< $(Kconfig)
24
25 nconfig: $(obj)/nconf
26         $< $(Kconfig)
27
28 # lxdialog stuff
29 check-lxdialog  := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
30
31 # Use recursively expanded variables so we do not call gcc unless
32 # we really need to do so. (Do not call gcc as part of make mrproper)
33 HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
34                     -DLOCALE
35
36 # ===========================================================================
37 # Shared Makefile for the various kconfig executables:
38 # conf:   Used for defconfig, oldconfig and related targets
39 # nconf:  Used for the nconfig target.
40 #         Utilizes ncurses
41 # mconf:  Used for the menuconfig target
42 #         Utilizes the lxdialog package
43 # qconf:  Used for the xconfig target
44 #         Based on QT which needs to be installed to compile it
45 # gconf:  Used for the gconfig target
46 #         Based on GTK which needs to be installed to compile it
47 # object files used by all kconfig flavours
48
49 lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
50 lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
51
52 conf-objs       := conf.o  zconf.tab.o
53 mconf-objs     := mconf.o zconf.tab.o $(lxdialog)
54 nconf-objs     := nconf.o zconf.tab.o nconf.gui.o
55 kxgettext-objs  := kxgettext.o zconf.tab.o
56
57 hostprogs-y := conf qconf gconf kxgettext
58
59 ifeq ($(MAKECMDGOALS),nconfig)
60         hostprogs-y += nconf
61 endif
62
63 ifeq ($(MAKECMDGOALS),menuconfig)
64         hostprogs-y += mconf
65 endif
66
67 ifeq ($(MAKECMDGOALS),xconfig)
68         qconf-target := 1
69 endif
70 ifeq ($(MAKECMDGOALS),gconfig)
71         gconf-target := 1
72 endif
73
74
75 ifeq ($(qconf-target),1)
76 qconf-cxxobjs   := qconf.o
77 qconf-objs      := kconfig_load.o zconf.tab.o
78 endif
79
80 ifeq ($(gconf-target),1)
81 gconf-objs      := gconf.o kconfig_load.o zconf.tab.o
82 endif
83
84 clean-files     := lkc_defs.h qconf.moc .tmp_qtcheck \
85                    .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
86 clean-files     += mconf qconf gconf nconf
87 clean-files     += config.pot linux.pot
88
89 # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
90 PHONY += $(obj)/dochecklxdialog
91 $(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
92 $(obj)/dochecklxdialog:
93         $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
94
95 always := dochecklxdialog
96
97 # Add environment specific flags
98 HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
99
100 # generated files seem to need this to find local include files
101 HOSTCFLAGS_lex.zconf.o  := -I$(src)
102 HOSTCFLAGS_zconf.tab.o  := -I$(src)
103
104 HOSTLOADLIBES_qconf     = $(KC_QT_LIBS) -ldl
105 HOSTCXXFLAGS_qconf.o    = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
106
107 HOSTLOADLIBES_gconf     = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` -ldl
108 HOSTCFLAGS_gconf.o      = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
109                           -D LKC_DIRECT_LINK
110
111 HOSTLOADLIBES_mconf   = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
112
113 HOSTLOADLIBES_nconf     = -lmenu -lpanel -lncurses
114 $(obj)/qconf.o: $(obj)/.tmp_qtcheck
115
116 ifeq ($(qconf-target),1)
117 $(obj)/.tmp_qtcheck: $(src)/Makefile
118 -include $(obj)/.tmp_qtcheck
119
120 # QT needs some extra effort...
121 $(obj)/.tmp_qtcheck:
122         @set -e; echo "  CHECK   qt"; dir=""; pkg=""; \
123         if ! pkg-config --exists QtCore 2> /dev/null; then \
124             echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \
125             pkg-config --exists qt 2> /dev/null && pkg=qt; \
126             pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
127             if [ -n "$$pkg" ]; then \
128               cflags="\$$(shell pkg-config $$pkg --cflags)"; \
129               libs="\$$(shell pkg-config $$pkg --libs)"; \
130               moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
131               dir="$$(pkg-config $$pkg --variable=prefix)"; \
132             else \
133               for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
134                 if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
135               done; \
136               if [ -z "$$dir" ]; then \
137                 echo "*"; \
138                 echo "* Unable to find any QT installation. Please make sure that"; \
139                 echo "* the QT4 or QT3 development package is correctly installed and"; \
140                 echo "* either qmake can be found or install pkg-config or set"; \
141                 echo "* the QTDIR environment variable to the correct location."; \
142                 echo "*"; \
143                 false; \
144               fi; \
145               libpath=$$dir/lib; lib=qt; osdir=""; \
146               $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
147                 osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
148               test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
149               test -f $$libpath/libqt-mt.so && lib=qt-mt; \
150               cflags="-I$$dir/include"; \
151               libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
152               moc="$$dir/bin/moc"; \
153             fi; \
154             if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
155               echo "*"; \
156               echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
157               echo "*"; \
158               moc="/usr/bin/moc"; \
159             fi; \
160         else \
161           cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \
162           libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \
163           binpath="\$$(shell pkg-config QtCore --variable=prefix)"; \
164           moc="$$binpath/bin/moc"; \
165         fi; \
166         echo "KC_QT_CFLAGS=$$cflags" > $@; \
167         echo "KC_QT_LIBS=$$libs" >> $@; \
168         echo "KC_QT_MOC=$$moc" >> $@
169 endif
170
171 $(obj)/gconf.o: $(obj)/.tmp_gtkcheck
172
173 ifeq ($(gconf-target),1)
174 -include $(obj)/.tmp_gtkcheck
175
176 # GTK needs some extra effort, too...
177 $(obj)/.tmp_gtkcheck:
178         @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then               \
179                 if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then                  \
180                         touch $@;                                                               \
181                 else                                                                    \
182                         echo "*";                                                       \
183                         echo "* GTK+ is present but version >= 2.0.0 is required.";     \
184                         echo "*";                                                       \
185                         false;                                                          \
186                 fi                                                                      \
187         else                                                                            \
188                 echo "*";                                                               \
189                 echo "* Unable to find the GTK+ installation. Please make sure that";   \
190                 echo "* the GTK+ 2.0 development package is correctly installed...";    \
191                 echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0.";                 \
192                 echo "*";                                                               \
193                 false;                                                                  \
194         fi
195 endif
196
197 $(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c
198
199 $(obj)/kconfig_load.o: $(obj)/lkc_defs.h
200
201 $(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h
202
203 $(obj)/gconf.o: $(obj)/lkc_defs.h
204
205 $(obj)/%.moc: $(src)/%.h
206         $(KC_QT_MOC) -i $< -o $@
207
208 $(obj)/lkc_defs.h: $(src)/lkc_proto.h
209         sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
210
211 # Extract gconf menu items for I18N support
212 $(obj)/gconf.glade.h: $(obj)/gconf.glade
213         intltool-extract --type=gettext/glade $(obj)/gconf.glade
214