Makefile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # ===========================================================================
  2. # OpenWrt configuration targets
  3. # These targets are used from top-level makefile
  4. # ===========================================================================
  5. # Shared Makefile for the various kconfig executables:
  6. # conf: Used for defconfig, oldconfig and related targets
  7. # mconf: Used for the mconfig target.
  8. # Utilizes the lxdialog package
  9. # qconf: Used for the xconfig target
  10. # Based on Qt which needs to be installed to compile it
  11. # object files used by all kconfig flavours
  12. # Platform specific fixes
  13. #
  14. # FreeBSD
  15. check_lxdialog = $(shell $(SHELL) $(CURDIR)/lxdialog/check-lxdialog.sh -$(1))
  16. export CFLAGS += -DKBUILD_NO_NLS -I. $(call check_lxdialog,ccflags)
  17. export CXXFLAGS += -DKBUILD_NO_NLS
  18. DISTRO-PKG-CONFIG := $(shell which -a pkg-config | grep -E '\/usr' | head -n 1)
  19. conf-objs := conf.o zconf.tab.o
  20. mconf-objs := mconf.o zconf.tab.o
  21. qconf-cxxobjs := qconf.o
  22. qconf-objs := zconf.tab.o
  23. lxdialog-objs := \
  24. lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o \
  25. lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
  26. clean-files := zconf.tab.c lex.zconf.c zconf.hash.c
  27. # Remove qconf junk files
  28. clean-files += $(qconf-cxxobjs) qconf.moc .tmp_qtcheck qconf
  29. all: conf mconf
  30. conf: $(conf-objs)
  31. mconf: $(mconf-objs) $(lxdialog-objs)
  32. $(CC) -o $@ $^ $(call check_lxdialog,ldflags $(CC))
  33. qconf: $(qconf-cxxobjs) $(qconf-objs)
  34. ifneq ($(DISTRO-PKG-CONFIG),)
  35. $(CXX) $(HOSTLOADLIBES_qconf) -o $@ $^
  36. else
  37. echo "You don't have 'pkg-config' installed. Cannot continue"
  38. echo "For now, you may use 'make menuconfig' instead of 'make xconfig'"
  39. endif
  40. clean:
  41. rm -f *.o lxdialog/*.o $(clean-files) conf mconf
  42. zconf.tab.o: zconf.lex.c zconf.hash.c confdata.c
  43. kconfig_load.o: lkc_defs.h
  44. zconf.tab.c: zconf.y
  45. zconf.lex.c: zconf.l
  46. zconf.hash.c: zconf.gperf
  47. %.tab.c: %.y
  48. cp $@_shipped $@ || bison -l -b $* -p $(notdir $*) $<
  49. %.lex.c: %.l
  50. cp $@_shipped $@ || flex -L -P$(notdir $*) -o$@ $<
  51. %.hash.c: %.gperf
  52. cp $@_shipped $@ || gperf < $< > $@
  53. ifeq ($(MAKECMDGOALS),qconf)
  54. qconf.o: .tmp_qtcheck
  55. .tmp_qtcheck: Makefile
  56. -include .tmp_qtcheck
  57. # Qt needs some extra effort...
  58. .tmp_qtcheck:
  59. @set -e; echo " CHECK qt"; \
  60. if $(DISTRO-PKG-CONFIG) --exists Qt5Core; then \
  61. cflags="-std=c++11 -fPIC `$(DISTRO-PKG-CONFIG) --cflags Qt5Core Qt5Gui Qt5Widgets`"; \
  62. libs=`$(DISTRO-PKG-CONFIG) --libs Qt5Core Qt5Gui Qt5Widgets`; \
  63. moc=`$(DISTRO-PKG-CONFIG) --variable=host_bins Qt5Core`/moc; \
  64. elif $(DISTRO-PKG-CONFIG) --exists QtCore; then \
  65. cflags=`$(DISTRO-PKG-CONFIG) --cflags QtCore QtGui`; \
  66. libs=`$(DISTRO-PKG-CONFIG) --libs QtCore QtGui`; \
  67. moc=`$(DISTRO-PKG-CONFIG) --variable=moc_location QtCore`; \
  68. else \
  69. echo >&2 "*"; \
  70. echo >&2 "* Could not find Qt via $(DISTRO-PKG-CONFIG)."; \
  71. echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"; \
  72. echo >&2 "*"; \
  73. exit 1; \
  74. fi; \
  75. echo "KC_QT_CFLAGS=$$cflags" > $@; \
  76. echo "KC_QT_LIBS=$$libs" >> $@; \
  77. echo "KC_QT_MOC=$$moc" >> $@
  78. endif
  79. #Define compiler flags to build qconf
  80. HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
  81. HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
  82. qconf.o: qconf.moc
  83. qconf.o: CXXFLAGS+=$(HOSTCXXFLAGS_qconf.o)
  84. moc = $(KC_QT_MOC) -i $< -o $@
  85. %.moc: %.h .tmp_qtcheck
  86. $(call moc)