[Asterisk-code-review] Another attempt at making the product build process cleaner ... (repotools[master])

George Joseph asteriskteam at digium.com
Tue May 22 08:15:04 CDT 2018


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/9030


Change subject: Another attempt at making the product build process cleaner and faster
......................................................................

Another attempt at making the product build process cleaner and faster

Change-Id: Ic7cf8156db30442310b338d6cdb4782928409531
---
M build_tools/Makefile.product_rules
1 file changed, 43 insertions(+), 30 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/repotools refs/changes/30/9030/1

diff --git a/build_tools/Makefile.product_rules b/build_tools/Makefile.product_rules
index f1d96ac..1a842ab 100644
--- a/build_tools/Makefile.product_rules
+++ b/build_tools/Makefile.product_rules
@@ -113,6 +113,8 @@
 $(info $(help))
 endif
 
+.PRECIOUS: $(LIBS)
+
 .PHONY: all
 all:
 	@echo
@@ -128,7 +130,7 @@
 		echo " [MAKE PREREQ] $@ $(ARCH) with $(DEBUG_CFLAGS)";\
 		$(MAKE) INDENT="+   " --quiet --no-print-directory -C libcp clean;\
 		$(MAKE) INDENT="+   " --quiet --no-print-directory -j -C libcp ARCH=$(ARCH) OPT="$(CFLAGS)" DEBUG="$(DEBUG_CFLAGS)" libcp.a && \
-		echo "$$currconfig" > last_libcp_build~;\
+		echo "$$currconfig" > last_$@~;\
 	else \
 		echo " [MAKE PREREQ] $@ $(ARCH) with $(DEBUG_CFLAGS) not needed";\
 	fi;
@@ -142,20 +144,28 @@
 	currconfig="$(ARCH) $(ASTERISK_CONFIGURE_FLAGS)";\
 	if [ "x$$lastconfig" != "x$$currconfig" ] ; then \
 		cd asterisk;\
-		echo " [MAKE PREREQ] $@ $(ARCH) $(ASTERISK_CONFIGURE_FLAGS). This may take a minute or 2...";\
+		echo " [MAKE PREREQ] $@ $(ASTERISK_CONFIGURE_FLAGS) This may take a minute or 2...";\
 		$(MAKE) --quiet --no-print-directory distclean &>/dev/null;\
-		./configure $(ASTERISK_CONFIGURE_FLAGS) &>/dev/null || exit 1;\
+		./configure $(ASTERISK_CONFIGURE_FLAGS) CFLAGS= &>/dev/null || exit 1;\
+		if [ "x$(AST_DEVMODE)" = "xyes" ] ; then \
+			$(MAKE) --quiet --no-print-directory -C menuselect ;\
+			$(MAKE) --quiet --no-print-directory menuselect-tree ;\
+			menuselect/menuselect --enable=DONT_OPTIMIZE menuselect.makeopts ;\
+			menuselect/menuselect --enable=BETTER_BACKTRACES menuselect.makeopts ;\
+			menuselect/menuselect --enable=MALLOC_DEBUG menuselect.makeopts ;\
+			menuselect/menuselect --enable=OPTIONAL_API menuselect.makeopts ;\
+			menuselect/menuselect --enable=TEST_FRAMEWORK menuselect.makeopts ;\
+		fi ;\
 		$(MAKE) --quiet --no-print-directory include/asterisk/buildopts.h &>/dev/null;\
 		sed -i -e /GCC_ATOMICS/d include/asterisk/autoconfig.h;\
 		cd ..;\
-		echo "$$currconfig" > last_asterisk_build~;\
+		echo "$$currconfig" > last_$@~;\
 	else \
-		echo " [MAKE PREREQ] $@ $(ARCH) $(ASTERISK_CONFIGURE_FLAGS).  not needed";\
+		echo " [MAKE PREREQ] $@ $(ASTERISK_CONFIGURE_FLAGS) not needed";\
 	fi;
 
-
 PJPROJECT_BUNDLED_NEEDED=$(if $(PJPROJECT_BUNDLED),$(PJPROJECT_BUNDLED:no=),)
