1# Modified by Broadcom Corp. Portions Copyright (c) Broadcom Corp, 2003.
2# Makefile for uClibc
3#
4# Copyright (C) 2002 Erik Andersen <andersen@codepoet.org>
5#
6# This program is free software; you can redistribute it and/or modify it under
7# the terms of the GNU Library General Public License as published by the Free
8# Software Foundation; either version 2 of the License, or (at your option) any
9# later version.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
14# details.
15#
16# You should have received a copy of the GNU Library General Public License
17# along with this program; if not, write to the Free Software Foundation, Inc.,
18# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20TOPDIR=../../
21#include $(TOPDIR)Rules.mak
22
23all: ncurses conf mconf
24
25LIBS = -lncurses
26ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
27	HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
28else
29ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
30	HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
31else
32ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h))
33	HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses.h>"
34else
35ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h))
36	HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
37else
38ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
39	HOSTNCURSES += -DCURSES_LOC="<ncurses.h>"
40else
41	HOSTNCURSES += -DCURSES_LOC="<curses.h>"
42endif
43endif
44endif
45endif
46endif
47
48CONF_SRC  =conf.c
49MCONF_SRC =mconf.c checklist.c menubox.c textbox.c yesno.c inputbox.c util.c msgbox.c
50SHARED_SRC=zconf.tab.c
51SHARED_DEPS:=lkc.h lkc_proto.h lkc_defs.h expr.h zconf.tab.h
52CONF_OBJS =$(patsubst %.c,%.o, $(CONF_SRC))
53MCONF_OBJS=$(patsubst %.c,%.o, $(MCONF_SRC))
54SHARED_OBJS=$(patsubst %.c,%.o, $(SHARED_SRC))
55
56conf: $(CONF_OBJS) $(SHARED_OBJS) 
57	$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@
58
59mconf: $(MCONF_OBJS) $(SHARED_OBJS)
60	$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS)
61
62$(CONF_OBJS): %.o : %.c $(SHARED_DEPS)
63	$(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
64
65$(MCONF_OBJS): %.o : %.c $(SHARED_DEPS)
66	$(HOSTCC) $(HOSTCFLAGS) $(HOSTNCURSES) -I. -c $< -o $@
67
68lkc_defs.h: lkc_proto.h
69	@sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
70
71###
72# The following requires flex/bison
73# By default we use the _shipped versions, uncomment the 
74# following line if you are modifying the flex/bison src.
75#LKC_GENPARSER := 1
76
77ifdef LKC_GENPARSER
78
79%.tab.c %.tab.h: %.y
80	bison -t -d -v -b $* -p $(notdir $*) $<
81
82lex.%.c: %.l
83	flex -P$(notdir $*) -o$@ $<
84else
85
86lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
87	$(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
88
89lex.zconf.c: lex.zconf.c_shipped
90	cp lex.zconf.c_shipped lex.zconf.c
91
92zconf.tab.o: zconf.tab.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(SHARED_DEPS)
93	$(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
94
95zconf.tab.c: zconf.tab.c_shipped
96	cp zconf.tab.c_shipped zconf.tab.c
97
98zconf.tab.h: zconf.tab.h_shipped
99	cp zconf.tab.h_shipped zconf.tab.h
100endif
101
102.PHONY: ncurses
103
104ncurses:
105	@echo "main() {}" > lxtemp.c
106	@if $(HOSTCC) lxtemp.c $(LIBS) ; then \
107		rm -f lxtemp.c a.out; \
108	else \
109		rm -f lxtemp.c; \
110		echo -e "\007" ;\
111		echo ">> Unable to find the Ncurses libraries." ;\
112		echo ">>" ;\
113		echo ">> You must have Ncurses installed in order" ;\
114		echo ">> to use 'make menuconfig'" ;\
115		echo ">>" ;\
116		echo ">> Maybe you want to try 'make config', which" ;\
117		echo ">> doesn't depend on the Ncurses libraries." ;\
118		echo ;\
119		exit 1 ;\
120	fi
121
122clean:
123	rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \
124		conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h
125