Version 0.1.10 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:
64         _version
65
66 build.h:
67         ./make_build_h
68
69 asterisk: .version build.h $(OBJS)
70         gcc -o asterisk -rdynamic $(OBJS) $(LIBS)
71
72 subdirs: 
73         for x in $(SUBDIRS); do $(MAKE) -C $$x || exit 1 ; done
74
75 clean:
76         for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
77         rm -f *.o *.so asterisk
78         rm -f build.h
79
80 datafiles: all
81         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/sounds/digits
82         for x in sounds/digits/*; do \
83                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds/digits ; \
84         done
85         for x in sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-*; do \
86                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds ; \
87         done
88         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/images
89         for x in images/*.jpg; do \
90                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/images ; \
91         done
92         mkdir -p $(AGI_DIR)
93
94 install: all datafiles
95         mkdir -p $(MODULES_DIR)
96         mkdir -p $(INSTALL_PREFIX)/usr/sbin
97         install -m 755 asterisk $(INSTALL_PREFIX)/usr/sbin/
98         install -m 755 astgenkey $(INSTALL_PREFIX)/usr/sbin/
99         for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
100         install -d $(INSTALL_PREFIX)/usr/include/asterisk
101         install include/asterisk/*.h $(INSTALL_PREFIX)/usr/include/asterisk
102         rm -f $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm
103         mkdir -p $(INSTALL_PREFIX)/var/spool/asterisk/vm
104         rm -f $(INSTALL_PREFIX)/usr/lib/asterisk/modules/chan_ixj.so
105         rm -f $(INSTALL_PREFIX)/usr/lib/asterisk/modules/chan_tor.so
106         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/sounds
107         mkdir -p $(INSTALL_PREFIX)/var/log/asterisk/cdr-csv
108         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/keys
109         install -m 644 keys/iaxtel.pub $(INSTALL_PREFIX)/var/lib/asterisk/keys
110         ( cd $(INSTALL_PREFIX)/var/lib/asterisk/sounds  ; ln -s ../../../spool/asterisk/vm . )
111         @echo " +---- Asterisk Installation Complete -------+"  
112         @echo " +                                           +"
113         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
114         @echo " +                                           +"
115         @echo " + Asterisk has successfully been installed. +"  
116         @echo " + If you would like to install the sample   +"  
117         @echo " + configuration files (overwriting any      +"
118         @echo " + existing config files), run:              +"  
119         @echo " +                                           +"
120         @echo " +               make samples                +"
121         @echo " +                                           +"
122         @echo " +-----------------  or ---------------------+"
123         @echo " +                                           +"
124         @echo " + You can go ahead and install the asterisk +"
125         @echo " + program documentation now or later run:   +"
126         @echo " +                                           +"
127         @echo " +              make progdocs                +"
128         @echo " +                                           +"
129         @echo " + **Note** This requires that you have      +"
130         @echo " + doxygen installed on your local system    +"
131         @echo " +-------------------------------------------+"
132 samples: all datafiles
133         mkdir -p $(INSTALL_PREFIX)/etc/asterisk
134         for x in configs/*.sample; do \
135                 if [ -f $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` ]; then \
136                         mv -f $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample`.old ; \
137                 fi ; \
138                 install $$x $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` ;\
139         done
140         for x in sounds/demo-*; do \
141                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds; \
142         done
143         mkdir -p $(INSTALL_PREFIX)/var/spool/asterisk/vm/1234/INBOX
144         :> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/unavail.gsm
145         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
146                 cat $(INSTALL_PREFIX)/var/lib/asterisk/sounds/$$x.gsm >> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/unavail.gsm ; \
147         done
148         :> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/busy.gsm
149         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
150                 cat $(INSTALL_PREFIX)/var/lib/asterisk/sounds/$$x.gsm >> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/busy.gsm ; \
151         done
152
153 mailbox:
154         ./addmailbox 
155         
156
157 rpm: __rpm
158
159 __rpm: _version
160         rm -rf /tmp/asterisk ; \
161         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
162         make INSTALL_PREFIX=/tmp/asterisk install ; \
163         make INSTALL_PREFIX=/tmp/asterisk samples ; \
164         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
165         cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
166         cp -f redhat/rpmrc /tmp/asterisk/ ; \
167         cp -f redhat/rpmmacros /tmp/asterisk/ ; \
168         sed "s/Version:/Version: $(RPMVERSION)/g" redhat/asterisk.spec > /tmp/asterisk/asterisk.spec ; \
169         rpm --rcfile /usr/lib/rpm/rpmrc:/tmp/asterisk/rpmrc -bb /tmp/asterisk/asterisk.spec ; \
170         mv /tmp/asterisk/redhat/RPMS/i386/asterisk* ./ ; \
171         rm -rf /tmp/asterisk
172
173 progdocs:
174         doxygen asterisk-ng-doxygen