Version 0.1.9 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 -Werror
30 CFLAGS=-pipe  -Wall -Wmissing-prototypes -Wmissing-declarations -O6 $(DEBUG) $(INCLUDE) -D_REENTRANT
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=channels pbx apps codecs formats agi
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 callerid.o fskmodem.o image.o app.o asterisk.o 
45 CC=gcc
46 INSTALL=install
47
48 _all: all
49         @echo " +--------- Asterisk Build Complete ---------+"  
50         @echo " + Asterisk has successfully been built, but +"  
51         @echo " + cannot be run before being installed by   +"  
52         @echo " + running:                                  +"  
53         @echo " +                                           +"
54         @echo " +               make install                +"  
55         @echo " +-------------------------------------------+"  
56
57 all: asterisk subdirs
58
59 _version: 
60         if [ -d CVS ] && ! [ -f .version ]; then echo "CVS-`date +"%D-%T"`" > .version; fi 
61
62 build.h:
63         ./make_build_h
64
65 asterisk: _version build.h $(OBJS)
66         gcc -o asterisk -rdynamic $(OBJS) $(LIBS)
67
68 subdirs: 
69         for x in $(SUBDIRS); do $(MAKE) -C $$x || exit 1 ; done
70
71 clean:
72         for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
73         rm -f *.o *.so asterisk
74         rm -f build.h
75
76 datafiles: all
77         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/sounds/digits
78         for x in sounds/digits/*; do \
79                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds/digits ; \
80         done
81         for x in sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-*; do \
82                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds ; \
83         done
84         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/images
85         for x in images/*.jpg; do \
86                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/images ; \
87         done
88         mkdir -p $(AGI_DIR)
89
90 install: all datafiles
91         mkdir -p $(MODULES_DIR)
92         mkdir -p $(INSTALL_PREFIX)/usr/sbin
93         install -m 755 asterisk $(INSTALL_PREFIX)/usr/sbin/
94         for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
95         install -d $(INSTALL_PREFIX)/usr/include/asterisk
96         install include/asterisk/*.h $(INSTALL_PREFIX)/usr/include/asterisk
97         rm -f $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm
98         mkdir -p $(INSTALL_PREFIX)/var/spool/asterisk/vm
99         rm -f $(INSTALL_PREFIX)/usr/lib/asterisk/modules/chan_ixj.so
100         rm -f $(INSTALL_PREFIX)/usr/lib/asterisk/modules/chan_tor.so
101         mkdir -p $(INSTALL_PREFIX)/var/lib/asterisk/sounds
102         ( cd $(INSTALL_PREFIX)/var/lib/asterisk/sounds  ; ln -s ../../../spool/asterisk/vm . )
103         @echo " +---- Asterisk Installation Complete -------+"  
104         @echo " +                                           +"
105         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
106         @echo " +                                           +"
107         @echo " + Asterisk has successfully been installed. +"  
108         @echo " + If you would like to install the sample   +"  
109         @echo " + configuration files (overwriting any      +"
110         @echo " + existing config files), run:              +"  
111         @echo " +                                           +"
112         @echo " +               make samples                +"
113         @echo " +                                           +"
114         @echo " +-----------------  or ---------------------+"
115         @echo " +                                           +"
116         @echo " + You can go ahead and install the asterisk +"
117         @echo " + program documentation now or later run:   +"
118         @echo " +                                           +"
119         @echo " +              make progdocs                +"
120         @echo " +                                           +"
121         @echo " + **Note** This requires that you have      +"
122         @echo " + doxygen installed on your local system    +"
123         @echo " +-------------------------------------------+"
124 samples: all datafiles
125         mkdir -p $(INSTALL_PREFIX)/etc/asterisk
126         for x in configs/*.sample; do \
127                 if [ -f $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` ]; then \
128                         mv -f $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample`.old ; \
129                 fi ; \
130                 install $$x $(INSTALL_PREFIX)/etc/asterisk/`basename $$x .sample` ;\
131         done
132         for x in sounds/demo-*; do \
133                 install $$x $(INSTALL_PREFIX)/var/lib/asterisk/sounds; \
134         done
135         mkdir -p $(INSTALL_PREFIX)/var/spool/asterisk/vm/1234/INBOX
136         :> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/unavail.gsm
137         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
138                 cat $(INSTALL_PREFIX)/var/lib/asterisk/sounds/$$x.gsm >> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/unavail.gsm ; \
139         done
140         :> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/busy.gsm
141         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
142                 cat $(INSTALL_PREFIX)/var/lib/asterisk/sounds/$$x.gsm >> $(INSTALL_PREFIX)/var/lib/asterisk/sounds/vm/1234/busy.gsm ; \
143         done
144
145 mailbox:
146         ./addmailbox 
147         
148
149 rpm: __rpm
150
151 __rpm: _version
152         rm -rf /tmp/asterisk ; \
153         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
154         make INSTALL_PREFIX=/tmp/asterisk install ; \
155         make INSTALL_PREFIX=/tmp/asterisk samples ; \
156         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
157         cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
158         cp -f redhat/rpmrc /tmp/asterisk/ ; \
159         cp -f redhat/rpmmacros /tmp/asterisk/ ; \
160         sed "s/Version:/Version: $(RPMVERSION)/g" redhat/asterisk.spec > /tmp/asterisk/asterisk.spec ; \
161         rpm --rcfile /usr/lib/rpm/rpmrc:/tmp/asterisk/rpmrc -bb /tmp/asterisk/asterisk.spec ; \
162         mv /tmp/asterisk/redhat/RPMS/i386/asterisk* ./ ; \
163         rm -rf /tmp/asterisk
164
165 progdocs:
166         doxygen asterisk-ng-doxygen