Add the --with-install-suffix configure option.

Fix some bugs in the Makefile's install target.
This commit is contained in:
Jason Evans 2010-01-17 01:49:20 -08:00
parent bbaaecb729
commit b0fd5016db
33 changed files with 161 additions and 95 deletions

4
.gitignore vendored
View File

@ -8,5 +8,9 @@
/jemalloc/doc/jemalloc.3
/jemalloc/lib/
/jemalloc/Makefile
/jemalloc/src/internal/jemalloc_internal\.h
/jemalloc/src/internal/mtrgraph_defs\.h
/jemalloc/src/internal/mtrplay_defs\.h
/jemalloc/src/jemalloc\.h
/jemalloc/src/jemalloc_defs\.h
/jemalloc/src/*.[od]

View File

@ -31,6 +31,11 @@ any of the following arguments (not a definitive list) to 'configure':
becomes <prefix>malloc(). This makes it possible to use jemalloc at the
same time as the system allocator.
--with-install-suffix=<suffix>
Append <suffix> to the base name of all installed files, such that multiple
versions of jemalloc can coexist in the same installation directory. For
example, libjemalloc.so.0 becomes libjemalloc<suffix>.so.0.
--enable-debug
Enable assertions and validation code. This incurs a substantial
performance hit, but is very useful during application development.

View File

@ -17,7 +17,7 @@ LIBDIR := @LIBDIR@
MANDIR := @MANDIR@
# Build parameters.
CPPFLAGS := @CPPFLAGS@
CPPFLAGS := @CPPFLAGS@ -I@srcroot@src -I@objroot@src
CFLAGS := @CFLAGS@ -fPIC -DPIC
ifeq (macho, @abi@)
CFLAGS += -dynamic
@ -33,17 +33,19 @@ SO := so
endif
REV := 0
# List of files to be installed.
# Lists of files.
BINS := @bins@
CHDRS := @srcroot@src/jemalloc.h @objroot@src/jemalloc_defs.h
CHDRS := @objroot@src/jemalloc@install_suffix@.h \
@objroot@src/jemalloc_defs@install_suffix@.h
CSRCS := @srcroot@src/jemalloc.c @srcroot@src/jemalloc_arena.c \
@srcroot@src/jemalloc_base.c @srcroot@src/jemalloc_chunk.c \
@srcroot@src/jemalloc_extent.c @srcroot@src/jemalloc_huge.c \
@srcroot@src/jemalloc_mutex.c @srcroot@src/jemalloc_stats.c \
@srcroot@src/jemalloc_tcache.c @srcroot@src/jemalloc_trace.c
DSOS := @objroot@lib/libjemalloc.so.$(REV) @objroot@lib/libjemalloc.so \
@objroot@lib/libjemalloc_pic.a
MAN3 := @objroot@doc/jemalloc.3
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
.PHONY: all dist install check clean distclean relclean
@ -62,16 +64,16 @@ all: $(DSOS) bins
$(DSOS): $(CSRCS:@srcroot@%.c=@objroot@%.o)
@mkdir -p $(@D)
$(CC) -shared -o $@ $+ $(LDFLAGS) $(LIBS)
ln -sf libjemalloc.so.$(REV) lib/libjemalloc.so
ar crus @objroot@lib/libjemalloc_pic.a $+
ln -sf libjemalloc@install_suffix@.so.$(REV) lib/libjemalloc@install_suffix@.so
ar crus @objroot@lib/libjemalloc@install_suffix@_pic.a $+
bins: $(BINS)
@objroot@bin/mtrgraph: @objroot@src/mtrgraph.o
@objroot@bin/mtrgraph@install_suffix@: @objroot@src/mtrgraph.o
@mkdir -p $(@D)
$(CC) -o $@ $< $(LDFLAGS) $(LIBS) $(GDLIBS)
@objroot@bin/%: @objroot@src/%.o
@objroot@bin/%@install_suffix@: @objroot@src/%.o
@mkdir -p $(@D)
$(CC) -o $@ $< $(LDFLAGS) $(LIBS)
@ -87,11 +89,10 @@ done
install -m 644 $$h $(INCLUDEDIR); \
done
install -d $(LIBDIR)
@for s in $(DSOS); do \
echo "install -m 755 $$s $(LIBDIR)"; \
install -m 755 $$s $(LIBDIR); \
done
install -d $(MANDIR)
install -m 755 @objroot@lib/libjemalloc@install_suffix@.so.$(REV) $(LIBDIR)
ln -sf libjemalloc@install_suffix@.so.$(REV) $(LIBDIR)/libjemalloc@install_suffix@.so
install -m 755 @objroot@lib/libjemalloc@install_suffix@_pic.a $(LIBDIR)
install -d $(MANDIR)/man3
@for m in $(MAN3); do \
echo "install -m 644 $$m $(MANDIR)/man3"; \
install -m 644 $$m $(MANDIR)/man3; \
@ -112,8 +113,8 @@ distclean: clean
rm -f @objroot@config.status
rm -f @objroot@cfghdrs.stamp
rm -f @objroot@cfgoutputs.stamp
rm -f @cfghdrs@
rm -f @cfgoutputs@
rm -f @cfghdrs_out@
rm -f @cfgoutputs_out@
relclean: distclean
rm -rf @objroot@autom4te.cache
@ -133,8 +134,7 @@ ifeq (@enable_autogen@, 1)
@srcroot@cfghdrs.stamp.in : @srcroot@configure.ac
echo stamp > @srcroot@cfghdrs.stamp.in
@objroot@cfghdrs.stamp : $(patsubst %, %.in, @cfghdrs@) \
@srcroot@configure
@objroot@cfghdrs.stamp : @cfghdrs_in@ @srcroot@configure
./@objroot@config.status
@touch $@
@ -144,8 +144,7 @@ ifeq (@enable_autogen@, 1)
@srcroot@cfgoutputs.stamp.in : @srcroot@configure.ac
echo stamp > @srcroot@cfgoutputs.stamp.in
@objroot@cfgoutputs.stamp : $(patsubst %, @srcroot@%.in, @cfgoutputs@) \
@srcroot@configure
@objroot@cfgoutputs.stamp : @cfgoutputs_in@ @srcroot@configure
./@objroot@config.status
@touch $@

View File

@ -80,9 +80,6 @@ MANDIR=`eval echo $mandir`
MANDIR=`eval echo $MANDIR`
AC_SUBST([MANDIR])
cfgoutputs="Makefile doc/jemalloc.3"
cfghdrs="src/jemalloc_defs.h"
dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise,
dnl just prevent autoconf from molesting CFLAGS.
CFLAGS=$CFLAGS
@ -246,20 +243,49 @@ AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH])
dnl Do not prefix public APIs by default.
AC_ARG_WITH([jemalloc_prefix],
[AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
if test "x$with_jemalloc_prefix" = "xno" ; then
JEMALLOC_PREFIX=
else
JEMALLOC_PREFIX="$with_jemalloc_prefix"
fi,
JEMALLOC_PREFIX=
[JEMALLOC_PREFIX="$with_jemalloc_prefix"],
[JEMALLOC_PREFIX=]
)
if test "x$JEMALLOC_PREFIX" != "x" ; then
AC_DEFINE([JEMALLOC_PREFIX], [ ])
jemalloc_prefix=$JEMALLOC_PREFIX
jemalloc_prefix="$JEMALLOC_PREFIX"
AC_SUBST([jemalloc_prefix])
AC_DEFINE_UNQUOTED([JEMALLOC_P(string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix)], [${JEMALLOC_PREFIX}##string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix])
fi
dnl Do not add suffix to installed files by default.
AC_ARG_WITH([install_suffix],
[AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
[INSTALL_SUFFIX="$with_install_suffix"],
[INSTALL_SUFFIX=]
)
install_suffix="$INSTALL_SUFFIX"
AC_SUBST([install_suffix])
cfgoutputs_in="Makefile doc/jemalloc.3.in"
cfgoutputs_in="${cfgoutputs_in} src/jemalloc.h.in"
cfgoutputs_in="${cfgoutputs_in} src/internal/jemalloc_internal.h.in"
cfgoutputs_out="Makefile doc/jemalloc${install_suffix}.3"
cfgoutputs_out="${cfgoutputs_out} src/jemalloc${install_suffix}.h"
cfgoutputs_out="${cfgoutputs_out} src/internal/jemalloc_internal.h"
cfgoutputs_tup="Makefile doc/jemalloc${install_suffix}.3:doc/jemalloc.3.in"
cfgoutputs_tup="${cfgoutputs_tup} src/jemalloc${install_suffix}.h:src/jemalloc.h.in"
cfgoutputs_tup="${cfgoutputs_tup} src/internal/jemalloc_internal.h"
cfghdrs_in="src/jemalloc_defs.h.in"
cfghdrs_in="${cfghdrs_in} src/internal/mtrgraph_defs.h.in"
cfghdrs_in="${cfghdrs_in} src/internal/mtrplay_defs.h.in"
cfghdrs_out="src/jemalloc_defs${install_suffix}.h"
cfghdrs_out="${cfghdrs_out} src/internal/mtrgraph_defs.h"
cfghdrs_out="${cfghdrs_out} src/internal/mtrplay_defs.h"
cfghdrs_tup="src/jemalloc_defs${install_suffix}.h:src/jemalloc_defs.h.in"
cfghdrs_tup="${cfghdrs_tup} src/internal/mtrgraph_defs.h"
cfghdrs_tup="${cfghdrs_tup} src/internal/mtrplay_defs.h"
dnl Do not compile with debugging by default.
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug], [Build debugging code])],
@ -577,7 +603,8 @@ AC_SUBST([enable_lazy_lock])
dnl ============================================================================
dnl Configure libgd for mtrgraph.
bins="${objroot}bin/jemtr2mtr ${objroot}bin/mtrplay"
bins="${objroot}bin/jemtr2mtr${install_suffix}"
bins="${bins} ${objroot}bin/mtrplay${install_suffix}"
GDLIBS=""
have_libgd="yes"
@ -590,7 +617,7 @@ AC_CHECK_HEADERS([gdfontg.h], , [have_libgd="no"])
AC_CHECK_LIB([gd], [gdImageCreate], [GDLIBS="-lgd"], [have_libgd="no"])
if test "x${have_libgd}" = "xyes" ; then
bins="${bins} ${objroot}bin/mtrgraph"
bins="${bins} ${objroot}bin/mtrgraph${install_suffix}"
fi
AC_SUBST([bins])
AC_SUBST([GDLIBS])
@ -600,13 +627,15 @@ dnl Check for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
dnl Process .in files.
AC_SUBST([cfghdrs])
AC_CONFIG_HEADERS([$cfghdrs cfghdrs.stamp])
AC_SUBST([cfghdrs_in])
AC_SUBST([cfghdrs_out])
AC_CONFIG_HEADERS([$cfghdrs_tup cfghdrs.stamp])
dnl ============================================================================
dnl Generate outputs.
AC_CONFIG_FILES([$cfgoutputs cfgoutputs.stamp])
AC_SUBST([cfgoutputs])
AC_CONFIG_FILES([$cfgoutputs_tup cfgoutputs.stamp])
AC_SUBST([cfgoutputs_in])
AC_SUBST([cfgoutputs_out])
AC_OUTPUT
dnl ============================================================================
@ -636,6 +665,7 @@ AC_MSG_RESULT([])
AC_MSG_RESULT([bins : ${bins}])
AC_MSG_RESULT([])
AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
AC_MSG_RESULT([install_suffix : ${install_suffix}])
AC_MSG_RESULT([autogen : ${enable_autogen}])
AC_MSG_RESULT([debug : ${enable_debug}])
AC_MSG_RESULT([stats : ${enable_stats}])

View File

@ -38,7 +38,7 @@
.\" @(#)malloc.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD: head/lib/libc/stdlib/malloc.3 182225 2008-08-27 02:00:53Z jasone $
.\"
.Dd January 3, 2010
.Dd January 17, 2010
.Dt JEMALLOC 3
.Os
.Sh NAME
@ -46,10 +46,10 @@
@roff_no_tcache@.Nm @jemalloc_prefix@malloc , @jemalloc_prefix@calloc , @jemalloc_prefix@posix_memalign , @jemalloc_prefix@realloc , @jemalloc_prefix@free , @jemalloc_prefix@malloc_usable_size , @jemalloc_prefix@malloc_stats_print
.Nd general purpose memory allocation functions
.Sh LIBRARY
.Lb libjemalloc
.Lb libjemalloc@install_suffix@
.Sh SYNOPSIS
.In stdlib.h
.In jemalloc.h
.In jemalloc@install_suffix@.h
.Ft void *
.Fn @jemalloc_prefix@malloc "size_t size"
.Ft void *

View File

@ -24,16 +24,16 @@
#include <pthread.h>
#define JEMALLOC_MANGLE
#include "jemalloc.h"
#include "../jemalloc@install_suffix@.h"
#ifdef JEMALLOC_LAZY_LOCK
#include <dlfcn.h>
#endif
#include "rb.h"
#include "internal/rb.h"
#if (defined(JEMALLOC_TCACHE) && defined(JEMALLOC_STATS))
#include "qr.h"
#include "ql.h"
#include "internal/qr.h"
#include "internal/ql.h"
#endif
extern void (*JEMALLOC_P(malloc_message))(const char *p1, const char *p2,
@ -168,29 +168,29 @@ extern void (*JEMALLOC_P(malloc_message))(const char *p1, const char *p2,
#define PAGE_CEILING(s) \
(((s) + PAGE_MASK) & ~PAGE_MASK)
#include "jemalloc_stats.h"
#include "jemalloc_mutex.h"
#include "jemalloc_extent.h"
#include "jemalloc_arena.h"
#include "jemalloc_base.h"
#include "jemalloc_chunk.h"
#include "jemalloc_huge.h"
#include "jemalloc_tcache.h"
#include "jemalloc_trace.h"
#include "internal/jemalloc_stats.h"
#include "internal/jemalloc_mutex.h"
#include "internal/jemalloc_extent.h"
#include "internal/jemalloc_arena.h"
#include "internal/jemalloc_base.h"
#include "internal/jemalloc_chunk.h"
#include "internal/jemalloc_huge.h"
#include "internal/jemalloc_tcache.h"
#include "internal/jemalloc_trace.h"
#undef JEMALLOC_H_TYPES
/******************************************************************************/
#define JEMALLOC_H_STRUCTS
#include "jemalloc_stats.h"
#include "jemalloc_mutex.h"
#include "jemalloc_extent.h"
#include "jemalloc_arena.h"
#include "jemalloc_base.h"
#include "jemalloc_chunk.h"
#include "jemalloc_huge.h"
#include "jemalloc_tcache.h"
#include "jemalloc_trace.h"
#include "internal/jemalloc_stats.h"
#include "internal/jemalloc_mutex.h"
#include "internal/jemalloc_extent.h"
#include "internal/jemalloc_arena.h"
#include "internal/jemalloc_base.h"
#include "internal/jemalloc_chunk.h"
#include "internal/jemalloc_huge.h"
#include "internal/jemalloc_tcache.h"
#include "internal/jemalloc_trace.h"
#undef JEMALLOC_H_STRUCTS
/******************************************************************************/
@ -238,26 +238,26 @@ arena_t *arenas_extend(unsigned ind);
arena_t *choose_arena_hard(void);
#endif
#include "jemalloc_stats.h"
#include "jemalloc_mutex.h"
#include "jemalloc_extent.h"
#include "jemalloc_arena.h"
#include "jemalloc_base.h"
#include "jemalloc_chunk.h"
#include "jemalloc_huge.h"
#include "jemalloc_tcache.h"
#include "jemalloc_trace.h"
#include "internal/jemalloc_stats.h"
#include "internal/jemalloc_mutex.h"
#include "internal/jemalloc_extent.h"
#include "internal/jemalloc_arena.h"
#include "internal/jemalloc_base.h"
#include "internal/jemalloc_chunk.h"
#include "internal/jemalloc_huge.h"
#include "internal/jemalloc_tcache.h"
#include "internal/jemalloc_trace.h"
#undef JEMALLOC_H_EXTERNS
/******************************************************************************/
#define JEMALLOC_H_INLINES
#include "jemalloc_stats.h"
#include "jemalloc_mutex.h"
#include "jemalloc_extent.h"
#include "jemalloc_base.h"
#include "jemalloc_chunk.h"
#include "jemalloc_huge.h"
#include "internal/jemalloc_stats.h"
#include "internal/jemalloc_mutex.h"
#include "internal/jemalloc_extent.h"
#include "internal/jemalloc_base.h"
#include "internal/jemalloc_chunk.h"
#include "internal/jemalloc_huge.h"
#ifndef JEMALLOC_ENABLE_INLINE
void malloc_write4(const char *p1, const char *p2, const char *p3,
@ -346,9 +346,9 @@ choose_arena(void)
}
#endif
#include "jemalloc_tcache.h"
#include "jemalloc_arena.h"
#include "jemalloc_trace.h"
#include "internal/jemalloc_tcache.h"
#include "internal/jemalloc_arena.h"
#include "internal/jemalloc_trace.h"
#ifndef JEMALLOC_ENABLE_INLINE
void *imalloc(size_t size);

