4ed85f4cc33a336237481f88a26aa3b5bb4c83d1
[sip-router] / utils / sercmd / Makefile
1 # $Id$
2 COREPATH=../..
3 include $(COREPATH)/Makefile.defs
4 include $(COREPATH)/Makefile.targets
5
6 auto_gen=
7 NAME=sercmd
8 RELEASE=0.2
9
10 readline_locations= /usr/include/readline/readline.h \
11                                         $(LOCALBASE)/include/readline/readline.h
12
13 use_readline ?=
14 ifneq (,$(MAKECMDGOALS))
15 ifeq (,$(filter-out $(nodep_targets),$(MAKECMDGOALS)))
16 #set it to empty, we don't need to detect/use it for clean, doc a.s.o
17 override use_readline:=
18 quiet=1
19 endif
20 endif #ifneq (,$(MAKECMDGOALS))
21
22
23 # erase common DEFS (not needed)
24 C_DEFS:=
25 DEFS:= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' \
26                 $(filter -D%HAVE -DARCH% -DOS% -D__CPU% -D__OS%, $(DEFS))
27 LIBS:=$(filter-out -lfl  -ldl -lpthread -lssl -lcrypto, $(LIBS))
28
29 ifeq ($(use_readline),)
30 readline_path := $(shell  \
31                                                 for r in $(readline_locations) ""; do \
32                                                         if [ -r "$$r" ] ; then echo $$r; exit; fi;  \
33                                                 done;\
34                                         )
35 ifneq ($(readline_path),)
36 use_readline := 1
37 endif
38 endif
39
40 ifeq ($(use_readline),1)
41         DEFS+=-DUSE_READLINE
42         LIBS+=-lreadline -lncurses
43 endif
44
45
46 include $(COREPATH)/Makefile.utils
47
48 ifeq (,$(quiet))
49 ifeq ($(use_readline),1)
50 $(info readline detected ($(readline_path)) )
51 $(info command completion enabled)
52 else
53 $(info "no readline include files detected, disabling readline support")
54 $(info "command completion disabled" )
55 $(info "to force readline support try 'make use_readline=1'")
56 endif
57 endif # ifeq (,$(quiet))
58
59 $(NAME).o: 
60
61 .PHONY: msg
62 msg:
63         @if [ "$(use_readline)" = "1" ]; then \
64                 echo; echo "readline detected ($(readline_path)):"; \
65                 echo "command completion enabled"; echo ; \
66         else \
67                 echo ; \
68                 echo "no readline include files detected, disabling readline support";\
69                 echo "command completion disabled"; \
70                 echo "(to force readline support try 'make use_readline=1')";\
71                 echo ; \
72         fi
73
74 modules: