Add variables for library prefix, and static library, object and executable suffixes
This makes hacking on Makefile easier.
This commit is contained in:
parent
72ca7220f2
commit
5bee66d3ed
58
Makefile.in
58
Makefile.in
@ -29,6 +29,10 @@ LDFLAGS := @LDFLAGS@
|
|||||||
LIBS := @LIBS@
|
LIBS := @LIBS@
|
||||||
RPATH_EXTRA := @RPATH_EXTRA@
|
RPATH_EXTRA := @RPATH_EXTRA@
|
||||||
SO := @so@
|
SO := @so@
|
||||||
|
O := @o@
|
||||||
|
A := @a@
|
||||||
|
EXE := @exe@
|
||||||
|
LIB := @lib@
|
||||||
ifeq (macho, @abi@)
|
ifeq (macho, @abi@)
|
||||||
WL_SONAME := dylib_install_name
|
WL_SONAME := dylib_install_name
|
||||||
else
|
else
|
||||||
@ -53,6 +57,8 @@ else
|
|||||||
TEST_LIBRARY_PATH :=
|
TEST_LIBRARY_PATH :=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
LIBJEMALLOC := $(LIB)jemalloc$(install_suffix)
|
||||||
|
|
||||||
# Lists of files.
|
# Lists of files.
|
||||||
BINS := $(srcroot)bin/pprof $(objroot)bin/jemalloc.sh
|
BINS := $(srcroot)bin/pprof $(objroot)bin/jemalloc.sh
|
||||||
CHDRS := $(objroot)include/jemalloc/jemalloc$(install_suffix).h \
|
CHDRS := $(objroot)include/jemalloc/jemalloc$(install_suffix).h \
|
||||||
@ -68,10 +74,10 @@ CSRCS := $(srcroot)src/jemalloc.c $(srcroot)src/arena.c $(srcroot)src/atomic.c \
|
|||||||
ifeq (macho, $(ABI))
|
ifeq (macho, $(ABI))
|
||||||
CSRCS += $(srcroot)src/zone.c
|
CSRCS += $(srcroot)src/zone.c
|
||||||
endif
|
endif
|
||||||
STATIC_LIBS := $(objroot)lib/libjemalloc$(install_suffix).a
|
STATIC_LIBS := $(objroot)lib/$(LIBJEMALLOC).$(A)
|
||||||
DSOS := $(objroot)lib/libjemalloc$(install_suffix).$(SO).$(REV) \
|
DSOS := $(objroot)lib/$(LIBJEMALLOC).$(SO).$(REV) \
|
||||||
$(objroot)lib/libjemalloc$(install_suffix).$(SO) \
|
$(objroot)lib/$(LIBJEMALLOC).$(SO) \
|
||||||
$(objroot)lib/libjemalloc$(install_suffix)_pic.a
|
$(objroot)lib/$(LIBJEMALLOC)_pic.$(A)
|
||||||
MAN3 := $(objroot)doc/jemalloc$(install_suffix).3
|
MAN3 := $(objroot)doc/jemalloc$(install_suffix).3
|
||||||
DOCS_XML := $(objroot)doc/jemalloc$(install_suffix).xml
|
DOCS_XML := $(objroot)doc/jemalloc$(install_suffix).xml
|
||||||
DOCS_HTML := $(DOCS_XML:$(objroot)%.xml=$(srcroot)%.html)
|
DOCS_HTML := $(DOCS_XML:$(objroot)%.xml=$(srcroot)%.html)
|
||||||
@ -90,7 +96,7 @@ endif
|
|||||||
.PHONY: install_html install_man install_doc install
|
.PHONY: install_html install_man install_doc install
|
||||||
.PHONY: tests check clean distclean relclean
|
.PHONY: tests check clean distclean relclean
|
||||||
|
|
||||||
.SECONDARY : $(CTESTS:$(srcroot)%.c=$(objroot)%.o)
|
.SECONDARY : $(CTESTS:$(srcroot)%.c=$(objroot)%.$(O))
|
||||||
|
|
||||||
# Default target.
|
# Default target.
|
||||||
all: build
|
all: build
|
||||||
@ -114,39 +120,39 @@ build_doc: $(DOCS)
|
|||||||
-include $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.d)
|
-include $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.d)
|
||||||
-include $(CTESTS:$(srcroot)%.c=$(objroot)%.d)
|
-include $(CTESTS:$(srcroot)%.c=$(objroot)%.d)
|
||||||
|
|
||||||
$(objroot)src/%.o: $(srcroot)src/%.c
|
$(objroot)src/%.$(O): $(srcroot)src/%.c
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
$(CC) $(CFLAGS) -c $(CPPFLAGS) -o $@ $<
|
$(CC) $(CFLAGS) -c $(CPPFLAGS) -o $@ $<
|
||||||
@$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.o=%.d) $<
|
@$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $<
|
||||||
|
|
||||||
$(objroot)src/%.pic.o: $(srcroot)src/%.c
|
$(objroot)src/%.pic.$(O): $(srcroot)src/%.c
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
$(CC) $(CFLAGS) -fPIC -DPIC -c $(CPPFLAGS) -o $@ $<
|
$(CC) $(CFLAGS) -fPIC -DPIC -c $(CPPFLAGS) -o $@ $<
|
||||||
@$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.o=%.d) $<
|
@$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $<
|
||||||
|
|
||||||
%.$(SO) : %.$(SO).$(REV)
|
%.$(SO) : %.$(SO).$(REV)
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
ln -sf $(<F) $@
|
ln -sf $(<F) $@
|
||||||
|
|
||||||
$(objroot)lib/libjemalloc$(install_suffix).$(SO).$(REV) : $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.o)
|
$(objroot)lib/$(LIBJEMALLOC).$(SO).$(REV) : $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.$(O))
|
||||||
@mkdir -p $(@D)
|
@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)
|
||||||
|
|
||||||
$(objroot)lib/libjemalloc$(install_suffix)_pic.a : $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.o)
|
$(objroot)lib/$(LIBJEMALLOC)_pic.$(A) : $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.$(O))
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
ar crus $@ $+
|
ar crus $@ $+
|
||||||
|
|
||||||
$(objroot)lib/libjemalloc$(install_suffix).a : $(CSRCS:$(srcroot)%.c=$(objroot)%.o)
|
$(objroot)lib/$(LIBJEMALLOC).$(A) : $(CSRCS:$(srcroot)%.c=$(objroot)%.$(O))
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
ar crus $@ $+
|
ar crus $@ $+
|
||||||
|
|
||||||
$(objroot)test/%.o: $(srcroot)test/%.c
|
$(objroot)test/%.$(O): $(srcroot)test/%.c
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
$(CC) $(CFLAGS) -c $(CPPFLAGS) -I$(objroot)test -o $@ $<
|
$(CC) $(CFLAGS) -c $(CPPFLAGS) -I$(objroot)test -o $@ $<
|
||||||
@$(CC) -MM $(CPPFLAGS) -I$(objroot)test -MT $@ -o $(@:%.o=%.d) $<
|
@$(CC) -MM $(CPPFLAGS) -I$(objroot)test -MT $@ -o $(@:%.$(O)=%.d) $<
|
||||||
|
|
||||||
$(objroot)test/%: $(objroot)test/%.o \
|
$(objroot)test/%$(EXE): $(objroot)test/%.$(O) \
|
||||||
$(objroot)lib/libjemalloc$(install_suffix).$(SO)
|
$(objroot)lib/$(LIBJEMALLOC).$(SO)
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
ifneq ($(RPATH), )
|
ifneq ($(RPATH), )
|
||||||
$(CC) -o $@ $< $(RPATH)$(objroot)lib -L$(objroot)lib -ljemalloc$(install_suffix) $(LIBS)
|
$(CC) -o $@ $< $(RPATH)$(objroot)lib -L$(objroot)lib -ljemalloc$(install_suffix) $(LIBS)
|
||||||
@ -174,13 +180,13 @@ done
|
|||||||
|
|
||||||
install_lib_shared: $(DSOS)
|
install_lib_shared: $(DSOS)
|
||||||
install -d $(LIBDIR)
|
install -d $(LIBDIR)
|
||||||
install -m 755 $(objroot)lib/libjemalloc$(install_suffix).$(SO).$(REV) $(LIBDIR)
|
install -m 755 $(objroot)lib/$(LIBJEMALLOC).$(SO).$(REV) $(LIBDIR)
|
||||||
ln -sf libjemalloc$(install_suffix).$(SO).$(REV) $(LIBDIR)/libjemalloc$(install_suffix).$(SO)
|
ln -sf $(LIBJEMALLOC).$(SO).$(REV) $(LIBDIR)/$(LIBJEMALLOC).$(SO)
|
||||||
|
|
||||||
install_lib_static: $(DSOS) $(STATIC_LIBS)
|
install_lib_static: $(DSOS) $(STATIC_LIBS)
|
||||||
install -d $(LIBDIR)
|
install -d $(LIBDIR)
|
||||||
install -m 755 $(objroot)lib/libjemalloc$(install_suffix)_pic.a $(LIBDIR)
|
install -m 755 $(objroot)lib/$(LIBJEMALLOC)_pic.$(A) $(LIBDIR)
|
||||||
install -m 755 $(objroot)lib/libjemalloc$(install_suffix).a $(LIBDIR)
|
install -m 755 $(objroot)lib/$(LIBJEMALLOC).$(A) $(LIBDIR)
|
||||||
|
|
||||||
install_lib: install_lib_shared install_lib_static
|
install_lib: install_lib_shared install_lib_static
|
||||||
|
|
||||||
@ -202,7 +208,7 @@ install_doc: install_doc_html install_doc_man
|
|||||||
|
|
||||||
install: install_bin install_include install_lib install_doc
|
install: install_bin install_include install_lib install_doc
|
||||||
|
|
||||||
tests: $(CTESTS:$(srcroot)%.c=$(objroot)%)
|
tests: $(CTESTS:$(srcroot)%.c=$(objroot)%$(EXE))
|
||||||
|
|
||||||
check: tests
|
check: tests
|
||||||
@mkdir -p $(objroot)test
|
@mkdir -p $(objroot)test
|
||||||
@ -212,7 +218,7 @@ check: tests
|
|||||||
for t in $(CTESTS:$(srcroot)%.c=$(objroot)%); do \
|
for t in $(CTESTS:$(srcroot)%.c=$(objroot)%); do \
|
||||||
total=`expr $$total + 1`; \
|
total=`expr $$total + 1`; \
|
||||||
/bin/echo -n "$${t} ... "; \
|
/bin/echo -n "$${t} ... "; \
|
||||||
$(TEST_LIBRARY_PATH) $${t} $(abs_srcroot) $(abs_objroot) \
|
$(TEST_LIBRARY_PATH) $${t}$(EXE) $(abs_srcroot) $(abs_objroot) \
|
||||||
> $(objroot)$${t}.out 2>&1; \
|
> $(objroot)$${t}.out 2>&1; \
|
||||||
if test -e "$(srcroot)$${t}.exp"; then \
|
if test -e "$(srcroot)$${t}.exp"; then \
|
||||||
diff -w -u $(srcroot)$${t}.exp \
|
diff -w -u $(srcroot)$${t}.exp \
|
||||||
@ -233,12 +239,12 @@ check: tests
|
|||||||
echo "Failures: $${failures}/$${total}"'
|
echo "Failures: $${failures}/$${total}"'
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(CSRCS:$(srcroot)%.c=$(objroot)%.o)
|
rm -f $(CSRCS:$(srcroot)%.c=$(objroot)%.$(O))
|
||||||
rm -f $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.o)
|
rm -f $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.$(O))
|
||||||
rm -f $(CSRCS:$(srcroot)%.c=$(objroot)%.d)
|
rm -f $(CSRCS:$(srcroot)%.c=$(objroot)%.d)
|
||||||
rm -f $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.d)
|
rm -f $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.d)
|
||||||
rm -f $(CTESTS:$(srcroot)%.c=$(objroot)%)
|
rm -f $(CTESTS:$(srcroot)%.c=$(objroot)%$(EXE))
|
||||||
rm -f $(CTESTS:$(srcroot)%.c=$(objroot)%.o)
|
rm -f $(CTESTS:$(srcroot)%.c=$(objroot)%.$(O))
|
||||||
rm -f $(CTESTS:$(srcroot)%.c=$(objroot)%.d)
|
rm -f $(CTESTS:$(srcroot)%.c=$(objroot)%.d)
|
||||||
rm -f $(CTESTS:$(srcroot)%.c=$(objroot)%.out)
|
rm -f $(CTESTS:$(srcroot)%.c=$(objroot)%.out)
|
||||||
rm -f $(DSOS) $(STATIC_LIBS)
|
rm -f $(DSOS) $(STATIC_LIBS)
|
||||||
|
@ -195,6 +195,10 @@ AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT])
|
|||||||
|
|
||||||
LD_PRELOAD_VAR="LD_PRELOAD"
|
LD_PRELOAD_VAR="LD_PRELOAD"
|
||||||
so="so"
|
so="so"
|
||||||
|
o="o"
|
||||||
|
a="a"
|
||||||
|
exe=
|
||||||
|
lib="lib"
|
||||||
|
|
||||||
dnl Heap profiling uses the log(3) function.
|
dnl Heap profiling uses the log(3) function.
|
||||||
LIBS="$LIBS -lm"
|
LIBS="$LIBS -lm"
|
||||||
@ -277,6 +281,10 @@ AC_SUBST([abi])
|
|||||||
AC_SUBST([RPATH])
|
AC_SUBST([RPATH])
|
||||||
AC_SUBST([LD_PRELOAD_VAR])
|
AC_SUBST([LD_PRELOAD_VAR])
|
||||||
AC_SUBST([so])
|
AC_SUBST([so])
|
||||||
|
AC_SUBST([o])
|
||||||
|
AC_SUBST([a])
|
||||||
|
AC_SUBST([exe])
|
||||||
|
AC_SUBST([lib])
|
||||||
|
|
||||||
JE_COMPILABLE([__attribute__ syntax],
|
JE_COMPILABLE([__attribute__ syntax],
|
||||||
[static __attribute__((unused)) void foo(void){}],
|
[static __attribute__((unused)) void foo(void){}],
|
||||||
|
Loading…
Reference in New Issue
Block a user