michael@0: # Clear out all vpaths, then set just one (default vpath) for the main build michael@0: # directory. michael@0: vpath michael@0: vpath % . michael@0: michael@0: # Clear the default suffixes, so that built-in rules are not used. michael@0: .SUFFIXES : michael@0: michael@0: SHELL := /bin/sh michael@0: michael@0: CC := @CC@ michael@0: michael@0: # Configuration parameters. michael@0: DESTDIR = michael@0: BINDIR := $(DESTDIR)@BINDIR@ michael@0: INCLUDEDIR := $(DESTDIR)@INCLUDEDIR@ michael@0: LIBDIR := $(DESTDIR)@LIBDIR@ michael@0: DATADIR := $(DESTDIR)@DATADIR@ michael@0: MANDIR := $(DESTDIR)@MANDIR@ michael@0: srcroot := @srcroot@ michael@0: objroot := @objroot@ michael@0: abs_srcroot := @abs_srcroot@ michael@0: abs_objroot := @abs_objroot@ michael@0: michael@0: # Build parameters. michael@0: CPPFLAGS := @CPPFLAGS@ -I$(srcroot)include -I$(objroot)include michael@0: CFLAGS := @CFLAGS@ michael@0: LDFLAGS := @LDFLAGS@ michael@0: EXTRA_LDFLAGS := @EXTRA_LDFLAGS@ michael@0: LIBS := @LIBS@ michael@0: RPATH_EXTRA := @RPATH_EXTRA@ michael@0: SO := @so@ michael@0: IMPORTLIB := @importlib@ michael@0: O := @o@ michael@0: A := @a@ michael@0: EXE := @exe@ michael@0: LIBPREFIX := @libprefix@ michael@0: REV := @rev@ michael@0: install_suffix := @install_suffix@ michael@0: ABI := @abi@ michael@0: XSLTPROC := @XSLTPROC@ michael@0: AUTOCONF := @AUTOCONF@ michael@0: _RPATH = @RPATH@ michael@0: RPATH = $(if $(1),$(call _RPATH,$(1))) michael@0: cfghdrs_in := @cfghdrs_in@ michael@0: cfghdrs_out := @cfghdrs_out@ michael@0: cfgoutputs_in := @cfgoutputs_in@ michael@0: cfgoutputs_out := @cfgoutputs_out@ michael@0: enable_autogen := @enable_autogen@ michael@0: enable_experimental := @enable_experimental@ michael@0: DSO_LDFLAGS = @DSO_LDFLAGS@ michael@0: SOREV = @SOREV@ michael@0: PIC_CFLAGS = @PIC_CFLAGS@ michael@0: CTARGET = @CTARGET@ michael@0: LDTARGET = @LDTARGET@ michael@0: MKLIB = @MKLIB@ michael@0: CC_MM = @CC_MM@ michael@0: michael@0: ifeq (macho, $(ABI)) michael@0: TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH="$(objroot)lib" michael@0: else michael@0: ifeq (pecoff, $(ABI)) michael@0: TEST_LIBRARY_PATH := PATH="$(PATH):$(objroot)lib" michael@0: else michael@0: TEST_LIBRARY_PATH := michael@0: endif michael@0: endif michael@0: michael@0: LIBJEMALLOC := $(LIBPREFIX)jemalloc$(install_suffix) michael@0: michael@0: # Lists of files. michael@0: BINS := $(srcroot)bin/pprof $(objroot)bin/jemalloc.sh michael@0: CHDRS := $(objroot)include/jemalloc/jemalloc$(install_suffix).h \ michael@0: $(objroot)include/jemalloc/jemalloc_defs$(install_suffix).h michael@0: CSRCS := $(srcroot)src/jemalloc.c $(srcroot)src/arena.c $(srcroot)src/atomic.c \ michael@0: $(srcroot)src/base.c $(srcroot)src/bitmap.c $(srcroot)src/chunk.c \ michael@0: $(srcroot)src/chunk_dss.c $(srcroot)src/chunk_mmap.c \ michael@0: $(srcroot)src/ckh.c $(srcroot)src/ctl.c $(srcroot)src/extent.c \ michael@0: $(srcroot)src/hash.c $(srcroot)src/huge.c $(srcroot)src/mb.c \ michael@0: $(srcroot)src/mutex.c $(srcroot)src/prof.c $(srcroot)src/quarantine.c \ michael@0: $(srcroot)src/rtree.c $(srcroot)src/stats.c $(srcroot)src/tcache.c \ michael@0: $(srcroot)src/util.c $(srcroot)src/tsd.c michael@0: ifeq (macho, $(ABI)) michael@0: CSRCS += $(srcroot)src/zone.c michael@0: endif michael@0: ifeq ($(IMPORTLIB),$(SO)) michael@0: STATIC_LIBS := $(objroot)lib/$(LIBJEMALLOC).$(A) michael@0: endif michael@0: ifdef PIC_CFLAGS michael@0: STATIC_LIBS += $(objroot)lib/$(LIBJEMALLOC)_pic.$(A) michael@0: else michael@0: STATIC_LIBS += $(objroot)lib/$(LIBJEMALLOC)_s.$(A) michael@0: endif michael@0: DSOS := $(objroot)lib/$(LIBJEMALLOC).$(SOREV) michael@0: ifneq ($(SOREV),$(SO)) michael@0: DSOS += $(objroot)lib/$(LIBJEMALLOC).$(SO) michael@0: endif michael@0: MAN3 := $(objroot)doc/jemalloc$(install_suffix).3 michael@0: DOCS_XML := $(objroot)doc/jemalloc$(install_suffix).xml michael@0: DOCS_HTML := $(DOCS_XML:$(objroot)%.xml=$(srcroot)%.html) michael@0: DOCS_MAN3 := $(DOCS_XML:$(objroot)%.xml=$(srcroot)%.3) michael@0: DOCS := $(DOCS_HTML) $(DOCS_MAN3) michael@0: CTESTS := $(srcroot)test/aligned_alloc.c $(srcroot)test/allocated.c \ michael@0: $(srcroot)test/ALLOCM_ARENA.c $(srcroot)test/bitmap.c \ michael@0: $(srcroot)test/mremap.c $(srcroot)test/posix_memalign.c \ michael@0: $(srcroot)test/thread_arena.c $(srcroot)test/thread_tcache_enabled.c michael@0: ifeq ($(enable_experimental), 1) michael@0: CTESTS += $(srcroot)test/allocm.c $(srcroot)test/rallocm.c michael@0: endif michael@0: michael@0: COBJS := $(CSRCS:$(srcroot)%.c=$(objroot)%.$(O)) michael@0: CPICOBJS := $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.$(O)) michael@0: CTESTOBJS := $(CTESTS:$(srcroot)%.c=$(objroot)%.$(O)) michael@0: michael@0: .PHONY: all dist doc_html doc_man doc michael@0: .PHONY: install_bin install_include install_lib michael@0: .PHONY: install_html install_man install_doc install michael@0: .PHONY: tests check clean distclean relclean michael@0: michael@0: .SECONDARY : $(CTESTOBJS) michael@0: michael@0: # Default target. michael@0: all: build michael@0: michael@0: dist: build_doc michael@0: michael@0: $(srcroot)doc/%.html : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/html.xsl michael@0: $(XSLTPROC) -o $@ $(objroot)doc/html.xsl $< michael@0: michael@0: $(srcroot)doc/%.3 : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/manpages.xsl michael@0: $(XSLTPROC) -o $@ $(objroot)doc/manpages.xsl $< michael@0: michael@0: build_doc_html: $(DOCS_HTML) michael@0: build_doc_man: $(DOCS_MAN3) michael@0: build_doc: $(DOCS) michael@0: michael@0: # michael@0: # Include generated dependency files. michael@0: # michael@0: ifdef CC_MM michael@0: -include $(COBJS:%.$(O)=%.d) michael@0: -include $(CPICOBJS:%.$(O)=%.d) michael@0: -include $(CTESTOBJS:%.$(O)=%.d) michael@0: endif michael@0: michael@0: $(COBJS): $(objroot)src/%.$(O): $(srcroot)src/%.c michael@0: $(CPICOBJS): $(objroot)src/%.pic.$(O): $(srcroot)src/%.c michael@0: $(CPICOBJS): CFLAGS += $(PIC_CFLAGS) michael@0: $(CTESTOBJS): $(objroot)test/%.$(O): $(srcroot)test/%.c michael@0: $(CTESTOBJS): CPPFLAGS += -I$(objroot)test michael@0: ifneq ($(IMPORTLIB),$(SO)) michael@0: $(COBJS): CPPFLAGS += -DDLLEXPORT michael@0: endif michael@0: michael@0: ifndef CC_MM michael@0: # Dependencies michael@0: HEADER_DIRS = $(srcroot)include/jemalloc/internal \ michael@0: $(objroot)include/jemalloc $(objroot)include/jemalloc/internal michael@0: HEADERS = $(wildcard $(foreach dir,$(HEADER_DIRS),$(dir)/*.h)) michael@0: $(COBJS) $(CPICOBJS) $(CTESTOBJS): $(HEADERS) michael@0: $(CTESTOBJS): $(objroot)test/jemalloc_test.h michael@0: endif michael@0: michael@0: $(COBJS) $(CPICOBJS) $(CTESTOBJS): %.$(O): michael@0: @mkdir -p $(@D) michael@0: $(CC) $(CFLAGS) -c $(CPPFLAGS) $(CTARGET) $< michael@0: ifdef CC_MM michael@0: @$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $< michael@0: endif michael@0: michael@0: ifneq ($(SOREV),$(SO)) michael@0: %.$(SO) : %.$(SOREV) michael@0: @mkdir -p $(@D) michael@0: ln -sf $( $(objroot)$${t}.out 2>&1; \ michael@0: if test -e "$(srcroot)$${t}.exp"; then \ michael@0: diff -w -u $(srcroot)$${t}.exp \ michael@0: $(objroot)$${t}.out >/dev/null 2>&1; \ michael@0: fail=$$?; \ michael@0: if test "$${fail}" -eq "1" ; then \ michael@0: failures=`expr $${failures} + 1`; \ michael@0: echo "*** FAIL ***"; \ michael@0: else \ michael@0: echo "pass"; \ michael@0: fi; \ michael@0: else \ michael@0: echo "*** FAIL *** (.exp file is missing)"; \ michael@0: failures=`expr $${failures} + 1`; \ michael@0: fi; \ michael@0: done; \ michael@0: echo "========================================="; \ michael@0: echo "Failures: $${failures}/$${total}"' michael@0: michael@0: clean: michael@0: rm -f $(COBJS) michael@0: rm -f $(CPICOBJS) michael@0: rm -f $(COBJS:%.$(O)=%.d) michael@0: rm -f $(CPICOBJS:%.$(O)=%.d) michael@0: rm -f $(CTESTOBJS:%.$(O)=%$(EXE)) michael@0: rm -f $(CTESTOBJS) michael@0: rm -f $(CTESTOBJS:%.$(O)=%.d) michael@0: rm -f $(CTESTOBJS:%.$(O)=%.out) michael@0: rm -f $(DSOS) $(STATIC_LIBS) michael@0: michael@0: distclean: clean michael@0: rm -rf $(objroot)autom4te.cache michael@0: rm -f $(objroot)config.log michael@0: rm -f $(objroot)config.status michael@0: rm -f $(objroot)config.stamp michael@0: rm -f $(cfghdrs_out) michael@0: rm -f $(cfgoutputs_out) michael@0: michael@0: relclean: distclean michael@0: rm -f $(objroot)configure michael@0: rm -f $(srcroot)VERSION michael@0: rm -f $(DOCS_HTML) michael@0: rm -f $(DOCS_MAN3) michael@0: michael@0: #=============================================================================== michael@0: # Re-configuration rules. michael@0: michael@0: ifeq ($(enable_autogen), 1) michael@0: $(srcroot)configure : $(srcroot)configure.ac michael@0: cd ./$(srcroot) && $(AUTOCONF) michael@0: michael@0: $(objroot)config.status : $(srcroot)configure michael@0: ./$(objroot)config.status --recheck michael@0: michael@0: $(srcroot)config.stamp.in : $(srcroot)configure.ac michael@0: echo stamp > $(srcroot)config.stamp.in michael@0: michael@0: $(objroot)config.stamp : $(cfgoutputs_in) $(cfghdrs_in) $(srcroot)configure michael@0: ./$(objroot)config.status michael@0: @touch $@ michael@0: michael@0: # There must be some action in order for make to re-read Makefile when it is michael@0: # out of date. michael@0: $(cfgoutputs_out) $(cfghdrs_out) : $(objroot)config.stamp michael@0: @true michael@0: endif