blob: 4c966f7a63c742ce2729e7a79224766936d32c1e [file] [log] [blame]
Eric Andersenc9f20d92002-12-05 08:41:41 +00001# Makefile for BusyBox
2#
3# Copyright (C) 2002 Erik Andersen <andersen@codepoet.org>
4
Eric Andersen7daa0762004-10-08 07:46:08 +00005top_srcdir=../..
6top_builddir=../..
7srcdir=$(top_srcdir)/scripts/config
Rob Landleye1d96332005-08-24 00:41:52 +00008include $(top_srcdir)/Rules.mak
Eric Andersenc9f20d92002-12-05 08:41:41 +00009
Eric Andersenc9f20d92002-12-05 08:41:41 +000010all: ncurses conf mconf
11
Peter Kjellerstedtbae38db2005-04-19 09:55:06 +000012ifeq ($(shell uname),SunOS)
13LIBS = -lcurses
14else
Eric Andersenc9f20d92002-12-05 08:41:41 +000015LIBS = -lncurses
Peter Kjellerstedtbae38db2005-04-19 09:55:06 +000016endif
Eric Andersenc9f20d92002-12-05 08:41:41 +000017ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
Eric Andersen068b6b02002-12-13 22:53:28 +000018 HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
Eric Andersenc9f20d92002-12-05 08:41:41 +000019else
20ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
Eric Andersen068b6b02002-12-13 22:53:28 +000021 HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
Eric Andersenc9f20d92002-12-05 08:41:41 +000022else
Eric Andersen575c7822003-01-11 18:07:38 +000023ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h))
24 HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses.h>"
25else
26ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h))
27 HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
28else
Eric Andersenc9f20d92002-12-05 08:41:41 +000029ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
Eric Andersen068b6b02002-12-13 22:53:28 +000030 HOSTNCURSES += -DCURSES_LOC="<ncurses.h>"
Eric Andersenc9f20d92002-12-05 08:41:41 +000031else
Eric Andersen068b6b02002-12-13 22:53:28 +000032 HOSTNCURSES += -DCURSES_LOC="<curses.h>"
Eric Andersenc9f20d92002-12-05 08:41:41 +000033endif
34endif
35endif
Eric Andersen575c7822003-01-11 18:07:38 +000036endif
37endif
Eric Andersenc9f20d92002-12-05 08:41:41 +000038
Peter Kjellerstedtbae38db2005-04-19 09:55:06 +000039CONF_SRC = conf.c
40MCONF_SRC = mconf.c
41LXD_SRC = lxdialog/checklist.c lxdialog/menubox.c lxdialog/textbox.c \
42 lxdialog/yesno.c lxdialog/inputbox.c lxdialog/util.c \
43 lxdialog/msgbox.c
Rob Landleye1d96332005-08-24 00:41:52 +000044
Peter Kjellerstedtbae38db2005-04-19 09:55:06 +000045SHARED_SRC = zconf.tab.c
46SHARED_DEPS := $(srcdir)/lkc.h $(srcdir)/lkc_proto.h \
47 lkc_defs.h $(srcdir)/expr.h zconf.tab.h
48CONF_OBJS = $(patsubst %.c,%.o, $(CONF_SRC))
49MCONF_OBJS = $(patsubst %.c,%.o, $(MCONF_SRC) $(LXD_SRC))
50SHARED_OBJS = $(patsubst %.c,%.o, $(SHARED_SRC))
Eric Andersenc9f20d92002-12-05 08:41:41 +000051
Eric Andersenc7bda1c2004-03-15 08:29:22 +000052conf: $(CONF_OBJS) $(SHARED_OBJS)
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000053 $(SECHO) " "HOSTCC $@ ; true
54 $(Q)$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@
Eric Andersenc9f20d92002-12-05 08:41:41 +000055
Eric Andersen068b6b02002-12-13 22:53:28 +000056mconf: $(MCONF_OBJS) $(SHARED_OBJS)
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000057 $(SECHO) " "HOSTCC $@ ; true
58 $(Q)$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS)
Eric Andersenc9f20d92002-12-05 08:41:41 +000059
Eric Andersen7daa0762004-10-08 07:46:08 +000060$(CONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS)
Mike Frysingerb38673f2006-02-02 01:41:53 +000061 $(compile.h) -I.
Eric Andersenc9f20d92002-12-05 08:41:41 +000062
Eric Andersen7daa0762004-10-08 07:46:08 +000063$(MCONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000064 @[ -d $(@D) ] || mkdir $(@D)
Mike Frysingerb38673f2006-02-02 01:41:53 +000065 $(compile.h) $(HOSTNCURSES) -I.
Eric Andersen068b6b02002-12-13 22:53:28 +000066
Eric Andersen7daa0762004-10-08 07:46:08 +000067lkc_defs.h: $(srcdir)/lkc_proto.h
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000068 @$(SED) < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
Eric Andersenc9f20d92002-12-05 08:41:41 +000069
70###
71# The following requires flex/bison
Eric Andersenc7bda1c2004-03-15 08:29:22 +000072# By default we use the _shipped versions, uncomment the
Eric Andersenc9f20d92002-12-05 08:41:41 +000073# following line if you are modifying the flex/bison src.
74#LKC_GENPARSER := 1
75
76ifdef LKC_GENPARSER
77
Eric Andersen7daa0762004-10-08 07:46:08 +000078%.tab.c %.tab.h: $(srcdir)/%.y
Eric Andersenc9f20d92002-12-05 08:41:41 +000079 bison -t -d -v -b $* -p $(notdir $*) $<
80
Eric Andersen7daa0762004-10-08 07:46:08 +000081lex.%.c: $(srcdir)/%.l
Eric Andersenc9f20d92002-12-05 08:41:41 +000082 flex -P$(notdir $*) -o$@ $<
83else
84
Eric Andersen068b6b02002-12-13 22:53:28 +000085lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
Mike Frysingerb38673f2006-02-02 01:41:53 +000086 $(compile.h) -I$(srcdir)
Eric Andersen068b6b02002-12-13 22:53:28 +000087
Eric Andersen7daa0762004-10-08 07:46:08 +000088lex.zconf.c: $(srcdir)/lex.zconf.c_shipped
Mike Frysingerb38673f2006-02-02 01:41:53 +000089 $(Q)cp $< $@
Eric Andersenc9f20d92002-12-05 08:41:41 +000090
Eric Andersen7daa0762004-10-08 07:46:08 +000091zconf.tab.c: $(srcdir)/zconf.tab.c_shipped
Mike Frysingerb38673f2006-02-02 01:41:53 +000092 $(Q)cp $< $@
Eric Andersen068b6b02002-12-13 22:53:28 +000093
Eric Andersen7daa0762004-10-08 07:46:08 +000094zconf.tab.h: $(srcdir)/zconf.tab.h_shipped
Mike Frysingerb38673f2006-02-02 01:41:53 +000095 $(Q)cp $< $@
Eric Andersenc9f20d92002-12-05 08:41:41 +000096endif
97
Eric Andersen7daa0762004-10-08 07:46:08 +000098zconf.tab.o: zconf.tab.c lex.zconf.c $(srcdir)/confdata.c $(srcdir)/expr.c \
99 $(srcdir)/symbol.c $(srcdir)/menu.c $(SHARED_DEPS)
Mike Frysingerb38673f2006-02-02 01:41:53 +0000100 $(compile.h) -I$(srcdir) -I.
Eric Andersen7daa0762004-10-08 07:46:08 +0000101
Eric Andersenc9f20d92002-12-05 08:41:41 +0000102.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 exit 1 ;\
117 fi
118
119clean:
120 rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \
121 conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h
122