blob: 716e130da53716b42761e34f787fbbd6e8d866d4 [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
Bernhard Reutner-Fischer022eb312006-03-02 17:33:25 +00005ifndef top_srcdir
Eric Andersen7daa0762004-10-08 07:46:08 +00006top_srcdir=../..
Bernhard Reutner-Fischer022eb312006-03-02 17:33:25 +00007endif
8ifndef top_builddir
Eric Andersen7daa0762004-10-08 07:46:08 +00009top_builddir=../..
Bernhard Reutner-Fischer022eb312006-03-02 17:33:25 +000010endif
Eric Andersen7daa0762004-10-08 07:46:08 +000011srcdir=$(top_srcdir)/scripts/config
Rob Landleye1d96332005-08-24 00:41:52 +000012include $(top_srcdir)/Rules.mak
Eric Andersenc9f20d92002-12-05 08:41:41 +000013
Eric Andersenc9f20d92002-12-05 08:41:41 +000014all: ncurses conf mconf
15
Peter Kjellerstedtbae38db2005-04-19 09:55:06 +000016ifeq ($(shell uname),SunOS)
17LIBS = -lcurses
18else
Eric Andersenc9f20d92002-12-05 08:41:41 +000019LIBS = -lncurses
Peter Kjellerstedtbae38db2005-04-19 09:55:06 +000020endif
Eric Andersenc9f20d92002-12-05 08:41:41 +000021ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
Eric Andersen068b6b02002-12-13 22:53:28 +000022 HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
Eric Andersenc9f20d92002-12-05 08:41:41 +000023else
24ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
Eric Andersen068b6b02002-12-13 22:53:28 +000025 HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
Eric Andersenc9f20d92002-12-05 08:41:41 +000026else
Eric Andersen575c7822003-01-11 18:07:38 +000027ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h))
28 HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses.h>"
29else
30ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h))
31 HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
32else
Eric Andersenc9f20d92002-12-05 08:41:41 +000033ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
Eric Andersen068b6b02002-12-13 22:53:28 +000034 HOSTNCURSES += -DCURSES_LOC="<ncurses.h>"
Eric Andersenc9f20d92002-12-05 08:41:41 +000035else
Eric Andersen068b6b02002-12-13 22:53:28 +000036 HOSTNCURSES += -DCURSES_LOC="<curses.h>"
Eric Andersenc9f20d92002-12-05 08:41:41 +000037endif
38endif
39endif
Eric Andersen575c7822003-01-11 18:07:38 +000040endif
41endif
Eric Andersenc9f20d92002-12-05 08:41:41 +000042
Peter Kjellerstedtbae38db2005-04-19 09:55:06 +000043CONF_SRC = conf.c
44MCONF_SRC = mconf.c
45LXD_SRC = lxdialog/checklist.c lxdialog/menubox.c lxdialog/textbox.c \
46 lxdialog/yesno.c lxdialog/inputbox.c lxdialog/util.c \
47 lxdialog/msgbox.c
Rob Landleye1d96332005-08-24 00:41:52 +000048
Peter Kjellerstedtbae38db2005-04-19 09:55:06 +000049SHARED_SRC = zconf.tab.c
50SHARED_DEPS := $(srcdir)/lkc.h $(srcdir)/lkc_proto.h \
51 lkc_defs.h $(srcdir)/expr.h zconf.tab.h
52CONF_OBJS = $(patsubst %.c,%.o, $(CONF_SRC))
53MCONF_OBJS = $(patsubst %.c,%.o, $(MCONF_SRC) $(LXD_SRC))
54SHARED_OBJS = $(patsubst %.c,%.o, $(SHARED_SRC))
Eric Andersenc9f20d92002-12-05 08:41:41 +000055
Eric Andersenc7bda1c2004-03-15 08:29:22 +000056conf: $(CONF_OBJS) $(SHARED_OBJS)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000057 $(do_link.h)
Eric Andersenc9f20d92002-12-05 08:41:41 +000058
Eric Andersen068b6b02002-12-13 22:53:28 +000059mconf: $(MCONF_OBJS) $(SHARED_OBJS)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000060 $(do_link.h) $(LIBS)
Eric Andersenc9f20d92002-12-05 08:41:41 +000061
Eric Andersen7daa0762004-10-08 07:46:08 +000062$(CONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS)
Mike Frysingerb38673f2006-02-02 01:41:53 +000063 $(compile.h) -I.
Eric Andersenc9f20d92002-12-05 08:41:41 +000064
Eric Andersen7daa0762004-10-08 07:46:08 +000065$(MCONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000066 @[ -d $(@D) ] || mkdir $(@D)
Mike Frysingerb38673f2006-02-02 01:41:53 +000067 $(compile.h) $(HOSTNCURSES) -I.
Eric Andersen068b6b02002-12-13 22:53:28 +000068
Eric Andersen7daa0762004-10-08 07:46:08 +000069lkc_defs.h: $(srcdir)/lkc_proto.h
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000070 @$(SED) < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
Eric Andersenc9f20d92002-12-05 08:41:41 +000071
72###
73# The following requires flex/bison
Eric Andersenc7bda1c2004-03-15 08:29:22 +000074# By default we use the _shipped versions, uncomment the
Eric Andersenc9f20d92002-12-05 08:41:41 +000075# following line if you are modifying the flex/bison src.
76#LKC_GENPARSER := 1
77
78ifdef LKC_GENPARSER
79
Eric Andersen7daa0762004-10-08 07:46:08 +000080%.tab.c %.tab.h: $(srcdir)/%.y
Eric Andersenc9f20d92002-12-05 08:41:41 +000081 bison -t -d -v -b $* -p $(notdir $*) $<
82
Eric Andersen7daa0762004-10-08 07:46:08 +000083lex.%.c: $(srcdir)/%.l
Eric Andersenc9f20d92002-12-05 08:41:41 +000084 flex -P$(notdir $*) -o$@ $<
85else
86
Eric Andersen068b6b02002-12-13 22:53:28 +000087lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
Mike Frysingerb38673f2006-02-02 01:41:53 +000088 $(compile.h) -I$(srcdir)
Eric Andersen068b6b02002-12-13 22:53:28 +000089
Eric Andersen7daa0762004-10-08 07:46:08 +000090lex.zconf.c: $(srcdir)/lex.zconf.c_shipped
Mike Frysingerb38673f2006-02-02 01:41:53 +000091 $(Q)cp $< $@
Eric Andersenc9f20d92002-12-05 08:41:41 +000092
Eric Andersen7daa0762004-10-08 07:46:08 +000093zconf.tab.c: $(srcdir)/zconf.tab.c_shipped
Mike Frysingerb38673f2006-02-02 01:41:53 +000094 $(Q)cp $< $@
Eric Andersen068b6b02002-12-13 22:53:28 +000095
Eric Andersen7daa0762004-10-08 07:46:08 +000096zconf.tab.h: $(srcdir)/zconf.tab.h_shipped
Mike Frysingerb38673f2006-02-02 01:41:53 +000097 $(Q)cp $< $@
Eric Andersenc9f20d92002-12-05 08:41:41 +000098endif
99
Eric Andersen7daa0762004-10-08 07:46:08 +0000100zconf.tab.o: zconf.tab.c lex.zconf.c $(srcdir)/confdata.c $(srcdir)/expr.c \
101 $(srcdir)/symbol.c $(srcdir)/menu.c $(SHARED_DEPS)
Mike Frysingerb38673f2006-02-02 01:41:53 +0000102 $(compile.h) -I$(srcdir) -I.
Eric Andersen7daa0762004-10-08 07:46:08 +0000103
Eric Andersenc9f20d92002-12-05 08:41:41 +0000104.PHONY: ncurses
105
106ncurses:
107 @echo "main() {}" > lxtemp.c
108 @if $(HOSTCC) lxtemp.c $(LIBS) ; then \
109 rm -f lxtemp.c a.out; \
110 else \
111 rm -f lxtemp.c; \
112 echo -e "\007" ;\
113 echo ">> Unable to find the Ncurses libraries." ;\
114 echo ">>" ;\
115 echo ">> You must have Ncurses installed in order" ;\
116 echo ">> to use 'make menuconfig'" ;\
117 echo ;\
118 exit 1 ;\
119 fi
120
121clean:
122 rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \
123 conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h
124