~davewalker/ubuntu/maverick/asterisk/lp_705014

« back to all changes in this revision

Viewing changes to .pc/make-clean-fixes/Makefile

  • Committer: Bazaar Package Importer
  • Author(s): Steve Beattie
  • Date: 2010-03-02 10:00:03 UTC
  • Revision ID: james.westby@ubuntu.com-20100302100003-qaycyl89gy31bz03
Tags: 1:1.6.2.2-1ubuntu2
debian/{control,rules}: re-enable hardened options to gain PIE build
(Debian bug 542741, LP: #527538)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
# All Makefiles use the following variables:
 
15
#
 
16
# ASTCFLAGS - compiler options provided by the user (if any)
 
17
# _ASTCFLAGS - compiler options provided by the build system
 
18
# ASTLDFLAGS - linker flags (not libraries) provided by the user (if any)
 
19
# _ASTLDFLAGS - linker flags (not libraries) provided by the build system
 
20
# LIBS - additional libraries, at top-level for all links,
 
21
#      on a single object just for that object
 
22
# SOLINK - linker flags used only for creating shared objects (.so files),
 
23
#      used for all .so links
 
24
#
 
25
# Values for ASTCFLAGS and ASTLDFLAGS can be specified in the
 
26
# environment when running make, as follows:
 
27
#
 
28
#       $ ASTCFLAGS="-Werror" make ...
 
29
#
 
30
# or as a variable value on the make command line itself:
 
31
#
 
32
#       $ make ASTCFLAGS="-Werror" ...
 
33
 
 
34
export ASTTOPDIR                # Top level dir, used in subdirs' Makefiles
 
35
export ASTERISKVERSION
 
36
export ASTERISKVERSIONNUM
 
37
 
 
38
#--- values used for default paths
 
39
 
 
40
# DESTDIR is the staging (or final) directory where files are copied
 
41
# during the install process. Define it before 'export', otherwise
 
42
# export will set it to the empty string making ?= fail.
 
43
# WARNING: do not put spaces or comments after the value.
 
44
DESTDIR?=$(INSTALL_PATH)
 
45
export DESTDIR
 
46
 
 
47
export INSTALL_PATH     # Additional prefix for the following paths
 
48
export ASTETCDIR                # Path for config files
 
49
export ASTVARRUNDIR
 
50
export MODULES_DIR
 
51
export ASTSPOOLDIR
 
52
export ASTVARLIBDIR
 
53
export ASTDATADIR
 
54
export ASTDBDIR
 
55
export ASTLOGDIR
 
56
export ASTLIBDIR
 
57
export ASTMANDIR
 
58
export ASTHEADERDIR
 
59
export ASTBINDIR
 
60
export ASTSBINDIR
 
61
export AGI_DIR
 
62
export ASTCONFPATH
 
63
 
 
64
export OSARCH                   # Operating system
 
65
export PROC                     # Processor type
 
66
 
 
67
export NOISY_BUILD              # Used in Makefile.rules
 
68
export MENUSELECT_CFLAGS        # Options selected in menuselect.
 
69
export AST_DEVMODE              # Set to "yes" for additional compiler
 
70
                                # and runtime checks
 
71
 
 
72
export SOLINK                   # linker flags for shared objects
 
73
export STATIC_BUILD             # Additional cflags, set to -static
 
74
                                # for static builds. Probably
 
75
                                # should go directly to ASTLDFLAGS
 
76
 
 
77
#--- paths to various commands
 
78
export CC
 
79
export CXX
 
80
export AR
 
81
export RANLIB
 
82
export HOST_CC
 
83
export INSTALL
 
84
export STRIP
 
85
export DOWNLOAD
 
86
export AWK
 
87
export GREP
 
88
export ID
 
89
export MD5
 
90
 
 
91
# even though we could use '-include makeopts' here, use a wildcard
 
92
# lookup anyway, so that make won't try to build makeopts if it doesn't
 
93
# exist (other rules will force it to be built if needed)
 
94
ifneq ($(wildcard makeopts),)
 
95
  include makeopts
 
96
endif
 
97
 
 
98
# start the primary CFLAGS and LDFLAGS with any that were provided
 
99
# to the configure script
 
100
_ASTCFLAGS:=$(CONFIG_CFLAGS)
 
101
_ASTLDFLAGS:=$(CONFIG_LDFLAGS)
 
102
 
 
103
# Some build systems, such as the one in openwrt, like to pass custom target
 
104
# CFLAGS and LDFLAGS in the COPTS and LDOPTS variables; these should also
 
105
# go before any build-system computed flags, since they are defaults, not
 
106
# overrides
 
107
_ASTCFLAGS+=$(COPTS)
 
108
_ASTLDFLAGS+=$(LDOPTS)
 
109
 
 
110
# libxml2 cflags
 
111
_ASTCFLAGS+=$(LIBXML2_INCLUDE)
 
112
 
 
113
#Uncomment this to see all build commands instead of 'quiet' output
 
114
#NOISY_BUILD=yes
 
115
 
 
116
empty:=
 
117
space:=$(empty) $(empty)
 
118
ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
 
119
 
 
120
# Overwite config files on "make samples"
 
121
OVERWRITE=y
 
122
 
 
123
# Include debug and macro symbols in the executables (-g) and profiling info (-pg)
 
124
DEBUG=-g3
 
125
 
 
126
 
 
127
# Define standard directories for various platforms
 
128
# These apply if they are not redefined in asterisk.conf 
 
129
ifeq ($(OSARCH),SunOS)
 
130
  ASTETCDIR=/var/etc/asterisk
 
131
  ASTLIBDIR=/opt/asterisk/lib
 
132
  ASTVARLIBDIR=/var/opt/asterisk
 
133
  ASTDBDIR=$(ASTVARLIBDIR)
 
134
  ASTKEYDIR=$(ASTVARLIBDIR)
 
135
  ASTSPOOLDIR=/var/spool/asterisk
 
136
  ASTLOGDIR=/var/log/asterisk
 
137
  ASTHEADERDIR=/opt/asterisk/include
 
138
  ASTBINDIR=/opt/asterisk/bin
 
139
  ASTSBINDIR=/opt/asterisk/sbin
 
140
  ASTVARRUNDIR=/var/run/asterisk
 
141
  ASTMANDIR=/opt/asterisk/man
 
142
else
 
143
  ASTETCDIR=$(sysconfdir)/asterisk
 
144
  ASTLIBDIR=$(libdir)/asterisk
 
145
  ASTHEADERDIR=$(includedir)/asterisk
 
146
  ASTBINDIR=$(bindir)
 
147
  ASTSBINDIR=$(sbindir)
 
148
  ASTSPOOLDIR=$(localstatedir)/spool/asterisk
 
149
  ASTLOGDIR=$(localstatedir)/log/asterisk
 
150
  ASTVARRUNDIR=$(localstatedir)/run/asterisk
 
151
  ASTMANDIR=$(mandir)
 
152
ifneq ($(findstring BSD,$(OSARCH)),)
 
153
  ASTVARLIBDIR=$(prefix)/share/asterisk
 
154
  ASTVARRUNDIR=$(localstatedir)/run/asterisk
 
155
  ASTDBDIR=$(localstatedir)/db/asterisk
 
156
else
 
157
  ASTVARLIBDIR=$(localstatedir)/lib/asterisk
 
158
  ASTDBDIR=$(ASTVARLIBDIR)
 
159
endif
 
160
  ASTKEYDIR=$(ASTVARLIBDIR)
 
161
endif
 
162
ifeq ($(ASTDATADIR),)
 
163
  ASTDATADIR:=$(ASTVARLIBDIR)
 
164
endif
 
165
 
 
166
# Asterisk.conf is located in ASTETCDIR or by using the -C flag
 
167
# when starting Asterisk
 
168
ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
 
169
MODULES_DIR=$(ASTLIBDIR)/modules
 
170
AGI_DIR=$(ASTDATADIR)/agi-bin
 
171
 
 
172
# If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
 
173
HTTP_DOCSDIR=/var/www/html
 
174
# Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
 
175
HTTP_CGIDIR=/var/www/cgi-bin
 
176
 
 
177
# Uncomment this to use the older DSP routines
 
178
#_ASTCFLAGS+=-DOLD_DSP_ROUTINES
 
179
 
 
180
# If the file .asterisk.makeopts is present in your home directory, you can
 
181
# include all of your favorite menuselect options so that every time you download
 
182
# a new version of Asterisk, you don't have to run menuselect to set them. 
 
183
# The file /etc/asterisk.makeopts will also be included but can be overridden
 
184
# by the file in your home directory.
 
185
 
 
186
GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
 
187
USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
 
188
 
 
189
MOD_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
 
190
OTHER_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
 
191
 
 
192
# Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
 
193
OPTIONS=
 
194
 
 
195
ifeq ($(OSARCH),linux-gnu)
 
196
  ifeq ($(PROC),x86_64)
 
197
    # You must have GCC 3.4 to use k8, otherwise use athlon
 
198
    PROC=k8
 
199
    #PROC=athlon
 
200
  endif
 
201
 
 
202
  ifeq ($(PROC),sparc64)
 
203
    #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
 
204
    #This works for even old (2.96) versions of gcc and provides a small boost either way.
 
205
    #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
 
206
    #So we go lowest common available by gcc and go a step down, still a step up from
 
207
    #the default as we now have a better instruction set to work with. - Belgarath
 
208
    PROC=ultrasparc
 
209
    OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
 
210
    OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
 
211
    OPTIONS+=-fomit-frame-pointer
 
212
  endif
 
213
 
 
214
  ifeq ($(PROC),arm)
 
215
    # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
 
216
    ifeq ($(SUB_PROC),maverick)
 
217
      OPTIONS+=-fsigned-char -mcpu=ep9312
 
218
    else
 
219
      ifeq ($(SUB_PROC),xscale)
 
220
        OPTIONS+=-fsigned-char -mcpu=xscale
 
221
      else
 
222
        OPTIONS+=-fsigned-char 
 
223
      endif
 
224
    endif
 
225
  endif
 
226
endif
 
227
 
 
228
ifeq ($(findstring -save-temps,$(_ASTCFLAGS) $(ASTCFLAGS)),)
 
229
  ifeq ($(findstring -pipe,$(_ASTCFLAGS) $(ASTCFLAGS)),)
 
230
    _ASTCFLAGS+=-pipe
 
231
  endif
 
232
endif
 
233
 
 
234
ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),)
 
