e15ec399c99323a8a7bfc6b0e4f73516df6df06c
[platform/upstream/busybox.git] / scripts / config / Makefile
1 # Makefile for BusyBox
2 #
3 # Copyright (C) 2002 Erik Andersen <andersen@codepoet.org>
4
5 TOPDIR=../../
6 include $(TOPDIR)Rules.mak
7
8 all: ncurses conf mconf
9
10 LIBS = -lncurses
11 ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
12         HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
13 else
14 ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
15         HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
16 else
17 ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h))
18         HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses.h>"
19 else
20 ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h))
21         HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
22 else
23 ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
24         HOSTNCURSES += -DCURSES_LOC="<ncurses.h>"
25 else
26         HOSTNCURSES += -DCURSES_LOC="<curses.h>"
27 endif
28 endif
29 endif
30 endif
31 endif
32
33 CONF_SRC  =conf.c
34 MCONF_SRC =mconf.c checklist.c menubox.c textbox.c yesno.c inputbox.c util.c msgbox.c
35 SHARED_SRC=zconf.tab.c
36 SHARED_DEPS:=lkc.h lkc_proto.h lkc_defs.h expr.h zconf.tab.h
37 CONF_OBJS =$(patsubst %.c,%.o, $(CONF_SRC))
38 MCONF_OBJS=$(patsubst %.c,%.o, $(MCONF_SRC))
39 SHARED_OBJS=$(patsubst %.c,%.o, $(SHARED_SRC))
40
41 conf: $(CONF_OBJS) $(SHARED_OBJS)
42         $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@
43
44 mconf: $(MCONF_OBJS) $(SHARED_OBJS)
45         $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS)
46
47 $(CONF_OBJS): %.o : %.c $(SHARED_DEPS)
48         $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
49
50 $(MCONF_OBJS): %.o : %.c $(SHARED_DEPS)
51         $(HOSTCC) $(HOSTCFLAGS) $(HOSTNCURSES) -I. -c $< -o $@
52
53 lkc_defs.h: lkc_proto.h
54         @sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
55
56 ###
57 # The following requires flex/bison
58 # By default we use the _shipped versions, uncomment the
59 # following line if you are modifying the flex/bison src.
60 #LKC_GENPARSER := 1
61
62 ifdef LKC_GENPARSER
63
64 %.tab.c %.tab.h: %.y
65         bison -t -d -v -b $* -p $(notdir $*) $<
66
67 lex.%.c: %.l
68         flex -P$(notdir $*) -o$@ $<
69 else
70
71 lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
72         $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
73
74 lex.zconf.c: lex.zconf.c_shipped
75         cp lex.zconf.c_shipped lex.zconf.c
76
77 zconf.tab.o: zconf.tab.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(SHARED_DEPS)
78         $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
79
80 zconf.tab.c: zconf.tab.c_shipped
81         cp zconf.tab.c_shipped zconf.tab.c
82
83 zconf.tab.h: zconf.tab.h_shipped
84         cp zconf.tab.h_shipped zconf.tab.h
85 endif
86
87 .PHONY: ncurses
88
89 ncurses:
90         @echo "main() {}" > lxtemp.c
91         @if $(HOSTCC) lxtemp.c $(LIBS) ; then \
92                 rm -f lxtemp.c a.out; \
93         else \
94                 rm -f lxtemp.c; \
95                 echo -e "\007" ;\
96                 echo ">> Unable to find the Ncurses libraries." ;\
97                 echo ">>" ;\
98                 echo ">> You must have Ncurses installed in order" ;\
99                 echo ">> to use 'make menuconfig'" ;\
100                 echo ;\
101                 exit 1 ;\
102         fi
103
104 clean:
105         rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \
106                 conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h
107