[PATCH 3/7] Use make variables instead of preprocessing

Mike Hommey mh+jemalloc at glandium.org
Mon Apr 16 07:30:22 PDT 2012


From: Mike Hommey <mh at glandium.org>

---
 Makefile.in |  202 ++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 109 insertions(+), 93 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 8cd0418..1c30f32 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -17,9 +17,13 @@ INCLUDEDIR := $(DESTDIR)@INCLUDEDIR@
 LIBDIR := $(DESTDIR)@LIBDIR@
 DATADIR := $(DESTDIR)@DATADIR@
 MANDIR := $(DESTDIR)@MANDIR@
+srcroot := @srcroot@
+objroot := @objroot@
+abs_srcroot := @abs_srcroot@
+abs_objroot := @abs_objroot@
 
 # Build parameters.
-CPPFLAGS := @CPPFLAGS@ -I at srcroot@include -I at objroot@include
+CPPFLAGS := @CPPFLAGS@ -I$(srcroot)include -I$(objroot)include
 CFLAGS := @CFLAGS@
 LDFLAGS := @LDFLAGS@
 LIBS := @LIBS@
@@ -31,42 +35,54 @@ else
 WL_SONAME := soname
 endif
 REV := @rev@
-ifeq (macho, @abi@)
-TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH=@objroot at lib
+install_suffix := @install_suffix@
+ABI := @abi@
+XSLTPROC := @XSLTPROC@
+AUTOCONF := @AUTOCONF@
+RPATH := @RPATH@
+cfghdrs_in := @cfghdrs_in@
+cfghdrs_out := @cfghdrs_out@
+cfgoutputs_in := @cfgoutputs_in@
+cfgoutputs_out := @cfgoutputs_out@
+enable_autogen := @enable_autogen@
+enable_experimental := @enable_experimental@
+
+ifeq (macho, $(ABI))
+TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH=$(objroot)lib
 else
 TEST_LIBRARY_PATH :=
 endif
 
 # Lists of files.
-BINS := @srcroot at bin/pprof @objroot at bin/jemalloc.sh
-CHDRS := @objroot at include/jemalloc/jemalloc at install_suffix@.h \
-	@objroot at include/jemalloc/jemalloc_defs at install_suffix@.h
-CSRCS := @srcroot at src/jemalloc.c @srcroot at src/arena.c @srcroot at src/atomic.c \
-	@srcroot at src/base.c @srcroot at src/bitmap.c @srcroot at src/chunk.c \
-	@srcroot at src/chunk_dss.c @srcroot at src/chunk_mmap.c \
-	@srcroot at src/ckh.c @srcroot at src/ctl.c @srcroot at src/extent.c \
-	@srcroot at src/hash.c @srcroot at src/huge.c @srcroot at src/mb.c \
-	@srcroot at src/mutex.c @srcroot at src/prof.c @srcroot at src/quarantine.c \
-	@srcroot at src/rtree.c @srcroot at src/stats.c @srcroot at src/tcache.c \
-	@srcroot at src/util.c @srcroot at src/tsd.c
-ifeq (macho, @abi@)
-CSRCS += @srcroot at src/zone.c
+BINS := $(srcroot)bin/pprof $(objroot)bin/jemalloc.sh
+CHDRS := $(objroot)include/jemalloc/jemalloc$(install_suffix).h \
+	$(objroot)include/jemalloc/jemalloc_defs$(install_suffix).h
+CSRCS := $(srcroot)src/jemalloc.c $(srcroot)src/arena.c $(srcroot)src/atomic.c \
+	$(srcroot)src/base.c $(srcroot)src/bitmap.c $(srcroot)src/chunk.c \
+	$(srcroot)src/chunk_dss.c $(srcroot)src/chunk_mmap.c \
+	$(srcroot)src/ckh.c $(srcroot)src/ctl.c $(srcroot)src/extent.c \
+	$(srcroot)src/hash.c $(srcroot)src/huge.c $(srcroot)src/mb.c \
+	$(srcroot)src/mutex.c $(srcroot)src/prof.c $(srcroot)src/quarantine.c \
+	$(srcroot)src/rtree.c $(srcroot)src/stats.c $(srcroot)src/tcache.c \
+	$(srcroot)src/util.c $(srcroot)src/tsd.c
+ifeq (macho, $(ABI))
+CSRCS += $(srcroot)src/zone.c
 endif
