aff39ce78e4ab556dc9a8b6b85c6ef2f6c35ce64
[asterisk/asterisk.git] / utils / Makefile
1 #
2 # Asterisk -- An open source telephony toolkit.
3
4 # Various utilities
5 #
6 # Copyright (C) 1999-2006, Digium
7 #
8 # Mark Spencer <markster@digium.com>
9 #
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
12 #
13
14 ASTTOPDIR?=..
15 -include $(ASTTOPDIR)/menuselect.makeopts
16
17 .PHONY: clean all uninstall
18
19 # to get check_expr, add it to the ALL_UTILS list -- this is a somewhat old checking
20 #     program that wants an ael file for input, and will check each $[] expr for
21 #     possible (old) problems, like spacing around operators, which dates back to
22 #     the 1.2 days. The neat part is that it will actually evaluate the expressions.
23 #     Users could use this to quickly check expressions in their .ael file.
24 # to get check_expr2, add it to the ALL_UTILS list -- this is a program that will
25 #     read in a file containing expressions (as if they were in $[ ]), one per line. 
26 #     It will, of course signal any syntax errors. Devs (like murf) should use this whenever
27 #     changes are made to ast_expr2.y or ast_expr2.fl (or the corresponding .c files),
28 #     as a regression test. Others (mere mortals?) need not bother, but they are
29 #     more than welcome to play! The regression test itself is in expr2.testinput.
30 ALL_UTILS:=$(MENUSELECT_UTILS)
31 UTILS:=$(ALL_UTILS)
32
33 LIBS += $(BKTR_LIB) # astobj2 with devmode uses backtrace
34
35 _ASTCFLAGS+=-DSTANDALONE
36
37 include $(ASTTOPDIR)/Makefile.rules
38
39 ifeq ($(OSARCH),SunOS)
40   LIBS+=-lsocket -lnsl
41   UTILS:=$(filter-out muted,$(UTILS))
42 endif
43
44 ifeq ($(OSARCH),OpenBSD)
45   UTILS:=$(filter-out muted,$(UTILS))
46 endif
47
48 ifeq ($(OSARCH),cygwin)
49   UTILS:=$(filter-out muted,$(UTILS))
50 endif
51
52 ifeq ($(OSARCH),mingw32)
53   UTILS:=
54 endif
55
56 ifneq ($(findstring darwin,$(OSARCH)),)
57   AUDIO_LIBS=-framework CoreAudio
58 endif
59
60 ifeq ($(POPT_LIB),)
61   UTILS:=$(filter-out smsq,$(UTILS))
62 endif
63
64 ifeq ($(NEWT_LIB),)
65   UTILS:=$(filter-out astman,$(UTILS))
66 endif
67
68 ifneq ($(filter pbx_ael,$(MENUSELECT_PBX)),)
69   UTILS:=$(filter-out aelparse,$(UTILS))
70   UTILS:=$(filter-out conf2ael,$(UTILS))
71 endif
72
73 all: $(UTILS)
74
75 install:
76         for x in $(UTILS); do \
77                 if [ "$$x" != "none" ]; then \
78                         $(INSTALL) -m 755 $$x "$(DESTDIR)$(ASTSBINDIR)/$$x"; \
79                 fi; \
80         done 
81
82 uninstall:
83         for x in $(ALL_UTILS); do rm -f "$(DESTDIR)$(ASTSBINDIR)/$$x"; done
84
85 clean:
86         rm -f *.o $(ALL_UTILS) check_expr
87         rm -f .*.d
88         rm -f *.s *.i
89         rm -f md5.c strcompat.c ast_expr2.c ast_expr2.h ast_expr2f.c pbx_ael.c pval.c hashtab.c lock.c
90         rm -f aelparse.c aelbison.c conf2ael
91         rm -f utils.c strings.c threadstorage.c sha1.c astobj2.c hashtest2 hashtest refcounter
92         rm -f db1-ast/.*.d
93         @$(MAKE) -C db1-ast clean
94
95 md5.c: $(ASTTOPDIR)/main/md5.c
96         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
97         $(CMD_PREFIX) cp "$<" "$@"
98
99 astman: astman.o md5.o
100 astman: LIBS+=$(NEWT_LIB)
101 astman.o: _ASTCFLAGS+=-DNO_MALLOC_DEBUG
102
103 stereorize: stereorize.o frame.o
104 stereorize: LIBS+=-lm
105
106 hashtab.c: $(ASTTOPDIR)/main/hashtab.c
107         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
108         $(CMD_PREFIX) cp "$<" "$@"
109
110 lock.c: $(ASTTOPDIR)/main/lock.c
111         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
112         $(CMD_PREFIX) cp "$<" "$@"
113
114 strcompat.c: $(ASTTOPDIR)/main/strcompat.c
115         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
116         $(CMD_PREFIX) cp "$<" "$@"
117
118 pval.c: $(ASTTOPDIR)/res/ael/pval.c
119         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
120         $(CMD_PREFIX) cp "$<" "$@"
121
122 ast_expr2.c: $(ASTTOPDIR)/main/ast_expr2.c
123         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
124         $(CMD_PREFIX) cp "$<" "$@"
125
126 ast_expr2.h: $(ASTTOPDIR)/main/ast_expr2.h
127         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
128         $(CMD_PREFIX) cp "$<" "$@"
129
130 ast_expr2f.c: $(ASTTOPDIR)/main/ast_expr2f.c
131         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
132         $(CMD_PREFIX) cp "$<" "$@"
133 ast_expr2f.o: _ASTCFLAGS+=-I$(ASTTOPDIR)/main -Wno-unused
134
135 check_expr: check_expr.o ast_expr2.o ast_expr2f.o strcompat.o threadstorage.o clicompat.o
136
137 aelbison.c: $(ASTTOPDIR)/res/ael/ael.tab.c
138         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
139         $(CMD_PREFIX) cp "$<" "$@"
140 aelbison.o: _ASTCFLAGS+=-I$(ASTTOPDIR)/res/ael -DYYENABLE_NLS=0
141
142 pbx_ael.c: $(ASTTOPDIR)/pbx/pbx_ael.c
143         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
144         $(CMD_PREFIX) cp "$<" "$@"
145
146 aelparse.c: $(ASTTOPDIR)/res/ael/ael_lex.c
147         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
148         $(CMD_PREFIX) cp "$<" "$@"
149
150 aelparse.o: _ASTCFLAGS+=-I$(ASTTOPDIR)/res -Wno-unused
151 aelparse: LIBS+=-lm
152 aelparse: aelparse.o aelbison.o pbx_ael.o hashtab.o lock.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o
153
154 astobj2.c: $(ASTTOPDIR)/main/astobj2.c
155         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
156         $(CMD_PREFIX) cp "$<" "$@"
157
158 utils.c: $(ASTTOPDIR)/main/utils.c
159         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
160         $(CMD_PREFIX) cp "$<" "$@"
161
162 poll.c: $(ASTTOPDIR)/main/poll.c
163         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
164         $(CMD_PREFIX) cp "$<" "$@"
165
166 strings.c: $(ASTTOPDIR)/main/strings.c
167         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
168         $(CMD_PREFIX) cp "$<" "$@"
169
170 sha1.c: $(ASTTOPDIR)/main/sha1.c
171         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
172         $(CMD_PREFIX) cp "$<" "$@"
173
174 threadstorage.c: $(ASTTOPDIR)/main/threadstorage.c
175         $(ECHO_PREFIX) echo "   [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
176         $(CMD_PREFIX) cp "$<" "$@"
177
178 hashtest2.o: _ASTCFLAGS+=-O0
179 hashtest2: hashtest2.o md5.o lock.o utils.o strings.o astobj2.o sha1.o strcompat.o threadstorage.o clicompat.o poll.o
180
181 hashtest: hashtest.o md5.o hashtab.o lock.o utils.o strings.o sha1.o strcompat.o threadstorage.o clicompat.o poll.o
182 hashtest.o: _ASTCFLAGS+=-O0
183
184 refcounter: refcounter.o md5.o hashtab.o lock.o utils.o strings.o sha1.o strcompat.o threadstorage.o clicompat.o poll.o
185 refcounter.o: _ASTCFLAGS+=-O0
186
187 extconf.o: extconf.c
188
189 conf2ael: conf2ael.o ast_expr2f.o ast_expr2.o hashtab.o lock.o aelbison.o aelparse.o pbx_ael.o pval.o extconf.o strcompat.o
190
191 check_expr2: $(ASTTOPDIR)/main/ast_expr2f.c $(ASTTOPDIR)/main/ast_expr2.c $(ASTTOPDIR)/main/ast_expr2.h
192         $(ECHO_PREFIX) echo "   [CC] ast_expr2f.c -> ast_expr2fz.o"
193         $(CC) -g -c -I$(ASTTOPDIR)/include -DSTANDALONE $(ASTTOPDIR)/main/ast_expr2f.c -o ast_expr2fz.o
194         $(ECHO_PREFIX) echo "   [CC] ast_expr2.c -> ast_expr2z.o"
195         $(CC) -g -c -I$(ASTTOPDIR)/include -DSTANDALONE2 $(ASTTOPDIR)/main/ast_expr2.c -o ast_expr2z.o
196         $(ECHO_PREFIX) echo "   [LD] ast_expr2fz.o ast_expr2z.o  -> check_expr2"
197         $(CC) -g -o check_expr2 ast_expr2fz.o ast_expr2z.o -lm
198         $(ECHO_PREFIX) echo "   [RM] ast_expr2fz.o ast_expr2z.o"
199         rm ast_expr2z.o ast_expr2fz.o 
200         ./check_expr2 expr2.testinput
201
202 smsq: smsq.o strcompat.o
203 smsq: LIBS+=$(POPT_LIB)
204
205 streamplayer: streamplayer.o
206
207 muted: muted.o
208 muted: LIBS+=$(AUDIO_LIBS)
209 muted: _ASTCFLAGS:=$(filter-out -Werror,$(_ASTCFLAGS))
210
211 CHECK_SUBDIR:   # do nothing, just make sure that we recurse in the subdir/
212 db1-ast/libdb1.a: CHECK_SUBDIR
213         _ASTCFLAGS="$(_ASTCFLAGS) -Wno-strict-aliasing" ASTCFLAGS="$(ASTCFLAGS)" $(MAKE) -C db1-ast libdb1.a
214
215 astdb2sqlite3: LIBS+=$(SQLITE3_LIB)
216 astdb2sqlite3: _ASTCFLAGS+=$(SQLITE3_INCLUDE)
217 astdb2sqlite3: db1-ast/libdb1.a
218
219 astdb2bdb: LIBS+=$(SQLITE3_LIB)
220 astdb2bdb: _ASTCFLAGS+=$(SQLITE3_INCLUDE)
221 astdb2bdb: db1-ast/libdb1.a
222
223 ifneq ($(wildcard .*.d),)
224    include .*.d
225 endif