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 ifneq ($(findstring MALLOC_DEBUG,$(MENUSELECT_CFLAGS)),)
15 ifeq ($(findstring astmm.h,$(ASTCFLAGS)),)
16 ASTCFLAGS+=-include $(ASTTOPDIR)/include/asterisk/astmm.h
20 ifeq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
21 ASTCFLAGS+=${GC_CFLAGS}
24 ifneq ($(findstring STATIC_BUILD,$(MENUSELECT_CFLAGS)),)
28 include $(ASTTOPDIR)/Makefile.rules
32 $(addsuffix .o,$(C_MODS)): ASTCFLAGS+=-DAST_MODULE=\"$*\" $(MENUSELECT_OPTS_$*:%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_INCLUDE))
33 $(addsuffix .oo,$(CC_MODS)): ASTCFLAGS+=-DAST_MODULE=\"$*\" $(MENUSELECT_OPTS_$*:%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_INCLUDE))
35 $(LOADABLE_MODS:%=%.so): ASTCFLAGS+=-fPIC
36 $(LOADABLE_MODS:%=%.so): LIBS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LIB))
37 $(LOADABLE_MODS:%=%.so): ASTLDFLAGS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LDFLAGS))
39 $(addsuffix .so,$(filter $(LOADABLE_MODS),$(C_MODS))): %.so: %.o
40 $(addsuffix .so,$(filter $(LOADABLE_MODS),$(CC_MODS))): %.so: %.oo
42 modules.link: $(addsuffix .o,$(filter $(EMBEDDED_MODS),$(C_MODS)))
43 modules.link: $(addsuffix .oo,$(filter $(EMBEDDED_MODS),$(CC_MODS)))
45 .PHONY: clean uninstall _all moduleinfo makeopts
47 ifneq ($(LOADABLE_MODS),)
48 _all: $(LOADABLE_MODS:%=%.so)
51 ifneq ($(EMBEDDED_MODS),)
54 @echo "../$(SUBDIR)/modules.link"
56 @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(C_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LDFLAGS))"
57 @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(CC_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LDFLAGS))"
59 @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(C_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LIB))"
60 @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(CC_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LIB))"
69 @for file in $(patsubst %,$(SUBDIR)/%,$(filter %.o,$^)); do echo "INPUT (../$${file})" >> $@; done
70 @for file in $(patsubst %,$(SUBDIR)/%,$(filter-out %.o,$^)); do echo "INPUT (../$${file})" >> $@; done
73 rm -f *.so *.o *.oo *.s *.i
78 for x in $(LOADABLE_MODS:%=%.so); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
83 rm -f .*.moduleinfo .moduleinfo
84 rm -f .*.makeopts .makeopts
87 @echo "<member name=\"$*\" displayname=\"$(shell $(GREP) -e AST_MODULE_INFO $< | head -n 1 | cut -d '"' -f 2)\" remove_on_change=\"$(SUBDIR)/$*.o $(SUBDIR)/$*.so\">" > $@
88 $(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $< >> $@
89 echo "</member>" >> $@
92 @echo "<member name=\"$*\" displayname=\"$(shell $(GREP) -e AST_MODULE_INFO $< | head -n 1 | cut -d '"' -f 2)\" remove_on_change=\"$(SUBDIR)/$*.oo $(SUBDIR)/$*.so\">" > $@
93 $(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $< >> $@
94 echo "</member>" >> $@
96 .moduleinfo:: $(addsuffix .moduleinfo,$(addprefix .,$(ALL_C_MODS) $(ALL_CC_MODS)))
97 @echo "<category name=\"MENUSELECT_$(MENUSELECT_CATEGORY)\" displayname=\"$(MENUSELECT_DESCRIPTION)\" remove_on_change=\"$(SUBDIR)/modules.link\">" > $@
99 @echo "</category>" >> $@
101 moduleinfo: .moduleinfo
105 @$(AWK) -f $(ASTTOPDIR)/build_tools/get_makeopts $< > $@
108 @$(AWK) -f $(ASTTOPDIR)/build_tools/get_makeopts $< > $@
110 .makeopts:: $(addsuffix .makeopts,$(addprefix .,$(ALL_C_MODS) $(ALL_CC_MODS)))
116 ifneq ($(wildcard .*.d),)