-ASTERISK_CONFIGURE_FLAGS=$(if $(PJPROJECT_BUNDLED_NEEDED),--with-pjproject-bundled) --host=$(BUILD_ARCH)-linux-gnu
+ASTERISK_CONFIGURE_FLAGS=$(if $(PJPROJECT_BUNDLED_NEEDED),--with-pjproject-bundled) --host=$(BUILD_ARCH)-linux-gnu  --libdir=$(LIBDIR) $(if $(call yesonly,$(AST_DEVMODE)),--enable-dev-mode,)
 PJPROJECT_INCLUDES=$(if $(PJPROJECT_BUNDLED_NEEDED),$(filter-out -O2,$(shell sed -n -r -e "s/PJPROJECT_INCLUDE=(.*)/\1/gp" asterisk/makeopts 2>/dev/null)))
 
 PRECHECKS=asterisk-configure libcp-build
@@ -165,35 +175,38 @@
 	@cmp -s $@.tmp $@ || mv $@.tmp $@
 	@rm -f $@.tmp
 
-include repotools/build_tools/Makefile.dependencies
+#####include repotools/build_tools/Makefile.dependencies
 
 CFLAGS+=$(MODULE_SDK_CFLAGS)
-MODULE_OBJS=$(MODULE_NAME).o $(MODULE_EXTRA_OBJS)
-$(MODULE_OBJS): CFLAGS+=-I$(ASTINCDIR) -I/usr/include -I -Iinclude -DAST_MODULE=\"$(MODULE_NAME)\" -DAST_MODULE_SELF_SYM=__internal_$(MODULE_NAME)_self
 
-$(sort $(MODULE_OBJS) $(MODULE_EXTRA_LIBRARY_OBJS)): %.o : %.c optarch.h version.h
-	$(ECHO_PREFIX) echo "  [CC] $@"
+%.o: CFLAGS+=-DAST_MODULE=\"$(LIBRARY_BASE_NAME)\" -DAST_MODULE_SELF_SYM=__internal_$(LIBRARY_BASE_NAME)_self -I$(ASTINCDIR)
+%.o: %.c optarch.h version.h
+	$(ECHO_PREFIX) echo "  [CC] $(LIBRARY_BASE_NAME):$@"
 	$(CMD_PREFIX) $(CC) -c $< -o $@ $(PJPROJECT_INCLUDES) $(CFLAGS) $(DEBUG_CFLAGS) $(WARN) $(MAKE_DEPS) $(COPYPROTECT_CFLAGS)
 
-
-$(MODULE_EXTRA_LIBRARIES): LIBRARY_NAME=$(@)
-$(MODULE_EXTRA_LIBRARIES): SOLINK=-shared -Wl,--version-script,$(subst .so,.exports,$(LIBRARY_NAME))
-$(MODULE_EXTRA_LIBRARIES): $(MODULE_EXTRA_LIBRARY_OBJS) $(MODULE_SDK_OBJS) $(MODULE_SDK_LIB)
+.%.exports: LIBRARY_BASE_NAME=$(basename $*)
+.%.exports:
+	@if [ ! -f $(LIBRARY_BASE_NAME).exports ] ; then \
+		echo "  [EXPORTS] $(LIBRARY_BASE_NAME)" ;\
+		echo -e "{\n\tglobal:\n\t\t_IO_stdin_used;\n\tlocal:\n\t\t*;\n};" > $@ ;\
+	else \
+		echo "  [EXPORTS CP] $(LIBRARY_BASE_NAME)" ;\
+		cp $(LIBRARY_BASE_NAME).exports $@ ;\
+	fi ;
+	
+$(MODULE_LIBS): LIBRARY_NAME=$(@)
+$(MODULE_LIBS): LIBRARY_BASE_NAME=$(basename $(LIBRARY_NAME))
+$(MODULE_LIBS): LINKER_SCRIPT=-Wl,--version-script,.$(basename $(LIBRARY_NAME)).exports
+$(MODULE_LIBS): SOLINK=-shared $(LINKER_SCRIPT)
+$(MODULE_LIBS): %.so: $(MODULE_SDK_OBJS) $(MODULE_SDK_LIB) | .%.exports
+	$(CMD_PREFIX) $(MAKE) --no-print-directory $(OBJS) LIBRARY_BASE_NAME=$(LIBRARY_BASE_NAME) NOISY_BUILD=$(NOISY_BUILD) PJPROJECT_INCLUDES="$(PJPROJECT_INCLUDES)"
 	$(ECHO_PREFIX) echo "  [LD] $(LIBRARY_NAME) $(ARCH)"
