include(ExternalProject)
macro(kconfig_set_variables)
- set(MCONF ${IDF_PATH}/tools/kconfig/mconf)
+ set(MCONF kconfig_bin/mconf)
set_default(SDKCONFIG ${PROJECT_PATH}/sdkconfig)
set(SDKCONFIG_HEADER ${CMAKE_BINARY_DIR}/sdkconfig.h)
set(ROOT_KCONFIG ${IDF_PATH}/Kconfig)
endmacro()
-# Use the existing Makefile to build mconf when needed
+# Use the existing Makefile to build mconf (out of tree) when needed
#
-# TODO: replace this with something more Windows-friendly
+# TODO: Find a solution on Windows
ExternalProject_Add(mconf
SOURCE_DIR ${IDF_PATH}/tools/kconfig
CONFIGURE_COMMAND ""
- BUILD_IN_SOURCE 1
- BUILD_COMMAND make mconf
- BUILD_BYPRODUCTS ${MCONF}
+ BINARY_DIR "kconfig_bin"
+ BUILD_COMMAND make -f ${IDF_PATH}/tools/kconfig/Makefile mconf
+ BUILD_BYPRODUCTS "kconfig_bin" ${MCONF}
INSTALL_COMMAND ""
EXCLUDE_FROM_ALL 1
)
+
# Find all Kconfig files for all components
function(kconfig_process_config)
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/config")
"COMPONENT_KCONFIGS=${kconfigs}"
"COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}"
"KCONFIG_CONFIG=${SDKCONFIG}"
- ${IDF_PATH}/tools/kconfig/mconf ${ROOT_KCONFIG}
+ ${MCONF} ${ROOT_KCONFIG}
VERBATIM
USES_TERMINAL)
# Kernel configuration targets
# These targets are used from top-level makefile
+# SRCDIR is kconfig source dir, allows for out-of-tree builds
+# if building in tree, SRCDIR==build dir
+SRCDIR := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
+
PHONY += xconfig gconfig menuconfig config silentoldconfig \
localmodconfig localyesconfig clean
@echo ' tinyconfig - Configure the tiniest possible kernel'
# lxdialog stuff
-check-lxdialog := lxdialog/check-lxdialog.sh
+check-lxdialog := $(SRCDIR)/lxdialog/check-lxdialog.sh
# Use recursively expanded variables so we do not call gcc unless
# we really need to do so. (Do not call gcc as part of make mrproper)
CFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
-DLOCALE -MD
+%.o: $(SRCDIR)/%.c
+ $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
+
+lxdialog/%.o: $(SRCDIR)/lxdialog/%.c
+ $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
+
+%.o: %.c
+ $(CC) -I $(SRCDIR) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
+
# ===========================================================================
# Shared Makefile for the various kconfig executables:
# conf: Used for defconfig, oldconfig and related targets
# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
PHONY += dochecklxdialog
$(addprefix ,$(lxdialog)): dochecklxdialog
-dochecklxdialog:
+dochecklxdialog: lxdialog
$(CONFIG_SHELL) $(check-lxdialog) -check $(CC) $(CFLAGS) $(LOADLIBES_mconf)
+lxdialog:
+ mkdir -p lxdialog
+
always := dochecklxdialog
# Add environment specific flags
gconf.glade
-mconf: $(mconf-objs)
+mconf: lxdialog $(mconf-objs)
$(CC) -o $@ $(mconf-objs) $(LOADLIBES_mconf)
conf: $(conf-objs)
zconf.tab.c: zconf.lex.c
-zconf.lex.c: zconf.l
- flex -L -P zconf -o zconf.lex.c zconf.l
+zconf.lex.c: $(SRCDIR)/zconf.l
+ flex -L -P zconf -o zconf.lex.c $<
-zconf.hash.c: zconf.gperf
+zconf.hash.c: $(SRCDIR)/zconf.gperf
# strip CRs on Windows systems where gperf will otherwise barf on them
- sed -E "s/\\x0D$$//" zconf.gperf | gperf -t --output-file zconf.hash.c -a -C -E -g -k '1,3,$$' -p -t
+ sed -E "s/\\x0D$$//" $< | gperf -t --output-file zconf.hash.c -a -C -E -g -k '1,3,$$' -p -t
-zconf.tab.c: zconf.y
- bison -t -l -p zconf -o zconf.tab.c zconf.y
+zconf.tab.c: $(SRCDIR)/zconf.y
+ bison -t -l -p zconf -o zconf.tab.c $<
clean:
rm -f $(clean-files)