235
  _ASTCFLAGS+=-Wall
 
236
endif
 
237
 
 
238
_ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
 
239
 
 
240
ifeq ($(AST_DEVMODE),yes)
 
241
  _ASTCFLAGS+=-Werror
 
242
  _ASTCFLAGS+=-Wunused
 
243
  _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
 
244
  _ASTCFLAGS+=$(AST_FORTIFY_SOURCE)
 
245
  _ASTCFLAGS+=-Wundef 
 
246
  _ASTCFLAGS+=-Wmissing-format-attribute
 
247
  _ASTCFLAGS+=-Wformat=2
 
248
endif
 
249
 
 
250
ifneq ($(findstring BSD,$(OSARCH)),)
 
251
  _ASTCFLAGS+=-isystem /usr/local/include
 
252
endif
 
253
 
 
254
ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
 
255
  ifneq ($(PROC),ultrasparc)
 
256
    _ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
 
257
  endif
 
258
endif
 
259
 
 
260
ifeq ($(PROC),ppc)
 
261
  _ASTCFLAGS+=-fsigned-char
 
262
endif
 
263
 
 
264
ifeq ($(OSARCH),FreeBSD)
 
265
  # -V is understood by BSD Make, not by GNU make.
 
266
  BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
 
267
  _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
 
268
endif
 