-	$(CMD_PREFIX) $(CC) $(CFLAGS) $(DEBUG_CFLAGS) $(SOLINK) -o .$(LIBRARY_NAME) $^ $(LDFLAGS) $(LIBS) $(COPYPROTECT_LIBS)
+	$(CMD_PREFIX) $(CC) $(CFLAGS) $(DEBUG_CFLAGS) $(SOLINK) -o .$(LIBRARY_NAME) $(OBJS) $^ $(LDFLAGS) $(LIBS) $(COPYPROTECT_LIBS)
 	$(CMD_PREFIX) echo "$(MODULE_NAME),$(VARIANT),$(PRODUCT_VERSION)" >.$(LIBRARY_NAME).ast_manifest
 	$(CMD_PREFIX) $(OBJCOPY) --add-section .ast_manifest=.$(LIBRARY_NAME).ast_manifest --set-section-flags .ast_manifest=noload,readonly .$(LIBRARY_NAME) $(LIBRARY_NAME)
-	$(CMD_PREFIX) rm .$(LIBRARY_NAME) .$(LIBRARY_NAME).ast_manifest *.o 2>/dev/null || :
+	$(CMD_PREFIX) rm .$(LIBRARY_NAME) .$(LIBRARY_NAME).ast_manifest .*.exports 2>/dev/null || :
 
-$(MODULE_NAME).so: LIBRARY_NAME=$(MODULE_NAME).so
-$(MODULE_NAME).so: SOLINK=-shared -Wl,--version-script,$(subst .so,.exports,$(LIBRARY_NAME))
-$(MODULE_NAME).so: $(MODULE_OBJS) $(MODULE_SDK_OBJS) $(MODULE_SDK_LIB)
-	$(ECHO_PREFIX) echo "  [LD] $(LIBRARY_NAME) $(ARCH)"
-	$(CMD_PREFIX) $(CC) $(CFLAGS) $(DEBUG_CFLAGS) $(SOLINK) -o .$(LIBRARY_NAME) $^ $(LDFLAGS) $(LIBS) $(COPYPROTECT_LIBS)
-	$(CMD_PREFIX) echo "$(LIBRARY_NAME),$(VARIANT),$(PRODUCT_VERSION)" >.$(LIBRARY_NAME).ast_manifest
-	$(CMD_PREFIX) $(OBJCOPY) --add-section .ast_manifest=.$(LIBRARY_NAME).ast_manifest --set-section-flags .ast_manifest=noload,readonly .$(LIBRARY_NAME) $(LIBRARY_NAME)
-	$(CMD_PREFIX) rm .$(LIBRARY_NAME) .$(LIBRARY_NAME).ast_manifest  *.o 2>/dev/null || :
-
+	
 .PHONY: base nocp debug
 
 base: COPYPROTECT=yes
@@ -234,7 +247,7 @@
 # we also don't want them in the $^ variable.  The "::" rules enforce both
 # conditions,
     $(VARIANTS):: clean $(PRECHECKS)
-    $(VARIANTS):: $(MODULE_NAME).so $(MODULE_EXTRA_LIBRARIES)
+    $(VARIANTS):: $(MODULE_LIBS)
 		$(ECHO_PREFIX) echo " [TAR] $(PRODUCT_DIR)"
 		$(CMD_PREFIX)repotools/build_tools/make_tarball $(call setflag,$(DEBUG),--no-strip) --version=$(PRODUCT_VERSION) \
 			--arch=$(ARCH) --package-name=$(MODULE_NAME) --variant=$(TAR_VARIANT) --manifest-in=$(MANIFEST_IN) --manifest-out=$(MANIFEST) $(PRODUCT_DIR).tar.gz $^
@@ -344,11 +357,11 @@
 .PHONY: clean distclean superclean
 clean::
 	$(ECHO_PREFIX) echo " [CLEAN]"
-	@rm -f *.o *.so manifest*.xml *~
+	@rm -f *.o *.so manifest*.xml .*.exports
 
 distclean:: clean
 	$(ECHO_PREFIX) echo " [DISTCLEAN]"
-	- at rm -f optarch.h version.h
+	- at rm -f optarch.h version.h *~
 
 superclean:: distclean
 	$(ECHO_PREFIX) echo " [SUPERCLEAN]"

-- 
To view, visit https://gerrit.asterisk.org/9030
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic7cf8156db30442310b338d6cdb4782928409531
Gerrit-Change-Number: 9030
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180522/1d56119e/attachment.html>


More information about the asterisk-code-review mailing list