openwrt/scripts/config/Makefile
Eneas U de Queiroz 8636a17214 build: simplify building *config targets
Instead of passing pkg-config location through a variable when building
qconf (make xconfig), prepend its parent directory to the PATH, as it is
being done for other conf targets.

Use a Makefile pattern rule to group all 'scripts/config/%onf'
(currently conf, mconf, qconf) targets in a single rule.  Add -O2 to
CFLAGS when building them as well.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2020-04-09 12:51:10 +02:00

103 lines
3.0 KiB
Makefile

# ===========================================================================
# OpenWrt configuration targets
# These targets are used from top-level makefile
# ===========================================================================
# Shared Makefile for the various kconfig executables:
# conf: Used for defconfig, oldconfig and related targets
# mconf: Used for the mconfig target.
# Utilizes the lxdialog package
# qconf: Used for the xconfig target
# Based on Qt which needs to be installed to compile it
# object files used by all kconfig flavours
# Platform specific fixes
#
# FreeBSD
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
conf-objs := conf.o zconf.tab.o
mconf-objs := mconf.o zconf.tab.o
qconf-cxxobjs := qconf.o
qconf-objs := zconf.tab.o
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 zconf.lex.c zconf.hash.c
# Remove qconf junk files
clean-files += $(qconf-cxxobjs) qconf.moc .tmp_qtcheck qconf
all: conf mconf
conf: $(conf-objs)
mconf: $(mconf-objs) $(lxdialog-objs)
$(CC) -o $@ $^ $(call check_lxdialog,ldflags $(CC))
qconf: $(qconf-cxxobjs) $(qconf-objs)
$(CXX) -o $@ $^ $(HOSTLOADLIBES_qconf)
clean:
rm -f *.o lxdialog/*.o $(clean-files) conf mconf
zconf.tab.o: zconf.lex.c zconf.hash.c confdata.c
kconfig_load.o: lkc_defs.h
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 $*) $<
%.lex.c: %.l
cp $@_shipped $@ || flex -L -P$(notdir $*) -o$@ $<
%.hash.c: %.gperf
cp $@_shipped $@ || gperf < $< > $@
ifeq ($(MAKECMDGOALS),qconf)
qconf.o: .tmp_qtcheck
.tmp_qtcheck: Makefile
-include .tmp_qtcheck
# Qt needs some extra effort...
.tmp_qtcheck:
@set -e; echo " CHECK qt"; \
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 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; \
fi; \
echo "KC_QT_CFLAGS=$$cflags" > $@; \
echo "KC_QT_LIBS=$$libs" >> $@; \
echo "KC_QT_MOC=$$moc" >> $@
endif
#Define compiler flags to build qconf
HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
qconf.o: qconf.moc
qconf.o: CXXFLAGS+=$(HOSTCXXFLAGS_qconf.o)
moc = $(KC_QT_MOC) -i $< -o $@
%.moc: %.h .tmp_qtcheck
$(call moc)