Debian Codegraph @

utils/kamcmd/Makefile

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