55b57b28086abead4c943b8e7a9f9d343e224e22
[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 MODULES_DIR=/usr/lib/asterisk/modules
18
19 # Pentium Pro Optimize
20 #PROC=i686
21 # Pentium Optimize
22 PROC=i586
23
24 DEBUG=-g #-pg
25 INCLUDE=-Iinclude -I../include
26 CFLAGS=-pipe  -Wall -Werror -Wmissing-prototypes -Wmissing-declarations -O6 $(DEBUG) $(INCLUDE) -D_REENTRANT
27 CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
28 ASTERISKVERSION=$(shell cat .version)
29 CFLAGS+=-DASTERISK_VERSION=\"$(ASTERISKVERSION)\"
30 CFLAGS+= -DDO_CRASH -DDEBUG_THREADS
31 CFLAGS+=# -fomit-frame-pointer 
32 SUBDIRS=channels pbx apps codecs formats
33 LIBS=-ldl -lpthread -lreadline -lncurses -lm
34 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
35         translate.o file.o say.o pbx.o cli.o md5.o \
36         ulaw.o callerid.o fskmodem.o asterisk.o 
37 CC=gcc
38 INSTALL=install
39
40 _all: all
41         @echo " +--------- Asterisk Build Complete ---------+"  
42         @echo " + Asterisk has successfully been built, but +"  
43         @echo " + cannot be run before being installed by   +"  
44         @echo " + running:                                  +"  
45         @echo " +                                           +"
46         @echo " +               make install                +"  
47         @echo " +                                           +"
48         @echo " +-------------------------------------------+"  
49
50 all: asterisk subdirs
51
52 _version: 
53         if [ -d CVS ]; then echo "CVS-`date +"%D-%T"`" > .version; fi 
54
55 build.h:
56         ./make_build_h
57
58 asterisk: _version build.h $(OBJS)
59         gcc -o asterisk -rdynamic $(OBJS) $(LIBS)
60
61 subdirs: 
62         for x in $(SUBDIRS); do $(MAKE) -C $$x || exit 1 ; done
63
64 clean:
65         for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
66         rm -f *.o *.so asterisk
67         rm -f build.h
68
69 datafiles: all
70         mkdir -p /var/lib/asterisk/sounds/digits
71         for x in sounds/digits/*; do \
72                 install $$x /var/lib/asterisk/sounds/digits ; \
73         done
74         for x in sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep*; do \
75                 install $$x /var/lib/asterisk/sounds ; \
76         done
77 install: all datafiles
78         mkdir -p $(MODULES_DIR)
79         mkdir -p /usr/sbin
80         install -m 755 asterisk /usr/sbin/
81         for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
82         install -d /usr/include/asterisk
83         install include/asterisk/*.h /usr/include/asterisk
84         rm -f /var/lib/asterisk/sounds/vm
85         mkdir -p /var/spool/asterisk/vm
86         rm -f /usr/lib/asterisk/modules/chan_ixj.so
87         mkdir -p /var/lib/asterisk/sounds
88         ( cd /var/lib/asterisk/sounds  ; ln -s ../../../spool/asterisk/vm . )
89         @echo " +---- Asterisk Installation Complete -------+"  
90         @echo " + Asterisk has successfully been installed. +"  
91         @echo " + If you would like to install the sample   +"  
92         @echo " + configuration files (overwriting any      +"
93         @echo " + existing config files), run:              +"  
94         @echo " +                                           +"
95         @echo " +               make samples                +"
96         @echo " +                                           +"
97         @echo " +-------------------------------------------+"  
98
99 samples: all datafiles
100         mkdir -p /etc/asterisk
101         for x in configs/*.sample; do \
102                 if [ -f /etc/asterisk/`basename $$x .sample` ]; then \
103                         mv -f /etc/asterisk/`basename $$x .sample` /etc/asterisk/`basename $$x .sample`.old ; \
104                 fi ; \
105                 install $$x /etc/asterisk/`basename $$x .sample` ;\
106         done
107         for x in sounds/demo-*; do \
108                 install $$x /var/lib/asterisk/sounds; \
109         done
110         mkdir -p /var/spool/asterisk/vm/1234/INBOX
111         :> /var/lib/asterisk/sounds/vm/1234/unavail.gsm
112         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
113                 cat /var/lib/asterisk/sounds/$$x.gsm >> /var/lib/asterisk/sounds/vm/1234/unavail.gsm ; \
114         done
115         :> /var/lib/asterisk/sounds/vm/1234/busy.gsm
116         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
117                 cat /var/lib/asterisk/sounds/$$x.gsm >> /var/lib/asterisk/sounds/vm/1234/busy.gsm ; \
118         done