Makefile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # $Id: Makefile 185 2008-10-28 12:24:05Z wbx $
  2. #-
  3. # This file is part of the OpenADK project. OpenADK is copyrighted
  4. # material, please see the LICENCE file in the top-level directory.
  5. include ${TOPDIR}/rules.mk
  6. CP=cp -fpR
  7. all: ncurses conf mconf
  8. LIBS= -lncurses
  9. ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
  10. HOSTNCURSES+= -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
  11. else
  12. ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
  13. HOSTNCURSES+= -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
  14. else
  15. ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h))
  16. HOSTCFLAGS+= -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses.h>"
  17. else
  18. ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h))
  19. HOSTCFLAGS+= -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
  20. else
  21. ifeq (/usr/pkg/include/ncurses.h, $(wildcard /usr/pkg/include/ncurses.h))
  22. HOSTCFLAGS+= -I/usr/pkg/include -DCURSES_LOC="<ncurses.h>"
  23. LIBS+= -L/usr/pkg/lib -Wl,-rpath -Wl,/usr/pkg/lib
  24. else
  25. ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
  26. HOSTNCURSES+= -DCURSES_LOC="<ncurses.h>"
  27. else
  28. HOSTNCURSES+= -DCURSES_LOC="<curses.h>"
  29. endif
  30. endif
  31. endif
  32. endif
  33. endif
  34. endif
  35. CONF_SRC =conf.c
  36. MCONF_SRC =mconf.c checklist.c menubox.c textbox.c yesno.c inputbox.c util.c msgbox.c
  37. SHARED_SRC=zconf.tab.c glob.c
  38. SHARED_DEPS:=lkc.h lkc_proto.h lkc_defs.h expr.h zconf.tab.h glob.h
  39. CONF_OBJS =$(patsubst %.c,%.o, $(CONF_SRC))
  40. MCONF_OBJS=$(patsubst %.c,%.o, $(MCONF_SRC))
  41. SHARED_OBJS=$(patsubst %.c,%.o, $(SHARED_SRC))
  42. conf: $(CONF_OBJS) $(SHARED_OBJS)
  43. $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@
  44. mconf: $(MCONF_OBJS) $(SHARED_OBJS)
  45. $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS)
  46. $(CONF_OBJS): %.o : %.c $(SHARED_DEPS)
  47. $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
  48. $(MCONF_OBJS): %.o : %.c $(SHARED_DEPS)
  49. $(HOSTCC) $(HOSTCFLAGS) $(HOSTNCURSES) -I. -c $< -o $@
  50. glob.o: glob.c $(SHARED_DEPS)
  51. $(HOSTCC) $(HOSTCFLAGS) -I. -c glob.c -o $@
  52. lkc_defs.h: lkc_proto.h
  53. @sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
  54. ###
  55. # The following requires flex/bison
  56. # By default we use the _shipped versions, uncomment the
  57. # following line if you are modifying the flex/bison src.
  58. LKC_GENPARSER:= 1
  59. ifdef LKC_GENPARSER
  60. %.tab.c %.tab.h: %.y
  61. bison -t -d -v -b $* -p $(notdir $*) $<
  62. lex.%.c: %.l
  63. flex -P$(notdir $*) -o$@ $<
  64. lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
  65. $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
  66. zconf.tab.o: zconf.tab.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(SHARED_DEPS)
  67. $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
  68. else
  69. lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
  70. $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
  71. lex.zconf.c: lex.zconf.c_shipped
  72. $(CP) lex.zconf.c_shipped lex.zconf.c
  73. zconf.tab.o: zconf.tab.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(SHARED_DEPS)
  74. $(HOSTCC) $(HOSTCFLAGS) -I. -c $< -o $@
  75. zconf.tab.c: zconf.tab.c_shipped
  76. $(CP) zconf.tab.c_shipped zconf.tab.c
  77. zconf.tab.h: zconf.tab.h_shipped
  78. $(CP) zconf.tab.h_shipped zconf.tab.h
  79. endif
  80. .PHONY: ncurses
  81. ncurses:
  82. @echo "int main(void) { return -1; }" > lxtemp.c
  83. @if $(HOSTCC) $(HOSTCFLAGS) lxtemp.c $(LIBS) ; then \
  84. rm -f lxtemp.c a.out; \
  85. else \
  86. rm -f lxtemp.c; \
  87. printf '\007'; \
  88. echo ">> Unable to find the Ncurses libraries." ;\
  89. echo ">>" ;\
  90. echo ">> You must have Ncurses installed in order" ;\
  91. echo ">> to use 'make menuconfig'" ;\
  92. echo ;\
  93. exit 1 ;\
  94. fi
  95. clean:
  96. rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \
  97. conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h