[asterisk-commits] Change in asterisk[master]: Build System: Create Makefile macro MOD_ADD_SOURCE.
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Apr 14 12:39:15 CDT 2015
Matt Jordan has submitted this change and it was merged.
Change subject: Build System: Create Makefile macro MOD_ADD_SOURCE.
......................................................................
Build System: Create Makefile macro MOD_ADD_SOURCE.
This new macro allows a single line to add all additional
sources to a module. This helps prevent modules from
missing steps, and makes future changes easier since
they can be made in a single place.
ASTERISK-24960 #close
Reported by: Corey Farrell
Change-Id: I38f12d8b72c5e7bb37a879b2fb51761a2855eb4b
---
M Makefile.moddir_rules
M addons/Makefile
M apps/Makefile
M channels/Makefile
M codecs/Makefile
M pbx/Makefile
M res/Makefile
M res/ari.make
M rest-api-templates/ari.make.mustache
9 files changed, 62 insertions(+), 158 deletions(-)
Approvals:
Matt Jordan: Looks good to me, approved; Verified
George Joseph: Looks good to me, but someone else must approve
diff --git a/Makefile.moddir_rules b/Makefile.moddir_rules
index 939e79f..673580d 100644
--- a/Makefile.moddir_rules
+++ b/Makefile.moddir_rules
@@ -62,6 +62,21 @@
MOD_ASTCFLAGS=-DAST_MODULE=\"$(1)\" $(MENUSELECT_OPTS_$(1):%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$(1)),$(value $(dep)_INCLUDE))
+define MOD_ADD_SOURCE
+$$(if $$(filter $(1),$$(EMBEDDED_MODS)),modules.link,$(1).so): $$(subst $(3),$(5),$(2))
+$$(subst $(3),$(5),$(2)): _ASTCFLAGS+=$$(call MOD_ASTCFLAGS,$(1))
+.$(1).moduleinfo: MODULEINFO_EXTRA_OUTPUT=" $$(addprefix $$(SUBDIR)/,$$(subst $(3),$(5),$(2)) $$(subst $(3),$(4),$(2)))"
+
+clean:: clean-$(1)$(3)
+
+clean-$(1)$(3):
+ rm -f $$(subst $(3),$(5),$(2)) $$(subst $(3),$(4),$(2))
+
+endef
+
+MOD_ADD_C=$(eval $(call MOD_ADD_SOURCE,$(1),$(2),.c,.i,.o))
+MOD_ADD_CC=$(eval $(call MOD_ADD_SOURCE,$(1),$(2),.cc,.ii,.oo))
+
$(addsuffix .oo,$(CC_MODS)) $(addsuffix .o,$(C_MODS)): \
_ASTCFLAGS+=$(call MOD_ASTCFLAGS,$*)
@@ -132,12 +147,12 @@
rm -f *.exports
.%.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\">" > $@
+ @echo "<member name=\"$*\" displayname=\"$(shell $(GREP) -e AST_MODULE_INFO $< | head -n 1 | cut -d '"' -f 2)\" remove_on_change=\"$(SUBDIR)/$*.o $(SUBDIR)/$*.i $(SUBDIR)/$*.so$(MODULEINFO_EXTRA_OUTPUT)\">" > $@
$(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $< >> $@
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\">" > $@
+ @echo "<member name=\"$*\" displayname=\"$(shell $(GREP) -e AST_MODULE_INFO $< | head -n 1 | cut -d '"' -f 2)\" remove_on_change=\"$(SUBDIR)/$*.oo $(SUBDIR)/$*.ii $(SUBDIR)/$*.so$(MODULEINFO_EXTRA_OUTPUT)\">" > $@
$(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $< >> $@
echo "</member>" >> $@
diff --git a/addons/Makefile b/addons/Makefile
index 96438f5..a02d35f 100644
--- a/addons/Makefile
+++ b/addons/Makefile
@@ -14,15 +14,17 @@
MENUSELECT_CATEGORY=ADDONS
MENUSELECT_DESCRIPTION=Add-ons (See README-addons.txt)
-H323OBJS:=ooCmdChannel.o ooLogChan.o ooUtils.o ooGkClient.o context.o \
- ooDateTime.o decode.o dlist.o encode.o errmgmt.o \
- memheap.o ootrace.o oochannels.o ooh245.o ooports.o \
- ooq931.o ooCapability.o ooSocket.o perutil.o eventHandler.o \
- ooCalls.o ooStackCmds.o ooh323.o ooh323ep.o printHandler.o \
- rtctype.o ooTimer.o h323/H235-SECURITY-MESSAGESDec.o \
- h323/H235-SECURITY-MESSAGESEnc.o h323/H323-MESSAGES.o h323/H323-MESSAGESDec.o \
- h323/H323-MESSAGESEnc.o h323/MULTIMEDIA-SYSTEM-CONTROL.o \
- h323/MULTIMEDIA-SYSTEM-CONTROLDec.o h323/MULTIMEDIA-SYSTEM-CONTROLEnc.o
+OOH323C:=ooCmdChannel.c ooLogChan.c ooUtils.c ooGkClient.c context.c \
+ ooDateTime.c decode.c dlist.c encode.c errmgmt.c \
+ memheap.c ootrace.c oochannels.c ooh245.c ooports.c \
+ ooq931.c ooCapability.c ooSocket.c perutil.c eventHandler.c \
+ ooCalls.c ooStackCmds.c ooh323.c ooh323ep.c printHandler.c \
+ rtctype.c ooTimer.c h323/H235-SECURITY-MESSAGESDec.c \
+ h323/H235-SECURITY-MESSAGESEnc.c h323/H323-MESSAGES.c h323/H323-MESSAGESDec.c \
+ h323/H323-MESSAGESEnc.c h323/MULTIMEDIA-SYSTEM-CONTROL.c \
+ h323/MULTIMEDIA-SYSTEM-CONTROLDec.c h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c
+
+H323SOURCE:=$(addprefix ooh323c/src/,$(OOH323C)) ooh323cDriver.c
H323CFLAGS:=-Iooh323c/src -Iooh323c/src/h323
@@ -57,16 +59,9 @@
include $(ASTTOPDIR)/Makefile.moddir_rules
-clean::
- if [ -f mp3/Makefile ] ; then $(MAKE) -C mp3 clean ; fi
- rm -f $(addprefix ooh323c/src/,$(H323OBJS))
-
-$(if $(filter format_mp3,$(EMBEDDED_MODS)),modules.link,format_mp3.so): mp3/common.o mp3/dct64_i386.o mp3/decode_ntom.o mp3/layer3.o mp3/tabinit.o mp3/interface.o
-
-chan_ooh323.o: _ASTCFLAGS+=$(H323CFLAGS)
-
$(if $(filter chan_ooh323,$(EMBEDDED_MODS)),modules.link,chan_ooh323.so): _ASTCFLAGS+=$(H323CFLAGS)
-$(if $(filter chan_ooh323,$(EMBEDDED_MODS)),modules.link,chan_ooh323.so): $(addprefix ooh323c/src/,$(H323OBJS)) chan_ooh323.o ooh323cDriver.o
-$(addprefix ooh323c/src/,$(H323OBJS)) chan_ooh323.o ooh323cDriver.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_ooh323)
+$(call MOD_ADD_C,chan_ooh323,$(H323SOURCE))
+
+$(call MOD_ADD_C,format_mp3,mp3/common.c mp3/dct64_i386.c mp3/decode_ntom.c mp3/layer3.c mp3/tabinit.c mp3/interface.c)
.PHONY: check_mp3
diff --git a/apps/Makefile b/apps/Makefile
index 1dfe8c8..7730460 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -27,11 +27,7 @@
include $(ASTTOPDIR)/Makefile.moddir_rules
-clean::
- rm -f confbridge/*.o confbridge/*.i
-
-$(if $(filter app_confbridge,$(EMBEDDED_MODS)),modules.link,app_confbridge.so): $(subst .c,.o,$(wildcard confbridge/*.c))
-$(subst .c,.o,$(wildcard confbridge/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,app_confbridge)
+$(call MOD_ADD_C,app_confbridge,$(wildcard confbridge/*.c))
ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
LIBS+= -lres_ael_share.so -lres_monitor.so -lres_speech.so
diff --git a/channels/Makefile b/channels/Makefile
index 1f4cff4..733ce41 100644
--- a/channels/Makefile
+++ b/channels/Makefile
@@ -23,46 +23,16 @@
LIBS+= -lres_monitor.so
endif
-clean::
- $(MAKE) -C misdn clean
- rm -f dahdi/*.o dahdi/*.i
- rm -f sip/*.o sip/*.i
- rm -f iax2/*.o iax2/*.i
- rm -f pjsip/*.o pjsip/*.i
-$(if $(filter chan_iax2,$(EMBEDDED_MODS)),modules.link,chan_iax2.so): $(subst .c,.o,$(wildcard iax2/*.c))
-$(subst .c,.o,$(wildcard iax2/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_iax2)
-
-$(if $(filter chan_sip,$(EMBEDDED_MODS)),modules.link,chan_sip.so): $(subst .c,.o,$(wildcard sip/*.c))
-$(subst .c,.o,$(wildcard sip/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_sip)
-
-$(if $(filter chan_pjsip,$(EMBEDDED_MODS)),modules.link,chan_pjsip.so): $(subst .c,.o,$(wildcard pjsip/*.c))
-$(subst .c,.o,$(wildcard pjsip/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_pjsip)
-
-# Additional objects to combine with chan_dahdi.so
-CHAN_DAHDI_OBJS= \
- $(subst .c,.o,$(wildcard dahdi/*.c)) \
- sig_analog.o \
- sig_pri.o \
- sig_ss7.o \
-
-$(if $(filter chan_dahdi,$(EMBEDDED_MODS)),modules.link,chan_dahdi.so): $(CHAN_DAHDI_OBJS)
-$(CHAN_DAHDI_OBJS): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_dahdi)
+$(call MOD_ADD_C,chan_iax2,$(wildcard iax2/*.c))
+$(call MOD_ADD_C,chan_sip,$(wildcard sip/*.c))
+$(call MOD_ADD_C,chan_pjsip,$(wildcard pjsip/*.c))
+$(call MOD_ADD_C,chan_dahdi,$(wildcard dahdi/*.c) sig_analog.c sig_pri.c sig_ss7.c)
+$(call MOD_ADD_C,chan_misdn,misdn_config.c misdn/isdn_lib.c misdn/isdn_msg_parser.c)
chan_misdn.o: _ASTCFLAGS+=-Imisdn
-
misdn_config.o: _ASTCFLAGS+=-Imisdn
-
misdn/isdn_lib.o: _ASTCFLAGS+=-Wno-strict-aliasing
-$(if $(filter chan_misdn,$(EMBEDDED_MODS)),modules.link,chan_misdn.so): misdn_config.o misdn/isdn_lib.o misdn/isdn_msg_parser.o
-misdn_config.o misdn/isdn_lib.o misdn/isdn_msg_parser.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_misdn)
-
-$(if $(filter chan_oss,$(EMBEDDED_MODS)),modules.link,chan_oss.so): console_video.o vgrabbers.o console_board.o
-console_video.o vgrabbers.o console_board.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_oss)
-
-chan_usbradio.o: ./xpmr/xpmr.c ./xpmr/xpmr.h ./xpmr/xpmr_coef.h
-
-chan_usbradio.so: LIBS+=-lusb -lasound
-chan_usbradio.so: _ASTCFLAGS+=-DNDEBUG
+$(call MOD_ADD_C,chan_oss,console_video.c vgrabbers.c console_board.c)
diff --git a/codecs/Makefile b/codecs/Makefile
index 32230ae..684ccc6 100644
--- a/codecs/Makefile
+++ b/codecs/Makefile
@@ -53,8 +53,6 @@
for dir in $(SUB_DIRS); do \
$(MAKE) -C $$dir clean; \
done
- rm -f g722/*.[oai]
- rm -f speex/*.[oai]
.PHONY: $(SUB_DIRS)
@@ -81,9 +79,8 @@
@$(MAKE) -C $(SUB_ILBC) all _ASTCFLAGS="$(filter-out -Wmissing-prototypes -Wmissing-declarations -Wshadow,$(_ASTCFLAGS)) $(AST_NO_STRICT_OVERFLOW)"
-$(if $(filter codec_g722,$(EMBEDDED_MODS)),modules.link,codec_g722.so): g722/g722_encode.o g722/g722_decode.o
-g722/g722_encode.o g722/g722_decode.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,codec_g722)
+$(call MOD_ADD_C,codec_g722,g722/g722_encode.c g722/g722_decode.c)
ifeq ($(BUILD_CPU),x86_64)
@@ -92,6 +89,5 @@
SPEEX_RESAMPLE_CFLAGS:=
endif
-$(if $(filter codec_resample,$(EMBEDDED_MODS)),modules.link,codec_resample.so): speex/resample.o
-
-speex/resample.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,codec_resample) $(SPEEX_RESAMPLE_CFLAGS)
+$(call MOD_ADD_C,codec_resample,speex/resample.c)
+speex/resample.o: _ASTCFLAGS+=$(SPEEX_RESAMPLE_CFLAGS)
diff --git a/pbx/Makefile b/pbx/Makefile
index 0afc4bc..4b02ce4 100644
--- a/pbx/Makefile
+++ b/pbx/Makefile
@@ -23,13 +23,4 @@
LIBS+= -lres_ael_share.so -lres_monitor.so
endif
-clean::
- rm -f ael/*.o ael/*.i
-
-dundi-parser.o: dundi-parser.h
-dundi-parser.o: _ASTCFLAGS+=-I.
-
-pbx_gtkconsole.o: _ASTCFLAGS+=-Wno-strict-prototypes
-
-$(if $(filter pbx_dundi,$(EMBEDDED_MODS)),modules.link,pbx_dundi.so): dundi-parser.o
-dundi-parser.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,pbx_dundi)
+$(call MOD_ADD_C,pbx_dundi,dundi-parser.c)
diff --git a/res/Makefile b/res/Makefile
index b98fb8e..e56a148 100644
--- a/res/Makefile
+++ b/res/Makefile
@@ -37,21 +37,6 @@
_ASTCFLAGS+=-Wno-parentheses-equality
endif
-$(if $(filter res_ais,$(EMBEDDED_MODS)),modules.link,res_ais.so): ais/clm.o ais/evt.o
-ais/clm.o ais/evt.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ais)
-
-$(if $(filter res_snmp,$(EMBEDDED_MODS)),modules.link,res_snmp.so): snmp/agent.o
-snmp/agent.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_snmp)
-
-$(if $(filter res_ael_share,$(EMBEDDED_MODS)),modules.link,res_ael_share.so): ael/ael_lex.o ael/ael.tab.o ael/pval.o
-ael/ael_lex.o ael/ael.tab.o ael/pval.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ael_share)
-
-$(if $(filter res_pjsip,$(EMBEDDED_MODS)),modules.link,res_pjsip.so): $(subst .c,.o,$(wildcard res_pjsip/*.c))
-$(subst .c,.o,$(wildcard res_pjsip/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_pjsip)
-
-$(if $(filter res_stasis,$(EMBEDDED_MODS)),modules.link,res_stasis.so): $(subst .c,.o,$(wildcard stasis/*.c))
-$(subst .c,.o,$(wildcard stasis/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_stasis)
-
ifneq ($(findstring REBUILD_PARSERS,$(MENUSELECT_CFLAGS)),)
ael/ael_lex.c: ael/ael.flex
else
@@ -75,22 +60,14 @@
ael/pval.o: ael/pval.c
-clean::
- rm -f snmp/*.[oi] ael/*.[oi] ais/*.[oi] ari/*.[oi]
- rm -f res_pjsip/*.[oi] stasis/*.[oi]
- rm -f parking/*.o parking/*.i stasis_recording/*.[oi]
-
-$(if $(filter res_parking,$(EMBEDDED_MODS)),modules.link,res_parking.so): $(subst .c,.o,$(wildcard parking/*.c))
-$(subst .c,.o,$(wildcard parking/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_parking)
-
-res_ari.so: ari/cli.o ari/config.o ari/ari_websockets.o
-ari/cli.o ari/config.o ari/ari_websockets.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari)
-
-res_ari_model.so: ari/ari_model_validators.o
-ari/ari_model_validators.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_model)
-
-res_stasis_recording.so: stasis_recording/stored.o
-stasis_recording/stored.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_stasis_recording)
+$(call MOD_ADD_C,res_ael_share,ael/ael_lex.c ael/ael.tab.c ael/pval.c)
+$(call MOD_ADD_C,res_stasis,$(wildcard stasis/*.c))
+$(call MOD_ADD_C,res_snmp,snmp/agent.c)
+$(call MOD_ADD_C,res_parking,$(wildcard parking/*.c))
+$(call MOD_ADD_C,res_pjsip,$(wildcard res_pjsip/*.c))
+$(call MOD_ADD_C,res_ari,ari/cli.c ari/config.c ari/ari_websockets.c)
+$(call MOD_ADD_C,res_ari_model,ari/ari_model_validators.c)
+$(call MOD_ADD_C,res_stasis_recording,stasis_recording/stored.c)
# Dependencies for res_ari_*.so are generated, so they're in this file
include ari.make
diff --git a/res/ari.make b/res/ari.make
index f9a87d3..dd32997 100644
--- a/res/ari.make
+++ b/res/ari.make
@@ -17,47 +17,14 @@
# rest-api-templates/ari.make.mustache
#
-res_ari_asterisk.so: ari/resource_asterisk.o
-
-ari/resource_asterisk.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_asterisk)
-
-res_ari_endpoints.so: ari/resource_endpoints.o
-
-ari/resource_endpoints.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_endpoints)
-
-res_ari_channels.so: ari/resource_channels.o
-
-ari/resource_channels.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_channels)
-
-res_ari_bridges.so: ari/resource_bridges.o
-
-ari/resource_bridges.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_bridges)
-
-res_ari_recordings.so: ari/resource_recordings.o
-
-ari/resource_recordings.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_recordings)
-
-res_ari_sounds.so: ari/resource_sounds.o
-
-ari/resource_sounds.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_sounds)
-
-res_ari_playbacks.so: ari/resource_playbacks.o
-
-ari/resource_playbacks.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_playbacks)
-
-res_ari_device_states.so: ari/resource_device_states.o
-
-ari/resource_device_states.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_device_states)
-
-res_ari_mailboxes.so: ari/resource_mailboxes.o
-
-ari/resource_mailboxes.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_mailboxes)
-
-res_ari_events.so: ari/resource_events.o
-
-ari/resource_events.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_events)
-
-res_ari_applications.so: ari/resource_applications.o
-
-ari/resource_applications.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_applications)
-
+$(call MOD_ADD_C,res_ari_asterisk,ari/resource_asterisk.c)
+$(call MOD_ADD_C,res_ari_endpoints,ari/resource_endpoints.c)
+$(call MOD_ADD_C,res_ari_channels,ari/resource_channels.c)
+$(call MOD_ADD_C,res_ari_bridges,ari/resource_bridges.c)
+$(call MOD_ADD_C,res_ari_recordings,ari/resource_recordings.c)
+$(call MOD_ADD_C,res_ari_sounds,ari/resource_sounds.c)
+$(call MOD_ADD_C,res_ari_playbacks,ari/resource_playbacks.c)
+$(call MOD_ADD_C,res_ari_device_states,ari/resource_device_states.c)
+$(call MOD_ADD_C,res_ari_mailboxes,ari/resource_mailboxes.c)
+$(call MOD_ADD_C,res_ari_events,ari/resource_events.c)
+$(call MOD_ADD_C,res_ari_applications,ari/resource_applications.c)
diff --git a/rest-api-templates/ari.make.mustache b/rest-api-templates/ari.make.mustache
index 50293cf..82f55cc 100644
--- a/rest-api-templates/ari.make.mustache
+++ b/rest-api-templates/ari.make.mustache
@@ -19,8 +19,5 @@
#
{{#apis}}
-res_ari_{{c_name}}.so: ari/resource_{{c_name}}.o
-
-ari/resource_{{c_name}}.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_{{c_name}})
-
+$(call MOD_ADD_C,res_ari_{{c_name}},ari/resource_{{c_name}}.c)
{{/apis}}
--
To view, visit https://gerrit.asterisk.org/105
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I38f12d8b72c5e7bb37a879b2fb51761a2855eb4b
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
More information about the asterisk-commits
mailing list