269
 
 
270
ifeq ($(OSARCH),NetBSD)
 
271
  _ASTCFLAGS+=-pthread -I/usr/pkg/include
 
272
endif
 
273
 
 
274
ifeq ($(OSARCH),OpenBSD)
 
275
  _ASTCFLAGS+=-pthread -ftrampolines
 
276
endif
 
277
 
 
278
ifeq ($(OSARCH),SunOS)
 
279
  _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__
 
280
endif
 
281
 
 
282
ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
 
283
 
 
284
ifneq ($(wildcard .version),)
 
285
  ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
 
286
endif
 
287
 
 
288
ifneq ($(wildcard .svn),)
 
289
  ASTERISKVERSIONNUM:=999999
 
290
endif
 
291
 
 
292
_ASTCFLAGS+=$(OPTIONS)
 
293
 
 
294
MOD_SUBDIRS:=channels pbx apps codecs formats cdr bridges funcs tests main res $(LOCAL_MOD_SUBDIRS)
 
295
OTHER_SUBDIRS:=utils agi
 
296
SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
 
297
SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
 
298
SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
 
299
SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
 
300
SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
 
301
MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
 
302
MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
 
303
MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
 
304
MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
 
305
 
 
306
ifneq ($(findstring darwin,$(OSARCH)),)
 
307
  _ASTCFLAGS+=-D__Darwin__
 
308
  SOLINK=-dynamic -bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace /usr/lib/bundle1.o
 
309
else
 
310
# These are used for all but Darwin
 
311
  SOLINK=-shared
 
312
  ifneq ($(findstring BSD,$(OSARCH)),)
 
313
    _ASTLDFLAGS+=-L/usr/local/lib
 
314
  endif
 
315
endif
 
316
 
 
317
ifeq ($(OSARCH),SunOS)
 
318
  SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
 
319
endif
 
320
 
 
321
ifeq ($(OSARCH),OpenBSD)
 
322
  SOLINK=-shared -fpic
 
323
endif
 
324
 
 
325
# comment to print directories during submakes
 
326
#PRINT_DIR=yes
 
327
 
 
328
SILENTMAKE:=$(MAKE) --quiet --no-print-directory
 
329
ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
 
330
SUBMAKE:=$(MAKE)
 
331
else
 
332
SUBMAKE:=$(MAKE) --quiet --no-print-directory
 
333
endif
 
334
 
 
335
# This is used when generating the doxygen documentation
 
336
ifneq ($(DOT),:)
 
337
  HAVEDOT=yes
 
338
else
 
339
  HAVEDOT=no
 
340
endif
 
341
 
 
342
# $(MAKE) is printed in several places, and we want it to be a
 
343
# fixed size string. Define a variable whose name has also the
 
344
# same size, so we can easily align text.
 
345
ifeq ($(MAKE), gmake)
 
346
        mK="gmake"
 
347
else
 
348
        mK=" make"
 
349
endif
 
350
 
 
351
all: _all
 
352
        @echo " +--------- Asterisk Build Complete ---------+"  
 
353
        @echo " + Asterisk has successfully been built, and +"  
 
354
        @echo " + can be installed by running:              +"
 
355
        @echo " +                                           +"
 
356
        @echo " +               $(mK) install               +"  
 
357
        @echo " +-------------------------------------------+"  
 
358
 
 
359
_all: cleantest makeopts $(SUBDIRS) doc/core-en_US.xml
 
360
 
 
361
makeopts: configure
 
362
        @echo "****"
 
363
        @echo "**** The configure script must be executed before running '$(MAKE)'." 
 
364
        @echo "****               Please run \"./configure\"."
 
365
        @echo "****"
 
366
        @exit 1
 
367
 
 
368
menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts build_tools/menuselect-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
 
369
        menuselect/menuselect --check-deps $@
 
370
        menuselect/menuselect --check-deps $@ $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
 
371
 
 
372
$(MOD_SUBDIRS_EMBED_LDSCRIPT):
 
373
        +@echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
 
374
 
 
375
$(MOD_SUBDIRS_EMBED_LDFLAGS):
 
376
        +@echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
 
377
 
 
378
$(MOD_SUBDIRS_EMBED_LIBS):
 
379
        +@echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
 
380
 
 
381
$(MOD_SUBDIRS_MENUSELECT_TREE):
 
382
        +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
 
383
        +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
 
384
 
 
385
makeopts.embed_rules: menuselect.makeopts
 
386
        @echo "Generating embedded module rules ..."
 
387
        @rm -f $@
 
388
        +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
 
389
        +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
 
390
        +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
 
391
 
 
392
$(SUBDIRS): main/version.c include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
 
393
 
 
394
ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
 
395
    # Non-windows:
 
