| 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 | CP=cp -fpR
|
|---|
| 8 |
|
|---|
| 9 | # Select the compiler needed to build binaries for your development system
|
|---|
| 10 | HOSTCC ?= gcc
|
|---|
| 11 | HOSTCFLAGS?= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fcommon
|
|---|
| 12 | # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
|
|---|
| 13 | LC_ALL:= C
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | all: ncurses conf mconf
|
|---|
| 17 |
|
|---|
| 18 | LIBS = -lncurses
|
|---|
| 19 | ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
|
|---|
| 20 | HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
|
|---|
| 21 | else
|
|---|
| 22 | ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
|
|---|
| 23 | HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
|
|---|
| 24 | else
|
|---|
| 25 | ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h))
|
|---|
| 26 | HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses.h>"
|
|---|
| 27 | else
|
|---|
| 28 | ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h))
|
|---|
| 29 | HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
|
|---|
| 30 | else
|
|---|
| 31 | ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
|
|---|
| 32 | HOSTNCURSES += -DCURSES_LOC="<ncurses.h>"
|
|---|
| 33 | else
|
|---|
| 34 | HOSTNCURSES += -DCURSES_LOC="<curses.h>"
|
|---|
| 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 | else
|
|---|
| 81 |
|
|---|
| 82 | lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
|
|---|
| 83 | $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
|
|---|
| 84 |
|
|---|
| 85 | lex.zconf.c: lex.zconf.c_shipped
|
|---|
| 86 | $(CP) lex.zconf.c_shipped lex.zconf.c
|
|---|
| 87 |
|
|---|
| 88 | zconf.tab.o: zconf.tab.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(SHARED_DEPS)
|
|---|
| 89 | $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
|
|---|
| 90 |
|
|---|
| 91 | zconf.tab.c: zconf.tab.c_shipped
|
|---|
| 92 | $(CP) zconf.tab.c_shipped zconf.tab.c
|
|---|
| 93 |
|
|---|
| 94 | zconf.tab.h: zconf.tab.h_shipped
|
|---|
| 95 | $(CP) zconf.tab.h_shipped zconf.tab.h
|
|---|
| 96 | endif
|
|---|
| 97 |
|
|---|
| 98 | .PHONY: ncurses
|
|---|
| 99 |
|
|---|
| 100 | ncurses:
|
|---|
| 101 | @echo "int main(void) { return -1; }" > lxtemp.c
|
|---|
| 102 | @if $(HOSTCC) $(HOSTCFLAGS) lxtemp.c $(LIBS) ; then \
|
|---|
| 103 | rm -f lxtemp.c a.out; \
|
|---|
| 104 | else \
|
|---|
| 105 | rm -f lxtemp.c; \
|
|---|
| 106 | echo -e "\007" ;\
|
|---|
| 107 | echo ">> Unable to find the Ncurses libraries." ;\
|
|---|
| 108 | echo ">>" ;\
|
|---|
| 109 | echo ">> You must have Ncurses installed in order" ;\
|
|---|
| 110 | echo ">> to use 'make menuconfig'" ;\
|
|---|
| 111 | echo ;\
|
|---|
| 112 | exit 1 ;\
|
|---|
| 113 | fi
|
|---|
| 114 |
|
|---|
| 115 | clean:
|
|---|
| 116 | @rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \
|
|---|
| 117 | conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h
|
|---|