aboutsummaryrefslogblamecommitdiff
path: root/net/asterisk10/files/patch-Makefile
blob: 4f02274d20ab9a7a77734c8e10061199e32cf9b2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                                                
                  







                                                                                                                        
                              





                       
                   


                                          

               




                                                                        

                                                                              
                  



                                            
                         
 

                                                               
                     

















                                                    
                                          


                                  
                                
 


                                 
                               
                                                                                                                                                          
                                                                                                                                                    
                    

                           
                    

                                                                                                     
                         


                                                                                              
                              
                                                                                                    
                   
                          



                        
                    



                                                                                               
                               
                  

                               


                           
                   
                           
      
 




                
                   







                                                                   
                     
                                                                           

                                     
                        





                                                                            
                         








                                                                            
                     















                                        
                   

                         
 
                                                                        
                                                                                                           
                                                       
                                                                                          
 

                              
                     
                                

               

                                                        

                                                                 

                                                                                           


                                                        





















                                                                                             
                     
            
                                                                                                                                                                                                             
                                                                 

                                                                                    




                                                        



                                                 
                                   

                                                                            
            

                                     


                              
                      


                






                                                   
                                             

                                                                         
                                                                           






                                                   
                                             

                                                                                
                                                                                  



                                                                                               
                                                                       







                                                                                             
              

                                                                      
          
                                                                          


                                                 


                                                       
                                                                     

















                                                                                                                    

                                                                                   
                                                                               




















                                                                 






                                                              

                                                              


                                                                 

                                                                                    
 
 





                                          

                                       
                                     



                                                                                         



                            
                                       
                                       


                                                                                                                                 
                                                              


                                                                                                
                      
                                                                                   
            







                                                                                      

                                                                            







                                                                                           

                                                                                 

                                                                                                                     


                                                                 

                                                                                    





                                                        

                                                                            
            
                                                              


                                                                      
                                                                                    
                                                                                                                               
                   







                                                                                                        
                     











                                                                                             
--- Makefile.orig	Tue Aug  9 17:18:53 2005
+++ Makefile	Tue Aug  9 17:33:29 2005
@@ -45,6 +45,15 @@
 PROC=$(shell uname -m)
 endif
 
+ifeq (${OSARCH},FreeBSD)
+ifeq ($(PROC),sparc64)
+PROC=ultrasparc
+OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
+OPTIONS+=$(shell if $(CC) -mcpu=v9 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v9"; fi)
+OPTIONS+=-fomit-frame-pointer
+endif
+endif
+
 # Pentium Pro Optimize
 #PROC=i686
 
@@ -63,10 +72,10 @@
 #K6OPT  = -DK6OPT
 
 #Tell gcc to optimize the asterisk's code
-OPTIMIZE+=-O6
+#OPTIMIZE+=-O6
 
 #Include debug symbols in the executables (-g) and profiling info (-pg)
-DEBUG=-g #-pg
+#DEBUG=-g #-pg
 
 # If you are running a radio application, define RADIO_RELAX so that the DTMF
 # will be received more reliably
@@ -91,7 +100,7 @@
 
 # Where to install asterisk after compiling
 # Default -> leave empty
-INSTALL_PREFIX=
+INSTALL_PREFIX=$(PREFIX)
 
 # Staging directory
 # Files are copied here temporarily during the install process
@@ -111,23 +120,23 @@
 # Don't use together with -DBUSYDETECT_TONEONLY
 BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
 
-ASTLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
-ASTVARLIBDIR=$(INSTALL_PREFIX)/var/lib/asterisk
+ASTLIBDIR=$(INSTALL_PREFIX)/lib/asterisk
+ASTVARLIBDIR=$(INSTALL_PREFIX)/share/asterisk
 ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk
-ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
-ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
-ASTHEADERDIR=$(INSTALL_PREFIX)/usr/include/asterisk
+ASTSPOOLDIR=/var/spool/asterisk
+ASTLOGDIR=/var/log/asterisk
+ASTHEADERDIR=$(INSTALL_PREFIX)/include/asterisk
 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
-ASTBINDIR=$(INSTALL_PREFIX)/usr/bin
-ASTSBINDIR=$(INSTALL_PREFIX)/usr/sbin
-ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
-ASTMANDIR=$(INSTALL_PREFIX)/usr/share/man
+ASTBINDIR=$(INSTALL_PREFIX)/bin
+ASTSBINDIR=$(INSTALL_PREFIX)/sbin
+ASTVARRUNDIR=/var/run
+ASTMANDIR=$(INSTALL_PREFIX)/man
 
 MODULES_DIR=$(ASTLIBDIR)/modules
 AGI_DIR=$(ASTVARLIBDIR)/agi-bin
 
 INCLUDE=-Iinclude -I../include
-CFLAGS=-pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
+CFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
 CFLAGS+=$(OPTIMIZE)
 
 ifneq ($(PROC),ultrasparc)
@@ -138,12 +147,8 @@
 CFLAGS+=$(shell if [ -f /usr/include/osp/osp.h ]; then echo "-DOSP_SUPPORT -I/usr/include/osp" ; fi)
 
 ifeq (${OSARCH},FreeBSD)
-OSVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
-CFLAGS+=$(shell if test ${OSVERSION} -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
-LIBS+=$(shell if test  ${OSVERSION} -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
-INCLUDE+=-I/usr/local/include
-CFLAGS+=$(shell if [ -d /usr/local/include/spandsp ]; then echo "-I/usr/local/include/spandsp"; fi)
-MPG123TARG=freebsd
+CFLAGS+=$(PTHREAD_CFLAGS)
+LIBS+=$(PTHREAD_LIBS)
 endif # FreeBSD
 
 ifeq (${OSARCH},NetBSD)
@@ -160,7 +165,10 @@
 #CFLAGS+=-DOLD_DSP_ROUTINES
 
 CFLAGS+=$(shell if [ -f /usr/include/linux/zaptel.h ]; then echo "-DZAPTEL_OPTIMIZATIONS"; fi)
-CFLAGS+=$(shell if [ -f /usr/local/include/zaptel.h ]; then echo "-DZAPTEL_OPTIMIZATIONS"; fi)
+CFLAGS+=-I$(LOCALBASE)/include
+ifdef WITH_ZAPTEL
+CFLAGS+=-DZAPTEL_OPTIMIZATIONS
+endif
 
 LIBEDIT=editline/libedit.a
 
@@ -222,7 +230,7 @@
 SOLINK=-shared -Xlinker -x
 endif
 
-CC=gcc
+CC?=gcc
 INSTALL=install
 
 _all: all
@@ -234,7 +242,7 @@
 	@echo " +               $(MAKE) install                +"  
 	@echo " +-------------------------------------------+"  
 
-all: depend asterisk subdirs 
+all: depend asterisk subdirs manpage
 
 editline/config.h:
 	cd editline && unset CFLAGS LIBS && ./configure ; \
@@ -243,13 +251,13 @@
 	cd editline && unset CFLAGS LIBS && test -f config.h || ./configure
 	$(MAKE) -C editline libedit.a
 
-db1-ast/libdb1.a: FORCE
-	@if [ -d db1-ast ]; then \
-		$(MAKE) -C db1-ast libdb1.a ; \
-	else \
-		echo "You need to do a cvs update -d not just cvs update"; \
-		exit 1; \
-	fi
+#db1-ast/libdb1.a: FORCE
+#	@if [ -d db1-ast ]; then \
+#		$(MAKE) -C db1-ast libdb1.a ; \
+#	else \
+#		echo "You need to do a cvs update -d not just cvs update"; \
+#		exit 1; \
+#	fi
 
 ifneq ($(wildcard .depend),)
 include .depend
@@ -271,13 +279,10 @@
 
 asterisk.o: asterisk.c build.h
 
-manpage: asterisk.8.gz
+manpage: asterisk.8
 
-asterisk.8.gz: asterisk.sgml
-	rm -f asterisk.8
-	docbook2man asterisk.sgml
-	mv ./*.8 asterisk.8
-	gzip asterisk.8
+asterisk.8: asterisk.8.gz
+	gzcat asterisk.8.gz > asterisk.8
 
 ifneq ($(strip $(ASTERISKVERSION)),)
 build.h: .version
@@ -295,8 +300,8 @@
 		exit 1; \
 	fi
 
-asterisk: editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
-	$(CC) $(DEBUG) -o asterisk $(ASTLINK) $(OBJS) $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
+asterisk: editline/libedit.a stdtime/libtime.a $(OBJS)
+	$(CC) $(DEBUG) -o asterisk $(ASTLINK) $(OBJS) $(LIBEDIT) stdtime/libtime.a $(LIBS)
 
 muted: muted.o
 	$(CC) -o muted muted.o
@@ -315,28 +320,28 @@
 	$(MAKE) -C stdtime clean
 
 datafiles: all
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits
+	$(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits
 	for x in sounds/digits/*.gsm; do \
 		if grep -q "^%`basename $$x`%" sounds.txt; then \
-			install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits ; \
+			$(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
 		fi; \
 	done
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters
+	$(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters
 	for x in sounds/letters/*.gsm; do \
 		if grep -q "^%`basename $$x`%" sounds.txt; then \
-			install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \
+			$(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
 		fi; \
 	done
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic
+	$(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic
 	for x in sounds/phonetic/*.gsm; do \
 		if grep -q "^%`basename $$x`%" sounds.txt; then \
-			install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \
+			$(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
@@ -344,18 +349,18 @@
 	done
 	for x in sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-* sounds/conf-* sounds/agent-* sounds/invalid* sounds/tt-* sounds/auth-* sounds/privacy-* sounds/queue-*; do \
 		if grep -q "^%`basename $$x`%" sounds.txt; then \
-			install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
+			$(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
 		fi; \
 	done
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/mohmp3
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/images
+	$(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/mohmp3
+	$(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/images
 	for x in images/*.jpg; do \
-		install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/images ; \
+		$(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTVARLIBDIR)/images ; \
 	done
-	mkdir -p $(DESTDIR)$(AGI_DIR)
+	$(MKDIR) $(DESTDIR)$(AGI_DIR)
 
 update: 
 	@if [ -d CVS ]; then \
@@ -367,127 +372,90 @@
 	fi
 
 bininstall: all
-	mkdir -p $(DESTDIR)$(MODULES_DIR)
-	mkdir -p $(DESTDIR)$(ASTSBINDIR)
-	mkdir -p $(DESTDIR)$(ASTETCDIR)
-	mkdir -p $(DESTDIR)$(ASTBINDIR)
-	mkdir -p $(DESTDIR)$(ASTSBINDIR)
-	mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
-	mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
-	mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
-	install -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/
-	install -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
-	install -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
+	$(MKDIR) $(DESTDIR)$(MODULES_DIR)
+	$(MKDIR) $(DESTDIR)$(ASTSBINDIR)
+	$(MKDIR) $(DESTDIR)$(ASTETCDIR)
+	$(MKDIR) $(DESTDIR)$(ASTBINDIR)
+	$(MKDIR) $(DESTDIR)$(ASTSBINDIR)
+	$(MKDIR) $(DESTDIR)$(ASTVARRUNDIR)
+	$(MKDIR) $(DESTDIR)$(ASTSPOOLDIR)/voicemail
+	$(MKDIR) $(DESTDIR)$(ASTSPOOLDIR)/tmp
+	$(BSD_INSTALL_PROGRAM) asterisk $(DESTDIR)$(ASTSBINDIR)/
+	$(BSD_INSTALL_SCRIPT) contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
+	$(BSD_INSTALL_SCRIPT) contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
 	if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
-		install -m 755 contrib/scripts/safe_asterisk $(DESTDIR)$(ASTSBINDIR)/ ;\
+		$(BSD_INSTALL_SCRIPT) contrib/scripts/safe_asterisk $(DESTDIR)$(ASTSBINDIR)/ ;\
 	fi
 	for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
-	install -d $(DESTDIR)$(ASTHEADERDIR)
-	install -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
+	$(MKDIR) $(DESTDIR)$(ASTHEADERDIR)
+	$(BSD_INSTALL_DATA) include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
 	rm -f $(DESTDIR)$(ASTVARLIBDIR)/sounds/vm
-	rm -f $(DESTDIR)$(ASTVARLIBDIR)/sounds/voicemail
-	if [ ! -h $(DESTDIR)$(ASTSPOOLDIR)/vm ] && [ -d $(DESTDIR)$(ASTSPOOLDIR)/vm ]; then \
-		mv $(DESTDIR)$(ASTSPOOLDIR)/vm $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default; \
-	else \
-		mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default; \
-		rm -f $(DESTDIR)$(ASTSPOOLDIR)/vm; \
-	fi
-	ln -s $(ASTSPOOLDIR)/voicemail/default $(DESTDIR)$(ASTSPOOLDIR)/vm
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds
-	mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/keys
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax
-	mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
-	install -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
-	install -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
-	install -m 644 asterisk.8.gz $(DESTDIR)$(ASTMANDIR)/man8
+	ln -sf $(ASTSPOOLDIR)/voicemail/default $(DESTDIR)$(ASTSPOOLDIR)/vm
+	$(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/sounds
+	$(MKDIR) $(DESTDIR)$(ASTLOGDIR)/cdr-csv
+	$(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/keys
+	$(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/firmware
+	$(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax
+	$(MKDIR) $(DESTDIR)$(ASTMANDIR)/man8
+	$(BSD_INSTALL_DATA) keys/iaxtel.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
+	$(BSD_INSTALL_DATA) keys/freeworlddialup.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
+	$(BSD_INSTALL_DATA) asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
 	if [ -d contrib/firmware/iax ]; then \
-		install -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax/iaxy.bin; \
+		$(BSD_INSTALL_DATA) contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax/iaxy.bin; \
 	else \
 		echo "You need to do cvs update -d not just cvs update" ; \
 	fi 
-	( cd $(DESTDIR)$(ASTVARLIBDIR)/sounds  ; ln -s $(ASTSPOOLDIR)/vm . )
-	( cd $(DESTDIR)$(ASTVARLIBDIR)/sounds  ; ln -s $(ASTSPOOLDIR)/voicemail . )
-	if [ -f mpg123-0.59r/mpg123 ]; then $(MAKE) -C mpg123-0.59r install; fi
-	@echo " +---- Asterisk Installation Complete -------+"  
-	@echo " +                                           +"
-	@echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
-	@echo " +                                           +"
-	@echo " + Asterisk has successfully been installed. +"  
-	@echo " + If you would like to install the sample   +"  
-	@echo " + configuration files (overwriting any      +"
-	@echo " + existing config files), run:              +"  
-	@echo " +                                           +"
-	@echo " +               $(MAKE) samples                +"
-	@echo " +                                           +"
-	@echo " +-----------------  or ---------------------+"
-	@echo " +                                           +"
-	@echo " + You can go ahead and install the asterisk +"
-	@echo " + program documentation now or later run:   +"
-	@echo " +                                           +"
-	@echo " +              $(MAKE) progdocs                +"
-	@echo " +                                           +"
-	@echo " + **Note** This requires that you have      +"
-	@echo " + doxygen installed on your local system    +"
-	@echo " +-------------------------------------------+"
-	@echo " +                                           +"
-	@echo " + ** NOTE FOR DOWNGRADING FROM CVS HEAD **  +"
-	@echo " +                                           +"
-	@echo " + If you are downgrading from CVS HEAD to   +"
-	@echo " + a stable release, remember to delete      +"
-	@echo " + everything from your asterisk modules     +"
-	@echo " + directory (/usr/lib/asterisk/modules/)    +"
-	@echo " + and the asterisk header directory         +"
-	@echo " + (/usr/include/asterisk/)                  +"
-	@echo " + before doing a '$(MAKE) install'.            +"
-	@echo " +                                           +"
-	@echo " +-------------------------------------------+"
+	( cd $(DESTDIR)$(ASTVARLIBDIR)/sounds  ; ln -sf $(ASTSPOOLDIR)/vm . )
+	( cd $(DESTDIR)$(ASTVARLIBDIR)/sounds  ; ln -sf $(ASTSPOOLDIR)/voicemail . )
 
 
-install: all datafiles bininstall
+install: all datafiles bininstall samples
 
 upgrade: all bininstall
 
 adsi: all
-	mkdir -p $(DESTDIR)$(ASTETCDIR)
+	$(MKDIR) $(DESTDIR)$(ASTETCDIR)
 	for x in configs/*.adsi; do \
+		$(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x`-dist; \
 		if ! [ -f $(DESTDIR)$(ASTETCDIRX)/$$x ]; then \
-			install -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x` ; \
+			$(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x` ; \
 		fi ; \
 	done
 
 samples: all datafiles adsi
-	mkdir -p $(DESTDIR)$(ASTETCDIR)
-	for x in configs/*.sample; do \
-		if [ -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ]; then \
-			mv -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample`.old ; \
+	$(MKDIR) $(DESTDIR)$(ASTETCDIR)
+	for x in configs/*.sample channels/h323/*.sample; do \
+		$(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample`-dist;\
+		if ! [ -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ]; then \
+			$(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ;\
 		fi ; \
-		install -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ;\
 	done
-	echo "[directories]" > $(DESTDIR)$(ASTETCDIR)/asterisk.conf
-	echo "astetcdir => $(ASTETCDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
-	echo "astmoddir => $(MODULES_DIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
-	echo "astvarlibdir => $(ASTVARLIBDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
-	echo "astagidir => $(AGI_DIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
-	echo "astspooldir => $(ASTSPOOLDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
-	echo "astrundir => $(ASTVARRUNDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
-	echo "astlogdir => $(ASTLOGDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
-	echo "[options]" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
-	echo "uniquename = asterisk" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
+	echo "[directories]" > $(DESTDIR)$(ASTETCDIR)/asterisk.conf-dist
+	echo "astetcdir => $(ASTETCDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf-dist
+	echo "astmoddir => $(MODULES_DIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf-dist
+	echo "astvarlibdir => $(ASTVARLIBDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf-dist
+	echo "astagidir => $(AGI_DIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf-dist
+	echo "astspooldir => $(ASTSPOOLDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf-dist
+	echo "astrundir => $(ASTVARRUNDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf-dist
+	echo "astlogdir => $(ASTLOGDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf-dist
+	echo "[options]" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf-dist
+	echo "uniquename = asterisk" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf-dist
+	if ! [ -f $(DESTDIR)$(ASTETCDIR)/asterisk.conf ]; then \
+		$(BSD_INSTALL_DATA) $(DESTDIR)$(ASTETCDIR)/asterisk.conf-dist $(DESTDIR)$(ASTETCDIR)/asterisk.conf; \
+	fi
 	for x in sounds/demo-*; do \
 		if grep -q "^%`basename $$x`%" sounds.txt; then \
-			install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
+			$(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
 		fi; \
 	done
 	for x in sounds/*.mp3; do \
-		install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \
+		$(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \
 	done
 	rm -f $(DESTDIR)$(ASTVARLIBDIR)/mohmp3/sample-hold.mp3
-	mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
+	$(MKDIR) $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
 	:> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
 	for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
 		cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
@@ -502,7 +470,7 @@
 	@[ -d $(DESTDIR)$(HTTPDIR)/html ] || ( echo "No http directory" && exit 1 )
 	@[ -d $(DESTDIR)$(HTTPDIR)/cgi-bin ] || ( echo "No cgi-bin directory" && exit 1 )
 	install -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTPDIR)/cgi-bin/vmail.cgi
-	mkdir -p $(DESTDIR)$(HTTPDIR)/html/_asterisk
+	$(MKDIR) $(DESTDIR)$(HTTPDIR)/html/_asterisk
 	for x in images/*.gif; do \
 		install -m 644 $$x $(DESTDIR)$(HTTPDIR)/html/_asterisk/; \
 	done
@@ -522,10 +490,10 @@
 
 __rpm: _version
 	rm -rf /tmp/asterisk ; \
-	mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
+	$(MKDIR) /tmp/asterisk/redhat/RPMS/i386 ; \
 	$(MAKE) DESTDIR=/tmp/asterisk install ; \
 	$(MAKE) DESTDIR=/tmp/asterisk samples ; \
-	mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
+	$(MKDIR) /tmp/asterisk/etc/rc.d/init.d ; \
 	cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
 	sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
 	rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec