kconfig/Makefile
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Mon Jul 23 22:02:23 2012 +0200 (2012-07-23)
changeset 3012 95173b196a88
parent 2836 1c4f3be68a6d
child 3019 6f23aba03281
permissions -rw-r--r--
scripts+samples: fix listings the samples

Since we use defconfigs to save the samples, listing all the
samples can no longer be done by passing all the sample names
at one to the script; we need to pass them one-by-one after
we expand the sample's defconfig ibnto a complete .config.

Reported-by: Bryan Hundven <bryanhundven@gmail.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
     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)
    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