kconfig/kconfig.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Oct 18 18:37:28 2008 +0000 (2008-10-18)
changeset 945 d0e5f04d2e06
parent 943 1cca90ce0481
child 946 253df9d80065
permissions -rw-r--r--
Extract the config files related stuff from the kconfig stuff
- create config/config.mk, with all the config.gen/ rules
- the only common points between config files and configurators:
- the top-level config file to include, stored in KCONFIG_TOP
- the config_file rules, which makes config files available to configurators
- dependency-files are renamed from %.d to %.dep (.d is reserved for directories)
- a few eye-candy here and there

/trunk/kconfig/kconfig.mk | 184 12 172 0 +++--------------------------------------------------
/trunk/config/config.mk | 118 9 109 0 +++-------------------------------
/trunk/ct-ng.in | 1 1 0 0 +
3 files changed, 22 insertions(+), 281 deletions(-)
yann@1
     1
# ===========================================================================
yann@197
     2
# crosstool-NG configuration targets
yann@1
     3
# These targets are used from top-level makefile
yann@1
     4
yann@148
     5
# Derive the project version from, well, the project version:
yann@148
     6
export PROJECTVERSION=$(CT_VERSION)
yann@148
     7
yann@926
     8
#-----------------------------------------------------------
yann@926
     9
# Some static /configuration/
yann@926
    10
yann@945
    11
# The place where the kconfig stuff lies
yann@926
    12
obj = kconfig
yann@926
    13
yann@926
    14
#-----------------------------------------------------------
yann@926
    15
# The configurators rules
yann@182
    16
yann@945
    17
PHONY += oldconfig menuconfig defoldconfig
yann@945
    18
yann@945
    19
menuconfig: $(obj)/mconf config_files
yann@945
    20
	@$(ECHO) "  MCONF $(KCONFIG_TOP)"
yann@940
    21
	$(SILENT)$< $(KCONFIG_TOP)
yann@1
    22
yann@945
    23
oldconfig: $(obj)/conf .config config_files
yann@945
    24
	@$(ECHO) "  CONF  $(KCONFIG_TOP)"
yann@940
    25
	$(SILENT)$< -s $(KCONFIG_TOP)
yann@1
    26
yann@945
    27
defoldconfig: $(obj)/conf .config config_files
yann@945
    28
	@$(ECHO) "  CONF  $(KCONFIG_TOP)"
yann@940
    29
	$(SILENT)yes "" |$< -s $(KCONFIG_TOP)
yann@159
    30
yann@926
    31
#-----------------------------------------------------------
yann@1
    32
# Help text used by make help
yann@926
    33
yann@176
    34
help-config::
yann@333
    35
	@echo  '  menuconfig         - Update current config using a menu based program'
yann@333
    36
	@echo  '  oldconfig          - Update current config using a provided .config as base'
yann@940
    37
	@echo  '  defoldconfig       - As oldconfig, above, but using defaults for new options'
yann@1
    38
yann@926
    39
#-----------------------------------------------------------
yann@940
    40
# Hmmm! Cheesy build!
yann@940
    41
# Or: where I can unveil my make-fu... :-]
yann@1
    42
yann@940
    43
# Oh! Files not here are there, in fact! :-)
yann@940
    44
vpath %.c $(CT_LIB_DIR)
yann@940
    45
vpath %.h $(CT_LIB_DIR)
yann@1
    46
yann@940
    47
# What is the compiler?
yann@940
    48
HOST_CC ?= gcc -funsigned-char
yann@182
    49
yann@943
    50
# Compiler flags to use gettext
yann@943
    51
EXTRA_CFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/check-gettext.sh $(HOST_CC) $(CFLAGS))
yann@943
    52
yann@940
    53
# Compiler and linker flags to use ncurses
yann@943
    54
EXTRA_CFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags)
yann@943
    55
EXTRA_LDFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC))
yann@182
    56
yann@940
    57
# Common source files, and lxdialog source files
yann@940
    58
SRC = kconfig/zconf.tab.c
yann@940
    59
LXSRC = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/kconfig/lxdialog/*.c))
yann@816
    60
yann@940
    61
# What's needed to build 'conf'
yann@940
    62
conf_SRC  = $(SRC) kconfig/conf.c
yann@940
    63
conf_OBJ  = $(patsubst %.c,%.o,$(conf_SRC))
yann@816
    64
yann@940
    65
# What's needed to build 'mconf'
yann@940
    66
mconf_SRC = $(SRC) $(LXSRC) kconfig/mconf.c
yann@940
    67
mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
yann@1
    68
yann@940
    69
# Cheesy auto-dependencies
yann@945
    70
DEPS = $(patsubst %.c,%.dep,$(sort $(conf_SRC) $(mconf_SRC)))
yann@945
    71
-include $(DEPS)
yann@940
    72
yann@940
    73
# This is not very nice, as they will get rebuild even if (dist)cleaning... :-(
yann@940
    74
# Should look into the Linux kernel Kbuild to see how they do that...
yann@940
    75
# To really make me look into this, keep the annoying "DEP xxx" messages.
yann@940
    76
# Also see the comment for the "%.o: %c" rule below
yann@945
    77
%.dep: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk $(CT_NG)
yann@940
    78
	$(SILENT)if [ ! -d $(obj)/lxdialog ]; then  \
yann@940
    79
	   $(ECHO) "  MKDIR $(obj)";           \
yann@940
    80
	   mkdir -p $(obj)/lxdialog;        \
yann@940
    81
	 fi
yann@940
    82
	@$(ECHO) "  DEP   $@"
yann@943
    83
	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |sed -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@
yann@940
    84
yann@940
    85
# Each .o must depend on the corresponding .c (obvious, isn't it?),
yann@940
    86
# but *can not* depend on kconfig/, because kconfig can be touched
yann@940
    87
# during the build (who's touching it, btw?) so each .o would be
yann@940
    88
# re-built when they sould not be.
yann@940
    89
# So manually check for presence of $(obj) (ie. kconfig), and only mkdir
yann@940
    90
# if needed. After all, that's not so bad...
yann@940
    91
# mkdir $(obj)/lxdialog, because we need it, and incidentally, that
yann@940
    92
# also creates $(obj).
yann@940
    93
# Also rebuild the object files is the makefile is changed
yann@940
    94
%.o: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk
yann@940
    95
	$(SILENT)if [ ! -d $(obj)/lxdialog ]; then  \
yann@940
    96
	   $(ECHO) "  MKDIR $(obj)";           \
yann@940
    97
	   mkdir -p $(obj)/lxdialog;        \
yann@940
    98
	 fi
yann@940
    99
	@$(ECHO) "  CC    $@"
yann@943
   100
	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
yann@940
   101
yann@940
   102
$(obj)/mconf: $(mconf_OBJ)
yann@940
   103
	@$(ECHO) '  LD    $@'
yann@943
   104
	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^
yann@940
   105
yann@940
   106
$(obj)/conf: $(conf_OBJ)
yann@940
   107
	@$(ECHO) '  LD    $@'
yann@943
   108
	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^
yann@1
   109
yann@926
   110
#-----------------------------------------------------------
yann@926
   111
# Cleaning up the mess...
yann@926
   112
yann@1
   113
clean::
yann@940
   114
	@$(ECHO) "  CLEAN kconfig"
yann@940
   115
	$(SILENT)rm -f kconfig/{,m}conf $(conf_OBJ) $(mconf_OBJ) $(DEPS)
yann@940
   116
	$(SILENT)rmdir --ignore-fail-on-non-empty kconfig{/lxdialog,} 2>/dev/null || true