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
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
78 for x in $(LOADABLE_MODS:%=%.so); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
82 ifneq ($(wildcard .*.d),)