Version 0.3.0 from FTP
[asterisk/asterisk.git] / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Top level Makefile
5 #
6 # Copyright (C) 1999, Mark Spencer
7 #
8 # Mark Spencer <markster@linux-support.net>
9 #
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
12 #
13
14 .EXPORT_ALL_VARIABLES:
15
16 INSTALL_PREFIX=
17
18 MODULES_DIR=$(INSTALL_PREFIX)/usr/lib/asterisk/modules
19 AGI_DIR=$(INSTALL_PREFIX)/var/lib/asterisk/agi-bin
20
21 # Pentium Pro Optimize
22 #PROC=i686
23 # Pentium Optimize
24 #PROC=i586
25 #PROC=k6
26 #PROC=ppc
27 PROC=$(shell uname -m)
28
29 DEBUG=-g #-pg
30 INCLUDE=-Iinclude -I../include
31 CFLAGS=-pipe  -Wall -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
32 CFLAGS+=-O6
33 CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
34 CFLAGS+=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
35
36 ASTERISKVERSION=$(shell if [ -f .version ]; then cat .version; fi)
37 HTTPDIR=$(shell if [ -d /var/www ]; then echo "/var/www"; else echo "/home/httpd"; fi)
38 RPMVERSION=$(shell sed 's/[-\/:]/_/g' .version)
39 CFLAGS+=-DASTERISK_VERSION=\"$(ASTERISKVERSION)\"
40 # Optional debugging parameters
41 CFLAGS+= -DDO_CRASH -DDEBUG_THREADS
42 # Uncomment next one to enable ast_frame tracing (for debugging)
43 #CLFAGS+= -DTRACE_FRAMES
44 CFLAGS+=# -fomit-frame-pointer 
45 SUBDIRS=res channels pbx apps codecs formats agi cdr astman
46 LIBS=-ldl -lpthread -lreadline -lncurses -lm #-lnjamd
47 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
48         translate.o file.o say.o pbx.o cli.o md5.o term.o \
49         ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
50         cdr.o tdd.o acl.o rtp.o manager.o asterisk.o ast_expr.o chanvars.o
51 CC=gcc
52 INSTALL=install
53
54 _all: all
55         @echo " +--------- Asterisk Build Complete ---------+"  
56         @echo " + Asterisk has successfully been built, but +"  
57         @echo " + cannot be run before being installed by   +"  
58         @echo " + running:                                  +"  
59         @echo " +                                           +"
60         @echo " +               make install                +"  
61         @echo " +-------------------------------------------+"  
62
63 all: asterisk subdirs
64
65 _version: 
66         if [ -d CVS ] && ! [ -f .version ]; then echo "CVS-`date +"%D-%T"`" > .version; fi 
67
68 .version: _version
69
70 .y.c:
71         bison $< --name-prefix=ast_yy -o $@
72
73 ast_expr.o: ast_expr.c
74
75 build.h:
76         ./make_build_h
77
78 asterisk: .version build.h $(OBJS)
79         gcc -o asterisk -rdynamic $(OBJS) $(LIBS)
80
81 subdirs: 
82         for x in $(SUBDIRS); do $(MAKE) -C $$x || exit 1 ; done
83
84 clean:
85         for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
86         rm -f *.o *.so asterisk
87         rm -f build.h 
88         rm -f ast_expr.c
89
90 datafiles: all
91         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/sounds/digits
92         for x in sounds/digits/*; do \
93                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds/digits ; \
94         done
95         for x in sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-* sounds/conf-* sounds/agent-*; do \
96                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds ; \
97         done
98         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/mohmp3
99         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/images
100         for x in images/*.jpg; do \
101                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/images ; \
102         done
103         mkdir -p $(AGI_DIR)
104
105 install: all datafiles
106         mkdir -p $(MODULES_DIR)
107         mkdir -p $(INSTALL_PREFIX)/usr/sbin
108         mkdir -p $(INSTALL_PREFIX)/etc/asterisk
109         install -m 755 asterisk $(INSTALL_PREFIX)/usr/sbin/
110         install -m 755 astgenkey $(INSTALL_PREFIX)/usr/sbin/
111         install -m 755 safe_asterisk $(INSTALL_PREFIX)/usr/sbin/
112         for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
113         install -d $(INSTALL_PREFIX)/usr/include/asterisk
114         install include/asterisk/*.h $(INSTALL_PREFIX)/usr/include/asterisk
115         rm -f $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm
116         mkdir -p $(INSTALL_PREFIX)/var/spool/asterisk/vm
117         rm -f $(INSTALL_PREFIX)/usr/lib/asterisk/modules/chan_ixj.so
118         rm -f $(INSTALL_PREFIX)/usr/lib/asterisk/modules/chan_tor.so
119         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/sounds
120         mkdir -p $(INSTALL_PREFIX)/var/log/asterisk/cdr-csv
121         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/keys
122         install -m 644 keys/iaxtel.pub $(INSTALL_PREFIX)/var/lib/asterisk/keys
123         ( cd $(INSTALL_PREFIX)/var/lib/asterisk/sounds  ; ln -s ../../../spool/asterisk/vm . )
124         @echo " +---- Asterisk Installation Complete -------+"  
125         @echo " +                                           +"
126         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
127         @echo " +                                           +"
128         @echo " + Asterisk has successfully been installed. +"  
129         @echo " + If you would like to install the sample   +"  
130         @echo " + configuration files (overwriting any      +"
131         @echo " + existing config files), run:              +"  
132         @echo " +                                           +"
133         @echo " +               make samples                +"
134         @echo " +                                           +"
135         @echo " +-----------------  or ---------------------+"
136         @echo " +                                           +"
137         @echo " + You can go ahead and install the asterisk +"
138         @echo " + program documentation now or later run:   +"
139         @echo " +                                           +"
140         @echo " +              make progdocs                +"
141         @echo " +                                           +"
142         @echo " + **Note** This requires that you have      +"
143         @echo " + doxygen installed on your local system    +"
144         @echo " +-------------------------------------------+"
145 adsi: all
146         mkdir -p /etc/asterisk
147         for x in configs/*.adsi; do \
148                 if ! [ -f $(INSTALL_PREFIX)/etc/asterisk/$$x ]; then \
149                         install -m 644 $$x $(INSTALL_PREFIX)/etc/asterisk/`basename $$x` ; \
150                 fi ; \
151         done
152
153 samples: all datafiles adsi
154         mkdir -p $(INSTALL_PREFIX)/etc/asterisk
155         for x in configs/*.sample; do \
156                 if [ -f $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` ]; then \
157                         mv -f $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample`.old ; \
158                 fi ; \
159                 install $$x $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` ;\
160         done
161         for x in sounds/demo-*; do \
162                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds; \
163         done
164         for x in sounds/*.mp3; do \
165                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/mohmp3 ; \
166         done
167         mkdir -p $(INSTALL_PREFIX)/var/spool/asterisk/vm/1234/INBOX
168         :> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/unavail.gsm
169         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
170                 cat $(INSTALL_PREFIX)/var/lib/asterisk/sounds/$$x.gsm >> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/unavail.gsm ; \
171         done
172         :> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/busy.gsm
173         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
174                 cat $(INSTALL_PREFIX)/var/lib/asterisk/sounds/$$x.gsm >> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/busy.gsm ; \
175         done
176
177 webvmail:
178         @[ -d $(HTTPDIR) ] || ( echo "No HTTP directory" && exit 1 )
179         @[ -d $(HTTPDIR)/html ] || ( echo "No http directory" && exit 1 )
180         @[ -d $(HTTPDIR)/cgi-bin ] || ( echo "No cgi-bin directory" && exit 1 )
181         install -m 4755 -o root -g root vmail.cgi $(HTTPDIR)/cgi-bin/vmail.cgi
182         mkdir -p $(HTTPDIR)/html/_asterisk
183         for x in images/*.gif; do \
184                 install -m 644 $$x $(HTTPDIR)/html/_asterisk/; \
185         done
186         @echo " +--------- Asterisk Web Voicemail ----------+"  
187         @echo " +                                           +"
188         @echo " + Asterisk Web Voicemail is installed in    +"
189         @echo " + your cgi-bin directory.  IT USES A SETUID +"
190         @echo " + ROOT PERL SCRIPT, SO IF YOU DON'T LIKE    +"
191         @echo " + THAT, UNINSTALL IT!                       +"
192         @echo " +                                           +"
193         @echo " +-------------------------------------------+"  
194
195 mailbox:
196         ./addmailbox 
197         
198
199 rpm: __rpm
200
201 __rpm: _version
202         rm -rf /tmp/asterisk ; \
203         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
204         make INSTALL_PREFIX=/tmp/asterisk install ; \
205         make INSTALL_PREFIX=/tmp/asterisk samples ; \
206         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
207         cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
208         cp -f redhat/rpmrc /tmp/asterisk/ ; \
209         cp -f redhat/rpmmacros /tmp/asterisk/ ; \
210         sed "s/Version:/Version: $(RPMVERSION)/g" redhat/asterisk.spec > /tmp/asterisk/asterisk.spec ; \
211         rpm --rcfile /usr/lib/rpm/rpmrc:/tmp/asterisk/rpmrc -bb /tmp/asterisk/asterisk.spec ; \
212         mv /tmp/asterisk/redhat/RPMS/i386/asterisk* ./ ; \
213         rm -rf /tmp/asterisk
214
215 progdocs:
216         doxygen asterisk-ng-doxygen
217
218 config:
219         if [ -d /etc/rc.d/init.d ]; then \
220                 install -m 755 init.asterisk /etc/rc.d/init.d/asterisk; \
221                 /sbin/chkconfig --add asterisk; \
222         elif [ -d /etc/init.d ]; then \
223                 install -m 755 init.asterisk /etc/init.d/asterisk; \
224         fi 
225
226