[PATCH] Use a make variable instead of preprocessing for srcroot, and simplify source files handling
Mike Hommey
mh+jemalloc at glandium.org
Thu Apr 12 08:14:36 PDT 2012
From: Mike Hommey <mh at glandium.org>
---
Makefile.in | 99 ++++++++++++++++++++++++++++++-----------------------------
1 file changed, 50 insertions(+), 49 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index da07db4..b879807 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -17,9 +17,10 @@ INCLUDEDIR := $(DESTDIR)@INCLUDEDIR@
LIBDIR := $(DESTDIR)@LIBDIR@
DATADIR := $(DESTDIR)@DATADIR@
MANDIR := $(DESTDIR)@MANDIR@
+srcroot := @srcroot@
# Build parameters.
-CPPFLAGS := @CPPFLAGS@ -I at srcroot@include -Iinclude
+CPPFLAGS := @CPPFLAGS@ -I$(srcroot)include -Iinclude
CFLAGS := @CFLAGS@
ifeq (macho, @abi@)
CFLAGS += -dynamic
@@ -41,19 +42,19 @@ TEST_LIBRARY_PATH :=
endif
# Lists of files.
-BINS := @srcroot at bin/pprof bin/jemalloc.sh
+BINS := $(srcroot)bin/pprof bin/jemalloc.sh
CHDRS := include/jemalloc/jemalloc at install_suffix@.h \
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
+CSRCS := src/jemalloc.c src/arena.c src/atomic.c \
+ src/base.c src/bitmap.c src/chunk.c \
+ src/chunk_dss.c src/chunk_mmap.c \
+ src/ckh.c src/ctl.c src/extent.c \
+ src/hash.c src/huge.c src/mb.c \
+ src/mutex.c src/prof.c src/quarantine.c \
+ src/rtree.c src/stats.c src/tcache.c \
+ src/util.c src/tsd.c
ifeq (macho, @abi@)
-CSRCS += @srcroot at src/zone.c
+CSRCS += src/zone.c
endif
STATIC_LIBS := lib/libjemalloc at install_suffix@.a
DSOS := lib/libjemalloc at install_suffix@.$(SO).$(REV) \
@@ -61,15 +62,15 @@ DSOS := lib/libjemalloc at install_suffix@.$(SO).$(REV) \
lib/libjemalloc at install_suffix@_pic.a
MAN3 := doc/jemalloc at install_suffix@.3
DOCS_XML := doc/jemalloc at install_suffix@.xml
-DOCS_HTML := $(DOCS_XML:%.xml=@srcroot@%.html)
-DOCS_MAN3 := $(DOCS_XML:%.xml=@srcroot@%.3)
+DOCS_HTML := $(DOCS_XML:%.xml=$(srcroot)%.html)
+DOCS_MAN3 := $(DOCS_XML:%.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
+CTESTS := test/aligned_alloc.c test/allocated.c \
+ test/bitmap.c test/mremap.c \
+ test/posix_memalign.c test/thread_arena.c \
+ test/thread_tcache_enabled.c
ifeq (@enable_experimental@, 1)
-CTESTS += @srcroot at test/allocm.c @srcroot at test/rallocm.c
+CTESTS += test/allocm.c test/rallocm.c
endif
.PHONY: all dist doc_html doc_man doc
@@ -77,17 +78,17 @@ endif
.PHONY: install_html install_man install_doc install
.PHONY: tests check clean distclean relclean
-.SECONDARY : $(CTESTS:@srcroot@%.c=%.o)
+.SECONDARY : $(CTESTS:%.c=%.o)
# Default target.
all: build
dist: build_doc
- at srcroot@doc/%.html : doc/%.xml @srcroot at doc/stylesheet.xsl doc/html.xsl
+$(srcroot)doc/%.html : doc/%.xml $(srcroot)doc/stylesheet.xsl doc/html.xsl
@XSLTPROC@ -o $@ doc/html.xsl $<
- at srcroot@doc/%.3 : doc/%.xml @srcroot at doc/stylesheet.xsl doc/manpages.xsl
+$(srcroot)doc/%.3 : doc/%.xml $(srcroot)doc/stylesheet.xsl doc/manpages.xsl
@XSLTPROC@ -o $@ doc/manpages.xsl $<
build_doc_html: $(DOCS_HTML)
@@ -97,16 +98,16 @@ build_doc: $(DOCS)
#
# Include generated dependency files.
#
--include $(CSRCS:@srcroot@%.c=%.d)
--include $(CSRCS:@srcroot@%.c=%.pic.d)
--include $(CTESTS:@srcroot@%.c=%.d)
+-include $(CSRCS:%.c=%.d)
+-include $(CSRCS:%.c=%.pic.d)
+-include $(CTESTS:%.c=%.d)
-src/%.o: @srcroot at src/%.c
+src/%.o: $(srcroot)src/%.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $(CPPFLAGS) -o $@ $<
@$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) $< | sed \"s/\($(subst /,\/,$(notdir $(basename $@)))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.o \2/g\" > $(@:%.o=%.d)"
-src/%.pic.o: @srcroot at src/%.c
+src/%.pic.o: $(srcroot)src/%.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) -fPIC -DPIC -c $(CPPFLAGS) -o $@ $<
@$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) $< | sed \"s/\($(subst /,\/,$(notdir $(basename $(basename $@))))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.pic.o \2/g\" > $(@:%.o=%.d)"
@@ -115,19 +116,19 @@ src/%.pic.o: @srcroot at src/%.c
@mkdir -p $(@D)
ln -sf $(<F) $@
-lib/libjemalloc at install_suffix@.$(SO).$(REV) : $(CSRCS:@srcroot@%.c=%.pic.o)
+lib/libjemalloc at install_suffix@.$(SO).$(REV) : $(CSRCS:%.c=%.pic.o)
@mkdir -p $(@D)
$(CC) -shared -Wl,-$(WL_SONAME),$(@F) $(RPATH_EXTRA:%=@RPATH@%) -o $@ $+ $(LDFLAGS) $(LIBS)
-lib/libjemalloc at install_suffix@_pic.a : $(CSRCS:@srcroot@%.c=%.pic.o)
+lib/libjemalloc at install_suffix@_pic.a : $(CSRCS:%.c=%.pic.o)
@mkdir -p $(@D)
ar crus $@ $+
-lib/libjemalloc at install_suffix@.a : $(CSRCS:@srcroot@%.c=%.o)
+lib/libjemalloc at install_suffix@.a : $(CSRCS:%.c=%.o)
@mkdir -p $(@D)
ar crus $@ $+
-test/%.o: @srcroot at test/%.c
+test/%.o: $(srcroot)test/%.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $(CPPFLAGS) -Itest -o $@ $<
@$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) -Itest $< | sed \"s/\($(subst /,\/,$(notdir $(basename $@)))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.o \2/g\" > $(@:%.o=%.d)"
@@ -192,20 +193,20 @@ install_doc: install_doc_html install_doc_man
install: install_bin install_include install_lib install_doc
-tests: $(CTESTS:@srcroot@%.c=%)
+tests: $(CTESTS:%.c=%)
check: tests
@mkdir -p test
@$(SHELL) -c 'total=0; \
failures=0; \
echo "========================================="; \
- for t in $(CTESTS:@srcroot@%.c=%); do \
+ for t in $(CTESTS:%.c=%); do \
total=`expr $$total + 1`; \
/bin/echo -n "$${t} ... "; \
$(TEST_LIBRARY_PATH) $${t} @abs_srcroot@ @abs_objroot@ \
> $${t}.out 2>&1; \
- if test -e "@srcroot@$${t}.exp"; then \
- diff -w -u @srcroot@$${t}.exp \
+ if test -e "$(srcroot)$${t}.exp"; then \
+ diff -w -u $(srcroot)$${t}.exp \
$${t}.out >/dev/null 2>&1; \
fail=$$?; \
if test "$${fail}" -eq "1" ; then \
@@ -223,14 +224,14 @@ check: tests
echo "Failures: $${failures}/$${total}"'
clean:
- rm -f $(CSRCS:@srcroot@%.c=%.o)
- rm -f $(CSRCS:@srcroot@%.c=%.pic.o)
- rm -f $(CSRCS:@srcroot@%.c=%.d)
- rm -f $(CSRCS:@srcroot@%.c=%.pic.d)
- rm -f $(CTESTS:@srcroot@%.c=%)
- rm -f $(CTESTS:@srcroot@%.c=%.o)
- rm -f $(CTESTS:@srcroot@%.c=%.d)
- rm -f $(CTESTS:@srcroot@%.c=%.out)
+ rm -f $(CSRCS:%.c=%.o)
+ rm -f $(CSRCS:%.c=%.pic.o)
+ rm -f $(CSRCS:%.c=%.d)
+ rm -f $(CSRCS:%.c=%.pic.d)
+ rm -f $(CTESTS:%.c=%)
+ rm -f $(CTESTS:%.c=%.o)
+ rm -f $(CTESTS:%.c=%.d)
+ rm -f $(CTESTS:%.c=%.out)
rm -f $(DSOS) $(STATIC_LIBS)
distclean: clean
@@ -243,7 +244,7 @@ distclean: clean
relclean: distclean
rm -f configure
- rm -f @srcroot at VERSION
+ rm -f $(srcroot)VERSION
rm -f $(DOCS_HTML)
rm -f $(DOCS_MAN3)
@@ -251,16 +252,16 @@ relclean: distclean
# Re-configuration rules.
ifeq (@enable_autogen@, 1)
- at srcroot@configure : @srcroot at configure.ac
- cd ./@srcroot@ && @AUTOCONF@
+$(srcroot)configure : $(srcroot)configure.ac
+ cd ./$(srcroot) && @AUTOCONF@
-config.status : @srcroot at configure
+config.status : $(srcroot)configure
./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 > $@
-config.stamp : @cfgoutputs_in@ @cfghdrs_in@ @srcroot at configure
+config.stamp : @cfgoutputs_in@ @cfghdrs_in@ $(srcroot)configure
./config.status
@touch $@
--
1.7.9.5
More information about the jemalloc-discuss
mailing list