kconfig/kconfig.mk
author Arnaud Lacombe <lacombar@gmail.com>
Tue Aug 03 06:17:51 2010 +0200 (2010-08-03)
changeset 2064 f5ebe8c429dc
parent 1803 2c0ed9ec9a8c
child 2125 4009fc9c47d5
permissions -rw-r--r--
libc/uClibc: add uClibc 0.9.30.3

This version has been released a couple of month ago, but it never reached
crosstool-ng tree. This may be linked to the fact that the current 0.9.30.2,
once patched, has nothing much different from 0.9.30.3, released.

I'm not including any patch with this upgrade, on purpose.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
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@945
     8
# The place where the kconfig stuff lies
yann@926
     9
obj = kconfig
yann@926
    10
yann@926
    11
#-----------------------------------------------------------
yann@926
    12
# The configurators rules
yann@182
    13
yann@959
    14
configurators = menuconfig oldconfig
yann@946
    15
PHONY += $(configurators)
yann@945
    16
yann@946
    17
$(configurators): config_files
yann@946
    18
yann@946
    19
menuconfig: $(obj)/mconf
yann@959
    20
	@$(ECHO) "  CONF  $(KCONFIG_TOP)"
yann@940
    21
	$(SILENT)$< $(KCONFIG_TOP)
yann@1
    22
yann@946
    23
oldconfig: $(obj)/conf .config
yann@945
    24
	@$(ECHO) "  CONF  $(KCONFIG_TOP)"
yann@940
    25
	$(SILENT)$< -s $(KCONFIG_TOP)
yann@1
    26
yann@1803
    27
# Always be silent, the stdout an be >.config
yann@1803
    28
extractconfig:
yann@1803
    29
	@awk 'BEGIN { dump=0; }                                                 \
yann@1803
    30
	      dump==1 && $$0~/^\[.....\][[:space:]]+(# |)CT_/ {                 \
yann@1803
    31
	          $$1="";                                                       \
yann@1803
    32
	          gsub("^[[:space:]]","");                                      \
yann@1803
    33
	          print;                                                        \
yann@1803
    34
	      }                                                                 \
yann@1803
    35
	      $$0~/Dumping user-supplied crosstool-NG configuration: done in/ { \
yann@1803
    36
	          dump=0;                                                       \
yann@1803
    37
	      }                                                                 \
yann@1803
    38
	      $$0~/Dumping user-supplied crosstool-NG configuration$$/ {        \
yann@1803
    39
	          dump=1;                                                       \
yann@1803
    40
	      }'
yann@1803
    41
yann@926
    42
#-----------------------------------------------------------
yann@1
    43
# Help text used by make help
yann@926
    44
yann@176
    45
help-config::
yann@333
    46
	@echo  '  menuconfig         - Update current config using a menu based program'
yann@333
    47
	@echo  '  oldconfig          - Update current config using a provided .config as base'
yann@1803
    48
	@echo  '  extractconfig      - Extract to stdout the configuration items from a'
yann@1803
    49
	@echo  '                       build.log file piped to stdin'
yann@1
    50
yann@926
    51
#-----------------------------------------------------------
yann@940
    52
# Hmmm! Cheesy build!
yann@940
    53
# Or: where I can unveil my make-fu... :-]
yann@1
    54
yann@940
    55
# Oh! Files not here are there, in fact! :-)
yann@940
    56
vpath %.c $(CT_LIB_DIR)
yann@940
    57
vpath %.h $(CT_LIB_DIR)
yann@1
    58
yann@940
    59
# What is the compiler?
yann@940
    60
HOST_CC ?= gcc -funsigned-char
yann@959
    61
HOST_LD ?= gcc
yann@959
    62
yann@959
    63
# Helpers
yann@959
    64
check_gettext = $(CT_LIB_DIR)/kconfig/check-gettext.sh
yann@959
    65
check_lxdialog = $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh
yann@959
    66
yann@959
    67
# Build flags
titus@1973
    68
CFLAGS =
yann@959
    69
LDFLAGS =
yann@182
    70
yann@943
    71
# Compiler flags to use gettext
yann@959
    72
INTL_CFLAGS = $(shell $(SHELL) $(check_gettext) $(HOST_CC) $(EXTRA_CFLAGS))
yann@943
    73
yann@940
    74
# Compiler and linker flags to use ncurses
yann@959
    75
NCURSES_CFLAGS = $(shell $(SHELL) $(check_lxdialog) -ccflags)
yann@959
    76
NCURSES_LDFLAGS = $(shell $(SHELL) $(check_lxdialog) -ldflags $(HOST_CC) $(LX_FLAGS) $(EXTRA_CFLAGS))
yann@182
    77
yann@959
    78
# Common source files
yann@959
    79
COMMON_SRC = kconfig/zconf.tab.c
yann@959
    80
COMMON_OBJ = $(patsubst %.c,%.o,$(COMMON_SRC))
yann@959
    81
COMMON_DEP = $(patsubst %.o,%.dep,$(COMMON_OBJ))
yann@959
    82
$(COMMON_OBJ) $(COMMON_DEP): CFLAGS += $(INTL_CFLAGS)
yann@959
    83
yann@959
    84
# lxdialog source files
yann@959
    85
