mirror of
git://sourceware.org/git/glibc.git
synced 2024-12-09 04:11:27 +08:00
9cd4747089
The current scheme to identify which module a translation unit is built in depends on defining multiple macros IS_IN_* and also defining NOT_IN_libc if we're building a non-libc module. In addition, there is an IN_LIB macro that does effectively the same thing, but for different modules (notably the systemtap probes). This macro scheme unifies both ideas to use just one macro IN_MODULE and assign it a value depending on the module it is being built into. If the module is not defined, it defaults to MODULE_libc. Patches that follow will replace uses of IS_IN_* variables with the IS_IN() macro. libc-symbols.h has been converted already to give an example of how such a transition will look. Verified that there are no relevant binary changes. One source change that will crop up repeatedly is that of nscd_stat, since it uses the build timestamp as a constant in its logic. * Makeconfig (in-module): Get value of libof set for the translation unit. (CPPFLAGS): Use $(in-module). * Makerules: Don't suffix routine names for nonlib. * include/libc-modules.h: New file. * include/libc-symbols.h: Include libc-modules.h (IS_IN): New macro to replace IS_IN_* macros. * elf/Makefile: Set libof-* for each routine. * elf/rtld-Rules: Likewise. * extra-modules.mk: Likewise. * iconv/Makefile: Likewise. * iconvdata/Makefile: Likewise. * locale/Makefile: Likewise. * malloc/Makefile: Likewise. * nss/Makefile: Likewise. * sysdeps/gnu/Makefile: Likewise. * sysdeps/ieee754/ldbl-opt/Makefile: Likewise. * sysdeps/unix/sysv/linux/Makefile: Likewise. * sysdeps/s390/s390-64/Makefile: Likewise. * nscd/Makefile: Set libof-* for each routine. Set CFLAGS and CPPFLAGS for nscd instead of nonlib.
161 lines
4.8 KiB
Makefile
161 lines
4.8 KiB
Makefile
# Copyright (C) 1991-2014 Free Software Foundation, Inc.
|
|
# This file is part of the GNU C Library.
|
|
|
|
# The GNU C Library is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
# License as published by the Free Software Foundation; either
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
# The GNU C Library is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# Lesser General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
# License along with the GNU C Library; if not, see
|
|
# <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
# Makefile for malloc routines
|
|
#
|
|
subdir := malloc
|
|
|
|
include ../Makeconfig
|
|
|
|
dist-headers := malloc.h
|
|
headers := $(dist-headers) obstack.h mcheck.h
|
|
tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
|
|
tst-mallocstate tst-mcheck tst-mallocfork tst-trim1 \
|
|
tst-malloc-usable tst-realloc tst-posix_memalign \
|
|
tst-pvalloc tst-memalign tst-mallopt
|
|
test-srcs = tst-mtrace
|
|
|
|
routines = malloc morecore mcheck mtrace obstack
|
|
|
|
install-lib := libmcheck.a
|
|
non-lib.a := libmcheck.a
|
|
|
|
# Additional library.
|
|
extra-libs = libmemusage
|
|
extra-libs-others = $(extra-libs)
|
|
|
|
libmemusage-routines = memusage
|
|
libmemusage-inhibit-o = $(filter-out .os,$(object-suffixes))
|
|
|
|
# These should be removed by `make clean'.
|
|
extra-objs = mcheck-init.o libmcheck.a
|
|
|
|
# Include the cleanup handler.
|
|
aux := set-freeres thread-freeres
|
|
|
|
CPPFLAGS-memusagestat = -DNOT_IN_libc
|
|
|
|
# The Perl script to analyze the output of the mtrace functions.
|
|
ifneq ($(PERL),no)
|
|
install-bin-script = mtrace
|
|
generated += mtrace
|
|
|
|
# The Perl script will print addresses and to do this nicely we must know
|
|
# whether we are on a 32 or 64 bit machine.
|
|
ifneq ($(findstring wordsize-32,$(config-sysdirs)),)
|
|
address-width=10
|
|
else
|
|
address-width=18
|
|
endif
|
|
endif
|
|
|
|
# Unless we get a test for the availability of libgd which also works
|
|
# for cross-compiling we disable the memusagestat generation in this
|
|
# situation.
|
|
ifneq ($(cross-compiling),yes)
|
|
# If the gd library is available we build the `memusagestat' program.
|
|
ifneq ($(LIBGD),no)
|
|
others: $(objpfx)memusage
|
|
install-bin = memusagestat
|
|
install-bin-script += memusage
|
|
generated += memusagestat memusage
|
|
extra-objs += memusagestat.o
|
|
|
|
# The configure.ac check for libgd and its headers did not use $SYSINCLUDES.
|
|
# The directory specified by --with-headers usually contains only the basic
|
|
# kernel interface headers, not something like libgd. So the simplest thing
|
|
# is to presume that the standard system headers will be ok for this file.
|
|
$(objpfx)memusagestat.o: sysincludes = # nothing
|
|
endif
|
|
endif
|
|
|
|
# Another goal which can be used to override the configure decision.
|
|
.PHONY: do-memusagestat
|
|
do-memusagestat: $(objpfx)memusagestat
|
|
|
|
memusagestat-modules = memusagestat
|
|
|
|
cpp-srcs-left := $(memusagestat-modules)
|
|
lib := memusagestat
|
|
include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
|
|
|
|
$(objpfx)memusagestat: $(memusagestat-modules:%=$(objpfx)%.o)
|
|
$(LINK.o) -o $@ $^ $(libgd-LDFLAGS) -lgd -lpng -lz -lm
|
|
|
|
ifeq ($(run-built-tests),yes)
|
|
ifeq (yes,$(build-shared))
|
|
ifneq ($(PERL),no)
|
|
tests-special += $(objpfx)tst-mtrace.out
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
include ../Rules
|
|
|
|
CFLAGS-mcheck-init.c = $(PIC-ccflag)
|
|
CFLAGS-obstack.c = $(uses-callbacks)
|
|
|
|
$(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
|
|
-rm -f $@
|
|
$(patsubst %/,cd % &&,$(objpfx)) \
|
|
$(LN_S) $(<F) $(@F)
|
|
|
|
lib: $(objpfx)libmcheck.a
|
|
|
|
ifeq ($(run-built-tests),yes)
|
|
ifeq (yes,$(build-shared))
|
|
ifneq ($(PERL),no)
|
|
$(objpfx)tst-mtrace.out: tst-mtrace.sh $(objpfx)tst-mtrace
|
|
$(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
|
|
'$(run-program-env)' '$(test-program-prefix-after-env)' ; \
|
|
$(evaluate-test)
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
tst-mcheck-ENV = MALLOC_CHECK_=3
|
|
tst-malloc-usable-ENV = MALLOC_CHECK_=3
|
|
|
|
# Uncomment this for test releases. For public releases it is too expensive.
|
|
#CPPFLAGS-malloc.o += -DMALLOC_DEBUG=1
|
|
|
|
sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')
|
|
|
|
$(objpfx)mtrace: mtrace.pl
|
|
rm -f $@.new
|
|
sed -e 's|@PERL@|$(PERL)|' -e 's|@XXX@|$(address-width)|' \
|
|
-e 's|@VERSION@|$(version)|' \
|
|
-e 's|@PKGVERSION@|$(PKGVERSION)|' \
|
|
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \
|
|
&& rm -f $@ && mv $@.new $@ && chmod +x $@
|
|
|
|
$(objpfx)memusage: memusage.sh
|
|
rm -f $@.new
|
|
sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
|
|
-e 's|@SLIBDIR@|$(sLIBdir)|' -e 's|@BINDIR@|$(bindir)|' \
|
|
-e 's|@PKGVERSION@|$(PKGVERSION)|' \
|
|
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \
|
|
&& rm -f $@ && mv $@.new $@ && chmod +x $@
|
|
|
|
|
|
# The implementation uses `dlsym'
|
|
$(objpfx)libmemusage.so: $(libdl)
|
|
|
|
# Extra dependencies
|
|
$(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c
|