Version 0.1.12 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 -O6 $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE
32 #CFLAGS+=-Werror
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
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 asterisk.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 build.h:
71         ./make_build_h
72
73 asterisk: .version build.h $(OBJS)
74         gcc -o asterisk -rdynamic $(OBJS) $(LIBS)
75
76 subdirs: 
77         for x in $(SUBDIRS); do $(MAKE) -C $$x || exit 1 ; done
78
79 clean:
80         for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
81         rm -f *.o *.so asterisk
82         rm -f build.h
83
84 datafiles: all
85         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/sounds/digits
86         for x in sounds/digits/*; do \
87                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds/digits ; \
88         done
89         for x in sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-* sounds/conf-*; do \
90                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds ; \
91         done
92         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/mohmp3
93         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/images
94         for x in images/*.jpg; do \
95                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/images ; \
96         done
97         mkdir -p $(AGI_DIR)
98
99 install: all datafiles
100         mkdir -p $(MODULES_DIR)
101         mkdir -p $(INSTALL_PREFIX)/usr/sbin
102         mkdir -p $(INSTALL_PREFIX)/etc/asterisk
103         install -m 755 asterisk $(INSTALL_PREFIX)/usr/sbin/
104         install -m 755 astgenkey $(INSTALL_PREFIX)/usr/sbin/
105         install -m 755 safe_asterisk $(INSTALL_PREFIX)/usr/sbin/
106         for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
107         install -d $(INSTALL_PREFIX)/usr/include/asterisk
108         install include/asterisk/*.h $(INSTALL_PREFIX)/usr/include/asterisk
109         rm -f $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm
110         mkdir -p $(INSTALL_PREFIX)/var/spool/asterisk/vm
111         rm -f $(INSTALL_PREFIX)/usr/lib/asterisk/modules/chan_ixj.so
112         rm -f $(INSTALL_PREFIX)/usr/lib/asterisk/modules/chan_tor.so
113         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/sounds
114         mkdir -p $(INSTALL_PREFIX)/var/log/asterisk/cdr-csv
115         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/keys
116         install -m 644 keys/iaxtel.pub $(INSTALL_PREFIX)/var/lib/asterisk/keys
117         ( cd $(INSTALL_PREFIX)/var/lib/asterisk/sounds  ; ln -s ../../../spool/asterisk/vm . )
118         @echo " +---- Asterisk Installation Complete -------+"  
119         @echo " +                                           +"
120         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
121         @echo " +                                           +"
122         @echo " + Asterisk has successfully been installed. +"  
123         @echo " + If you would like to install the sample   +"  
124         @echo " + configuration files (overwriting any      +"
125         @echo " + existing config files), run:              +"  
126         @echo " +                                           +"
127         @echo " +               make samples                +"
128         @echo " +                                           +"
129         @echo " +-----------------  or ---------------------+"
130         @echo " +                                           +"
131         @echo " + You can go ahead and install the asterisk +"
132         @echo " + program documentation now or later run:   +"
133         @echo " +                                           +"
134         @echo " +              make progdocs                +"
135         @echo " +                                           +"
136         @echo " + **Note** This requires that you have      +"
137         @echo " + doxygen installed on your local system    +"
138         @echo " +-------------------------------------------+"
139 adsi: all
140         mkdir -p /etc/asterisk
141         for x in configs/*.adsi; do \
142                 if ! [ -f $(INSTALL_PREFIX)/etc/asterisk/$$x ]; then \
143                         install -m 644 $$x $(INSTALL_PREFIX)/etc/asterisk/`basename $$x` ; \
144                 fi ; \
145         done
146
147 samples: all datafiles adsi
148         mkdir -p $(INSTALL_PREFIX)/etc/asterisk
149         for x in configs/*.sample; do \
150                 if [ -f $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` ]; then \
151                         mv -f $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample`.old ; \
152                 fi ; \
153                 install $$x $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` ;\
154         done
155         for x in sounds/demo-*; do \
156                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds; \
157         done
158         for x in sounds/*.mp3; do \
159                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/mohmp3 ; \
160         done
161         mkdir -p $(INSTALL_PREFIX)/var/spool/asterisk/vm/1234/INBOX
162         :> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/unavail.gsm
163         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
164                 cat $(INSTALL_PREFIX)/var/lib/asterisk/sounds/$$x.gsm >> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/unavail.gsm ; \
165         done
166         :> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/busy.gsm
167         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
168                 cat $(INSTALL_PREFIX)/var/lib/asterisk/sounds/$$x.gsm >> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/busy.gsm ; \
169         done
170
171 webvmail:
172         @[ -d $(HTTPDIR) ] || ( echo "No HTTP directory" && exit 1 )
173         @[ -d $(HTTPDIR)/html ] || ( echo "No http directory" && exit 1 )
174         @[ -d $(HTTPDIR)/cgi-bin ] || ( echo "No cgi-bin directory" && exit 1 )
175         install -m 4755 -o root -g root vmail.cgi $(HTTPDIR)/cgi-bin/vmail.cgi
176         mkdir -p $(HTTPDIR)/html/_asterisk
177         for x in images/*.gif; do \
178                 install -m 644 $$x $(HTTPDIR)/html/_asterisk/; \
179         done
180         @echo " +--------- Asterisk Web Voicemail ----------+"  
181         @echo " +                                           +"
182         @echo " + Asterisk Web Voicemail is installed in    +"
183         @echo " + your cgi-bin directory.  IT USES A SETUID +"
184         @echo " + ROOT PERL SCRIPT, SO IF YOU DON'T LIKE    +"
185         @echo " + THAT, UNINSTALL IT!                       +"
186         @echo " +                                           +"
187         @echo " +-------------------------------------------+"  
188
189 mailbox:
190         ./addmailbox 
191         
192
193 rpm: __rpm
194
195 __rpm: _version
196         rm -rf /tmp/asterisk ; \
197         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
198         make INSTALL_PREFIX=/tmp/asterisk install ; \
199         make INSTALL_PREFIX=/tmp/asterisk samples ; \
200         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
201         cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
202         cp -f redhat/rpmrc /tmp/asterisk/ ; \
203         cp -f redhat/rpmmacros /tmp/asterisk/ ; \
204         sed "s/Version:/Version: $(RPMVERSION)/g" redhat/asterisk.spec > /tmp/asterisk/asterisk.spec ; \
205         rpm --rcfile /usr/lib/rpm/rpmrc:/tmp/asterisk/rpmrc -bb /tmp/asterisk/asterisk.spec ; \
206         mv /tmp/asterisk/redhat/RPMS/i386/asterisk* ./ ; \
207         rm -rf /tmp/asterisk
208
209 progdocs:
210         doxygen asterisk-ng-doxygen
211
212 config:
213         if [ -d /etc/rc.d/init.d ]; then \
214                 install -m 755 init.asterisk /etc/rc.d/init.d/asterisk; \
215                 /sbin/chkconfig --add asterisk; \
216         elif [ -d /etc/init.d ]; then \
217                 install -m 755 init.asterisk /etc/init.d/asterisk; \
218         fi 
219
220