Makefile 3.8 KB

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