Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. ifeq ($(FLAVOUR),ser)
  10. NAME?=sercmd
  11. else
  12. NAME?=kamcmd
  13. endif
  14. readline_localpath=$(LOCALBASE)/include/readline/readline.h
  15. readline_locations= /usr/include/readline/readline.h \
  16. $(readline_localpath)
  17. use_readline ?=
  18. ifneq (,$(MAKECMDGOALS))
  19. ifeq (,$(filter-out $(nodep_targets),$(MAKECMDGOALS)))
  20. #set it to empty, we don't need to detect/use it for clean, doc a.s.o
  21. override use_readline:=
  22. quiet=1
  23. endif
  24. endif #ifneq (,$(MAKECMDGOALS))
  25. # erase common DEFS (not needed)
  26. C_DEFS:=
  27. DEFS:= -DNAME='"$(NAME)"' -DSRNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -D__OS_$(OS) \
  28. -DRUN_DIR='"$(run_target)"' \
  29. $(filter -D%HAVE -DARCH% -DOS% -D__CPU% -D__OS%, $(DEFS))
  30. # use proper libs (we can't rely on LIBS value since we might be called
  31. # from a module Makefile)
  32. #LIBS:=$(filter-out -lfl -ldl -lpthread -lssl -lcrypto, $(LIBS))
  33. ifeq ($(OS), linux)
  34. LIBS:= -lresolv
  35. endif
  36. ifeq ($(OS), solaris)
  37. LIBS:= -lresolv -L$(LOCALBASE)/lib -lxnet -lnsl
  38. endif
  39. ifeq ($(OS), freebsd)
  40. LIBS:=
  41. endif
  42. ifeq ($(OS), dragonfly)
  43. LIBS:= -L$(LOCALBASE)/lib
  44. endif
  45. ifeq ($(OS), openbsd)
  46. LIBS:=
  47. endif
  48. ifeq ($(OS), netbsd)
  49. LIBS:=
  50. endif
  51. ifeq ($(OS), darwin)
  52. readline_locations= /opt/local/include/readline/readline.h \
  53. /usr/include/readline/readline.h \
  54. $(readline_localpath)
  55. LIBS:= -lresolv
  56. endif
  57. ifneq (,$(findstring cygwin, $(OS)))
  58. LIBS:= -lresolv
  59. endif
  60. ifeq ($(use_readline),)
  61. readline_path := $(shell \
  62. for r in $(readline_locations) ""; do \
  63. if [ -r "$$r" ] ; then echo $$r; exit; fi; \
  64. done;\
  65. )
  66. ifneq ($(readline_path),)
  67. use_readline := 1
  68. endif
  69. endif
  70. ifeq ($(use_readline),1)
  71. ifneq (,$(findstring opt, $(readline_path)))
  72. DEFS+=-DUSE_READLINE -I /opt/local/include
  73. LIBS+=-L/opt/local/lib -lreadline -lncurses
  74. else
  75. ifeq ($(readline_path),$(readline_localpath))
  76. DEFS+=-I$(LOCALBASE)/include
  77. LIBS+=-L$(LOCALBASE)/lib
  78. endif
  79. DEFS+=-DUSE_READLINE
  80. LIBS+=-lreadline -lncurses
  81. endif
  82. endif
  83. include $(COREPATH)/Makefile.utils
  84. ifeq (,$(quiet))
  85. ifeq ($(use_readline),1)
  86. $(info readline detected ($(readline_path)) )
  87. $(info command completion enabled)
  88. else
  89. $(info "no readline include files detected, disabling readline support")
  90. $(info "command completion disabled" )
  91. $(info "to force readline support try 'make use_readline=1'")
  92. endif
  93. endif # ifeq (,$(quiet))
  94. $(NAME).o:
  95. .PHONY: msg
  96. msg:
  97. @if [ "$(use_readline)" = "1" ]; then \
  98. echo; echo "readline detected ($(readline_path)):"; \
  99. echo "command completion enabled"; echo ; \
  100. else \
  101. echo ; \
  102. echo "no readline include files detected, disabling readline support";\
  103. echo "command completion disabled"; \
  104. echo "(to force readline support try 'make use_readline=1')";\
  105. echo ; \
  106. fi
  107. modules: