aboutsummaryrefslogtreecommitdiff
path: root/net/asterisk16/files/patch-Makefile
blob: 176c4ba74d4eba08a56237ded7ca1b1a75e538fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
--- Makefile.orig	Tue Jul 12 00:36:27 2005
+++ Makefile	Tue Jul 12 01:24:50 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
+ifndef WITHOUT_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