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