Makefile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #
  2. #
  3. COREPATH=../../src/
  4. include $(COREPATH)/Makefile.defs
  5. include $(COREPATH)/Makefile.targets
  6. auto_gen=
  7. RELEASE=1.5
  8. UTIL_SRC_NAME=kamcmd
  9. # Pass CUSTOM_NAME to overwrite the kamcmd/sercmd bin name
  10. ifeq ($(CUSTOM_NAME),)
  11. ifeq ($(FLAVOUR),ser)
  12. NAME=sercmd
  13. else
  14. NAME=kamcmd
  15. endif
  16. else
  17. NAME=$(CUSTOM_NAME)
  18. endif
  19. readline_localpath=$(LOCALBASE)/include/readline/readline.h
  20. readline_locations= /usr/include/readline/readline.h \
  21. $(readline_localpath)
  22. ifeq ($(CROSS_COMPILE),)
  23. BUILDER = $(shell which pkg-config)
  24. ifneq ($(BUILDER),)
  25. PKGREADLINE = $(shell $(BUILDER) --exists readline > /dev/null 2>&1 ; echo $$? )
  26. ifneq ($(PKGREADLINE),0)
  27. BUILDER =
  28. endif
  29. endif
  30. endif
  31. use_readline ?=
  32. ifneq (,$(MAKECMDGOALS))
  33. ifeq (,$(filter-out $(nodep_targets),$(MAKECMDGOALS)))
  34. #set it to empty, we don't need to detect/use it for clean, doc a.s.o
  35. override use_readline:=
  36. quiet=1
  37. endif
  38. endif #ifneq (,$(MAKECMDGOALS))
  39. # erase common DEFS (not needed)
  40. C_DEFS:=
  41. DEFS:= -DNAME='"$(NAME)"' -DSRNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -D__OS_$(OS) \
  42. -DRUN_DIR='"$(run_target)"' \
  43. $(filter -D%HAVE -DARCH% -DOS% -D__CPU% -D__OS%, $(DEFS))
  44. # use proper libs (we can't rely on LIBS value since we might be called
  45. # from a module Makefile)
  46. #LIBS:=$(filter-out -lfl -ldl -lpthread -lssl -lcrypto, $(LIBS))
  47. ifeq ($(OS), linux)
  48. LIBS:= -lresolv
  49. endif
  50. ifeq ($(OS), solaris)
  51. LIBS:= -lresolv -L$(LOCALBASE)/lib -lxnet -lnsl
  52. endif
  53. ifeq ($(OS), freebsd)
  54. LIBS:=
  55. endif
  56. ifeq ($(OS), dragonfly)
  57. LIBS:= -L$(LOCALBASE)/lib
  58. endif
  59. ifeq ($(OS), openbsd)
  60. LIBS:=
  61. endif
  62. ifeq ($(OS), netbsd)
  63. LIBS:=
  64. endif
  65. ifeq ($(OS), darwin)
  66. readline_locations= /opt/local/include/readline/readline.h \
  67. /usr/include/readline/readline.h \
  68. $(readline_localpath)
  69. LIBS:= -lresolv
  70. endif
  71. ifneq (,$(findstring cygwin, $(OS)))
  72. LIBS:= -lresolv
  73. endif
  74. # detect libreadline
  75. ifneq ($(BUILDER),)
  76. DEFS += $(shell $(BUILDER) --cflags readline)
  77. DEFS+=-DUSE_READLINE
  78. LIBS += $(shell $(BUILDER) --libs readline)
  79. use_readline := 1
  80. else
  81. ifeq ($(use_readline),)
  82. readline_path := $(shell \
  83. for r in $(readline_locations) ""; do \
  84. if [ -r "$$r" ] ; then echo $$r; exit; fi; \
  85. done;\
  86. )
  87. ifneq ($(readline_path),)
  88. use_readline := 1
  89. endif
  90. endif
  91. ifeq ($(use_readline),1)
  92. ifneq (,$(findstring opt, $(readline_path)))
  93. DEFS+=-DUSE_READLINE -I /opt/local/include
  94. LIBS+=-L/opt/local/lib -lreadline -lncurses
  95. else
  96. ifeq ($(readline_path),$(readline_localpath))
  97. DEFS+=-I$(LOCALBASE)/include
  98. LIBS+=-L$(LOCALBASE)/lib
  99. endif
  100. DEFS+=-DUSE_READLINE
  101. LIBS+=-lreadline -lncurses
  102. endif
  103. endif # ifeq ($(use_readline),1)
  104. endif # ifneq ($(BUILDER),)
  105. include $(COREPATH)/Makefile.utils
  106. ifeq (,$(quiet))
  107. ifeq ($(use_readline),1)
  108. ifneq ($(BUILDER),)
  109. $(info readline detected via pkg-config)
  110. else
  111. $(info readline detected ($(readline_path)) )
  112. endif
  113. $(info command completion enabled)
  114. else
  115. $(info "no readline include files detected, disabling readline support")
  116. $(info "command completion disabled" )
  117. $(info "to force readline support try 'make use_readline=1'")
  118. endif
  119. endif # ifeq (,$(quiet))
  120. $(NAME).o:
  121. .PHONY: msg
  122. msg:
  123. @if [ "$(use_readline)" = "1" ]; then \
  124. if [ "$(BUILDER)" = "" ]; then \
  125. echo; echo "readline detected ($(readline_path)):"; \
  126. else \
  127. echo; echo "readline detected via pkg-config"; \
  128. fi; \
  129. echo "command completion enabled"; echo ; \
  130. else \
  131. echo ; \
  132. echo "no readline include files detected, disabling readline support";\
  133. echo "command completion disabled"; \
  134. echo "(to force readline support try 'make use_readline=1')";\
  135. echo ; \
  136. fi
  137. modules: