2 # Asterisk -- A telephony toolkit for Linux.
4 # Makefile rules for subdirectories containing modules
6 # Copyright (C) 2006, Digium, Inc.
8 # Kevin P. Fleming <kpfleming@digium.com>
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
14 ifeq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
15 ASTCFLAGS+=${GC_CFLAGS}
18 ifneq ($(findstring STATIC_BUILD,$(MENUSELECT_CFLAGS)),)
22 include $(ASTTOPDIR)/Makefile.rules
26 $(addsuffix .o,$(C_MODS)): ASTCFLAGS+=-DAST_MODULE=\"$*\" $(MENUSELECT_OPTS_$*:%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_INCLUDE))
27 $(addsuffix .oo,$(CC_MODS)): ASTCFLAGS+=-DAST_MODULE=\"$*\" $(MENUSELECT_OPTS_$*:%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_INCLUDE))
29 $(LOADABLE_MODS:%=%.so): ASTCFLAGS+=-fPIC
30 $(LOADABLE_MODS:%=%.so): LIBS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LIB))
31 $(LOADABLE_MODS:%=%.so): ASTLDFLAGS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LDFLAGS))
33 $(addsuffix .so,$(filter $(LOADABLE_MODS),$(C_MODS))): %.so: %.o
34 $(addsuffix .so,$(filter $(LOADABLE_MODS),$(CC_MODS))): %.so: %.oo
36 modules.link: $(addsuffix .o,$(filter $(EMBEDDED_MODS),$(C_MODS)))
37 modules.link: $(addsuffix .oo,$(filter $(EMBEDDED_MODS),$(CC_MODS)))
39 .PHONY: clean uninstall _all moduleinfo makeopts
41 ifneq ($(LOADABLE_MODS),)
42 _all: $(LOADABLE_MODS:%=%.so)
45 ifneq ($(EMBEDDED_MODS),)
48 @echo "../$(SUBDIR)/modules.link"
50 @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(C_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LDFLAGS))"
51 @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(CC_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LDFLAGS))"
53 @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(C_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LIB))"
54 @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(CC_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LIB))"
63 @for file in $(patsubst %,$(SUBDIR)/%,$(filter %.o,$^)); do echo "INPUT (../$${file})" >> $@; done
64 @for file in $(patsubst %,$(SUBDIR)/%,$(filter-out %.o,$^)); do echo "INPUT (../$${file})" >> $@; done
67 rm -f *.so *.o *.oo *.s *.i
72 for x in $(LOADABLE_MODS:%=%.so); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
77 rm -f .*.moduleinfo .moduleinfo
78 rm -f .*.makeopts .makeopts
81 @echo "<member name=\"$*\" displayname=\"$(shell $(GREP) -e AST_MODULE_INFO $< | head -n 1 | cut -d '"' -f 2)\" remove_on_change=\"$(SUBDIR)/$*.o $(SUBDIR)/$*.so\">" > $@
82 $(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $< >> $@
83 echo "</member>" >> $@
86 @echo "<member name=\"$*\" displayname=\"$(shell $(GREP) -e AST_MODULE_INFO $< | head -n 1 | cut -d '"' -f 2)\" remove_on_change=\"$(SUBDIR)/$*.oo $(SUBDIR)/$*.so\">" > $@
87 $(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $< >> $@
88 echo "</member>" >> $@
90 .moduleinfo:: $(addsuffix .moduleinfo,$(addprefix .,$(ALL_C_MODS) $(ALL_CC_MODS)))
91 @echo "<category name=\"MENUSELECT_$(MENUSELECT_CATEGORY)\" displayname=\"$(MENUSELECT_DESCRIPTION)\" remove_on_change=\"$(SUBDIR)/modules.link\">" > $@
93 @echo "</category>" >> $@
95 moduleinfo: .moduleinfo
99 @$(AWK) -f $(ASTTOPDIR)/build_tools/get_makeopts $< > $@
102 @$(AWK) -f $(ASTTOPDIR)/build_tools/get_makeopts $< > $@
104 .makeopts:: $(addsuffix .makeopts,$(addprefix .,$(ALL_C_MODS) $(ALL_CC_MODS)))
110 ifneq ($(wildcard .*.d),)