396
    # ensure that all module subdirectories are processed before 'main' during
 
397
    # a parallel build, since if there are modules selected to be embedded the
 
398
    # directories containing them must be completed before the main Asterisk
 
399
    # binary can be built
 
400
main: $(filter-out main,$(MOD_SUBDIRS))
 
401
else
 
402
    # Windows: we need to build main (i.e. the asterisk dll) first,
 
403
    # followed by res, followed by the other directories, because
 
404
    # dll symbols must be resolved during linking and not at runtime.
 
405
D1:= $(filter-out main,$(MOD_SUBDIRS))
 
406
D1:= $(filter-out res,$(D1))
 
407
 
 
408
$(D1): res
 
409
res:    main
 
410
endif
 
411
 
 
412
$(MOD_SUBDIRS):
 
413
        +@_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
 
414
 
 
415
$(OTHER_SUBDIRS):
 
416
        +@_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
 
417
 
 
418
defaults.h: makeopts
 
419
        @build_tools/make_defaults_h > $@.tmp
 
420
        @cmp -s $@.tmp $@ || mv $@.tmp $@
 
421
        @rm -f $@.tmp
 
422
 
 
423
main/version.c: FORCE
 
424
        @build_tools/make_version_c > $@.tmp
 
425
        @cmp -s $@.tmp $@ || mv $@.tmp $@
 
426
        @rm -f $@.tmp
 
427
 
 
428
include/asterisk/version.h: FORCE
 
429
        @build_tools/make_version_h > $@.tmp
 
430
        @cmp -s $@.tmp $@ || mv $@.tmp $@
 
431
        @rm -f $@.tmp
 
432
 
 
433
include/asterisk/buildopts.h: menuselect.makeopts
 
434
        @build_tools/make_buildopts_h > $@.tmp
 
435
        @cmp -s $@.tmp $@ || mv $@.tmp $@
 
436
        @rm -f $@.tmp
 
437
 
 
438
include/asterisk/build.h:
 
439
        @build_tools/make_build_h > $@.tmp
 
440
        @cmp -s $@.tmp $@ || mv $@.tmp $@
 
441
        @rm -f $@.tmp
 
442
 
 
443
$(SUBDIRS_CLEAN):
 
444
        +@$(SUBMAKE) -C $(@:-clean=) clean
 
445
 
 
446
$(SUBDIRS_DIST_CLEAN):
 
447
        +@$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
 
448
 
 
449
clean: $(SUBDIRS_CLEAN) _clean
 
450
 
 
451
_clean:
 
452
        rm -f defaults.h
 
453
        rm -f include/asterisk/build.h
 
454
        rm -f main/version.c
 
455
        rm -f include/asterisk/version.h
 
456
        @$(MAKE) -C menuselect clean
 
457
        cp -f .cleancount .lastclean
 
458
 
 
459
dist-clean: distclean
 
460
 
 
461
distclean: $(SUBDIRS_DIST_CLEAN) _clean
 
462
        @$(MAKE) -C menuselect dist-clean
 
463
        @$(MAKE) -C sounds dist-clean
 
464
        rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
 
465
        rm -f makeopts.embed_rules
 
466
        rm -f config.log config.status config.cache
 
467
        rm -rf autom4te.cache
 
468
        rm -f include/asterisk/autoconfig.h
 
469
        rm -f include/asterisk/buildopts.h
 
470
        rm -rf doc/api
 
471
        rm -f build_tools/menuselect-deps
 
472
 
 
473
datafiles: _all
 
474
        if [ `$(ID) -u` = 0 ]; then \
 
475
                CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; \
 
476
        fi
 
477
# Should static HTTP be installed during make samples or even with its own target ala
 
478
# webvoicemail?  There are portions here that *could* be customized but might also be
 
479
# improved a lot.  I'll put it here for now.
 
480
        mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
 
