Makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. include ${ADK_TOPDIR}/prereq.mk
  4. ifneq ($(filter-out clean,${MAKECMDGOALS}),)
  5. include ${ADK_TOPDIR}/rules.mk
  6. endif
  7. CP=cp -fpR
  8. HOST_CFLAGS+=-DKBUILD_NO_NLS -w
  9. all: ncurses conf mconf
  10. LIBS=
  11. ifeq (/usr/lib/libtinfo.so, $(wildcard /usr/lib/libtinfo.so))
  12. LIBS= -ltinfo
  13. endif
  14. ifeq (/usr/include/ncursesw/curses.h, $(wildcard /usr/include/ncursesw/curses.h))
  15. HOST_CFLAGS+= -I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"
  16. LIBS+= -lncursesw
  17. else
  18. ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
  19. HOST_CFLAGS+= -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
  20. LIBS+= -lncurses
  21. else
  22. ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
  23. HOST_CFLAGS+= -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
  24. LIBS+= -lncurses
  25. else
  26. ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h))
  27. HOST_CFLAGS+= -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses.h>"
  28. LIBS+= -lncurses
  29. else
  30. ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h))
  31. HOST_CFLAGS+= -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
  32. LIBS+= -lncurses
  33. else
  34. ifeq (/usr/local/opt/ncurses/include/ncursesw/ncurses.h, $(wildcard /usr/local/opt/ncurses/include/ncursesw/ncurses.h))
  35. HOST_CFLAGS+= -I/usr/local/opt/ncurses/include -DCURSES_LOC="<ncursesw/ncurses.h>"
  36. LIBS+= -L/usr/local/opt/ncurses/lib -Wl,-rpath -Wl,/usr/local/opt/ncurses/lib -lncursesw
  37. else
  38. ifeq (/usr/pkg/include/ncurses.h, $(wildcard /usr/pkg/include/ncurses.h))
  39. HOST_CFLAGS+= -I/usr/pkg/include -DCURSES_LOC="<ncurses.h>"
  40. LIBS+= -L/usr/pkg/lib -Wl,-rpath -Wl,/usr/pkg/lib -lncurses
  41. else
  42. ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
  43. HOST_CFLAGS+= -DCURSES_LOC="<ncurses.h>"
  44. LIBS+= -lncurses
  45. else
  46. HOST_CFLAGS+= -DCURSES_LOC="<curses.h>"
  47. LIBS= -lcurses
  48. endif
  49. endif
  50. endif
  51. endif
  52. endif
  53. endif
  54. endif
  55. endif
  56. CONF_SRC =conf.c
  57. MCONF_SRC =mconf.c $(wildcard lxdialog/*.c)
  58. SHARED_SRC=zconf.tab.c
  59. SHARED_DEPS:=lkc.h lkc_proto.h lkc_defs.h expr.h zconf.tab.h
  60. CONF_OBJS =$(patsubst %.c,%.o, $(CONF_SRC))
  61. MCONF_OBJS=$(patsubst %.c,%.o, $(MCONF_SRC))
  62. SHARED_OBJS=$(patsubst %.c,%.o, $(SHARED_SRC))
  63. conf: $(CONF_OBJS) $(SHARED_OBJS)
  64. @$(HOST_CC) $(HOST_CFLAGS) $^ -o $@ 2>/dev/null
  65. mconf: $(MCONF_OBJS) $(SHARED_OBJS)
  66. @$(HOST_CC) $(HOST_CFLAGS) $^ -o $@ $(LIBS) 2>/dev/null
  67. $(CONF_OBJS): %.o : %.c $(SHARED_DEPS)
  68. @$(HOST_CC) $(HOST_CFLAGS) -I. -c $< -o $@ 2>/dev/null
  69. $(MCONF_OBJS): %.o : %.c $(SHARED_DEPS)
  70. @$(HOST_CC) $(HOST_CFLAGS) -I. -c $< -o $@ 2>/dev/null
  71. glob.o: glob.c $(SHARED_DEPS)
  72. @$(HOST_CC) $(HOST_CFLAGS) -I. -c glob.c -o $@ 2>/dev/null
  73. lkc_defs.h: lkc_proto.h
  74. @sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
  75. ###
  76. # The following requires flex/bison
  77. # By default we use the _shipped versions, uncomment the
  78. # following line if you are modifying the flex/bison src.
  79. # LKC_GENPARSER:= 1
  80. ifdef LKC_GENPARSER
  81. %.tab.c %.tab.h: %.y
  82. bison -t -d -v -b $* -p $(notdir $*) $<
  83. %.hash.c: %.gperf
  84. gperf -t --output-file zconf.hash.c -a -C -E -g -k '1,3,$$' -p -t zconf.gperf
  85. lex.%.c: %.l
  86. flex -P$(notdir $*) -o$@ $<
  87. lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
  88. @$(HOST_CC) $(HOST_CFLAGS) -I. -c $< -o $@
  89. zconf.tab.o: zconf.tab.c zconf.hash.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(SHARED_DEPS)
  90. @$(HOST_CC) $(HOST_CFLAGS) -I. -c $< -o $@
  91. else
  92. lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
  93. @$(HOST_CC) $(HOST_CFLAGS) -I. -c $< -o $@
  94. lex.zconf.c: lex.zconf.c_shipped
  95. @$(CP) lex.zconf.c_shipped lex.zconf.c
  96. zconf.hash.c: zconf.hash.c_shipped
  97. @$(CP) zconf.hash.c_shipped zconf.hash.c
  98. zconf.tab.o: zconf.tab.c zconf.hash.c lex.zconf.c confdata.c expr.c symbol.c menu.c $(SHARED_DEPS)
  99. @$(HOST_CC) $(HOST_CFLAGS) -I. -c $< -o $@
  100. zconf.tab.c: zconf.tab.c_shipped
  101. @$(CP) zconf.tab.c_shipped zconf.tab.c
  102. zconf.tab.h: zconf.tab.h_shipped
  103. @$(CP) zconf.tab.h_shipped zconf.tab.h
  104. endif
  105. .PHONY: ncurses
  106. ncurses:
  107. @echo "int main(void) { return -1; }" > lxtemp.c
  108. @if $(HOST_CC) $(HOST_CFLAGS) lxtemp.c $(LIBS) ; then \
  109. rm -f lxtemp.c a.out; \
  110. else \
  111. rm -f lxtemp.c; \
  112. printf '\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. clean:
  121. @rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) zconf.hash.c \
  122. conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h