![rizzo](/assets/img/avatar_default.png)
generate loadable and embedded module lists. Individual Makefiles now are a lot simpler, possibly as simple as this: -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/menuselect.makedeps MODULE_PREFIX=cdr_ all: _all include $(ASTTOPDIR)/Makefile.moddir_rules and also more flexible because in a single directory we can combine various types of modules (app_, cdr_, func_, ... ) by simply listing them in the MODULE_PREFIX variable. The individual Makefiles can also create list of modules to be excluded by listing them in the variablel MODULE_EXCLUDE (see an example in channels/Makefile). With this change it becomes trivial to integrate a directory with locally created/modified sources into the main build. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@92082 f38db490-d61c-443f-a65b-d21fe96a405b
143 lines
5 KiB
Makefile
143 lines
5 KiB
Makefile
#
|
|
# Asterisk -- A telephony toolkit for Linux.
|
|
#
|
|
# Makefile rules for subdirectories containing modules
|
|
#
|
|
# 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
|
|
#
|
|
|
|
# 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 MALLOC_DEBUG,$(MENUSELECT_CFLAGS)),)
|
|
ifeq ($(findstring astmm.h,$(ASTCFLAGS)),)
|
|
ASTCFLAGS+=-include $(ASTTOPDIR)/include/asterisk/astmm.h
|
|
endif
|
|
endif
|
|
|
|
ifeq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
|
|
ASTCFLAGS+=${GC_CFLAGS}
|
|
endif
|
|
|
|
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
|
|
# C_MODS, CC_MODS, LOADABLE_MODS and EMBEDDED_MODS.
|
|
# Each word of MODULE_PREFIX is a prefix for filenames that we consider
|
|
# valid C or CC modules (eg. app_, func_ ...).
|
|
# Use MODULE_EXCLUDE to specify additional modules to exclude.
|
|
|
|
ifneq ($(MODULE_PREFIX),)
|
|
# Compute the lowercase and uppercase directory name. The former
|
|
# is used as a key in MENUSELECT_EMBED, the latter is part of
|
|
# the name of the MENUSELECT_* variable containing the exclude list
|
|
# generated by menuselect.
|
|
A:=$(notdir $(CURDIR))
|
|
B:=$(shell echo $A | tr "[a-z]" "[A-Z]")
|
|
# MENUSELECT_$(L) contains the list of modules excluded by menuselect.
|
|
# MODULE_EXCLUDE contains the locally generated exclude list
|
|
L:=$(MENUSELECT_$(B)) $(MODULE_EXCLUDE)
|
|
# construct the list of C and CC modules from the content of the directory
|
|
C_MODS:=
|
|
CC_MODS:=
|
|
C_MODS+=$(foreach pre,$(MODULE_PREFIX),$(filter-out $(L),$(patsubst %.c,%,$(wildcard $(pre)*.c))))
|
|
CC_MODS+=$(foreach pre,$(MODULE_PREFIX),$(filter-out $(L),$(patsubst %.cc,%,$(wildcard $(pre)*.cc))))
|
|
|
|
# and store in the list of embedded or loadable modules
|
|
ifneq ($(findstring $(A),$(MENUSELECT_EMBED)),)
|
|
EMBEDDED_MODS:=$(C_MODS) $(CC_MODS)
|
|
else
|
|
LOADABLE_MODS:=$(C_MODS) $(CC_MODS)
|
|
endif
|
|
endif
|
|
# debugging
|
|
# x:=$(shell echo 'in $(B)' >&2)
|
|
# x:=$(shell echo 'filtered out $(L)' >&2)
|
|
# x:=$(shell echo 'C_MODS= $(C_MODS)' >&2)
|
|
# x:=$(shell sleep 2)
|
|
|
|
# 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')
|
|
|
|
$(addsuffix .oo,$(CC_MODS)) $(addsuffix .o,$(C_MODS)): \
|
|
ASTCFLAGS+= -DAST_MODULE=\"$*\" $(MENUSELECT_OPTS_$*:%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_INCLUDE))
|
|
|
|
ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
|
|
# don't define -fPIC on mingw32 and cygwin, it is the default
|
|
$(LOADABLE_MODS:%=%.so): ASTCFLAGS+=-fPIC
|
|
endif
|
|
|
|
# For loadable modules, pass _LIB and _LDFLAGS from menuselect.
|
|
$(LOADABLE_MODS:%=%.so): LIBS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LIB))
|
|
$(LOADABLE_MODS:%=%.so): ASTLDFLAGS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LDFLAGS))
|
|
|
|
$(EMBEDDED_MODS:%=%.o): ASTCFLAGS+=-DEMBEDDED_MODULE=$*
|
|
|
|
$(addsuffix .so,$(filter $(LOADABLE_MODS),$(C_MODS))): %.so: %.o
|
|
$(addsuffix .so,$(filter $(LOADABLE_MODS),$(CC_MODS))): %.so: %.oo
|
|
|
|
modules.link: $(addsuffix .eo,$(filter $(EMBEDDED_MODS),$(C_MODS)))
|
|
|
|
.PHONY: clean uninstall _all
|
|
|
|
ifneq ($(LOADABLE_MODS),)
|
|
_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
|
|
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 $@
|
|
@for file in $(patsubst %,$(SUBDIR)/%,$(filter %.eo,$^)); do echo "INPUT (../$${file})" >> $@; done
|
|
@for file in $(patsubst %,$(SUBDIR)/%,$(filter-out %.eo,$^)); do echo "INPUT (../$${file})" >> $@; done
|
|
|
|
clean::
|
|
rm -f *.so *.o *.oo *.eo
|
|
rm -f .*.o.d .*.oo.d
|
|
rm -f *.s *.i
|
|
rm -f modules.link
|
|
|
|
install:: all
|
|
@echo "Installing modules from `basename $(CURDIR)`..."
|
|
@for x in $(LOADABLE_MODS:%=%.so); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
|
|
|
|
uninstall::
|
|
|
|
ifneq ($(wildcard .*.d),)
|
|
include .*.d
|
|
endif
|