-STATIC_LIBS := @objroot at lib/libjemalloc at install_suffix@.a
-DSOS := @objroot at lib/libjemalloc at install_suffix@.$(SO).$(REV) \
-	@objroot at lib/libjemalloc at install_suffix@.$(SO) \
-	@objroot at lib/libjemalloc at install_suffix@_pic.a
-MAN3 := @objroot at doc/jemalloc at install_suffix@.3
-DOCS_XML := @objroot at doc/jemalloc at install_suffix@.xml
-DOCS_HTML := $(DOCS_XML:@objroot@%.xml=@srcroot@%.html)
-DOCS_MAN3 := $(DOCS_XML:@objroot@%.xml=@srcroot@%.3)
+STATIC_LIBS := $(objroot)lib/libjemalloc$(install_suffix).a
+DSOS := $(objroot)lib/libjemalloc$(install_suffix).$(SO).$(REV) \
+	$(objroot)lib/libjemalloc$(install_suffix).$(SO) \
+	$(objroot)lib/libjemalloc$(install_suffix)_pic.a
+MAN3 := $(objroot)doc/jemalloc$(install_suffix).3
+DOCS_XML := $(objroot)doc/jemalloc$(install_suffix).xml
+DOCS_HTML := $(DOCS_XML:$(objroot)%.xml=$(srcroot)%.html)
+DOCS_MAN3 := $(DOCS_XML:$(objroot)%.xml=$(srcroot)%.3)
 DOCS := $(DOCS_HTML) $(DOCS_MAN3)
-CTESTS := @srcroot at test/aligned_alloc.c @srcroot at test/allocated.c \
-	@srcroot at test/bitmap.c @srcroot at test/mremap.c \
-	@srcroot at test/posix_memalign.c @srcroot at test/thread_arena.c \
-	@srcroot at test/thread_tcache_enabled.c
-ifeq (@enable_experimental@, 1)
-CTESTS += @srcroot at test/allocm.c @srcroot at test/rallocm.c
+CTESTS := $(srcroot)test/aligned_alloc.c $(srcroot)test/allocated.c \
+	$(srcroot)test/bitmap.c $(srcroot)test/mremap.c \
+	$(srcroot)test/posix_memalign.c $(srcroot)test/thread_arena.c \
+	$(srcroot)test/thread_tcache_enabled.c
+ifeq ($(enable_experimental), 1)
+CTESTS += $(srcroot)test/allocm.c $(srcroot)test/rallocm.c
 endif
 
 .PHONY: all dist doc_html doc_man doc
@@ -74,18 +90,18 @@ endif
 .PHONY: install_html install_man install_doc install
 .PHONY: tests check clean distclean relclean
 
-.SECONDARY : $(CTESTS:@srcroot@%.c=@objroot@%.o)
+.SECONDARY : $(CTESTS:$(srcroot)%.c=$(objroot)%.o)
 
 # Default target.
 all: build
 
 dist: build_doc
 
- at srcroot@doc/%.html : @objroot at doc/%.xml @srcroot at doc/stylesheet.xsl @objroot at doc/html.xsl
-	@XSLTPROC@ -o $@ @objroot at doc/html.xsl $<
+$(srcroot)doc/%.html : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/html.xsl
+	$(XSLTPROC) -o $@ $(objroot)doc/html.xsl $<
 
- at srcroot@doc/%.3 : @objroot at doc/%.xml @srcroot at doc/stylesheet.xsl @objroot at doc/manpages.xsl
-	@XSLTPROC@ -o $@ @objroot at doc/manpages.xsl $<
+$(srcroot)doc/%.3 : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/manpages.xsl
+	$(XSLTPROC) -o $@ $(objroot)doc/manpages.xsl $<
 
 build_doc_html: $(DOCS_HTML)
 build_doc_man: $(DOCS_MAN3)