View File

@ -0,0 +1,14 @@
#ifndef MTRGRAPH_DEFS_H_
#define MTRGRAPH_DEFS_H_
/* Defined if __attribute__((...)) syntax is supported. */
#undef JEMALLOC_HAVE_ATTR
#ifdef JEMALLOC_HAVE_ATTR
# define JEMALLOC_ATTR(s) __attribute__((s))
#else
# define JEMALLOC_ATTR(s)
#endif
#undef JEMALLOC_DEBUG
#endif /* MTRGRAPH_DEFS_H_ */

View File

@ -0,0 +1,14 @@
#ifndef MTRPLAY_DEFS_H_
#define MTRPLAY_DEFS_H_
/* Defined if __attribute__((...)) syntax is supported. */
#undef JEMALLOC_HAVE_ATTR
#ifdef JEMALLOC_HAVE_ATTR
# define JEMALLOC_ATTR(s) __attribute__((s))
#else
# define JEMALLOC_ATTR(s)
#endif
#undef JEMALLOC_DEBUG
#endif /* MTRPLAY_DEFS_H_ */

View File

@ -90,7 +90,7 @@
*/
#define JEMALLOC_C_
#include "jemalloc_internal.h"
#include "internal/jemalloc_internal.h"
/******************************************************************************/
/* Data. */

View File

@ -4,7 +4,7 @@
extern "C" {
#endif
#include "jemalloc_defs.h"
#include "jemalloc_defs@install_suffix@.h"
#ifndef JEMALLOC_P
# define JEMALLOC_P(s) s
#endif

View File

@ -1,5 +1,5 @@
#define JEMALLOC_ARENA_C_
#include "jemalloc_internal.h"
#include "internal/jemalloc_internal.h"
/******************************************************************************/
/* Data. */

View File

@ -1,5 +1,5 @@
#define JEMALLOC_BASE_C_
#include "jemalloc_internal.h"
#include "internal/jemalloc_internal.h"
#ifdef JEMALLOC_STATS
size_t base_mapped;

View File

@ -1,5 +1,5 @@
#define JEMALLOC_CHUNK_C_
#include "jemalloc_internal.h"
#include "internal/jemalloc_internal.h"
/******************************************************************************/
/* Data. */

View File

@ -1,5 +1,5 @@
#define JEMALLOC_EXTENT_C_
#include "jemalloc_internal.h"
#include "internal/jemalloc_internal.h"
/******************************************************************************/

View File

@ -1,5 +1,5 @@
#define JEMALLOC_HUGE_C_
#include "jemalloc_internal.h"
#include "internal/jemalloc_internal.h"
/******************************************************************************/
/* Data. */

View File

@ -1,5 +1,5 @@
#define JEMALLOC_MUTEX_C_
#include "jemalloc_internal.h"
#include "internal/jemalloc_internal.h"
/******************************************************************************/
/* Data. */

View File

@ -1,5 +1,5 @@
#define JEMALLOC_STATS_C_
#include "jemalloc_internal.h"
#include "internal/jemalloc_internal.h"
/******************************************************************************/
/* Data. */

View File

@ -1,5 +1,5 @@
#define JEMALLOC_TCACHE_C_
#include "jemalloc_internal.h"
#include "internal/jemalloc_internal.h"
#ifdef JEMALLOC_TCACHE
/******************************************************************************/
/* Data. */

View File

@ -1,5 +1,5 @@
#define JEMALLOC_TRACE_C_
#include "jemalloc_internal.h"
#include "internal/jemalloc_internal.h"
#ifdef JEMALLOC_TRACE
/******************************************************************************/
/* Data. */

View File

@ -15,12 +15,12 @@
#include <gdfontl.h>
#include <gdfontg.h>
#include "jemalloc.h"
#include "internal/mtrgraph_defs.h"
#ifndef JEMALLOC_DEBUG
# define NDEBUG
#endif
#include <assert.h>
#include "rb.h"
#include "internal/rb.h"
typedef struct
{

View File

@ -16,12 +16,12 @@
#include <sys/mman.h>
#include <sys/types.h>
#include "jemalloc_defs.h"
#include "internal/mtrplay_defs.h"
#ifndef JEMALLOC_DEBUG
# define NDEBUG
#endif
#include <assert.h>
#include "rb.h"
#include "internal/rb.h"
typedef struct record_s record_t;
struct record_s {