Move WITH_SMDI from the Makefiles to be handled by menuselect. It will now be
[asterisk/asterisk.git] / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Top level Makefile
5 #
6 # Copyright (C) 1999-2006, Digium, Inc.
7 #
8 # Mark Spencer <markster@digium.com>
9 #
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
12 #
13
14 .EXPORT_ALL_VARIABLES:
15
16 # Create OPTIONS variable
17 OPTIONS=
18
19 # If cross compiling, define these to suit
20 #CROSS_COMPILE=/opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-
21 #CROSS_COMPILE_BIN=/opt/montavista/pro/devkit/arm/xscale_be/bin/
22 #CROSS_COMPILE_TARGET=/opt/montavista/pro/devkit/arm/xscale_be/target
23 #CROSS_ARCH=Linux
24 #CROSS_PROC=arm
25 #SUB_PROC=xscale # or maverick
26
27 ifeq ($(CROSS_COMPILE),)
28   OSARCH=$(shell uname -s)
29   PROC?=$(shell uname -m)
30 else
31   OSARCH=$(CROSS_ARCH)
32   PROC=$(CROSS_PROC)
33 endif
34
35 PWD=$(shell pwd)
36
37 # Remember the MAKELEVEL at the top
38 MAKETOPLEVEL?=$(MAKELEVEL)
39
40 ifeq ($(findstring dont-optimize,$(MAKECMDGOALS)),)
41 # More GSM codec optimization
42 # Uncomment to enable MMXTM optimizations for x86 architecture CPU's
43 # which support MMX instructions.  This should be newer pentiums,
44 # ppro's, etc, as well as the AMD K6 and K7.  
45 #K6OPT  = -DK6OPT
46
47 # Tell gcc to optimize the code
48 OPTIMIZE+=-O6
49 else
50   # Stack backtraces, while useful for debugging, are incompatible with optimizations
51   ifeq (${OSARCH},Linux)
52     CFLAGS+=-DSTACK_BACKTRACES
53   endif
54 endif
55
56 # Overwite config files on "make samples"
57 OVERWRITE=y
58
59 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
60 DEBUG=-g3
61
62 # Staging directory
63 # Files are copied here temporarily during the install process
64 # For example, make DESTDIR=/tmp/asterisk woud put things in
65 # /tmp/asterisk/etc/asterisk
66 # !!! Watch out, put no spaces or comments after the value !!!
67 DESTDIR?=
68 #DESTDIR?=/tmp/asterisk
69
70 # Original busydetect routine
71 #BUSYDETECT = -DBUSYDETECT
72
73 # Improved busydetect routine, comment the previous one if you use this one
74 #BUSYDETECT+= -DBUSYDETECT_MARTIN 
75 # Detect the busy signal looking only at tone lengths
76 # For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
77 #BUSYDETECT+= -DBUSYDETECT_TONEONLY
78 # Enforce the detection of busy signal (get rid of false hangups)
79 # Don't use together with -DBUSYDETECT_TONEONLY
80 #BUSYDETECT+= -DBUSYDETECT_COMPARE_TONE_AND_SILENCE
81
82 # Define standard directories for various platforms
83 # These apply if they are not redefined in asterisk.conf 
84 ifeq ($(OSARCH),SunOS)
85   ASTETCDIR=$(INSTALL_PREFIX)/etc/opt/asterisk
86   ASTLIBDIR=$(INSTALL_PREFIX)/opt/asterisk/lib
87   ASTVARLIBDIR=$(INSTALL_PREFIX)/var/opt/asterisk/lib
88   ASTSPOOLDIR=$(INSTALL_PREFIX)/var/opt/asterisk/spool
89   ASTLOGDIR=$(INSTALL_PREFIX)/var/opt/asterisk/log
90   ASTHEADERDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/include/asterisk
91   ASTBINDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/bin
92   ASTSBINDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/sbin
93   ASTVARRUNDIR=$(INSTALL_PREFIX)/var/opt/asterisk/run
94   ASTMANDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/share/man
95 else
96 ifeq ($(OSARCH),FreeBSD)
97   PREFIX?=/usr/local
98   ASTETCDIR=$(INSTALL_PREFIX)$(PREFIX)/etc/asterisk
99   ASTLIBDIR=$(INSTALL_PREFIX)$(PREFIX)/lib/asterisk
100   ASTVARLIBDIR=$(INSTALL_PREFIX)$(PREFIX)/share/asterisk
101   ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
102   ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
103   ASTHEADERDIR=$(INSTALL_PREFIX)$(PREFIX)/include/asterisk
104   ASTBINDIR=$(INSTALL_PREFIX)$(PREFIX)/bin
105   ASTSBINDIR=$(INSTALL_PREFIX)$(PREFIX)/sbin
106   ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
107   ASTMANDIR=$(INSTALL_PREFIX)$(PREFIX)/man
108 else
109   ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk
110   ASTLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
111   ASTVARLIBDIR=$(INSTALL_PREFIX)/var/lib/asterisk
112   ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
113   ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
114   ASTHEADERDIR=$(INSTALL_PREFIX)/usr/include/asterisk
115   ASTBINDIR=$(INSTALL_PREFIX)/usr/bin
116   ASTSBINDIR=$(INSTALL_PREFIX)/usr/sbin
117   ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
118   ASTMANDIR=$(INSTALL_PREFIX)/usr/share/man
119 endif
120 endif
121 ASTDATADIR?=$(ASTVARLIBDIR)
122
123 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
124 # when starting Asterisk
125 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
126 MODULES_DIR=$(ASTLIBDIR)/modules
127 AGI_DIR=$(ASTDATADIR)/agi-bin
128
129 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
130 HTTP_DOCSDIR=/var/www/html
131 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
132 HTTP_CGIDIR=/var/www/cgi-bin
133
134 ASTCFLAGS=
135
136 # Uncomment this to use the older DSP routines
137 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
138
139 # If the file .asterisk.makeopts is present in your home directory, you can
140 # include all of your favorite menuselect options so that every time you download
141 # a new version of Asterisk, you don't have to run menuselect to set them. 
142 # The file /etc/asterisk.makeopts will also be included but can be overridden
143 # by the file in your home directory.
144
145 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
146 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
147
148 ifneq ($(wildcard menuselect.makeopts),)
149   include menuselect.makeopts
150 endif
151
152 ifneq ($(wildcard makeopts),)
153   include makeopts
154 endif
155
156 TOPDIR_CFLAGS=-include include/autoconfig.h -Iinclude
157 MOD_SUBDIR_CFLAGS=-include ../include/autoconfig.h -I../include -I..
158 OTHER_SUBDIR_CFLAGS=-include ../include/autoconfig.h -I../include -I..
159
160 #   *CLI> show memory allocations [filename]
161 #   *CLI> show memory summary [filename]
162 ifneq ($(findstring MALLOC_DEBUG,$(MENUSELECT_CFLAGS)),)
163   TOPDIR_CFLAGS+=-include include/asterisk/astmm.h
164   MOD_SUBDIR_CFLAGS+=-include ../include/asterisk/astmm.h
165 endif
166
167 MOD_SUBDIR_CFLAGS+=-fPIC
168
169 ifeq ($(OSARCH),Linux)
170   ifeq ($(PROC),x86_64)
171     # You must have GCC 3.4 to use k8, otherwise use athlon
172     PROC=k8
173     #PROC=athlon
174   endif
175
176   ifeq ($(PROC),sparc64)
177     #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
178     #This works for even old (2.96) versions of gcc and provides a small boost either way.
179     #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
180     #So we go lowest common available by gcc and go a step down, still a step up from
181     #the default as we now have a better instruction set to work with. - Belgarath
182     PROC=ultrasparc
183     OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
184     OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
185     OPTIONS+=-fomit-frame-pointer
186   endif
187
188   ifeq ($(PROC),arm)
189     # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
190     ifeq ($(SUB_PROC),maverick)
191       OPTIONS+=-fsigned-char -mcpu=ep9312
192     else
193       ifeq ($(SUB_PROC),xscale)
194         OPTIONS+=-fsigned-char -mcpu=xscale
195       else
196         OPTIONS+=-fsigned-char 
197       endif
198     endif
199   endif
200   MPG123TARG=linux
201 endif
202
203 GREP=grep
204 ID=id
205
206 ifeq ($(OSARCH),SunOS)
207   GREP=/usr/xpg4/bin/grep
208   M4=/usr/local/bin/m4
209   ID=/usr/xpg4/bin/id
210 endif
211
212 ASTCFLAGS+=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
213 ASTCFLAGS+=$(OPTIMIZE)
214
215 ifeq ($(AST_DEVMODE),yes)
216   ASTCFLAGS+=-Werror -Wunused
217 endif
218
219 ifeq ($(shell gcc -v 2>&1 | grep 'gcc version' | cut -f3 -d' ' | cut -f1 -d.),4)
220 ASTCFLAGS+=-Wno-pointer-sign
221 endif
222 ASTOBJ=-o asterisk
223
224 ifeq ($(findstring BSD,$(OSARCH)),BSD)
225   ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
226 endif
227
228 ifneq ($(PROC),ultrasparc)
229   ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
230 endif
231
232 ifeq ($(PROC),ppc)
233   ASTCFLAGS+=-fsigned-char
234 endif
235
236 ifeq ($(OSARCH),FreeBSD)
237   BSDVERSION=$(shell make -V OSVERSION -f $(CROSS_COMPILE_TARGET)/usr/share/mk/bsd.port.subdir.mk)
238   ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
239   LIBS+=$(shell if test  $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
240   ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/spandsp),)
241     ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/spandsp
242   endif
243   MPG123TARG=freebsd
244 endif # FreeBSD
245
246 ifeq ($(OSARCH),NetBSD)
247   AST_CFLAGS+=-pthread -I$(CROSS_COMPILE_TARGET)/usr/pkg/include
248   MPG123TARG=netbsd
249 endif
250
251 ifeq ($(OSARCH),OpenBSD)
252   ASTCFLAGS+=-pthread
253 endif
254
255 ifeq ($(OSARCH),SunOS)
256   ASTCFLAGS+=-Wcast-align -DSOLARIS -Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
257 endif
258
259 LIBEDIT=editline/libedit.a
260
261 ASTERISKVERSION:=$(shell build_tools/make_version .)
262
263 ifneq ($(wildcard .version),)
264   ASTERISKVERSIONNUM:=$(shell awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version)
265   RPMVERSION:=$(shell sed 's/[-\/:]/_/g' .version)
266 else
267   RPMVERSION=unknown
268 endif
269
270 # CVS mirrors of SVN have .svnrevision files showing
271 # which SVN revision they are based on, and .svnbranch
272 # showing the branch they are made from
273 ifneq ($(wildcard .svnrevision),)
274   ASTERISKVERSIONNUM=999999
275 else
276   ifneq ($(wildcard .svn),)
277     ASTERISKVERSIONNUM=999999
278   endif
279 endif
280
281 ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
282 ifeq ($(findstring dont-optimize,$(MAKECMDGOALS)),)
283 ASTCFLAGS+=-fomit-frame-pointer
284 endif
285
286 MOD_SUBDIRS=res channels pbx apps codecs formats cdr funcs
287 SUBDIRS:=$(MOD_SUBDIRS) utils stdtime agi
288
289 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
290         translate.o file.o pbx.o cli.o md5.o term.o \
291         ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
292         cdr.o tdd.o acl.o rtp.o udptl.o manager.o asterisk.o \
293         dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
294         astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
295         utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
296         netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
297         cryptostub.o sha1.o http.o
298
299 # we need to link in the objects statically, not as a library, because
300 # otherwise modules will not have them available if none of the static
301 # objects use it.
302 OBJS+=stdtime/localtime.o
303
304 # At the moment say.o is an optional component which can be overridden
305 # by a module.
306 OBJS+=say.o
307
308 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sys/poll.h),)
309   OBJS+= poll.o
310   ASTCFLAGS+=-DPOLLCOMPAT
311 endif
312
313 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/dlfcn.h),)
314   OBJS+= dlfcn.o
315   ASTCFLAGS+=-DDLFCNCOMPAT
316 endif
317
318 ifeq ($(OSARCH),Linux)
319   LIBS+=-ldl -lpthread $(EDITLINE_LIBS) -lm -lresolv  #-lnjamd
320 else
321   LIBS+=$(EDITLINE_LIBS) -lm
322 endif
323
324 ifeq ($(OSARCH),Darwin)
325   LIBS+=-lresolv
326   ASTCFLAGS+=-D__Darwin__
327   AUDIO_LIBS=-framework CoreAudio
328   ASTLINK=-Wl,-dynamic
329   SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
330   # Mac on Intel CoreDuo does not need poll compatibility layer
331   ifneq ($(PROC),i386)
332     OBJS+=poll.o
333     ASTCFLAGS+=-DPOLLCOMPAT
334   endif
335 else
336 # These are used for all but Darwin
337   ASTLINK=-Wl,-E 
338   SOLINK=-shared -Xlinker -x
339   ifeq ($(findstring BSD,$(OSARCH)),BSD)
340     SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
341   endif
342 endif
343
344 ifeq ($(OSARCH),FreeBSD)
345   LIBS+=-lcrypto
346 endif
347
348 ifeq ($(OSARCH),NetBSD)
349   LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib $(EDITLINE_LIBS)
350 endif
351
352 ifeq ($(OSARCH),OpenBSD)
353   LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIBS)
354 endif
355
356 ifeq ($(OSARCH),SunOS)
357   LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
358   OBJS+=strcompat.o
359   MENUSELECT_OBJS+=strcompat.o
360   ASTLINK=
361   SOLINK=-shared -fpic -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
362 endif
363
364 ifeq ($(MAKETOPLEVEL),$(MAKELEVEL))
365   CFLAGS+=$(TOPDIR_CFLAGS)$(ASTCFLAGS)
366 endif
367
368 # This is used when generating the doxygen documentation
369 ifneq ($(DOT),:)
370   HAVEDOT=yes
371 else
372   HAVEDOT=no
373 endif
374
375 INSTALL=install
376
377 _all: all
378         @echo " +--------- Asterisk Build Complete ---------+"  
379         @echo " + Asterisk has successfully been built, but +"  
380         @echo " + cannot be run before being installed by   +"  
381         @echo " + running:                                  +"  
382         @echo " +                                           +"
383         @echo " +               make install                +"  
384         @echo " +-------------------------------------------+"  
385
386 all: cleantest config.status menuselect.makeopts depend asterisk subdirs
387
388 config.status: configure
389         @CFLAGS="" ./configure
390         @echo "****"
391         @echo "**** The configure script was just executed, so 'make' needs to be"
392         @echo "**** restarted."
393         @echo "****"
394         @exit 1
395
396 makeopts: configure
397         @CFLAGS="" ./configure
398         @echo "****"
399         @echo "**** The configure script was just executed, so 'make' needs to be"
400         @echo "**** restarted."
401         @echo "****"
402         @exit 1
403
404 menuselect.makeopts: build_tools/menuselect makeopts.xml
405         @build_tools/menuselect --check-deps ${GLOBAL_MAKEOPTS} ${USER_MAKEOPTS} $@
406
407 #ifneq ($(wildcard tags),)
408 ctags: tags
409 #endif
410
411 ifneq ($(wildcard TAGS),)
412 all: TAGS
413 endif
414
415 editline/config.h:
416         cd editline && unset CFLAGS LIBS && CFLAGS="$(OPTIMIZE)" ./configure ; \
417
418 editline/libedit.a:
419         cd editline && unset CFLAGS LIBS && test -f config.h || CFLAGS="$(OPTIMIZE)" ./configure
420         $(MAKE) -C editline libedit.a
421
422 db1-ast/libdb1.a:
423         $(MAKE) -C db1-ast libdb1.a
424
425 ifneq ($(wildcard .depend),)
426   include .depend
427 endif
428
429 ifneq ($(wildcard .tags-depend),)
430   include .tags-depend
431 endif
432
433 ast_expr2.c ast_expr2.h:
434         bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
435
436 ast_expr2f.c:
437         flex -o $@ --full ast_expr2.fl
438
439 testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
440         gcc -g -c -DSTANDALONE ast_expr2f.c
441         gcc -g -c -DSTANDALONE ast_expr2.c
442         gcc -g -o testexpr2 ast_expr2f.o ast_expr2.o
443         rm ast_expr2.o ast_expr2f.o 
444
445 manpage: asterisk.8
446
447 asterisk.8: asterisk.sgml
448         rm -f asterisk.8
449         docbook2man asterisk.sgml
450         mv ./*.8 asterisk.8
451
452 asterisk.pdf: asterisk.sgml
453         docbook2pdf asterisk.sgml
454
455 asterisk.ps: asterisk.sgml
456         docbook2ps asterisk.sgml
457
458 asterisk.html: asterisk.sgml
459         docbook2html asterisk.sgml
460         mv r1.html asterisk.html
461
462 asterisk.txt: asterisk.sgml
463         docbook2txt asterisk.sgml
464
465 defaults.h: makeopts
466         @build_tools/make_defaults_h > $@.tmp
467         @if cmp -s $@.tmp $@ ; then echo ; else \
468                 mv $@.tmp $@ ; \
469         fi
470         @rm -f $@.tmp
471
472 include/asterisk/version.h:
473         @build_tools/make_version_h > $@.tmp
474         @if cmp -s $@.tmp $@ ; then echo; else \
475                 mv $@.tmp $@ ; \
476         fi
477         @rm -f $@.tmp
478
479 include/asterisk/buildopts.h: menuselect.makeopts
480         @build_tools/make_buildopts_h > $@.tmp
481         @if cmp -s $@.tmp $@ ; then echo; else \
482                 mv $@.tmp $@ ; \
483         fi
484         @rm -f $@.tmp
485
486 stdtime/libtime.a:
487         CFLAGS="$(MOD_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C stdtime libtime.a
488
489 asterisk: include/asterisk/buildopts.h editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
490         build_tools/make_build_h > include/asterisk/build.h.tmp
491         if cmp -s include/asterisk/build.h.tmp include/asterisk/build.h ; then echo ; else \
492                 mv include/asterisk/build.h.tmp include/asterisk/build.h ; \
493         fi
494         rm -f include/asterisk/build.h.tmp
495         $(CC) -c -o buildinfo.o $(CFLAGS) buildinfo.c
496         $(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
497
498 muted: muted.o
499         $(CC) $(AUDIO_LIBS) -o muted muted.o
500
501 subdirs: 
502         @for x in $(MOD_SUBDIRS); do CFLAGS="$(MOD_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $$x || exit 1 ; done
503         @CFLAGS="$(OTHER_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C utils
504         @CFLAGS="$(OTHER_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C agi
505
506 clean-depend:
507         @for x in $(SUBDIRS); do $(MAKE) -C $$x clean-depend || exit 1 ; done
508         rm -f .depend .tags-depend
509
510 clean: clean-depend
511         @for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
512         rm -f *.o *.so asterisk
513         rm -f defaults.h
514         rm -f include/asterisk/build.h
515         rm -f include/asterisk/version.h
516         rm -f .tags-sources tags TAGS
517         @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
518         @if [ -d mpg123-0.59r ]; then $(MAKE) -C mpg123-0.59r clean; fi
519         $(MAKE) -C db1-ast clean
520         $(MAKE) -C stdtime clean
521
522 distclean: dist-clean
523
524 dist-clean: clean
525         rm -f menuselect.makeopts makeopts makeopts.xml
526         rm -f config.log config.status
527         rm -f include/autoconfig.h
528         rm -f include/asterisk/buildopts.h
529         $(MAKE) -C mxml clean
530         $(MAKE) -C build_tools dist-clean
531
532 datafiles: all
533         if [ x`$(ID) -un` = xroot ]; then sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
534 # Should static HTTP be installed during make samples or even with its own target ala
535 # webvoicemail?  There are portions here that *could* be customized but might also be
536 # improved a lot.  I'll put it here for now.
537         mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
538         for x in static-http/*; do \
539                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
540         done
541         mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/digits
542         mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/priv-callerintros
543         for x in sounds/digits/*.gsm; do \
544                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
545                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/digits ; \
546                 else \
547                         echo "No description for $$x"; \
548                         exit 1; \
549                 fi; \
550         done
551         mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/dictate
552         for x in sounds/dictate/*.gsm; do \
553                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
554                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/dictate ; \
555                 else \
556                         echo "No description for $$x"; \
557                         exit 1; \
558                 fi; \
559         done
560         mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/letters
561         for x in sounds/letters/*.gsm; do \
562                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
563                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/letters ; \
564                 else \
565                         echo "No description for $$x"; \
566                         exit 1; \
567                 fi; \
568         done
569         mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/phonetic
570         for x in sounds/phonetic/*.gsm; do \
571                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
572                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/phonetic ; \
573                 else \
574                         echo "No description for $$x"; \
575                         exit 1; \
576                 fi; \
577         done
578         for x in sounds/demo-* 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-* sounds/spy-* sounds/priv-* sounds/screen-* sounds/hello-*; do \
579                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
580                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds ; \
581                 else \
582                         echo "No description for $$x"; \
583                         exit 1; \
584                 fi; \
585         done
586         mkdir -p $(DESTDIR)$(ASTDATADIR)/mohmp3
587         mkdir -p $(DESTDIR)$(ASTDATADIR)/images
588         for x in images/*.jpg; do \
589                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
590         done
591         mkdir -p $(DESTDIR)$(AGI_DIR)
592
593 update: 
594         @if [ -d .svn ]; then \
595                 echo "Updating from Subversion..." ; \
596                 svn update | tee update.out; \
597                 rm -f .version; \
598                 if [ `grep -c ^C update.out` -gt 0 ]; then \
599                         echo ; echo "The following files have conflicts:" ; \
600                         grep ^C update.out | cut -b4- ; \
601                 fi ; \
602                 rm -f update.out; \
603                 $(MAKE) clean-depend; \
604         elif [ -d CVS ]; then \
605                 echo "Updating from CVS..." ; \
606                 cvs -q -z3 update -Pd | tee update.out; \
607                 rm -f .version; \
608                 if [ `grep -c ^C update.out` -gt 0 ]; then \
609                         echo ; echo "The following files have conflicts:" ; \
610                         grep ^C update.out | cut -d' ' -f2- ; \
611                 fi ; \
612                 rm -f update.out; \
613                 $(MAKE) clean-depend; \
614         else \
615                 echo "Not under version control";  \
616         fi
617
618 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
619 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
620
621 bininstall: all
622         mkdir -p $(DESTDIR)$(MODULES_DIR)
623         mkdir -p $(DESTDIR)$(ASTSBINDIR)
624         mkdir -p $(DESTDIR)$(ASTETCDIR)
625         mkdir -p $(DESTDIR)$(ASTBINDIR)
626         mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
627         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
628         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
629         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
630         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
631         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
632         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
633         if [ -f asterisk ]; then $(INSTALL) -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/; fi
634         if [ -f asterisk.dll ]; then $(INSTALL) -m 755 asterisk.dll $(DESTDIR)$(ASTSBINDIR)/; fi
635         ln -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
636         $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
637         $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
638         if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
639                 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
640                 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
641         fi
642         $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
643         $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
644         if [ -n "$(OLDHEADERS)" ]; then \
645                 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
646         fi
647         mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds
648         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
649         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
650         mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
651         mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
652         mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
653         mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
654         $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
655         $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
656         $(INSTALL) -m 644 asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
657         $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
658         $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
659         $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
660         if [ -d contrib/firmware/iax ]; then \
661                 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
662         else \
663                 echo "You need to do cvs update -d not just cvs update" ; \
664         fi 
665         if [ -f mpg123-0.59r/mpg123 ]; then $(MAKE) -C mpg123-0.59r install; fi
666
667 install-subdirs:
668         @for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
669
670 NEWMODS=$(notdir $(wildcard */*.so))
671 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
672
673 oldmodcheck:
674         @if [ -n "$(OLDMODS)" ]; then \
675                 echo " WARNING WARNING WARNING" ;\
676                 echo "" ;\
677                 echo " Your Asterisk modules directory, located at" ;\
678                 echo " $(DESTDIR)$(MODULES_DIR)" ;\
679                 echo " contains modules that were not installed by this " ;\
680                 echo " version of Asterisk. Please ensure that these" ;\
681                 echo " modules are compatible with this version before" ;\
682                 echo " attempting to run Asterisk." ;\
683                 echo "" ;\
684                 for f in $(OLDMODS); do \
685                         echo "    $$f" ;\
686                 done ;\
687                 echo "" ;\
688                 echo " WARNING WARNING WARNING" ;\
689         fi
690
691 install: all datafiles bininstall install-subdirs
692         @if [ -x /usr/sbin/asterisk-post-install ]; then \
693                 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
694         fi
695         @echo " +---- Asterisk Installation Complete -------+"  
696         @echo " +                                           +"
697         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
698         @echo " +                                           +"
699         @echo " + Asterisk has successfully been installed. +"  
700         @echo " + If you would like to install the sample   +"  
701         @echo " + configuration files (overwriting any      +"
702         @echo " + existing config files), run:              +"  
703         @echo " +                                           +"
704         @echo " +               $(MAKE) samples                +"
705         @echo " +                                           +"
706         @echo " +-----------------  or ---------------------+"
707         @echo " +                                           +"
708         @echo " + You can go ahead and install the asterisk +"
709         @echo " + program documentation now or later run:   +"
710         @echo " +                                           +"
711         @echo " +              $(MAKE) progdocs                +"
712         @echo " +                                           +"
713         @echo " + **Note** This requires that you have      +"
714         @echo " + doxygen installed on your local system    +"
715         @echo " +-------------------------------------------+"
716         @$(MAKE) -s oldmodcheck
717
718 upgrade: all bininstall
719
720 adsi:
721         mkdir -p $(DESTDIR)$(ASTETCDIR)
722         for x in configs/*.adsi; do \
723                 if [ ! -f $(DESTDIR)$(ASTETCDIRX)/$$x ]; then \
724                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x` ; \
725                 fi ; \
726         done
727
728 samples: adsi
729         mkdir -p $(DESTDIR)$(ASTETCDIR)
730         for x in configs/*.sample; do \
731                 if [ -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ]; then \
732                         if [ "$(OVERWRITE)" = "y" ]; then \
733                                 if cmp -s $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $$x ; then \
734                                         echo "Config file $$x is unchanged"; \
735                                         continue; \
736                                 fi ; \
737                                 mv -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample`.old ; \
738                         else \
739                                 echo "Skipping config file $$x"; \
740                                 continue; \
741                         fi ;\
742                 fi ; \
743                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ;\
744         done
745         if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
746                 ( \
747                 echo "[directories]" ; \
748                 echo "astetcdir => $(ASTETCDIR)" ; \
749                 echo "astmoddir => $(MODULES_DIR)" ; \
750                 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
751                 echo "astdatadir => $(ASTDATADIR)" ; \
752                 echo "astagidir => $(AGI_DIR)" ; \
753                 echo "astspooldir => $(ASTSPOOLDIR)" ; \
754                 echo "astrundir => $(ASTVARRUNDIR)" ; \
755                 echo "astlogdir => $(ASTLOGDIR)" ; \
756                 echo "" ; \
757                 echo "; Changing the following lines may compromise your security." ; \
758                 echo ";[files]" ; \
759                 echo ";astctlpermissions = 0660" ; \
760                 echo ";astctlowner = root" ; \
761                 echo ";astctlgroup = apache" ; \
762                 echo ";astctl = asterisk.ctl" ; \
763                 echo ";[options]" ; \
764                 echo ";internal_timing = yes" ; \
765                 ) > $(DESTDIR)$(ASTCONFPATH) ; \
766         else \
767                 echo "Skipping asterisk.conf creation"; \
768         fi
769         mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds ; \
770         for x in sounds/demo-*; do \
771                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
772                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds ; \
773                 else \
774                         echo "No description for $$x"; \
775                         exit 1; \
776                 fi; \
777         done
778         mkdir -p $(DESTDIR)$(ASTDATADIR)/mohmp3 ; \
779         for x in sounds/*.mp3; do \
780                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/mohmp3 ; \
781         done
782         rm -f $(DESTDIR)$(ASTDATADIR)/mohmp3/sample-hold.mp3
783         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
784         :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
785         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
786                 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
787         done
788         :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
789         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
790                 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
791         done
792
793 webvmail:
794         @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
795         @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
796         $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
797         mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
798         for x in images/*.gif; do \
799                 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
800         done
801         @echo " +--------- Asterisk Web Voicemail ----------+"  
802         @echo " +                                           +"
803         @echo " + Asterisk Web Voicemail is installed in    +"
804         @echo " + your cgi-bin directory:                   +"
805         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
806         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
807         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
808         @echo " +                                           +"
809         @echo " + Other static items have been stored in:   +"
810         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
811         @echo " +                                           +"
812         @echo " + If these paths do not match your httpd    +"
813         @echo " + installation, correct the definitions     +"
814         @echo " + in your Makefile of HTTP_CGIDIR and       +"
815         @echo " + HTTP_DOCSDIR                              +"
816         @echo " +                                           +"
817         @echo " +-------------------------------------------+"  
818
819 spec: 
820         sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
821
822 rpm: __rpm
823
824 __rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
825         rm -rf /tmp/asterisk ; \
826         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
827         $(MAKE) DESTDIR=/tmp/asterisk install ; \
828         $(MAKE) DESTDIR=/tmp/asterisk samples ; \
829         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
830         cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
831         rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
832
833 progdocs:
834         (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
835         echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen - 
836
837 mpg123:
838         @wget -V >/dev/null || (echo "You need wget" ; false )
839         [ -f mpg123-0.59r.tar.gz ] || wget http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz
840         [ -d mpg123-0.59r ] || tar xfz mpg123-0.59r.tar.gz
841         $(MAKE) -C mpg123-0.59r $(MPG123TARG)
842
843 config:
844         @if [ "${OSARCH}" = "Linux" ]; then \
845                 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
846                         $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
847                         /sbin/chkconfig --add asterisk; \
848                 elif [ -f /etc/debian_version ]; then \
849                         $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk; \
850                         /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; \
851                 elif [ -f /etc/gentoo-release ]; then \
852                         $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk /etc/init.d/asterisk; \
853                         /sbin/rc-update add asterisk default; \
854                 elif [ -f /etc/mandrake-release ]; then \
855                         $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk /etc/rc.d/init.d/asterisk; \
856                         /sbin/chkconfig --add asterisk; \
857                 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
858                         $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk /etc/init.d/asterisk; \
859                         /sbin/chkconfig --add asterisk; \
860                 elif [ -f /etc/slackware-version ]; then \
861                         echo "Slackware is not currently supported, although an init script does exist for it." \
862                 else \
863                         echo "We could not install init scripts for your distribution."; \
864                 fi \
865         else \
866                 echo "We could not install init scripts for your operating system."; \
867         fi
868
869 dont-optimize: _all
870
871 valgrind: dont-optimize
872
873 depend: include/asterisk/version.h include/asterisk/buildopts.h .depend defaults.h 
874         @for x in $(SUBDIRS); do $(MAKE) -C $$x depend || exit 1 ; done
875
876 .depend: include/asterisk/version.h include/asterisk/buildopts.h defaults.h
877         build_tools/mkdep $(CFLAGS) $(wildcard *.c)
878
879 .tags-depend:
880         @echo -n ".tags-depend: " > $@
881         @find . -maxdepth 1 -name \*.c -printf "\t%p \\\\\n" >> $@
882         @find . -maxdepth 1 -name \*.h -printf "\t%p \\\\\n" >> $@
883         @find $(SUBDIRS) -name \*.c -printf "\t%p \\\\\n" >> $@
884         @find $(SUBDIRS) -name \*.h -printf "\t%p \\\\\n" >> $@
885         @find include -name \*.h -printf "\t%p \\\\\n" >> $@
886         @echo >> $@
887
888 .tags-sources:
889         @rm -f $@
890         @find . -maxdepth 1 -name \*.c -print >> $@
891         @find . -maxdepth 1 -name \*.h -print >> $@
892         @find $(SUBDIRS) -name \*.c -print >> $@
893         @find $(SUBDIRS) -name \*.h -print >> $@
894         @find include -name \*.h -print >> $@
895
896 tags: .tags-depend .tags-sources
897         ctags -L .tags-sources -o $@
898
899 ctags: tags
900
901 TAGS: .tags-depend .tags-sources
902         etags -o $@ `cat .tags-sources`
903
904 etags: TAGS
905
906 FORCE:
907
908 %_env:
909         $(MAKE) -C $(shell echo $@ | sed "s/_env//g") env
910
911 env:
912         env
913
914 # If the cleancount has been changed, force a make clean.
915 # .cleancount is the global clean count, and .lastclean is the 
916 # last clean count we had
917
918 cleantest:
919         @if cmp -s .cleancount .lastclean ; then echo ; else \
920                 $(MAKE) clean; cp -f .cleancount .lastclean;\
921         fi
922
923 _uninstall:
924         rm -f $(DESTDIR)$(MODULES_DIR)/*
925         rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
926         rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
927         rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
928         rm -rf $(DESTDIR)$(ASTHEADERDIR)
929         rm -rf $(DESTDIR)$(ASTDATADIR)/sounds
930         rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
931         rm -rf $(DESTDIR)$(ASTMANDIR)/man8
932         for x in $(SUBDIRS); do $(MAKE) -C $$x uninstall || exit 1 ; done
933
934 uninstall: _uninstall
935         @echo " +--------- Asterisk Uninstall Complete -----+"  
936         @echo " + Asterisk binaries, sounds, man pages,     +"  
937         @echo " + headers, modules, and firmware builds,    +"  
938         @echo " + have all been uninstalled.                +"  
939         @echo " +                                           +"
940         @echo " + To remove ALL traces of Asterisk,         +"
941         @echo " + including configuration, spool            +"
942         @echo " + directories, and logs, run the following  +"
943         @echo " + command:                                  +"
944         @echo " +                                           +"
945         @echo " +            $(MAKE) uninstall-all             +"  
946         @echo " +-------------------------------------------+"  
947
948 uninstall-all: _uninstall
949         rm -rf $(DESTDIR)$(ASTLIBDIR)
950         rm -rf $(DESTDIR)$(ASTVARLIBDIR)
951         rm -rf $(DESTDIR)$(ASTDATADIR)
952         rm -rf $(DESTDIR)$(ASTSPOOLDIR)
953         rm -rf $(DESTDIR)$(ASTETCDIR)
954         rm -rf $(DESTDIR)$(ASTLOGDIR)
955
956 menuselect: build_tools/menuselect makeopts.xml
957         -@build_tools/menuselect ${GLOBAL_MAKEOPTS} ${USER_MAKEOPTS} menuselect.makeopts && echo "menuselect changes saved!" || echo "menuselect changes NOT saved!"
958
959 build_tools/menuselect: build_tools/menuselect.c build_tools/menuselect_curses.c build_tools/menuselect.h config.status mxml/libmxml.a $(MENUSELECT_OBJS)
960         $(MAKE) -C build_tools menuselect
961
962 mxml/libmxml.a:
963         @cd mxml && unset CFLAGS LIBS && test -f config.h || ./configure
964         $(MAKE) -C mxml libmxml.a
965
966 makeopts.xml: $(foreach dir,$(MOD_SUBDIRS),$(dir)/*.c) build_tools/cflags.xml
967         @echo "Generating list of available modules ..."
968         @build_tools/prep_moduledeps > $@