kconfig/kconfig.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Sep 21 22:42:35 2011 +0200 (2011-09-21)
changeset 2677 7df89370f805
parent 2564 5d4e91c0343e
child 2835 0a2fa748727e
permissions -rw-r--r--
kernel/linux: add alternate download locations

Since kernel.org is dead, and there is no announced or known estimated
time or return to normality, it is impossible to download any kernel at
this time.

Add a known-working mirror.

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