|
|
|
#
|
|
|
|
# Asterisk -- A telephony toolkit for Linux.
|
|
|
|
#
|
|
|
|
# Makefile rules for subdirectories containing modules
|
|
|
|
#
|
|
|
|
# Copyright (C) 2006, Digium, Inc.
|
|
|
|
#
|
|
|
|
# Kevin P. Fleming <kpfleming@digium.com>
|
|
|
|
#
|
|
|
|
# This program is free software, distributed under the terms of
|
|
|
|
# the GNU General Public License
|
|
|
|
#
|
|
|
|
|
|
|
|
# Makefile rules for building modules.
|
|
|
|
|
|
|
|
# In most cases, we set target-specific variables for certain targets
|
|
|
|
# (remember that they apply recursively to prerequisites).
|
|
|
|
# Also note that we can only set one variable per rule, so we have to
|
|
|
|
# repeat the left hand side to set multiple variables.
|
|
|
|
|
|
|
|
ifeq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
|
|
|
|
ASTCFLAGS+=${GC_CFLAGS}
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(findstring STATIC_BUILD,$(MENUSELECT_CFLAGS)),)
|
|
|
|
STATIC_BUILD=-static
|
|
|
|
endif
|
|
|
|
|
|
|
|
include $(ASTTOPDIR)/Makefile.rules
|
|
|
|
|
|
|
|
# If MODULE_PREFIX is defined, use it to run the standard functions to set
|
|
|
|
# C_MODS, CC_MODS, LOADABLE_MODS and EMBEDDED_MODS.
|
|
|
|
# Each word of MODULE_PREFIX is a prefix for filenames that we consider
|
|
|
|
# valid C or CC modules (eg. app, func ...). Note that the underscore
|
|
|
|
# is added here, and does not need to be in MODULE_PREFIX
|
|
|
|
#
|
|
|
|
# Use MODULE_EXCLUDE to specify additional modules to exclude.
|
|
|
|
|
|
|
|
ifneq ($(MODULE_PREFIX),)
|
|
|
|
ALL_C_MODS:=
|
|
|
|
ALL_C_MODS+=$(foreach p,$(MODULE_PREFIX),$(patsubst %.c,%,$(wildcard $(p)_*.c)))
|
|
|
|
ALL_CC_MODS:=
|
|
|
|
ALL_CC_MODS+=$(foreach p,$(MODULE_PREFIX),$(patsubst %.cc,%,$(wildcard $(p)_*.cc)))
|
|
|
|
|
|
|
|
C_MODS:=$(filter-out $(MENUSELECT_$(MENUSELECT_CATEGORY)),$(ALL_C_MODS))
|
|
|
|
CC_MODS:=$(filter-out $(MENUSELECT_$(MENUSELECT_CATEGORY)),$(ALL_CC_MODS))
|
|
|
|
|
|
|
|
# and store in the list of embedded or loadable modules
|
|
|
|
ifneq ($(findstring $(MENUSELECT_CATEGORY),$(MENUSELECT_EMBED)),)
|
|
|
|
EMBEDDED_MODS:=$(C_MODS) $(CC_MODS)
|
|
|
|
else
|
|
|
|
LOADABLE_MODS:=$(C_MODS) $(CC_MODS)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Both C++ and C++ sources need their module name in AST_MODULE
|
|
|
|
# We also pass whatever _INCLUDE list is generated by menuselect
|
|
|
|
# (they are stored in file 'makeopts')
|
|
|
|
|
|
|
|
$(addsuffix .oo,$(CC_MODS)) $(addsuffix .o,$(C_MODS)): \
|
|
|
|
ASTCFLAGS+= -DAST_MODULE=\"$*\" $(MENUSELECT_OPTS_$*:%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_INCLUDE))
|
|
|
|
|
|
|
|
ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
|
|
|
|
# don't define -fPIC on mingw32 and cygwin, it is the default
|
|
|
|
$(LOADABLE_MODS:%=%.so): ASTCFLAGS+=-fPIC
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For loadable modules, pass _LIB and _LDFLAGS from menuselect.
|
|
|
|
$(LOADABLE_MODS:%=%.so): LIBS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LIB))
|
|
|
|
$(LOADABLE_MODS:%=%.so): ASTLDFLAGS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LDFLAGS))
|
|
|
|
|
|
|
|
$(EMBEDDED_MODS:%=%.o): ASTCFLAGS+=-DEMBEDDED_MODULE=$*
|
|
|
|
|
|
|
|
$(addsuffix .so,$(filter $(LOADABLE_MODS),$(C_MODS))): %.so: %.o
|
|
|
|
$(addsuffix .so,$(filter $(LOADABLE_MODS),$(CC_MODS))): %.so: %.oo
|
|
|
|
|
|
|
|
modules.link: $(addsuffix .eo,$(filter $(EMBEDDED_MODS),$(C_MODS)))
|
|
|
|
|
|
|
|
.PHONY: clean uninstall _all moduleinfo makeopts
|
|
|
|
|
|
|
|
ifneq ($(LOADABLE_MODS),)
|
|
|
|
_all: $(LOADABLE_MODS:%=%.so)
|
|
|
|
ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
|
|
|
|
# linker options and extra libraries for cygwin
|
|
|
|
SOLINK=-Wl,--out-implib=lib$@.a -shared
|
|
|
|
LIBS+=-L$(ASTTOPDIR)/main -lasterisk -L$(ASTTOPDIR)/res $($@_LIBS)
|
|
|
|
# additional libraries in res/
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(EMBEDDED_MODS),)
|
|
|
|
_all: modules.link
|
|
|
|
__embed_ldscript:
|
|
|
|
@echo "../$(SUBDIR)/modules.link"
|
|
|
|
__embed_ldflags:
|
|
|
|
@echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(C_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LDFLAGS))"
|
|
|
|
@echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(CC_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LDFLAGS))"
|
|
|
|
__embed_libs:
|
|
|
|
@echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(C_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LIB))"
|
|
|
|
@echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(CC_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LIB))"
|
|
|
|
else
|
|
|
|
__embed_ldscript:
|
|
|
|
__embed_ldflags:
|
|
|
|
__embed_libs:
|
|
|
|
endif
|
|
|
|
|
|
|
|
modules.link:
|
|
|
|
@rm -f $@
|
|
|
|
@for file in $(patsubst %,$(SUBDIR)/%,$(filter %.eo,$^)); do echo "INPUT (../$${file})" >> $@; done
|
|
|
|
@for file in $(patsubst %,$(SUBDIR)/%,$(filter-out %.eo,$^)); do echo "INPUT (../$${file})" >> $@; done
|
|
|
|
|
|
|
|
clean::
|
Merged revisions 157859 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r157859 | kpfleming | 2008-11-19 15:34:47 -0600 (Wed, 19 Nov 2008) | 7 lines
the gcc optimizer frequently finds broken code (use of uninitalized variables, unreachable code, etc.), which is good. however, developers usually compile with the optimizer turned off, because if they need to debug the resulting code, optimized code makes that process very difficult. this means that we get code changes committed that weren't adequately checked over for these sorts of problems.
with this build system change, if (and only if) --enable-dev-mode was used and DONT_OPTIMIZE is turned on, when a source file is compiled it will actually be preprocessed (into a .i or .ii file), then compiled once with optimization (with the result sent to /dev/null) and again without optimization (but only if the first compile succeeded, of course).
while making these changes, i did some cleanup work in Makefile.rules to move commonly-used combinations of flag variables into their own variables, to make the file easier to read and maintain
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@157974 65c4cc65-6c06-0410-ace0-fbb531ad65f3
16 years ago
|
|
|
rm -f *.so *.o *.oo *.eo *.i *.ii
|
|
|
|
rm -f .*.o.d .*.oo.d
|
|
|
|
rm -f *.s *.i
|
|
|
|
rm -f modules.link
|
|
|
|
|
|
|
|
install:: all
|
|
|
|
@echo "Installing modules from `basename $(CURDIR)`..."
|
|
|
|
@for x in $(LOADABLE_MODS:%=%.so); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
|
|
|
|
|
|
|
|
uninstall::
|
|
|
|
|
|
|
|
dist-clean::
|
|
|
|
rm -f .*.moduleinfo .moduleinfo
|
|
|
|
rm -f .*.makeopts .makeopts
|
|
|
|
rm -f .*.d
|
|
|
|
|
|
|
|
.%.moduleinfo: %.c
|
|
|
|
@echo "<member name=\"$*\" displayname=\"$(shell $(GREP) -e AST_MODULE_INFO $< | head -n 1 | cut -d '"' -f 2)\" remove_on_change=\"$(SUBDIR)/$*.o $(SUBDIR)/$*.so\">" > $@
|
|
|
|
$(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $< >> $@
|
|
|
|
echo "</member>" >> $@
|
|
|
|
|
|
|
|
.%.moduleinfo: %.cc
|
|
|
|
@echo "<member name=\"$*\" displayname=\"$(shell $(GREP) -e AST_MODULE_INFO $< | head -n 1 | cut -d '"' -f 2)\" remove_on_change=\"$(SUBDIR)/$*.oo $(SUBDIR)/$*.so\">" > $@
|
|
|
|
$(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $< >> $@
|
|
|
|
echo "</member>" >> $@
|
|
|
|
|
|
|
|
.moduleinfo:: $(addsuffix .moduleinfo,$(addprefix .,$(ALL_C_MODS) $(ALL_CC_MODS)))
|
|
|
|
@echo "<category name=\"MENUSELECT_$(MENUSELECT_CATEGORY)\" displayname=\"$(MENUSELECT_DESCRIPTION)\" remove_on_change=\"$(SUBDIR)/modules.link\">" > $@
|
|
|
|
@cat $^ >> $@
|
|
|
|
@echo "</category>" >> $@
|
|
|
|
|
|
|
|
moduleinfo: .moduleinfo
|
|
|
|
@cat $<
|
|
|
|
|
|
|
|
.%.makeopts: %.c
|
|
|
|
@$(AWK) -f $(ASTTOPDIR)/build_tools/get_makeopts $< > $@
|
|
|
|
|
|
|
|
.%.makeopts: %.cc
|
|
|
|
@$(AWK) -f $(ASTTOPDIR)/build_tools/get_makeopts $< > $@
|
|
|
|
|
|
|
|
.makeopts:: $(addsuffix .makeopts,$(addprefix .,$(ALL_C_MODS) $(ALL_CC_MODS)))
|
|
|
|
@cat $^ > $@
|
|
|
|
|
|
|
|
makeopts: .makeopts
|
|
|
|
@cat $<
|
|
|
|
|
|
|
|
ifneq ($(wildcard .*.d),)
|
|
|
|
include .*.d
|
|
|
|
endif
|