LX_SRC = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/kconfig/lxdialog/*.c))
yann@959
    86
LX_OBJ = $(patsubst %.c,%.o,$(LX_SRC))
yann@959
    87
LX_DEP = $(patsubst %.o,%.dep,$(LX_OBJ))
yann@959
    88
$(LX_OBJ) $(LX_DEP): CFLAGS += $(NCURSES_CFLAGS) $(INTL_CFLAGS)
yann@816
    89
yann@940
    90
# What's needed to build 'conf'
yann@959
    91
conf_SRC = kconfig/conf.c
yann@959
    92
conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC))
yann@959
    93
conf_DEP = $(patsubst %.o,%.dep,$(conf_OBJ))
yann@959
    94
$(conf_OBJ) $(conf_DEP): CFLAGS += $(INTL_CFLAGS)
yann@816
    95
yann@940
    96
# What's needed to build 'mconf'
yann@959
    97
mconf_SRC = kconfig/mconf.c
yann@940
    98
mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
yann@959
    99
mconf_DEP = $(patsubst %.c,%.dep,$(mconf_SRC))
yann@959
   100
$(mconf_OBJ) $(mconf_DEP): CFLAGS += $(NCURSES_CFLAGS) $(INTL_CFLAGS)
yann@959
   101
$(obj)/mconf: LDFLAGS += $(NCURSES_LDFLAGS)
yann@1087
   102
ifeq ($(shell uname -o 2>/dev/null || echo unknown),Cygwin)
yann@1087
   103
$(obj)/mconf: LDFLAGS += -Wl,--enable-auto-import
yann@1087
   104
endif
yann@959
   105
yann@959
   106
# These are generated files:
yann@959
   107
ALL_OBJS = $(sort $(COMMON_OBJ) $(LX_OBJ) $(conf_OBJ) $(mconf_OBJ))
yann@959
   108
ALL_DEPS = $(sort $(COMMON_DEP) $(LX_DEP) $(conf_DEP) $(mconf_DEP))
yann@1
   109
yann@940
   110
# Cheesy auto-dependencies
yann@946
   111
# Only parse the following if a configurator was called, to avoid building
yann@946
   112
# dependencies when not needed (eg. list-steps, list-samples...)
yann@946
   113
# We must be carefull what we enclose, because we need some of the variable
yann@946
   114
# definitions for clean (and distclean) at least.
yann@946
   115
# Just protecting the "-include $(DEPS)" line should be sufficient.
yann@946
   116
yann@946
   117
ifneq ($(strip $(MAKECMDGOALS)),)
yann@946
   118
ifneq ($(strip $(filter $(configurators),$(MAKECMDGOALS))),)
yann@946
   119
yann@959
   120
DEPS = $(COMMON_DEP)
yann@959
   121
ifneq ($(strip $(filter oldconfig,$(MAKECMDGOALS))),)
yann@959
   122
DEPS += $(conf_DEP)
yann@959
   123
endif
yann@959
   124
ifneq ($(strip $(filter menuconfig,$(MAKECMDGOALS))),)
yann@959
   125
DEPS += $(mconf_DEP) $(LX_DEP)
yann@959
   126
endif
yann@959
   127
yann@945
   128
-include $(DEPS)
yann@940
   129
yann@946
   130
endif # MAKECMDGOALS contains a configurator rule
yann@946
   131
endif # MAKECMDGOALS != ""
yann@946
   132
yann@959
   133
# Each .o or .dep *can not* directly depend on kconfig/, because kconfig can
yann@959
   134
# be touched during the build (who's touching it, btw?) so each .o or .dep
yann@959
   135
# would be re-built when it sould not be.
yann@959
   136
# So manually check for presence of $(obj) (ie. kconfig), and only mkdir
yann@959
   137
# if needed. After all, that's not so bad...
yann@959
   138
# mkdir $(obj)/lxdialog, because we need it, and incidentally, that
yann@959
   139
# also creates $(obj).
yann@959
   140
define check_kconfig_dir
yann@940
   141
	$(SILENT)if [ ! -d $(obj)/lxdialog ]; then  \
yann@940
   142
	   $(ECHO) "  MKDIR $(obj)";           \
yann@940
   143
	   mkdir -p $(obj)/lxdialog;        \
yann@940
   144
	 fi
yann@959
   145
endef
yann@959
   146
yann@959
   147
# Build the dependency for C files
yann@959
   148
%.dep: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk
yann@959
   149
	$(check_kconfig_dir)
yann@940
   150
	@$(ECHO) "  DEP   $@"
yann@1155
   151
	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |$(sed) -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@
yann@940
   152
yann@959
   153
# Build C files
yann@940
   154
%.o: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk
yann@959
   155
	$(check_kconfig_dir)
yann@940
   156
	@$(ECHO) "  CC    $@"
yann@943
   157
	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
yann@940
   158
yann@959
   159
# Actual link
yann@959
   160
$(obj)/mconf: $(COMMON_OBJ) $(LX_OBJ) $(mconf_OBJ)
yann@940
   161
	@$(ECHO) '  LD    $@'
yann@1087
   162
	$(SILENT)$(HOST_LD) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS)
yann@940
   163
yann@959
   164
$(obj)/conf: $(COMMON_OBJ) $(conf_OBJ)
yann@940
   165
	@$(ECHO) '  LD    $@'
yann@1087
   166
	$(SILENT)$(HOST_LD) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS)
yann@1
   167
yann@926
   168
#-----------------------------------------------------------
yann@926
   169
# Cleaning up the mess...
yann@926
   170
yann@1
   171
clean::
yann@940
   172
	@$(ECHO) "  CLEAN kconfig"
yann@1254
   173
	$(SILENT)rm -f kconfig/{,m}conf{,.exe} $(ALL_OBJS) $(ALL_DEPS)
yann@940
   174
	$(SILENT)rmdir --ignore-fail-on-non-empty kconfig{/lxdialog,} 2>/dev/null || true