481
        for x in static-http/*; do \
 
482
                $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
 
483
        done
 
484
        if [ -d doc/tex/asterisk ] ; then \
 
485
                        mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
 
486
                        for n in doc/tex/asterisk/* ; do \
 
487
                                $(INSTALL) -m 644 $$n $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
 
488
                        done \
 
489
        fi
 
490
        mkdir -p $(DESTDIR)$(ASTDATADIR)/images
 
491
        for x in images/*.jpg; do \
 
492
                $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
 
493
        done
 
494
        mkdir -p $(DESTDIR)$(AGI_DIR)
 
495
        $(MAKE) -C sounds install
 
496
 
 
497
doc/core-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
 
498
        @printf "Building Documentation For: "
 
499
        @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
 
500
        @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
 
501
        @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
 
502
        @for x in $(MOD_SUBDIRS); do \
 
503
                printf "$$x " ; \
 
504
                for i in $$x/*.c; do \
 
505
                        $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
 
506
                done ; \
 
507
        done
 
508
        @echo
 
509
        @echo "</docs>" >> $@
 
510
 
 
511
validate-docs: doc/core-en_US.xml
 
512
ifeq ($(XMLSTARLET),:)
 
513
        @echo "---------------------------------------------------------------"
 
514
        @echo "--- Please install xmlstarlet to validate the documentation ---"
 
515
        @echo "---------------------------------------------------------------"
 
516
else
 
517
        $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
 
518
endif
 
519
 
 
520
update: 
 
521
        @if [ -d .svn ]; then \
 
522
                echo "Updating from Subversion..." ; \
 
523
                fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
 
524
                svn update | tee update.out; \
 
525
                torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
 
526
                echo "`date`  Updated from revision $${fromrev} to $${torev}." >> update.log; \
 
527
                rm -f .version; \
 
528
                if [ `grep -c ^C update.out` -gt 0 ]; then \
 
529
                        echo ; echo "The following files have conflicts:" ; \
 
530
                        grep ^C update.out | cut -b4- ; \
 
531
                fi ; \
 
532
                rm -f update.out; \
 
533
        else \
 
534
                echo "Not under version control";  \
 
535
        fi
 
536
 
 
537
NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
 
538
OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
 
539
 
 
540
installdirs:
 
541
        mkdir -p $(DESTDIR)$(MODULES_DIR)
 
542
        mkdir -p $(DESTDIR)$(ASTSBINDIR)
 
543
        mkdir -p $(DESTDIR)$(ASTETCDIR)
 
544
        mkdir -p $(DESTDIR)$(ASTBINDIR)
 
545
        mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
 
546
        mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
 
547
        mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
 
548
        mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
 
549
        mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
 
550
        mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
 
551
        mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
 
552
 
 
553
bininstall: _all installdirs $(SUBDIRS_INSTALL)
 
554
        $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
 
555
        $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
 
556
        $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
 
557
        $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
 
558
        if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
 
559
                cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
 
560
                chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
 
561
        fi
 
562
        $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
 
563
        $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
 
564
        $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
 
565
        if [ -n "$(OLDHEADERS)" ]; then \
 
566
                rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
 
567
        fi
 
568
        mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation
 
569
        mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation/thirdparty
 
570
        mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
 
571
        mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
 
572
        mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
 
573
        mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
 
574
        mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
 
575
        mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
 
576
        $(INSTALL) -m 644 doc/core-*.xml $(DESTDIR)$(ASTDATADIR)/documentation
 
577
        $(INSTALL) -m 644 doc/appdocsxml.dtd $(DESTDIR)$(ASTDATADIR)/documentation
 
578
        $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
 
579
        $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
 
580
        $(INSTALL) -m 644 doc/asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
 
581
        $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
 
582
        $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
 
583
        $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
 
584
        if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
 
585
                $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
 
586
        fi
 
587
 
 
588
$(SUBDIRS_INSTALL):
 
589
        @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
 
590
 
 
591
NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
 
592
OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
 
593
 
 
594
oldmodcheck:
 
595
        @if [ -n "$(OLDMODS)" ]; then \
 
596
                echo " WARNING WARNING WARNING" ;\
 
597
                echo "" ;\
 
598
                echo " Your Asterisk modules directory, located at" ;\
 
599
                echo " $(DESTDIR)$(MODULES_DIR)" ;\
 
600
                echo " contains modules that were not installed by this " ;\
 
601
                echo " version of Asterisk. Please ensure that these" ;\
 
602
                echo " modules are compatible with this version before" ;\
 
603
                echo " attempting to run Asterisk." ;\
 
604
                echo "" ;\
 
605
                for f in $(OLDMODS); do \
 
606
                        echo "    $$f" ;\
 
607
                done ;\
 
608
                echo "" ;\
 
609
                echo " WARNING WARNING WARNING" ;\
 
610
        fi
 
611
 
 
612
badshell:
 
613
ifneq ($(findstring ~/,$(DESTDIR)),)
 
614
        @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
 
615
        @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
 
616
        @exit 1
 
617
endif
 
618
 
 
619
install: badshell datafiles bininstall
 
620
        @if [ -x /usr/sbin/asterisk-post-install ]; then \
 
621
                /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
 
622
        fi
 
623
        @echo " +---- Asterisk Installation Complete -------+"  
 
624
        @echo " +                                           +"
 
625
        @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
 
626
        @echo " +                                           +"
 
627
        @echo " + Asterisk has successfully been installed. +"  
 
628
        @echo " + If you would like to install the sample   +"  
 
629
        @echo " + configuration files (overwriting any      +"
 
630
        @echo " + existing config files), run:              +"  
 
631
        @echo " +                                           +"
 
632
        @echo " +               $(mK) samples               +"
 
633
        @echo " +                                           +"
 
634
        @echo " +-----------------  or ---------------------+"
 
635
        @echo " +                                           +"
 
636
        @echo " + You can go ahead and install the asterisk +"
 
637
        @echo " + program documentation now or later run:   +"
 
638
        @echo " +                                           +"
 
639
        @echo " +              $(mK) progdocs               +"
 
640
        @echo " +                                           +"
 
641
        @echo " + **Note** This requires that you have      +"
 
642
        @echo " + doxygen installed on your local system    +"
 
643
        @echo " +-------------------------------------------+"
 
644
        @$(MAKE) -s oldmodcheck
 
645
 
 
646
isntall: install
 
647
 
 
648
upgrade: bininstall
 
649
 
 
650
# XXX why *.adsi is installed first ?
 
651
adsi:
 
652
        @echo Installing adsi config files...
 
653
        @mkdir -p $(DESTDIR)$(ASTETCDIR)
 
654
        @for x in configs/*.adsi; do \
 
655
                dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
 
656
                if [ -f $${dst} ] ; then \
 
657
                        echo "Overwriting $$x" ; \
 
658
                else \
 
659
                        echo "Installing $$x" ; \
 
660
                fi ; \
 
661
                $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
 
662
        done
 
663
 
 
664
samples: adsi
 
665
        @echo Installing other config files...
 
666
        @mkdir -p $(DESTDIR)$(ASTETCDIR)
 
667
        @for x in configs/*.sample; do \
 
668
                dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ;        \
 
669
                if [ -f $${dst} ]; then \
 
670
                        if [ "$(OVERWRITE)" = "y" ]; then \
 
671
                                if cmp -s $${dst} $$x ; then \
 
672
                                        echo "Config file $$x is unchanged"; \
 
673
                                        continue; \
 
674
                                fi ; \
 
675
                                mv -f $${dst} $${dst}.old ; \
 
676
                        else \
 
677
                                echo "Skipping config file $$x"; \
 
678
                                continue; \
 
679
                        fi ;\
 
680
                fi ; \
 
681
                echo "Installing file $$x"; \
 
682
                $(INSTALL) -m 644 $$x $${dst} ;\
 
683
        done
 
684
        @if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
 
685
                echo "Creating asterisk.conf"; \
 
686
                ( \
 
687
                echo "[directories](!) ; remove the (!) to enable this" ; \
 
688
                echo "astetcdir => $(ASTETCDIR)" ; \
 
689
                echo "astmoddir => $(MODULES_DIR)" ; \
 
690
                echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
 
691
                echo "astdbdir => $(ASTDBDIR)" ; \
 
692
                echo "astkeydir => $(ASTKEYDIR)" ; \
 
693
                echo "astdatadir => $(ASTDATADIR)" ; \
 
694
                echo "astagidir => $(AGI_DIR)" ; \
 
695
                echo "astspooldir => $(ASTSPOOLDIR)" ; \
 
696
                echo "astrundir => $(ASTVARRUNDIR)" ; \
 
697
                echo "astlogdir => $(ASTLOGDIR)" ; \
 
698
                echo "" ; \
 
699
                echo "[options]" ; \
 
700
                echo ";verbose = 3" ; \
 
701
                echo ";debug = 3" ; \
 
702
                echo ";alwaysfork = yes ; same as -F at startup" ; \
 
703
                echo ";nofork = yes ; same as -f at startup" ; \
 
704
                echo ";quiet = yes ; same as -q at startup" ; \
 
705
                echo ";timestamp = yes ; same as -T at startup" ; \
 
706
                echo ";execincludes = yes ; support #exec in config files" ; \
 
707
                echo ";console = yes ; Run as console (same as -c at startup)" ; \
 
708
                echo ";highpriority = yes ; Run realtime priority (same as -p at startup)" ; \
 
709
                echo ";initcrypto = yes ; Initialize crypto keys (same as -i at startup)" ; \
 
710
                echo ";nocolor = yes ; Disable console colors" ; \
 
711
                echo ";dontwarn = yes ; Disable some warnings" ; \
 
712
                echo ";dumpcore = yes ; Dump core on crash (same as -g at startup)" ; \
 
713
                echo ";languageprefix = yes ; Use the new sound prefix path syntax" ; \
 
714
                echo ";internal_timing = yes" ; \
 
715
                echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \
 
716
                echo ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure, or systemname if set" ; \
 
717
                echo ";maxcalls = 10 ; Maximum amount of calls allowed" ; \
 
718
                echo ";maxload = 0.9 ; Asterisk stops accepting new calls if the load average exceed this limit" ; \
 
719
                echo ";maxfiles = 1000 ; Maximum amount of openfiles" ; \
 
720
                echo ";minmemfree = 1 ; in MBs, Asterisk stops accepting new calls if the amount of free memory falls below this watermark" ; \
 
721
                echo ";cache_record_files = yes ; Cache recorded sound files to another directory during recording" ; \
 
722
                echo ";record_cache_dir = /tmp ; Specify cache directory (used in cnjunction with cache_record_files)" ; \
 
723
                echo ";transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded" ; \
 
724
                echo ";transmit_silence = yes ; Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated" ; \
 
725
                echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
 
726
                echo ";runuser = asterisk ; The user to run as" ; \
 
727
                echo ";rungroup = asterisk ; The group to run as" ; \
 
728
                echo ";lightbackground = yes ; If your terminal is set for a light-colored background" ; \
 
729
                echo "documentation_language = en_US ; Set the Language you want Documentation displayed in. Value is in the same format as locale names" ; \
 
730
                echo ";hideconnect = yes ; Hide messages displayed when a remote console connects and disconnects" ; \
 
731
                echo "" ; \
 
732
                echo "; Changing the following lines may compromise your security." ; \
 
733
                echo ";[files]" ; \
 
734
                echo ";astctlpermissions = 0660" ; \
 
735
                echo ";astctlowner = root" ; \
 
736
                echo ";astctlgroup = apache" ; \
 
737
                echo ";astctl = asterisk.ctl" ; \
 
738
                echo "" ; \
 
739
                echo "[compat]" ; \
 
740
                echo "pbx_realtime=1.6" ; \
 
741
                echo "res_agi=1.6" ; \
 
742
                echo "app_set=1.6" ; \
 
743
                ) > $(DESTDIR)$(ASTCONFPATH) ; \
 
744
        else \
 
745
                echo "Skipping asterisk.conf creation"; \
 
746
        fi
 
747
        mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
 
748
        build_tools/make_sample_voicemail $(DESTDIR)/$(ASTDATADIR) $(DESTDIR)/$(ASTSPOOLDIR)
 
749
        @mkdir -p $(DESTDIR)$(ASTDATADIR)/phoneprov
 
750
        @for x in phoneprov/*; do \
 
751
                dst="$(DESTDIR)$(ASTDATADIR)/$$x" ;     \
 
752
                if [ -f $${dst} ]; then \
 
753
                        if [ "$(OVERWRITE)" = "y" ]; then \
 
754
                                if cmp -s $${dst} $$x ; then \
 
755
                                        echo "Config file $$x is unchanged"; \
 
756
                                        continue; \
 
757
                                fi ; \
 
758
                                mv -f $${dst} $${dst}.old ; \
 
759
                        else \
 
760
                                echo "Skipping config file $$x"; \
 
761
                                continue; \
 
762
                        fi ;\
 
763
                fi ; \
 
764
                echo "Installing file $$x"; \
 
765
                $(INSTALL) -m 644 $$x $${dst} ;\
 
766
        done
 
767
 
 
768
webvmail:
 
769
        @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
 
770
        @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
 
771
        $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
 
772
        mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
 
773
        for x in images/*.gif; do \
 
774
                $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
 
775
        done
 
776
        @echo " +--------- Asterisk Web Voicemail ----------+"  
 
777
        @echo " +                                           +"
 
778
        @echo " + Asterisk Web Voicemail is installed in    +"
 
779
        @echo " + your cgi-bin directory:                   +"
 
780
        @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
 
781
        @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
 
782
        @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
 
783
        @echo " +                                           +"
 
784
        @echo " + Other static items have been stored in:   +"
 
785
        @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
 
786
        @echo " +                                           +"
 
787
        @echo " + If these paths do not match your httpd    +"
 
788
        @echo " + installation, correct the definitions     +"
 
789
        @echo " + in your Makefile of HTTP_CGIDIR and       +"
 
790
        @echo " + HTTP_DOCSDIR                              +"
 
791
        @echo " +                                           +"
 
792
        @echo " +-------------------------------------------+"  
 
793
 
 
794
progdocs:
 
795
        (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
 
796
        echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen - 
 
797
 
 
798
install-logrotate:
 
799
        if [ ! -d $(ASTETCDIR)/../logrotate.d ]; then \
 
800
                mkdir $(ASTETCDIR)/../logrotate.d ; \
 
801
        fi
 
802
        sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
 
803
        install -m 0644 contrib/scripts/asterisk.logrotate.tmp $(ASTETCDIR)/../logrotate.d/asterisk
 
804
        rm -f contrib/scripts/asterisk.logrotate.tmp
 
805
 
 
806
config:
 
807
        @if [ "${OSARCH}" = "linux-gnu" ]; then \
 
808
                if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
 
809
                        cat contrib/init.d/rc.redhat.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/rc.d/init.d/asterisk ;\
 
810
                        chmod 755 $(DESTDIR)/etc/rc.d/init.d/asterisk;\
 
811
                        if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
 
812
                elif [ -f /etc/debian_version ]; then \
 
813
                        cat contrib/init.d/rc.debian.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/init.d/asterisk ;\
 
814
                        chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
 
815
                        if [ -z "$(DESTDIR)" ]; then /usr/sbin/update-rc.d asterisk defaults 50 91; fi; \
 
816
                elif [ -f /etc/gentoo-release ]; then \
 
817
                        cat contrib/init.d/rc.gentoo.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/init.d/asterisk ;\
 
818
                        chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
 
819
                        if [ -z "$(DESTDIR)" ]; then /sbin/rc-update add asterisk default; fi; \
 
820
                elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ]; then \
 
821
                        cat contrib/init.d/rc.mandriva.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/rc.d/init.d/asterisk ;\
 
822
                        chmod 755 $(DESTDIR)/etc/rc.d/init.d/asterisk;\
 
823
                        if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
 
824
                elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
 
825
                        cat contrib/init.d/rc.suse.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/init.d/asterisk ;\
 
826
                        chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
 
827
                        if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
 
828
                elif [ -f /etc/arch-release -o -f /etc/arch-release ]; then \
 
829
                        cat contrib/init.d/rc.archlinux.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/rc.d/asterisk ;\
 
830
                        chmod 755 $(DESTDIR)/etc/rc.d/asterisk;\
 
831
                elif [ -f /etc/slackware-version ]; then \
 
832
                        echo "Slackware is not currently supported, although an init script does exist for it."; \
 
833
                else \
 
834
                        echo "We could not install init scripts for your distribution."; \
 
835
                fi \
 
836
        else \
 
837
                echo "We could not install init scripts for your operating system."; \
 
838
        fi
 
839
 
 
840
sounds:
 
841
        $(MAKE) -C sounds all
 
842
 
 
843
# If the cleancount has been changed, force a make clean.
 
844
# .cleancount is the global clean count, and .lastclean is the 
 
845
# last clean count we had
 
846
 
 
847
cleantest:
 
848
        @cmp -s .cleancount .lastclean || $(MAKE) clean
 
849
 
 
850
$(SUBDIRS_UNINSTALL):
 
851
        @$(SUBMAKE) -C $(@:-uninstall=) uninstall
 
852
 
 
853
_uninstall: $(SUBDIRS_UNINSTALL)
 
854
        rm -f $(DESTDIR)$(MODULES_DIR)/*
 
855
        rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
 
856
        rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
 
857
        rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
 
858
        rm -rf $(DESTDIR)$(ASTHEADERDIR)
 
859
        rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
 
860
        rm -f $(DESTDIR)$(ASTMANDIR)/man8/asterisk.8
 
861
        rm -f $(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8
 
862
        rm -f $(DESTDIR)$(ASTMANDIR)/man8/autosupport.8
 
863
        rm -f $(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8
 
864
        $(MAKE) -C sounds uninstall
 
865
 
 
866
uninstall: _uninstall
 
867
        @echo " +--------- Asterisk Uninstall Complete -----+"  
 
868
        @echo " + Asterisk binaries, sounds, man pages,     +"  
 
869
        @echo " + headers, modules, and firmware builds,    +"  
 
870
        @echo " + have all been uninstalled.                +"  
 
871
        @echo " +                                           +"
 
872
        @echo " + To remove ALL traces of Asterisk,         +"
 
873
        @echo " + including configuration, spool            +"
 
874
        @echo " + directories, and logs, run the following  +"
 
875
        @echo " + command:                                  +"
 
876
        @echo " +                                           +"
 
877
        @echo " +            $(mK) uninstall-all            +"  
 
878
        @echo " +-------------------------------------------+"  
 
879
 
 
880
uninstall-all: _uninstall
 
881
        rm -rf $(DESTDIR)$(ASTLIBDIR)
 
882
        rm -rf $(DESTDIR)$(ASTVARLIBDIR)
 
883
        rm -rf $(DESTDIR)$(ASTDATADIR)
 
884
        rm -rf $(DESTDIR)$(ASTSPOOLDIR)
 
885
        rm -rf $(DESTDIR)$(ASTETCDIR)
 
886
        rm -rf $(DESTDIR)$(ASTLOGDIR)
 
887
 
 
888
menuconfig: menuselect
 
889
 
 
890
cmenuconfig: cmenuselect
 
891
 
 
892
gmenuconfig: gmenuselect
 
893
 
 
894
nmenuconfig: nmenuselect
 
895
 
 
896
menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
 
897
        @if [ -x menuselect/nmenuselect ]; then \
 
898
                $(MAKE) nmenuselect; \
 
899
        elif [ -x menuselect/cmenuselect ]; then \
 
900
                $(MAKE) cmenuselect; \
 
901
        elif [ -x menuselect/gmenuselect ]; then \
 
902
                $(MAKE) gmenuselect; \
 
903
        else \
 
904
                echo "No menuselect user interface found. Install ncurses,"; \
 
905
                echo "newt or GTK libraries to build one and re-rerun"; \
 
906
                echo "'make menuselect'."; \
 
907
        fi
 
908
 
 
909
cmenuselect: menuselect/cmenuselect menuselect-tree menuselect.makeopts
 
910
        -@menuselect/cmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
 
911
 
 
912
gmenuselect: menuselect/gmenuselect menuselect-tree menuselect.makeopts
 
913
        -@menuselect/gmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
 
914
 
 
915
nmenuselect: menuselect/nmenuselect menuselect-tree menuselect.makeopts
 
916
        -@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
 
917
 
 
918
# options for make in menuselect/
 
919
MAKE_MENUSELECT=CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
 
920
 
 
921
menuselect/menuselect: menuselect/makeopts
 
922
        +$(MAKE_MENUSELECT) menuselect
 
923
 
 
924
menuselect/cmenuselect: menuselect/makeopts
 
925
        +$(MAKE_MENUSELECT) cmenuselect
 
926
 
 
927
menuselect/gmenuselect: menuselect/makeopts
 
928
        +$(MAKE_MENUSELECT) gmenuselect
 
929
 
 
930
menuselect/nmenuselect: menuselect/makeopts
 
931
        +$(MAKE_MENUSELECT) nmenuselect
 
932
 
 
933
menuselect/makeopts: makeopts
 
934
        +$(MAKE_MENUSELECT) makeopts
 
935
 
 
936
menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml build_tools/embed_modules.xml configure
 
937
        @echo "Generating input for menuselect ..."
 
938
        @echo "<?xml version=\"1.0\"?>" > $@
 
939
        @echo >> $@
 
940
        @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
 
941
        +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
 
942
        @cat build_tools/cflags.xml >> $@
 
943
        +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
 
944
        @if [ "${AST_DEVMODE}" = "yes" ]; then \
 
945
                cat build_tools/cflags-devmode.xml >> $@; \
 
946
        fi
 
947
        @cat build_tools/embed_modules.xml >> $@
 
948
        @cat sounds/sounds.xml >> $@
 
949
        @echo "</menu>" >> $@
 
950
 
 
951
pdf: asterisk.pdf
 
952
asterisk.pdf:
 
953
        $(MAKE) -C doc/tex asterisk.pdf
 
954
 
 
955
.PHONY: menuselect
 
956
.PHONY: main
 
957
.PHONY: sounds
 
958
.PHONY: clean
 
959
.PHONY: dist-clean
 
960
.PHONY: distclean
 
961
.PHONY: all
 
962
.PHONY: prereqs
 
963
.PHONY: cleantest
 
964
.PHONY: uninstall
 
965
.PHONY: _uninstall
 
966
.PHONY: uninstall-all
 
967
.PHONY: pdf
 
968
.PHONY: dont-optimize
 
969
.PHONY: badshell
 
970
.PHONY: installdirs
 
971
.PHONY: validate-docs
 
972
.PHONY: _clean
 
973
.PHONY: $(SUBDIRS_INSTALL)
 
974
.PHONY: $(SUBDIRS_DIST_CLEAN)
 
975
.PHONY: $(SUBDIRS_CLEAN)
 
976
.PHONY: $(SUBDIRS_UNINSTALL)
 
977
.PHONY: $(SUBDIRS)
 
978
.PHONY: $(MOD_SUBDIRS_EMBED_LDSCRIPT)
 
979
.PHONY: $(MOD_SUBDIRS_EMBED_LDFLAGS)
 
980
.PHONY: $(MOD_SUBDIRS_EMBED_LIBS)
 
981
 
 
982
FORCE:
 
983