massive rewrite of the pkgmaker logic
[openadk.git] / config / Makefile
blob1f3143e34ca0241fc7141e274a580e3db8b9bfb2
1 # This file is part of the OpenADK project. OpenADK is copyrighted
2 # material, please see the LICENCE file in the top-level directory.
4 ifneq ($(filter-out clean,${MAKECMDGOALS}),)
5 include ${TOPDIR}/rules.mk
6 endif
8 CP=cp -fpR
9 HOSTCFLAGS+=-DKBUILD_NO_NLS
11 all: ncurses conf mconf
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 LIBS= -lcurses
35 endif
36 endif
37 endif
38 endif
39 endif
40 endif
42 CONF_SRC =conf.c
43 MCONF_SRC =mconf.c $(wildcard lxdialog/*.c)
44 SHARED_SRC=zconf.tab.c
45 SHARED_DEPS:=lkc.h lkc_proto.h lkc_defs.h expr.h zconf.tab.h
46 CONF_OBJS =$(patsubst %.c,%.o, $(CONF_SRC))
47 MCONF_OBJS=$(patsubst %.c,%.o, $(MCONF_SRC))
48 SHARED_OBJS=$(patsubst %.c,%.o, $(SHARED_SRC))
50 conf: $(CONF_OBJS) $(SHARED_OBJS)
51 $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) $^ -o $@
53 mconf: $(MCONF_OBJS) $(SHARED_OBJS)
54 $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS)
56 $(CONF_OBJS): %.o : %.c $(SHARED_DEPS)
57 $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
59 $(MCONF_OBJS): %.o : %.c $(SHARED_DEPS)
60 $(HOSTCC) $(HOSTCFLAGS) $(HOSTNCURSES) -I. -c $< -o $@
62 glob.o: glob.c $(SHARED_DEPS)
63 $(HOSTCC) $(HOSTCFLAGS) -I. -c glob.c -o $@
65 lkc_defs.h: lkc_proto.h
66 @sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
68 ###
69 # The following requires flex/bison
70 # By default we use the _shipped versions, uncomment the
71 # following line if you are modifying the flex/bison src.
72 #LKC_GENPARSER:= 1
74 ifdef LKC_GENPARSER
76 %.tab.c %.tab.h: %.y
77 bison -t -d -v -b $* -p $(notdir $*) $<
79 %.hash.c: %.gperf
80 gperf < $< > $@
82 lex.%.c: %.l
83 flex -P$(notdir $*) -o$@ $<
85 lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
86 $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
88 zconf.tab.o: zconf.tab.c zconf.hash.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(SHARED_DEPS)
89 $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
91 else
93 lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
94 $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
96 lex.zconf.c: lex.zconf.c_shipped
97 $(CP) lex.zconf.c_shipped lex.zconf.c
99 zconf.hash.c: zconf.hash.c_shipped
100 $(CP) zconf.hash.c_shipped zconf.hash.c
102 zconf.tab.o: zconf.tab.c zconf.hash.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(SHARED_DEPS)
103 $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
105 zconf.tab.c: zconf.tab.c_shipped
106 $(CP) zconf.tab.c_shipped zconf.tab.c
108 zconf.tab.h: zconf.tab.h_shipped
109 $(CP) zconf.tab.h_shipped zconf.tab.h
110 endif
112 .PHONY: ncurses
114 ncurses:
115 @echo "int main(void) { return -1; }" > lxtemp.c
116 @if $(HOSTCC) $(HOSTCFLAGS) lxtemp.c $(LIBS) ; then \
117 rm -f lxtemp.c a.out; \
118 else \
119 rm -f lxtemp.c; \
120 printf '\007'; \
121 echo ">> Unable to find the Ncurses libraries." ;\
122 echo ">>" ;\
123 echo ">> You must have Ncurses installed in order" ;\
124 echo ">> to use 'make menuconfig'" ;\
125 echo ;\
126 exit 1 ;\
129 clean:
130 @rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) zconf.hash.c \
131 conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h