689b99e8f640526d00f5e7ece775c6daa5e7303e
[asterisk/asterisk.git] / utils / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
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 -include $(ASTTOPDIR)/menuselect.makeopts
15
16 .PHONY: clean all uninstall
17
18 # to get check_expr, add it to the ALL_UTILS list
19 ALL_UTILS:=astman smsq stereorize streamplayer aelparse muted check_expr conf2ael hashtest2 hashtest
20 UTILS:=$(ALL_UTILS)
21
22 LIBS += $(BKTR_LIB)     # astobj2 with devmode uses backtrace
23
24 include $(ASTTOPDIR)/Makefile.rules
25
26 ifeq ($(OSARCH),SunOS)
27   LIBS+=-lsocket -lnsl
28   UTILS:=$(filter-out muted,$(UTILS))
29 endif
30
31 ifeq ($(OSARCH),OpenBSD)
32   UTILS:=$(filter-out muted,$(UTILS))
33 endif
34
35 ifeq ($(OSARCH),cygwin)
36   UTILS:=$(filter-out muted,$(UTILS))
37 endif
38
39 ifeq ($(OSARCH),mingw32)
40   UTILS:=
41 endif
42
43 ifneq ($(findstring darwin,$(OSARCH)),)
44   AUDIO_LIBS=-framework CoreAudio
45 endif
46
47 ifeq ($(POPT_LIB),)
48   UTILS:=$(filter-out smsq,$(UTILS))
49 endif
50
51 ifeq ($(NEWT_LIB),)
52   UTILS:=$(filter-out astman,$(UTILS))
53 endif
54
55 ifneq ($(filter pbx_ael,$(MENUSELECT_PBX)),)
56   UTILS:=$(filter-out aelparse,$(UTILS))
57   UTILS:=$(filter-out conf2ael,$(UTILS))
58 endif
59
60 all: $(UTILS)
61
62 install:
63         for x in $(UTILS); do \
64                 if [ "$$x" != "none" ]; then \
65                         $(INSTALL) -m 755 $$x $(DESTDIR)$(ASTSBINDIR)/$$x; \
66                 fi; \
67         done 
68
69 uninstall:
70         for x in $(ALL_UTILS); do rm -f $$x $(DESTDIR)$(ASTSBINDIR)/$$x; done
71
72 clean:
73         rm -f *.o $(ALL_UTILS) check_expr
74         rm -f .*.o.d .*.oo.d
75         rm -f *.s *.i
76         rm -f md5.c strcompat.c ast_expr2.c ast_expr2f.c pbx_ael.c pval.c hashtab.c
77         rm -f aelparse.c aelbison.c conf2ael
78         rm -f utils.c threadstorage.c sha1.c astobj2.c hashtest2 hashtest
79
80 md5.c: ../main/md5.c
81         @cp $< $@
82
83 astman: astman.o md5.o
84 astman: LIBS+=$(NEWT_LIB)
85
86 stereorize: stereorize.o frame.o
87 stereorize: LIBS+=-lm
88
89 hashtab.c: ../main/hashtab.c
90         @cp $< $@
91
92 strcompat.c: ../main/strcompat.c
93         @cp $< $@
94
95 ../main/ast_expr2.c:
96         @echo "   [BISON] ../main/ast_expr2.y -> $@"
97         @bison -o $@ -d --name-prefix=ast_yy ../main/ast_expr2.y
98
99 ../main/ast_expr2f.c:
100         @echo "   [FLEX] ../main/ast_expr2.fl -> $@"
101         @flex -o $@ --full ../main/ast_expr2.fl
102
103 pval.c: ../res/ael/pval.c
104         @cp $< $@
105
106 ast_expr2.c: ../main/ast_expr2.c
107         @cp $< $@
108
109 ast_expr2f.c: ../main/ast_expr2f.c
110         @cp $< $@
111
112 ast_expr2f.o: ASTCFLAGS+=-DSTANDALONE_AEL -I../main
113
114 pval.o : ASTCFLAGS+=-DSTANDALONE
115
116 check_expr: check_expr.o ast_expr2.o ast_expr2f.o strcompat.o threadstorage.o clicompat.o
117
118 aelbison.c: ../res/ael/ael.tab.c
119         @cp $< $@
120
121 aelbison.o: ASTCFLAGS+=-I../res/ael  -DYYENABLE_NLS=0
122
123 pbx_ael.c: ../pbx/pbx_ael.c
124         @cp $< $@
125
126 pbx_ael.o: ASTCFLAGS+=-DSTANDALONE_AEL
127
128 aelparse.c: ../res/ael/ael_lex.c
129         @cp $< $@
130
131 aelparse.o: ASTCFLAGS+=-I../res -DSTANDALONE_AEL
132
133 aelparse: aelparse.o aelbison.o pbx_ael.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o
134
135 astobj2.c: ../main/astobj2.c
136         @cp $< $@
137
138 utils.c: ../main/utils.c
139         @cp $< $@
140
141 sha1.c: ../main/sha1.c
142         @cp $< $@
143
144 threadstorage.c: ../main/threadstorage.c
145         @cp $< $@
146
147 hashtest2.o: ASTCFLAGS+=-O0
148
149 hashtest2: hashtest2.o md5.o utils.o astobj2.o sha1.o strcompat.o threadstorage.o clicompat.o
150
151 hashtest: hashtest.o md5.o hashtab.o utils.o sha1.o strcompat.o threadstorage.o clicompat.o
152
153 hashtest.o: ASTCFLAGS+=-O0
154
155 extconf.o: extconf.c
156
157 conf2ael: conf2ael.o ast_expr2f.o ast_expr2.o aelbison.o aelparse.o pbx_ael.o pval.o extconf.o strcompat.o
158
159 testexpr2s: ../main/ast_expr2f.c ../main/ast_expr2.c ../main/ast_expr2.h
160         $(CC) -g -c -I../include -DSTANDALONE_AEL ../main/ast_expr2f.c -o ast_expr2f.o
161         $(CC) -g -c -I../include -DSTANDALONE_AEL ../main/ast_expr2.c -o ast_expr2.o
162         $(CC) -g -o testexpr2s ast_expr2f.o ast_expr2.o
163         rm ast_expr2.o ast_expr2f.o 
164         ./testexpr2s expr2.testinput
165
166 smsq: smsq.o strcompat.o
167 smsq: LIBS+=$(POPT_LIB)
168
169 streamplayer: streamplayer.o
170
171 muted: muted.o
172 muted: LIBS+=$(AUDIO_LIBS)
173
174 ifneq ($(wildcard .*.d),)
175    include .*.d
176 endif