2006-06-24 23:26:19 +00:00
|
|
|
#
|
|
|
|
# Asterisk -- A telephony toolkit for Linux.
|
|
|
|
#
|
2006-08-21 02:11:39 +00:00
|
|
|
# Makefile rules for subdirectories containing modules
|
2006-06-24 23:26:19 +00:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2006-08-26 16:45:35 +00:00
|
|
|
ifeq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
|
2006-09-29 18:25:49 +00:00
|
|
|
ASTCFLAGS+=${GC_CFLAGS}
|
2006-08-26 16:45:35 +00:00
|
|
|
endif
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
ifneq ($(findstring STATIC_BUILD,$(MENUSELECT_CFLAGS)),)
|
|
|
|
STATIC_BUILD=-static
|
|
|
|
endif
|
|
|
|
|
2006-07-06 23:18:45 +00:00
|
|
|
include $(ASTTOPDIR)/Makefile.rules
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
comma:=,
|
2006-07-06 23:18:45 +00:00
|
|
|
|
2006-09-29 22:47:40 +00:00
|
|
|
$(addsuffix .o,$(C_MODS)): ASTCFLAGS+=-DAST_MODULE=\"$*\" $(MENUSELECT_OPTS_$*:%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_INCLUDE))
|
|
|
|
$(addsuffix .oo,$(CC_MODS)): ASTCFLAGS+=-DAST_MODULE=\"$*\" $(MENUSELECT_OPTS_$*:%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_INCLUDE))
|
2006-06-24 23:26:19 +00:00
|
|
|
|
2006-09-29 22:47:40 +00:00
|
|
|
$(LOADABLE_MODS:%=%.so): ASTCFLAGS+=-fPIC
|
|
|
|
$(LOADABLE_MODS:%=%.so): LIBS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LIB))
|
|
|
|
$(LOADABLE_MODS:%=%.so): ASTLDFLAGS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LDFLAGS))
|
2006-06-24 23:26:19 +00:00
|
|
|
|
2006-09-29 22:47:40 +00:00
|
|
|
$(addsuffix .so,$(filter $(LOADABLE_MODS),$(C_MODS))): %.so: %.o
|
|
|
|
$(addsuffix .so,$(filter $(LOADABLE_MODS),$(CC_MODS))): %.so: %.oo
|
2006-07-06 23:18:45 +00:00
|
|
|
|
2006-09-29 22:47:40 +00:00
|
|
|
modules.link: $(addsuffix .o,$(filter $(EMBEDDED_MODS),$(C_MODS)))
|
|
|
|
modules.link: $(addsuffix .oo,$(filter $(EMBEDDED_MODS),$(CC_MODS)))
|
2006-06-24 23:26:19 +00:00
|
|
|
|
2007-12-17 06:44:51 +00:00
|
|
|
.PHONY: clean uninstall _all moduleinfo makeopts
|
2006-06-24 23:26:19 +00:00
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
ifneq ($(LOADABLE_MODS),)
|
|
|
|
_all: $(LOADABLE_MODS:%=%.so)
|
|
|
|
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 $@
|
2006-09-29 22:47:40 +00:00
|
|
|
@for file in $(patsubst %,$(SUBDIR)/%,$(filter %.o,$^)); do echo "INPUT (../$${file})" >> $@; done
|
|
|
|
@for file in $(patsubst %,$(SUBDIR)/%,$(filter-out %.o,$^)); do echo "INPUT (../$${file})" >> $@; done
|
2006-06-24 23:26:19 +00:00
|
|
|
|
2006-12-16 21:14:34 +00:00
|
|
|
clean::
|
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/branches/1.4@157859 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-11-19 21:34:47 +00:00
|
|
|
rm -f *.so *.o *.oo *.s *.i *.ii
|
2008-11-26 18:36:24 +00:00
|
|
|
rm -f .*.d
|
2006-08-21 02:11:39 +00:00
|
|
|
rm -f modules.link
|
2006-06-24 23:26:19 +00:00
|
|
|
|
|
|
|
install:: all
|
2006-08-21 02:11:39 +00:00
|
|
|
for x in $(LOADABLE_MODS:%=%.so); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
|
2006-06-24 23:26:19 +00:00
|
|
|
|
|
|
|
uninstall::
|
|
|
|
|
2007-12-17 06:44:51 +00:00
|
|
|
dist-clean::
|
|
|
|
rm -f .*.moduleinfo .moduleinfo
|
|
|
|
rm -f .*.makeopts .makeopts
|
|
|
|
|
|
|
|
.%.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 $<
|
|
|
|
|
2006-12-16 21:14:34 +00:00
|
|
|
ifneq ($(wildcard .*.d),)
|
|
|
|
include .*.d
|
2006-09-09 03:27:21 +00:00
|
|
|
endif
|