|
Packit |
6c4009 |
# Copyright (C) 1991-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
# This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
# modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
# License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
# version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
# Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
# License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
# <http://www.gnu.org/licenses/>.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#
|
|
Packit |
6c4009 |
# Rules for making a subdirectory in the GNU C library.
|
|
Packit |
6c4009 |
# Each subdirectory Makefile defines some variables and includes this.
|
|
Packit |
6c4009 |
#
|
|
Packit |
6c4009 |
ifneq (,)
|
|
Packit |
6c4009 |
This makefile requires GNU Make.
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
all: # Don't let the default goal come from Makeconfig.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
include $(firstword $(..) ../)Makeconfig
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifndef subdir
|
|
Packit |
6c4009 |
Each subdirectory makefile must define the `subdir' variable.
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
# This ` unconfuses emacs.
|
|
Packit |
6c4009 |
# This is benign and useless in GNU make before 3.63.
|
|
Packit |
6c4009 |
export subdir := $(subdir)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# This is the default target; it makes the library and auxiliary programs.
|
|
Packit |
6c4009 |
.PHONY: all
|
|
Packit |
6c4009 |
all: objs lib others
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifeq ($(build-programs),yes)
|
|
Packit |
6c4009 |
others: $(addprefix $(objpfx),$(extra-objs) \
|
|
Packit |
6c4009 |
$(install-lib) \
|
|
Packit |
6c4009 |
$(install-bin) $(install-bin-script) \
|
|
Packit |
6c4009 |
$(install-rootsbin) $(install-sbin))
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
others: $(addprefix $(objpfx),$(extra-objs) \
|
|
Packit |
6c4009 |
$(install-lib))
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq "$(findstring env,$(origin headers))" ""
|
|
Packit |
6c4009 |
headers :=
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq "$(findstring env,$(origin generated))" ""
|
|
Packit |
6c4009 |
generated :=
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq "$(findstring env,$(origin common-generated))" ""
|
|
Packit |
6c4009 |
common-generated :=
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# See below. This must be set before Makerules processes it.
|
|
Packit |
6c4009 |
before-compile += $(common-objpfx)bits/stdio_lim.h
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
include $(..)Makerules
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.PHONY: subdir_lib
|
|
Packit |
6c4009 |
subdir_lib: lib-noranlib
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Some subdirs need to install a dummy library.
|
|
Packit |
6c4009 |
# They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
|
|
Packit |
6c4009 |
dep-dummy-lib = $(common-objpfx)dummy.o
|
|
Packit |
6c4009 |
define make-dummy-lib
|
|
Packit |
6c4009 |
$(AR) cr$(verbose) $@ $<
|
|
Packit |
6c4009 |
endef
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
$(common-objpfx)dummy.c:
|
|
Packit |
6c4009 |
rm -f $@
|
|
Packit |
6c4009 |
(echo 'extern void __dummy__ (void);'; \
|
|
Packit |
6c4009 |
echo 'void __dummy__ (void) { }') > $@
|
|
Packit |
6c4009 |
common-generated += dummy.o dummy.c
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq "$(headers)" ""
|
|
Packit |
6c4009 |
# Special test of all the installed headers in this directory.
|
|
Packit |
6c4009 |
tests-special += $(objpfx)check-installed-headers-c.out
|
|
Packit |
6c4009 |
libof-check-installed-headers-c := testsuite
|
|
Packit |
6c4009 |
$(objpfx)check-installed-headers-c.out: \
|
|
Packit |
6c4009 |
$(..)scripts/check-installed-headers.sh $(headers)
|
|
Packit |
6c4009 |
$(SHELL) $(..)scripts/check-installed-headers.sh c \
|
|
Packit |
6c4009 |
"$(CC) $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \
|
|
Packit |
6c4009 |
$(headers) > $@; \
|
|
Packit |
6c4009 |
$(evaluate-test)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq "$(CXX)" ""
|
|
Packit |
6c4009 |
tests-special += $(objpfx)check-installed-headers-cxx.out
|
|
Packit |
6c4009 |
libof-check-installed-headers-cxx := testsuite
|
|
Packit |
6c4009 |
$(objpfx)check-installed-headers-cxx.out: \
|
|
Packit |
6c4009 |
$(..)scripts/check-installed-headers.sh $(headers)
|
|
Packit |
6c4009 |
$(SHELL) $(..)scripts/check-installed-headers.sh c++ \
|
|
Packit |
6c4009 |
"$(CXX) $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
|
|
Packit |
6c4009 |
$(headers) > $@; \
|
|
Packit |
6c4009 |
$(evaluate-test)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# This makes all the auxiliary and test programs.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.PHONY: others tests bench bench-build
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Test programs for the pretty printers.
|
|
Packit |
6c4009 |
tests-printers-programs := $(addprefix $(objpfx),$(tests-printers))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# .out files with the output of running the pretty printer tests.
|
|
Packit |
6c4009 |
tests-printers-out := $(patsubst %,$(objpfx)%.out,$(tests-printers))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifndef PYTHON
|
|
Packit |
6c4009 |
# Mark tests-printers tests as unsupported if we don't have PYTHON.
|
|
Packit |
6c4009 |
tests-unsupported += $(tests-printers)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifeq ($(build-programs),yes)
|
|
Packit |
6c4009 |
others: $(addprefix $(objpfx),$(others) $(sysdep-others) $(extra-objs))
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
others: $(addprefix $(objpfx),$(extra-objs))
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Generate constant files for Python pretty printers if required.
|
|
Packit |
6c4009 |
others: $(py-const)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifeq ($(run-built-tests),no)
|
|
Packit |
6c4009 |
tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported), \
|
|
Packit |
6c4009 |
$(tests) $(tests-internal)) \
|
|
Packit |
6c4009 |
$(test-srcs)) $(tests-special) \
|
|
Packit |
6c4009 |
$(tests-printers-programs)
|
|
Packit |
6c4009 |
xtests: tests $(xtests-special)
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
tests: $(tests:%=$(objpfx)%.out) $(tests-internal:%=$(objpfx)%.out) \
|
|
Packit |
6c4009 |
$(tests-special) $(tests-printers-out)
|
|
Packit |
6c4009 |
xtests: tests $(xtests:%=$(objpfx)%.out) $(xtests-special)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special))
|
|
Packit |
6c4009 |
xtests-special-notdir = $(patsubst $(objpfx)%, %, $(xtests-special))
|
|
Packit |
6c4009 |
ifeq ($(run-built-tests),no)
|
|
Packit |
6c4009 |
tests-expected =
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
tests-expected = $(tests) $(tests-internal) $(tests-printers)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
tests:
|
|
Packit |
6c4009 |
$(..)scripts/merge-test-results.sh -s $(objpfx) $(subdir) \
|
|
Packit |
6c4009 |
$(sort $(tests-expected) $(tests-special-notdir:.out=)) \
|
|
Packit |
6c4009 |
> $(objpfx)subdir-tests.sum
|
|
Packit |
6c4009 |
xtests:
|
|
Packit |
6c4009 |
$(..)scripts/merge-test-results.sh -s $(objpfx) $(subdir) \
|
|
Packit |
6c4009 |
$(sort $(xtests) $(xtests-special-notdir:.out=)) \
|
|
Packit |
6c4009 |
> $(objpfx)subdir-xtests.sum
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifeq ($(build-programs),yes)
|
|
Packit |
6c4009 |
binaries-all-notests = $(others) $(sysdep-others)
|
|
Packit |
6c4009 |
binaries-all-tests = $(tests) $(tests-internal) $(xtests) $(test-srcs)
|
|
Packit |
6c4009 |
binaries-all = $(binaries-all-notests) $(binaries-all-tests)
|
|
Packit |
6c4009 |
binaries-static-notests = $(others-static)
|
|
Packit |
6c4009 |
binaries-static-tests = $(tests-static) $(xtests-static)
|
|
Packit |
6c4009 |
binaries-static = $(binaries-static-notests) $(binaries-static-tests)
|
|
Packit |
6c4009 |
ifeq (yesyes,$(have-fpie)$(build-shared))
|
|
Packit |
6c4009 |
binaries-pie-tests = $(tests-pie) $(xtests-pie)
|
|
Packit |
6c4009 |
binaries-pie-notests = $(others-pie)
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
binaries-pie-tests =
|
|
Packit |
6c4009 |
binaries-pie-notests =
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
binaries-all-notests =
|
|
Packit |
6c4009 |
binaries-all-tests = $(tests) $(tests-internal) $(xtests) $(test-srcs)
|
|
Packit |
6c4009 |
binaries-all = $(binaries-all-tests)
|
|
Packit |
6c4009 |
binaries-static-notests =
|
|
Packit |
6c4009 |
binaries-static-tests =
|
|
Packit |
6c4009 |
binaries-static =
|
|
Packit |
6c4009 |
binaries-pie-tests =
|
|
Packit |
6c4009 |
binaries-pie-notests =
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
binaries-pie = $(binaries-pie-tests) $(binaries-pie-notests)
|
|
Packit |
6c4009 |
binaries-shared-tests = $(filter-out $(binaries-pie) $(binaries-static), \
|
|
Packit |
6c4009 |
$(binaries-all-tests))
|
|
Packit |
6c4009 |
binaries-shared-notests = $(filter-out $(binaries-pie) $(binaries-static), \
|
|
Packit |
6c4009 |
$(binaries-all-notests))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq "$(strip $(binaries-shared-notests))" ""
|
|
Packit |
6c4009 |
$(addprefix $(objpfx),$(binaries-shared-notests)): %: %.o \
|
|
Packit |
6c4009 |
$(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
|
|
Packit |
6c4009 |
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
|
|
Packit |
6c4009 |
$(+link)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq "$(strip $(binaries-shared-tests))" ""
|
|
Packit |
6c4009 |
$(addprefix $(objpfx),$(binaries-shared-tests)): %: %.o \
|
|
Packit |
6c4009 |
$(link-extra-libs-tests) \
|
|
Packit |
6c4009 |
$(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
|
|
Packit |
6c4009 |
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
|
|
Packit |
6c4009 |
$(+link-tests)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq "$(strip $(binaries-pie-tests))" ""
|
|
Packit |
6c4009 |
$(addprefix $(objpfx),$(binaries-pie-tests)): %: %.o \
|
|
Packit |
6c4009 |
$(link-extra-libs-tests) \
|
|
Packit |
6c4009 |
$(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
|
|
Packit |
6c4009 |
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
|
|
Packit |
6c4009 |
$(+link-pie-tests)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq "$(strip $(binaries-pie-notests))" ""
|
|
Packit |
6c4009 |
$(addprefix $(objpfx),$(binaries-pie-notests)): %: %.o \
|
|
Packit |
6c4009 |
$(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
|
|
Packit |
6c4009 |
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
|
|
Packit |
6c4009 |
$(+link-pie)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq "$(strip $(binaries-static-notests))" ""
|
|
Packit |
6c4009 |
$(addprefix $(objpfx),$(binaries-static-notests)): %: %.o \
|
|
Packit |
6c4009 |
$(sort $(filter $(common-objpfx)lib%,$(link-libc-static))) \
|
|
Packit |
6c4009 |
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
|
|
Packit |
6c4009 |
$(+link-static)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq "$(strip $(binaries-static-tests))" ""
|
|
Packit |
6c4009 |
$(addprefix $(objpfx),$(binaries-static-tests)): %: %.o \
|
|
Packit |
6c4009 |
$(link-extra-libs-tests) \
|
|
Packit |
6c4009 |
$(sort $(filter $(common-objpfx)lib%,$(link-libc-static-tests))) \
|
|
Packit |
6c4009 |
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
|
|
Packit |
6c4009 |
$(+link-static-tests)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq "$(strip $(tests) $(tests-internal) $(xtests) $(test-srcs))" ""
|
|
Packit |
6c4009 |
# These are the implicit rules for making test outputs
|
|
Packit |
6c4009 |
# from the test programs and whatever input files are present.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
define make-test-out
|
|
Packit |
6c4009 |
$(if $($*-ENV-only),$(test-wrapper-env-only) $($*-ENV-only),\
|
|
Packit |
6c4009 |
$(test-wrapper-env) $(run-program-env) $($*-ENV)) \
|
|
Packit |
6c4009 |
$(host-test-program-cmd) $($*-ARGS)
|
|
Packit |
6c4009 |
endef
|
|
Packit |
6c4009 |
$(objpfx)%.out: %.input $(objpfx)%
|
|
Packit |
6c4009 |
$(make-test-out) > $@ < $(word 1,$^); \
|
|
Packit |
6c4009 |
$(evaluate-test)
|
|
Packit |
6c4009 |
$(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
|
|
Packit |
6c4009 |
$(make-test-out) > $@; \
|
|
Packit |
6c4009 |
$(evaluate-test)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# tests-unsupported lists tests that we will not try to build at all in
|
|
Packit |
6c4009 |
# this configuration. Note this runs every time because it does not
|
|
Packit |
6c4009 |
# actually create its target. The dependency on Makefile is meant to
|
|
Packit |
6c4009 |
# ensure that it runs after a Makefile change to add a test to the list
|
|
Packit |
6c4009 |
# when it previously ran and produced a .out file (probably for a failure).
|
|
Packit |
6c4009 |
ifneq "$(strip $(tests-unsupported))" ""
|
|
Packit |
6c4009 |
$(tests-unsupported:%=$(objpfx)%.out): $(objpfx)%.out: Makefile
|
|
Packit |
6c4009 |
@rm -f $@
|
|
Packit |
6c4009 |
$(..)scripts/evaluate-test.sh $(patsubst $(common-objpfx)%.out,%,$@) \
|
|
Packit |
6c4009 |
77 false false > $(@:.out=.test-result)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
endif # tests
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifdef PYTHON
|
|
Packit |
6c4009 |
ifneq "$(strip $(tests-printers))" ""
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Static pattern rule for building the test programs for the pretty printers.
|
|
Packit |
6c4009 |
$(tests-printers-programs): %: %.o $(tests-printers-libs) \
|
|
Packit |
6c4009 |
$(sort $(filter $(common-objpfx)lib%,$(link-libc-static-tests))) \
|
|
Packit |
6c4009 |
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
|
|
Packit |
6c4009 |
$(+link-printers-tests)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Add the paths to the generated constants file and test_common_printers.py
|
|
Packit |
6c4009 |
# to PYTHONPATH so the test scripts can find them.
|
|
Packit |
6c4009 |
py-env := PYTHONPATH=$(py-const-dir):$(..)scripts:$${PYTHONPATH}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Static pattern rule that matches the test-* targets to their .c and .py
|
|
Packit |
6c4009 |
# prerequisites. It'll run the corresponding test script for each test program
|
|
Packit |
6c4009 |
# we compiled and place its output in the corresponding .out file.
|
|
Packit |
6c4009 |
# The pretty printer files and test_common_printers.py must be present for all.
|
|
Packit |
6c4009 |
$(tests-printers-out): $(objpfx)%.out: $(objpfx)% %.py %.c $(pretty-printers) \
|
|
Packit |
6c4009 |
$(..)scripts/test_printers_common.py
|
|
Packit |
6c4009 |
$(test-wrapper-env) $(py-env) \
|
|
Packit |
6c4009 |
$(PYTHON) $*.py $*.c $(objpfx)$* $(pretty-printers) > $@; \
|
|
Packit |
6c4009 |
$(evaluate-test)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.PHONY: distclean realclean subdir_distclean subdir_realclean \
|
|
Packit |
6c4009 |
subdir_clean subdir_mostlyclean subdir_testclean
|
|
Packit |
6c4009 |
subdir_mostlyclean: mostlyclean
|
|
Packit |
6c4009 |
subdir_clean: clean
|
|
Packit |
6c4009 |
subdir_distclean: distclean
|
|
Packit |
6c4009 |
subdir_realclean: realclean
|
|
Packit |
6c4009 |
subdir_testclean: do-tests-clean
|
|
Packit |
6c4009 |
realclean: distclean
|
|
Packit |
6c4009 |
distclean: clean
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# We want to install everything except the library itself, but update all
|
|
Packit |
6c4009 |
# our portions of the library because the parent make will install it later
|
|
Packit |
6c4009 |
# (likewise the stubs file).
|
|
Packit |
6c4009 |
.PHONY: subdir_install
|
|
Packit |
6c4009 |
subdir_install: install-no-libc.a lib-noranlib stubs
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.PHONY: subdir_objs subdir_stubs
|
|
Packit |
6c4009 |
subdir_objs: objs
|
|
Packit |
6c4009 |
subdir_stubs: stubs
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Target required by the Hurd to ensure that all the MiG-generated
|
|
Packit |
6c4009 |
# headers are in place before building a subdirectory.
|
|
Packit |
6c4009 |
.PHONY: before-compile
|
|
Packit |
6c4009 |
before-compile: $(before-compile)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
$(common-objpfx)dummy.o: $(common-objpfx)dummy.c $(before-compile);
|
|
Packit |
6c4009 |
$(compile-command.c)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Local Variables:
|
|
Packit |
6c4009 |
# mode: makefile
|
|
Packit |
6c4009 |
# End:
|