Version 0.1.11 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
15 .EXPORT_ALL_VARIABLES:
16
17 INSTALL_PREFIX=
18
19 MODULES_DIR=$(INSTALL_PREFIX)/usr/lib/asterisk/modules
20 AGI_DIR=$(INSTALL_PREFIX)/var/lib/asterisk/agi-bin
21
22 # Pentium Pro Optimize
23 #PROC=i686
24 # Pentium Optimize
25 PROC=i586
26
27 DEBUG=-g #-pg
28 INCLUDE=-Iinclude -I../include
29 CFLAGS=-pipe  -Wall -Wmissing-prototypes -Wmissing-declarations -O6 $(DEBUG) $(INCLUDE) -D_REENTRANT
30 #CFLAGS+=-Werror
31 CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
32 ASTERISKVERSION=$(shell if [ -f .version ]; then cat .version; fi)
33 RPMVERSION=$(shell sed 's/[-\/:]/_/g' .version)
34 CFLAGS+=-DASTERISK_VERSION=\"$(ASTERISKVERSION)\"
35 # Optional debugging parameters
36 CFLAGS+= -DDO_CRASH -DDEBUG_THREADS
37 # Uncomment next one to enable ast_frame tracing (for debugging)
38 #CLFAGS+= -DTRACE_FRAMES
39 CFLAGS+=# -fomit-frame-pointer 
40 SUBDIRS=res channels pbx apps codecs formats agi cdr
41 LIBS=-ldl -lpthread -lreadline -lncurses -lm
42 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
43         translate.o file.o say.o pbx.o cli.o md5.o \
44         ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
45         cdr.o tdd.o asterisk.o 
46 CC=gcc
47 INSTALL=install
48
49 _all: all
50         @echo " +--------- Asterisk Build Complete ---------+"  
51         @echo " + Asterisk has successfully been built, but +"  
52         @echo " + cannot be run before being installed by   +"  
53         @echo " + running:                                  +"  
54         @echo " +                                           +"
55         @echo " +               make install                +"  
56         @echo " +-------------------------------------------+"  
57
58 all: asterisk subdirs
59
60 _version: 
61         if [ -d CVS ] && ! [ -f .version ]; then echo "CVS-`date +"%D-%T"`" > .version; fi 
62
63 .version: _version
64
65 build.h:
66         ./make_build_h
67
68 asterisk: .version build.h $(OBJS)
69         gcc -o asterisk -rdynamic $(OBJS) $(LIBS)
70
71 subdirs: 
72         for x in $(SUBDIRS); do $(MAKE) -C $$x || exit 1 ; done
73
74 clean:
75         for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
76         rm -f *.o *.so asterisk
77         rm -f build.h
78
79 datafiles: all
80         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/sounds/digits
81         for x in sounds/digits/*; do \
82                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds/digits ; \
83         done
84         for x in sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-*; do \
85                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds ; \
86         done
87         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/images
88         for x in images/*.jpg; do \
89                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/images ; \
90         done
91         mkdir -p $(AGI_DIR)
92
93 install: all datafiles
94         mkdir -p $(MODULES_DIR)
95         mkdir -p $(INSTALL_PREFIX)/usr/sbin
96         install -m 755 asterisk $(INSTALL_PREFIX)/usr/sbin/
97         install -m 755 astgenkey $(INSTALL_PREFIX)/usr/sbin/
98         for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
99         install -d $(INSTALL_PREFIX)/usr/include/asterisk
100         install include/asterisk/*.h $(INSTALL_PREFIX)/usr/include/asterisk
101         rm -f $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm
102         mkdir -p $(INSTALL_PREFIX)/var/spool/asterisk/vm
103         rm -f $(INSTALL_PREFIX)/usr/lib/asterisk/modules/chan_ixj.so
104         rm -f $(INSTALL_PREFIX)/usr/lib/asterisk/modules/chan_tor.so
105         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/sounds
106         mkdir -p $(INSTALL_PREFIX)/var/log/asterisk/cdr-csv
107         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/keys
108         install -m 644 keys/iaxtel.pub $(INSTALL_PREFIX)/var/lib/asterisk/keys
109         ( cd $(INSTALL_PREFIX)/var/lib/asterisk/sounds  ; ln -s ../../../spool/asterisk/vm . )
110         @echo " +---- Asterisk Installation Complete -------+"  
111         @echo " +                                           +"
112         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
113         @echo " +                                           +"
114         @echo " + Asterisk has successfully been installed. +"  
115         @echo " + If you would like to install the sample   +"  
116         @echo " + configuration files (overwriting any      +"
117         @echo " + existing config files), run:              +"  
118         @echo " +                                           +"
119         @echo " +               make samples                +"
120         @echo " +                                           +"
121         @echo " +-----------------  or ---------------------+"
122         @echo " +                                           +"
123         @echo " + You can go ahead and install the asterisk +"
124         @echo " + program documentation now or later run:   +"
125         @echo " +                                           +"
126         @echo " +              make progdocs                +"
127         @echo " +                                           +"
128         @echo " + **Note** This requires that you have      +"
129         @echo " + doxygen installed on your local system    +"
130         @echo " +-------------------------------------------+"
131 samples: all datafiles
132         mkdir -p $(INSTALL_PREFIX)/etc/asterisk
133         for x in configs/*.sample; do \
134                 if [ -f $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` ]; then \
135                         mv -f $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample`.old ; \
136                 fi ; \
137                 install $$x $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` ;\
138         done
139         for x in sounds/demo-*; do \
140                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds; \
141         done
142         mkdir -p $(INSTALL_PREFIX)/var/spool/asterisk/vm/1234/INBOX
143         :> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/unavail.gsm
144         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
145                 cat $(INSTALL_PREFIX)/var/lib/asterisk/sounds/$$x.gsm >> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/unavail.gsm ; \
146         done
147         :> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/busy.gsm
148         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
149                 cat $(INSTALL_PREFIX)/var/lib/asterisk/sounds/$$x.gsm >> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/busy.gsm ; \
150         done
151
152 mailbox:
153         ./addmailbox 
154         
155
156 rpm: __rpm
157
158 __rpm: _version
159         rm -rf /tmp/asterisk ; \
160         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
161         make INSTALL_PREFIX=/tmp/asterisk install ; \
162         make INSTALL_PREFIX=/tmp/asterisk samples ; \
163         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
164         cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
165         cp -f redhat/rpmrc /tmp/asterisk/ ; \
166         cp -f redhat/rpmmacros /tmp/asterisk/ ; \
167         sed "s/Version:/Version: $(RPMVERSION)/g" redhat/asterisk.spec > /tmp/asterisk/asterisk.spec ; \
168         rpm --rcfile /usr/lib/rpm/rpmrc:/tmp/asterisk/rpmrc -bb /tmp/asterisk/asterisk.spec ; \
169         mv /tmp/asterisk/redhat/RPMS/i386/asterisk* ./ ; \
170         rm -rf /tmp/asterisk
171
172 progdocs:
173         doxygen asterisk-ng-doxygen