Files
asterisk/Makefile.moddir_rules
T

145 lines
5.0 KiB
Makefile
Raw Normal View History

2006-06-24 23:26:19 +00:00
#
2012-10-18 14:17:40 +00:00
# Asterisk -- An open source telephony toolkit.
#
# 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
#
2007-11-05 17:27:02 +00:00
# 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.
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
2017-03-24 08:43:05 -04:00
# C_MODS, CC_MODS and LOADABLE_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_CC_MODS:=
2009-06-30 17:04:35 +00:00
ALL_C_MODS+=$(foreach p,$(MODULE_PREFIX),$(patsubst %.c,%,$(wildcard $(p)_*.c)))
ALL_CC_MODS+=$(foreach p,$(MODULE_PREFIX),$(patsubst %.cc,%,$(wildcard $(p)_*.cc)))
2009-06-30 17:04:35 +00:00
endif
2009-06-30 17:04:35 +00:00
C_MODS:=$(filter-out $(MENUSELECT_$(MENUSELECT_CATEGORY)),$(ALL_C_MODS))
CC_MODS:=$(filter-out $(MENUSELECT_$(MENUSELECT_CATEGORY)),$(ALL_CC_MODS))
2017-03-24 08:43:05 -04:00
LOADABLE_MODS:=$(C_MODS) $(CC_MODS)
2007-11-05 17:27:02 +00:00
# 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'). This is also necessary
# for components used to build modules, which can't be determined
# by the rules in this file, so the MOD_ASTCFLAGS definition
# is used to collect the required flags for a module... which can
# then be used any place they are required.
MOD_ASTCFLAGS=-DAST_MODULE=\"$(1)\" $(MENUSELECT_OPTS_$(1):%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$(1)),$(value $(dep)_INCLUDE))
2007-11-05 17:27:02 +00:00
$(addsuffix .oo,$(CC_MODS)) $(addsuffix .o,$(C_MODS)): \
_ASTCFLAGS+=$(call MOD_ASTCFLAGS,$*)
2006-06-24 23:26:19 +00:00
ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
# don't define -fPIC on mingw32 and cygwin, it is the default
2009-07-21 13:28:04 +00:00
$(LOADABLE_MODS:%=%.so): _ASTCFLAGS+=-fPIC
2007-11-17 02:50:52 +00:00
endif
# For loadable modules, pass _LIB and _LDFLAGS from menuselect.
2006-09-29 22:48:43 +00:00
$(LOADABLE_MODS:%=%.so): LIBS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LIB))
2009-07-21 13:28:04 +00:00
$(LOADABLE_MODS:%=%.so): _ASTLDFLAGS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LDFLAGS))
2006-06-24 23:26:19 +00:00
2006-09-29 22:48:43 +00:00
$(addsuffix .so,$(filter $(LOADABLE_MODS),$(C_MODS))): %.so: %.o
$(addsuffix .so,$(filter $(LOADABLE_MODS),$(CC_MODS))): %.so: %.oo
2007-12-17 07:25:35 +00:00
.PHONY: clean uninstall _all moduleinfo makeopts
2006-06-24 23:26:19 +00:00
_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
2006-06-24 23:26:19 +00:00
2006-12-16 21:24:52 +00:00
clean::
2008-11-20 00:08:12 +00:00
rm -f *.so *.o *.oo *.eo *.i *.ii
2008-11-26 19:08:56 +00:00
rm -f .*.d
rm -f *.s *.i
rm -f *.gcda *.gcno
rm -f modules.link
2006-06-24 23:26:19 +00:00
install:: all
2007-12-10 02:06:40 +00:00
@echo "Installing modules from `basename $(CURDIR)`..."
@for x in $(LOADABLE_MODS:%=%.so); do $(INSTALL) -m 755 $$x "$(DESTDIR)$(ASTMODDIR)" ; done
ifneq ($(findstring :,$(XMLSTARLET)$(BASH)),:)
@if [ -f .moduleinfo ] ; then \
declare -A DISABLED_MODS ;\
for x in $(MENUSELECT_$(MENUSELECT_CATEGORY)) ; do DISABLED_MODS[$${x}]=1 ; done ;\
EXTERNAL_MODS=$$(xmlstarlet sel -t -m "/category/member[support_level = 'external']" -v "@name" -n .moduleinfo) ;\
for x in $${EXTERNAL_MODS} ; do \
if [ -z "$${DISABLED_MODS[$${x}]}" ] ; then \
$(ASTTOPDIR)/build_tools/download_externals $${x} ;\
fi ;\
done ;\
fi
endif
2006-06-24 23:26:19 +00:00
uninstall::
2007-12-17 07:25:35 +00:00
dist-clean::
rm -f .*.moduleinfo .moduleinfo
rm -f .*.makeopts .makeopts
rm -f *.exports
2007-12-17 07:25:35 +00:00
.%.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\">" > $@
2015-04-29 07:39:22 -04:00
$(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $^ >> $@
2007-12-17 07:25:35 +00:00
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\">" > $@
2015-04-29 07:39:22 -04:00
$(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $^ >> $@
2007-12-17 07:25:35 +00:00
echo "</member>" >> $@
2016-07-24 17:27:26 -06:00
.moduleinfo:: $(addsuffix .moduleinfo,$(addprefix .,$(sort $(ALL_C_MODS) $(ALL_CC_MODS)))) $(wildcard $(call tolower,$(MENUSELECT_CATEGORY)).xml)
2017-03-24 08:43:05 -04:00
@echo "<category name=\"MENUSELECT_$(MENUSELECT_CATEGORY)\" displayname=\"$(MENUSELECT_DESCRIPTION)\">" > $@
2007-12-17 07:25:35 +00:00
@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:24:52 +00:00
ifneq ($(wildcard .*.d),)
include .*.d
endif