build: simplify building *config targets
[oweals/openwrt.git] / scripts / config / Makefile
index 96202732028d2ac0034c984b60ba1eadf7883011..1f9184e3aa2d75a9288735cd16d69ff80de9bb79 100644 (file)
@@ -20,8 +20,6 @@ check_lxdialog = $(shell $(SHELL) $(CURDIR)/lxdialog/check-lxdialog.sh -$(1))
 export CFLAGS += -DKBUILD_NO_NLS -I. $(call check_lxdialog,ccflags)
 export CXXFLAGS += -DKBUILD_NO_NLS
 
-DISTRO-PKG-CONFIG := $(shell which -a pkg-config | grep -E '\/usr' | head -n 1)
-
 conf-objs      := conf.o zconf.tab.o
 mconf-objs     := mconf.o zconf.tab.o
 qconf-cxxobjs  := qconf.o
@@ -31,9 +29,9 @@ lxdialog-objs := \
        lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o \
        lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
 
-clean-files    := zconf.tab.c lex.zconf.c zconf.hash.c
+clean-files    := zconf.tab.c zconf.lex.c zconf.hash.c
 # Remove qconf junk files
-clean-files    += $(qconf-cxxobjs) qconf.moc .tmp_qtcheck
+clean-files    += $(qconf-cxxobjs) qconf.moc .tmp_qtcheck qconf
 
 all: conf mconf
 
@@ -41,12 +39,7 @@ conf: $(conf-objs)
 mconf: $(mconf-objs) $(lxdialog-objs)
        $(CC) -o $@ $^ $(call check_lxdialog,ldflags $(CC))
 qconf: $(qconf-cxxobjs) $(qconf-objs)
-ifneq ($(DISTRO-PKG-CONFIG),)
-       $(CXX) $(HOSTLOADLIBES_qconf) -o $@ $^
-else
-       echo "You don't have 'pkg-config' installed. Cannot continue"
-       echo "For now, you may use 'make menuconfig' instead of 'make xconfig'"
-endif
+       $(CXX) -o $@ $^ $(HOSTLOADLIBES_qconf)
 
 clean:
        rm -f *.o lxdialog/*.o $(clean-files) conf mconf
@@ -55,9 +48,9 @@ zconf.tab.o: zconf.lex.c zconf.hash.c confdata.c
 
 kconfig_load.o: lkc_defs.h
 
-zconf.tab.c: zconf.y
-zconf.lex.c: zconf.l
-zconf.hash.c: zconf.gperf
+zconf.tab.c: zconf.y $(wildcard zconf.tab.c_shipped)
+zconf.lex.c: zconf.l $(wildcard zconf.lex.c_shipped)
+zconf.hash.c: zconf.gperf $(wildcard zconf.hash.c_shipped)
 
 %.tab.c: %.y
        cp $@_shipped $@ || bison -l -b $* -p $(notdir $*) $<
@@ -76,17 +69,17 @@ qconf.o: .tmp_qtcheck
 # Qt needs some extra effort...
 .tmp_qtcheck:
        @set -e; echo "  CHECK   qt"; \
-       if $(DISTRO-PKG-CONFIG) --exists Qt5Core; then \
-           cflags="-std=c++11 -fPIC `$(DISTRO-PKG-CONFIG) --cflags Qt5Core Qt5Gui Qt5Widgets`"; \
-           libs=`$(DISTRO-PKG-CONFIG) --libs Qt5Core Qt5Gui Qt5Widgets`; \
-           moc=`$(DISTRO-PKG-CONFIG) --variable=host_bins Qt5Core`/moc; \
-       elif $(DISTRO-PKG-CONFIG) --exists QtCore; then \
-           cflags=`$(DISTRO-PKG-CONFIG) --cflags QtCore QtGui`; \
-           libs=`$(DISTRO-PKG-CONFIG) --libs QtCore QtGui`; \
-           moc=`$(DISTRO-PKG-CONFIG) --variable=moc_location QtCore`; \
+       if pkg-config --exists Qt5Core; then \
+           cflags="-std=c++11 -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets`"; \
+           libs=`pkg-config --libs Qt5Core Qt5Gui Qt5Widgets`; \
+           moc=`pkg-config --variable=host_bins Qt5Core`/moc; \
+       elif pkg-config --exists QtCore; then \
+           cflags=`pkg-config --cflags QtCore QtGui`; \
+           libs=`pkg-config --libs QtCore QtGui`; \
+           moc=`pkg-config --variable=moc_location QtCore`; \
        else \
            echo >&2 "*"; \
-           echo >&2 "* Could not find Qt via $(DISTRO-PKG-CONFIG)."; \
+           echo >&2 "* Could not find Qt via pkg-config."; \
            echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"; \
            echo >&2 "*"; \
            exit 1; \