kconfig/Makefile
author Cody Schafer <dev@codyps.com>
Fri May 09 19:13:49 2014 -0700 (2014-05-09)
changeset 3312 4876ff97e039
parent 3019 6f23aba03281
child 3325 069f43a215cc
permissions -rw-r--r--
cc/gcc: allow CC_EXTRA_CONFIG_ARRAY on baremetal

The final bare-metal compiler is built using the core backend.
Currently the core uses the CC_CORE_EXTRA_CONFIG_ARRAY variable.

While this works as supposed to, this can leave the user puzzled
in the menuconfig, since all he can see is the core options, not
the final options.

Only show the core options if any of the core passes are needed,
and use the final options in the core-backend if we're issuing
the bare-metal compiler.

Signed-off-by: Cody P Schafer <dev@codyps.com>
[yann.morin.1998@free.fr: hide core options if no core pass needed;
use final option in core backend if issuing the bare-metal compiler]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Message-Id: <22181e546ba746202489.1399688067@localhost>
Patchwork-Id: 347586
     1 #-----------------------------------------------------------
     2 # Hmmm! Cheesy build!
     3 # Or: where I can unveil my make-fu... :-]
     4 
     5 all: conf mconf nconf
     6 	@true   # Just be silent, you fscking son of a fscking beach...
     7 
     8 # Build flags
     9 CFLAGS = -DCONFIG_=\"CT_\" -DPACKAGE="\"crosstool-NG $(VERSION)\""
    10 LDFLAGS =
    11 
    12 # Compiler flags to use gettext
    13 ifeq ($(gettext),)
    14 INTL_CFLAGS = -DKBUILD_NO_NLS
    15 endif
    16 
    17 # Compiler and linker flags to use ncurses
    18 NCURSES_CFLAGS = -DCURSES_LOC="\"$(curses_hdr)\""
    19 NCURSES_LDFLAGS = $(LIBS)
    20 
    21 # Common source files
    22 COMMON_SRC = zconf.tab.c
    23 COMMON_OBJ = $(patsubst %.c,%.o,$(COMMON_SRC))
    24 COMMON_DEP = $(patsubst %.o,%.dep,$(COMMON_OBJ))
    25 $(COMMON_OBJ) $(COMMON_DEP): CFLAGS += $(INTL_CFLAGS) -I.
    26 
    27 # lxdialog source files
    28 LX_SRC = $(wildcard lxdialog/*.c)
    29 LX_OBJ = $(patsubst %.c,%.o,$(LX_SRC))
    30 LX_DEP = $(patsubst %.o,%.dep,$(LX_OBJ))
    31 $(LX_OBJ) $(LX_DEP): CFLAGS += $(NCURSES_CFLAGS) $(INTL_CFLAGS)
    32 
    33 # What's needed to build 'conf'
    34 conf_SRC = conf.c
    35 conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC))
    36 conf_DEP = $(patsubst %.o,%.dep,$(conf_OBJ))
    37 $(conf_OBJ) $(conf_DEP): CFLAGS += $(INTL_CFLAGS)
    38 
    39 # What's needed to build 'mconf'
    40 mconf_SRC = mconf.c
    41 mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
    42 mconf_DEP = $(patsubst %.c,%.dep,$(mconf_SRC))
    43 $(mconf_OBJ) $(mconf_DEP): CFLAGS += $(NCURSES_CFLAGS) $(INTL_CFLAGS)
    44 mconf: LDFLAGS += $(NCURSES_LDFLAGS)
    45 
    46 # What's needed to build 'nconf'
    47 nconf_SRC = nconf.c nconf.gui.c
    48 nconf_OBJ = $(patsubst %.c,%.o,$(nconf_SRC))
    49 nconf_DEP = $(patsubst %.c,%.dep,$(nconf_SRC))
    50 $(nconf_OBJ) $(nconf_DEP): CFLAGS += $(INTL_CFLAGS) -I/usr/include/ncurses
    51 nconf: LDFLAGS += -lmenu -lpanel -lncurses
    52 
    53 # Under Cygwin, we need to auto-import some libs (which ones, exactly?)
    54 # for mconf and nconf to lin properly.
    55 ifeq ($(shell uname -o 2>/dev/null || echo unknown),Cygwin)
    56 mconf: LDFLAGS += -Wl,--enable-auto-import
    57 nconf: LDFLAGS += -Wl,--enable-auto-import
    58 endif
    59 
    60 # These are generated files:
    61 ALL_OBJS = $(sort $(COMMON_OBJ) $(LX_OBJ) $(conf_OBJ) $(mconf_OBJ) $(nconf_OBJ))
    62 ALL_DEPS = $(sort $(COMMON_DEP) $(LX_DEP) $(conf_DEP) $(mconf_DEP) $(nconf_DEP))
    63 
    64 # Cheesy auto-dependencies
    65 DEPS = $(COMMON_DEP)
    66 DEPS += $(conf_DEP)
    67 DEPS += $(mconf_DEP) $(LX_DEP)
    68 DEPS += $(nconf_DEP)
    69 -include $(DEPS)
    70 
    71 # Build the dependency for C files
    72 %.dep: %.c
    73 	@echo "  DEP    '$@'"
    74 	@$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |$(sed) -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@
    75 
    76 # Generate the grammar parser
    77 zconf.tab.o: zconf.tab.c zconf.hash.c lex.zconf.c
    78 zconf.tab.dep: zconf.tab.c zconf.hash.c lex.zconf.c
    79 
    80 .PRECIOUS: zconf.tab.c
    81 zconf.tab.c: zconf.y
    82 	@echo "  BISON  '$@'"
    83 	@bison -l -b zconf -p zconf $<
    84 
    85 zconf.hash.c: zconf.gperf
    86 	@echo "  GPERF  '$@'"
    87 	@$(gperf) < $< > $@
    88 
    89 lex.zconf.c: zconf.l
    90 	@echo "  LEX    '$@'"
    91 	@flex -L -Pzconf -o$@ $<
    92 
    93 # Build C files
    94 %.o: %.c
    95 	@echo "  CC     '$@'"
    96 	@$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
    97 
    98 # Actual link
    99 mconf: $(COMMON_OBJ) $(LX_OBJ) $(mconf_OBJ)
   100 	@echo "  LD     '$@'"
   101 	@$(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS)
   102 
   103 nconf: $(COMMON_OBJ) $(nconf_OBJ)
   104 	@echo "  LD     '$@'"
   105 	@$(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS)
   106 
   107 conf: $(COMMON_OBJ) $(conf_OBJ)
   108 	@echo "  LD     '$@'"
   109 	@$(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS)
   110 
   111 #-----------------------------------------------------------
   112 # Cleaning up the mess...
   113 
   114 clean:
   115 	@echo "  RM     'kconfig'"
   116 	@rm -f conf mconf nconf $(ALL_OBJS) $(ALL_DEPS)
   117 	@rm -f rm -f zconf.tab.c zconf.hash.c lex.zconf.c lex.backup