@@ -94,16 +110,16 @@ build_doc: $(DOCS)
 #
 # Include generated dependency files.
 #
--include $(CSRCS:@srcroot@%.c=@objroot@%.d)
--include $(CSRCS:@srcroot@%.c=@objroot@%.pic.d)
--include $(CTESTS:@srcroot@%.c=@objroot@%.d)
+-include $(CSRCS:$(srcroot)%.c=$(objroot)%.d)
+-include $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.d)
+-include $(CTESTS:$(srcroot)%.c=$(objroot)%.d)
 
- at objroot@src/%.o: @srcroot at src/%.c
+$(objroot)src/%.o: $(srcroot)src/%.c
 	@mkdir -p $(@D)
 	$(CC) $(CFLAGS) -c $(CPPFLAGS) -o $@ $<
 	@$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.o=%.d) $<
 
- at objroot@src/%.pic.o: @srcroot at src/%.c
+$(objroot)src/%.pic.o: $(srcroot)src/%.c
 	@mkdir -p $(@D)
 	$(CC) $(CFLAGS) -fPIC -DPIC -c $(CPPFLAGS) -o $@ $<
 	@$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.o=%.d) $<
@@ -112,30 +128,30 @@ build_doc: $(DOCS)
 	@mkdir -p $(@D)
 	ln -sf $(<F) $@
 
- at objroot@lib/libjemalloc at install_suffix@.$(SO).$(REV) : $(CSRCS:@srcroot@%.c=@objroot@%.pic.o)
+$(objroot)lib/libjemalloc$(install_suffix).$(SO).$(REV) : $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.o)
 	@mkdir -p $(@D)
-	$(CC) -shared -Wl,-$(WL_SONAME),$(@F) $(RPATH_EXTRA:%=@RPATH@%) -o $@ $+ $(LDFLAGS) $(LIBS)
+	$(CC) -shared -Wl,-$(WL_SONAME),$(@F) $(RPATH_EXTRA:%=$(RPATH)%) -o $@ $+ $(LDFLAGS) $(LIBS)
 
- at objroot@lib/libjemalloc at install_suffix@_pic.a : $(CSRCS:@srcroot@%.c=@objroot@%.pic.o)
+$(objroot)lib/libjemalloc$(install_suffix)_pic.a : $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.o)
 	@mkdir -p $(@D)
 	ar crus $@ $+
 
- at objroot@lib/libjemalloc at install_suffix@.a : $(CSRCS:@srcroot@%.c=@objroot@%.o)
+$(objroot)lib/libjemalloc$(install_suffix).a : $(CSRCS:$(srcroot)%.c=$(objroot)%.o)
 	@mkdir -p $(@D)
 	ar crus $@ $+
 
- at objroot@test/%.o: @srcroot at test/%.c
+$(objroot)test/%.o: $(srcroot)test/%.c
 	@mkdir -p $(@D)
-	$(CC) $(CFLAGS) -c $(CPPFLAGS) -I at objroot@test -o $@ $<
-	@$(CC) -MM $(CPPFLAGS) -I at objroot@test -MT $@ -o $(@:%.o=%.d) $<
+	$(CC) $(CFLAGS) -c $(CPPFLAGS) -I$(objroot)test -o $@ $<
+	@$(CC) -MM $(CPPFLAGS) -I$(objroot)test -MT $@ -o $(@:%.o=%.d) $<
 
- at objroot@test/%: @objroot at test/%.o \
-		 @objroot at lib/libjemalloc at install_suffix@.$(SO)
+$(objroot)test/%: $(objroot)test/%.o \
+		 $(objroot)lib/libjemalloc$(install_suffix).$(SO)
 	@mkdir -p $(@D)
-ifneq (@RPATH@, )
-	$(CC) -o $@ $< @RPATH@@objroot at lib -L at objroot@lib -ljemalloc at install_suffix@ $(LIBS)
+ifneq ($(RPATH), )
+	$(CC) -o $@ $< $(RPATH)$(objroot)lib -L$(objroot)lib -ljemalloc$(install_suffix) $(LIBS)
 else
-	$(CC) -o $@ $< -L at objroot@lib -ljemalloc at install_suffix@ $(LIBS)
+	$(CC) -o $@ $< -L$(objroot)lib -ljemalloc$(install_suffix) $(LIBS)
 endif
 
 build_lib_shared: $(DSOS)
@@ -158,21 +174,21 @@ done
 
 install_lib_shared: $(DSOS)
 	install -d $(LIBDIR)
-	install -m 755 @objroot at lib/libjemalloc at install_suffix@.$(SO).$(REV) $(LIBDIR)
-	ln -sf libjemalloc at install_suffix@.$(SO).$(REV) $(LIBDIR)/libjemalloc at install_suffix@.$(SO)
+	install -m 755 $(objroot)lib/libjemalloc$(install_suffix).$(SO).$(REV) $(LIBDIR)
+	ln -sf libjemalloc$(install_suffix).$(SO).$(REV) $(LIBDIR)/libjemalloc$(install_suffix).$(SO)
 
 install_lib_static: $(DSOS) $(STATIC_LIBS)
 	install -d $(LIBDIR)
-	install -m 755 @objroot at lib/libjemalloc at install_suffix@_pic.a $(LIBDIR)
-	install -m 755 @objroot at lib/libjemalloc at install_suffix@.a $(LIBDIR)
+	install -m 755 $(objroot)lib/libjemalloc$(install_suffix)_pic.a $(LIBDIR)
+	install -m 755 $(objroot)lib/libjemalloc$(install_suffix).a $(LIBDIR)
 
 install_lib: install_lib_shared install_lib_static
 
 install_doc_html:
-	install -d $(DATADIR)/doc/jemalloc at install_suffix@
+	install -d $(DATADIR)/doc/jemalloc$(install_suffix)
 	@for d in $(DOCS_HTML); do \
-	echo "install -m 644 $$d $(DATADIR)/doc/jemalloc at install_suffix@"; \
-	install -m 644 $$d $(DATADIR)/doc/jemalloc at install_suffix@; \
+	echo "install -m 644 $$d $(DATADIR)/doc/jemalloc$(install_suffix)"; \
+	install -m 644 $$d $(DATADIR)/doc/jemalloc$(install_suffix); \
 done
 
 install_doc_man:
@@ -186,21 +202,21 @@ install_doc: install_doc_html install_doc_man
 
 install: install_bin install_include install_lib install_doc
 
-tests: $(CTESTS:@srcroot@%.c=@objroot@%)
+tests: $(CTESTS:$(srcroot)%.c=$(objroot)%)
 
 check: tests
-	@mkdir -p @objroot at test
+	@mkdir -p $(objroot)test
 	@$(SHELL) -c 'total=0; \
 		failures=0; \
 		echo "========================================="; \
-		for t in $(CTESTS:@srcroot@%.c=@objroot@%); do \
+		for t in $(CTESTS:$(srcroot)%.c=$(objroot)%); do \
 			total=`expr $$total + 1`; \
 			/bin/echo -n "$${t} ... "; \
-			$(TEST_LIBRARY_PATH) $${t} @abs_srcroot@ @abs_objroot@ \
-			  > @objroot@$${t}.out 2>&1; \
-			if test -e "@srcroot@$${t}.exp"; then \
-				diff -w -u @srcroot@$${t}.exp \
-				  @objroot@$${t}.out >/dev/null 2>&1; \
+			$(TEST_LIBRARY_PATH) $${t} $(abs_srcroot) $(abs_objroot) \
+			  > $(objroot)$${t}.out 2>&1; \
+			if test -e "$(srcroot)$${t}.exp"; then \
+				diff -w -u $(srcroot)$${t}.exp \
+				  $(objroot)$${t}.out >/dev/null 2>&1; \
 				fail=$$?; \
 				if test "$${fail}" -eq "1" ; then \
 					failures=`expr $${failures} + 1`; \
@@ -217,49 +233,49 @@ check: tests
 		echo "Failures: $${failures}/$${total}"'
 
 clean:
-	rm -f $(CSRCS:@srcroot@%.c=@objroot@%.o)
-	rm -f $(CSRCS:@srcroot@%.c=@objroot@%.pic.o)
-	rm -f $(CSRCS:@srcroot@%.c=@objroot@%.d)
-	rm -f $(CSRCS:@srcroot@%.c=@objroot@%.pic.d)
-	rm -f $(CTESTS:@srcroot@%.c=@objroot@%)
-	rm -f $(CTESTS:@srcroot@%.c=@objroot@%.o)
-	rm -f $(CTESTS:@srcroot@%.c=@objroot@%.d)
-	rm -f $(CTESTS:@srcroot@%.c=@objroot@%.out)
+	rm -f $(CSRCS:$(srcroot)%.c=$(objroot)%.o)
+	rm -f $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.o)
+	rm -f $(CSRCS:$(srcroot)%.c=$(objroot)%.d)
+	rm -f $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.d)
+	rm -f $(CTESTS:$(srcroot)%.c=$(objroot)%)
+	rm -f $(CTESTS:$(srcroot)%.c=$(objroot)%.o)
+	rm -f $(CTESTS:$(srcroot)%.c=$(objroot)%.d)
+	rm -f $(CTESTS:$(srcroot)%.c=$(objroot)%.out)
 	rm -f $(DSOS) $(STATIC_LIBS)
 
 distclean: clean
-	rm -rf @objroot at autom4te.cache
-	rm -f @objroot at config.log
-	rm -f @objroot at config.status
-	rm -f @objroot at config.stamp
-	rm -f @cfghdrs_out@
-	rm -f @cfgoutputs_out@
+	rm -rf $(objroot)autom4te.cache
+	rm -f $(objroot)config.log
+	rm -f $(objroot)config.status
+	rm -f $(objroot)config.stamp
+	rm -f $(cfghdrs_out)
+	rm -f $(cfgoutputs_out)
 
 relclean: distclean
-	rm -f @objroot at configure
-	rm -f @srcroot at VERSION
+	rm -f $(objroot)configure
+	rm -f $(srcroot)VERSION
 	rm -f $(DOCS_HTML)
 	rm -f $(DOCS_MAN3)
 
 #===============================================================================
 # Re-configuration rules.
 
-ifeq (@enable_autogen@, 1)
- at srcroot@configure : @srcroot at configure.ac
-	cd ./@srcroot@ && @AUTOCONF@
+ifeq ($(enable_autogen), 1)
+$(srcroot)configure : $(srcroot)configure.ac
+	cd ./$(srcroot) && $(AUTOCONF)
 
- at objroot@config.status : @srcroot at configure
-	./@objroot at config.status --recheck
+$(objroot)config.status : $(srcroot)configure
+	./$(objroot)config.status --recheck
 
- at srcroot@config.stamp.in : @srcroot at configure.ac
-	echo stamp > @srcroot at config.stamp.in
+$(srcroot)config.stamp.in : $(srcroot)configure.ac
+	echo stamp > $(srcroot)config.stamp.in
 
- at objroot@config.stamp : @cfgoutputs_in@ @cfghdrs_in@ @srcroot at configure
-	./@objroot at config.status
+$(objroot)config.stamp : $(cfgoutputs_in) $(cfghdrs_in) $(srcroot)configure
+	./$(objroot)config.status
 	@touch $@
 
 # There must be some action in order for make to re-read Makefile when it is
 # out of date.
- at cfgoutputs_out@ @cfghdrs_out@ : @objroot at config.stamp
+$(cfgoutputs_out) $(cfghdrs_out) : $(objroot)config.stamp
 	@true
 endif
-- 
1.7.10




More information about the jemalloc-discuss mailing list