root/trunk/freewrt/tools/config/Makefile

Revision 3920, 3.6 kB (checked in by tg, 2 years ago)

make 'make distclean' really remove everything

Line 
1 # $FreeWRT$
2 #-
3 # This file is part of the FreeWRT project. FreeWRT is copyrighted
4 # material, please see the LICENCE file in the top-level directory
5 # or at http://www.freewrt.org/licence for details.
6
7 include ${TOPDIR}/rules.mk
8
9 CP=cp -fpR
10
11 all: ncurses conf mconf
12
13 LIBS=           -lncurses
14 ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
15 HOSTNCURSES+=   -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
16 else
17 ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
18 HOSTNCURSES+=   -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
19 else
20 ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h))
21 HOSTCFLAGS+=    -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses.h>"
22 else
23 ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h))
24 HOSTCFLAGS+=    -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
25 else
26 ifeq (/usr/pkg/include/ncurses.h, $(wildcard /usr/pkg/include/ncurses.h))
27 HOSTCFLAGS+=    -I/usr/pkg/include -DCURSES_LOC="<ncurses.h>"
28 LIBS+=          -L/usr/pkg/lib -Wl,-rpath -Wl,/usr/pkg/lib
29 else
30 ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
31 HOSTNCURSES+=   -DCURSES_LOC="<ncurses.h>"
32 else
33 HOSTNCURSES+=   -DCURSES_LOC="<curses.h>"
34 endif
35 endif
36 endif
37 endif
38 endif
39 endif
40
41 CONF_SRC  =conf.c
42 MCONF_SRC =mconf.c checklist.c menubox.c textbox.c yesno.c inputbox.c util.c msgbox.c
43 SHARED_SRC=zconf.tab.c glob.c
44 SHARED_DEPS:=lkc.h lkc_proto.h lkc_defs.h expr.h zconf.tab.h glob.h
45 CONF_OBJS =$(patsubst %.c,%.o, $(CONF_SRC))
46 MCONF_OBJS=$(patsubst %.c,%.o, $(MCONF_SRC))
47 SHARED_OBJS=$(patsubst %.c,%.o, $(SHARED_SRC))
48
49 conf: $(CONF_OBJS) $(SHARED_OBJS)
50         $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@
51
52 mconf: $(MCONF_OBJS) $(SHARED_OBJS)
53         $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS)
54
55 $(CONF_OBJS): %.o : %.c $(SHARED_DEPS)
56         $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
57
58 $(MCONF_OBJS): %.o : %.c $(SHARED_DEPS)
59         $(HOSTCC) $(HOSTCFLAGS) $(HOSTNCURSES) -I. -c $< -o $@
60
61 glob.o: glob.c $(SHARED_DEPS)
62         $(HOSTCC) $(HOSTCFLAGS) -I. -c glob.c -o $@
63
64 lkc_defs.h: lkc_proto.h
65         @sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
66
67 ###
68 # The following requires flex/bison
69 # By default we use the _shipped versions, uncomment the
70 # following line if you are modifying the flex/bison src.
71 LKC_GENPARSER:= 1
72
73 ifdef LKC_GENPARSER
74
75 %.tab.c %.tab.h: %.y
76         bison -t -d -v -b $* -p $(notdir $*) $<
77
78 lex.%.c: %.l
79         flex -P$(notdir $*) -o$@ $<
80
81 lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
82         $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
83
84 zconf.tab.o: zconf.tab.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(SHARED_DEPS)
85         $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
86
87 else
88
89 lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
90         $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
91
92 lex.zconf.c: lex.zconf.c_shipped
93         $(CP) lex.zconf.c_shipped lex.zconf.c
94
95 zconf.tab.o: zconf.tab.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(SHARED_DEPS)
96         $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
97
98 zconf.tab.c: zconf.tab.c_shipped
99         $(CP) zconf.tab.c_shipped zconf.tab.c
100
101 zconf.tab.h: zconf.tab.h_shipped
102         $(CP) zconf.tab.h_shipped zconf.tab.h
103 endif
104
105 .PHONY: ncurses
106
107 ncurses:
108         @echo "int main(void) { return -1; }" > lxtemp.c
109         @if $(HOSTCC) $(HOSTCFLAGS) lxtemp.c $(LIBS) ; then \
110                 rm -f lxtemp.c a.out; \
111         else \
112                 rm -f lxtemp.c; \
113                 printf '\007'; \
114                 echo ">> Unable to find the Ncurses libraries." ;\
115                 echo ">>" ;\
116                 echo ">> You must have Ncurses installed in order" ;\
117                 echo ">> to use 'make menuconfig'" ;\
118                 echo ;\
119                 exit 1 ;\
120         fi
121
122 clean:
123         rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) conf mconf \
124             zconf.tab.c zconf.tab.h zconf.output lex.backup lex.zconf.c \
125             lkc_defs.h
Note: See TracBrowser for help on using the browser.