build: fix xconfig target
[openwrt/openwrt.git] / scripts / config / Makefile
1 # ===========================================================================
2 # OpenWrt configuration targets
3 # These targets are used from top-level makefile
4
5 # ===========================================================================
6 # Shared Makefile for the various kconfig executables:
7 # conf: Used for defconfig, oldconfig and related targets
8 # mconf: Used for the mconfig target.
9 # Utilizes the lxdialog package
10 # qconf: Used for the xconfig target
11 # Based on Qt which needs to be installed to compile it
12 # object files used by all kconfig flavours
13
14
15 # Platform specific fixes
16 #
17 # FreeBSD
18
19 check_lxdialog = $(shell $(SHELL) $(CURDIR)/lxdialog/check-lxdialog.sh -$(1))
20 export CFLAGS += -DKBUILD_NO_NLS -I. $(call check_lxdialog,ccflags)
21 export CXXFLAGS += -DKBUILD_NO_NLS
22
23 conf-objs := conf.o zconf.tab.o
24 mconf-objs := mconf.o zconf.tab.o
25 qconf-cxxobjs := qconf.o
26 qconf-objs := zconf.tab.o
27
28 lxdialog-objs := \
29 lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o \
30 lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
31
32 clean-files := zconf.tab.c zconf.lex.c zconf.hash.c
33 # Remove qconf junk files
34 clean-files += $(qconf-cxxobjs) qconf.moc .tmp_qtcheck qconf
35
36 all: conf mconf
37
38 conf: $(conf-objs)
39 mconf: $(mconf-objs) $(lxdialog-objs)
40 $(CC) -o $@ $^ $(call check_lxdialog,ldflags $(CC))
41 qconf: $(qconf-cxxobjs) $(qconf-objs)
42 ifneq ($(DISTRO-PKG-CONFIG),)
43 $(CXX) -o $@ $^ $(HOSTLOADLIBES_qconf)
44 else
45 echo "You don't have 'pkg-config' installed. Cannot continue"
46 echo "For now, you may use 'make menuconfig' instead of 'make xconfig'"
47 endif
48
49 clean:
50 rm -f *.o lxdialog/*.o $(clean-files) conf mconf
51
52 zconf.tab.o: zconf.lex.c zconf.hash.c confdata.c
53
54 kconfig_load.o: lkc_defs.h
55
56 zconf.tab.c: zconf.y $(wildcard zconf.tab.c_shipped)
57 zconf.lex.c: zconf.l $(wildcard zconf.lex.c_shipped)
58 zconf.hash.c: zconf.gperf $(wildcard zconf.hash.c_shipped)
59
60 %.tab.c: %.y
61 cp $@_shipped $@ || bison -l -b $* -p $(notdir $*) $<
62
63 %.lex.c: %.l
64 cp $@_shipped $@ || flex -L -P$(notdir $*) -o$@ $<
65
66 %.hash.c: %.gperf
67 cp $@_shipped $@ || gperf < $< > $@
68
69 ifeq ($(MAKECMDGOALS),qconf)
70 qconf.o: .tmp_qtcheck
71 .tmp_qtcheck: Makefile
72 -include .tmp_qtcheck
73
74 # Qt needs some extra effort...
75 .tmp_qtcheck:
76 @set -e; echo " CHECK qt"; \
77 if $(DISTRO-PKG-CONFIG) --exists Qt5Core; then \
78 cflags="-std=c++11 -fPIC `$(DISTRO-PKG-CONFIG) --cflags Qt5Core Qt5Gui Qt5Widgets`"; \
79 libs=`$(DISTRO-PKG-CONFIG) --libs Qt5Core Qt5Gui Qt5Widgets`; \
80 moc=`$(DISTRO-PKG-CONFIG) --variable=host_bins Qt5Core`/moc; \
81 elif $(DISTRO-PKG-CONFIG) --exists QtCore; then \
82 cflags=`$(DISTRO-PKG-CONFIG) --cflags QtCore QtGui`; \
83 libs=`$(DISTRO-PKG-CONFIG) --libs QtCore QtGui`; \
84 moc=`$(DISTRO-PKG-CONFIG) --variable=moc_location QtCore`; \
85 else \
86 echo >&2 "*"; \
87 echo >&2 "* Could not find Qt via $(DISTRO-PKG-CONFIG)."; \
88 echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"; \
89 echo >&2 "*"; \
90 exit 1; \
91 fi; \
92 echo "KC_QT_CFLAGS=$$cflags" > $@; \
93 echo "KC_QT_LIBS=$$libs" >> $@; \
94 echo "KC_QT_MOC=$$moc" >> $@
95 endif
96
97 #Define compiler flags to build qconf
98 HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
99 HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
100
101 qconf.o: qconf.moc
102 qconf.o: CXXFLAGS+=$(HOSTCXXFLAGS_qconf.o)
103
104 moc = $(KC_QT_MOC) -i $< -o $@
105
106 %.moc: %.h .tmp_qtcheck
107 $(call moc)