unexport LC_ALL
LC_COLLATE=C
LC_NUMERIC=C
export LC_COLLATE LC_NUMERIC
top_srcdir ?= $(CURDIR)
include $(top_srcdir)/include/mk/env_pre.mk
include $(top_srcdir)/include/mk/automake.mk
.SUFFIXES:
.SUFFIXES: .am .default .h .in .m4 .mk
vpath %.am $(top_srcdir)/m4
vpath %.default $(top_srcdir)/include
vpath %.h $(top_srcdir)/include:$(top_builddir)/include
vpath %.in $(top_srcdir)/include
vpath %.m4 $(top_srcdir)/m4
vpath %.mk $(top_srcdir)/mk:$(top_srcdir)/mk/include
COMMON_TARGETS := pan utils
define target_to_dir_dep_mapping
ifeq ($$(filter %-clean,$(1)),)
$(1): | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1)))
else
$(1):: | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1)))
endif
endef
COMMON_TARGETS += testcases tools metadata
ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL))
INSTALL_TARGETS += runtest scenario_groups testscripts
CLEAN_TARGETS += include runtest scenario_groups testscripts
endif
INSTALL_TARGETS += $(COMMON_TARGETS)
CLEAN_TARGETS += $(COMMON_TARGETS) lib libs
BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS) $(INSTALL_TARGETS))
CLEAN_TARGETS := $(addsuffix -clean,$(CLEAN_TARGETS))
INSTALL_TARGETS := $(addsuffix -install,$(INSTALL_TARGETS))
MAKE_TARGETS := $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS)))
CHECK_TARGETS := $(addsuffix -check,testcases lib)
all: $(addsuffix -all,$(COMMON_TARGETS)) Version
$(MAKE_TARGETS): lib-all libs-all
.PHONY: include-all include-install
include-install: $(top_builddir)/include/config.h include/mk/config.mk include-all
INSTALL_DIR := $(DESTDIR)/$(prefix)
INSTALL_DIR := $(abspath $(INSTALL_DIR))
$(sort $(addprefix $(abs_top_builddir)/,$(BOOTSTRAP_TARGETS)) $(INSTALL_DIR) $(DESTDIR)/$(bindir)):
mkdir -m 00755 -p "$@"
lib-install: lib-all
libs-all: $(abs_top_builddir)/libs
$(MAKE_TARGETS) include-all lib-all libs-all:
$(MAKE) -C "$(subst -all,,$@)" \
-f "$(abs_top_srcdir)/$(subst -all,,$@)/Makefile" all
$(CHECK_TARGETS): tools-all
$(MAKE) -C "$(subst -check,,$@)" \
-f "$(abs_top_srcdir)/$(subst -check,,$@)/Makefile" check
$(filter-out include-clean,$(CLEAN_TARGETS))::
-$(MAKE) -C "$(subst -clean,,$@)" \
-f "$(abs_top_srcdir)/$(subst -clean,,$@)/Makefile" clean
ifneq ($(filter clean distclean,$(MAKECMDGOALS)),)
INCLUDE_CLEAN_RDEP_SUBJECT := $(CLEAN_TARGETS)
else
ifneq ($(filter %clean,$(MAKECMDGOALS)),)
INCLUDE_CLEAN_RDEP_SUBJECT := $(MAKECMDGOALS)
endif
endif
INCLUDE_CLEAN_RDEPS := $(filter-out include-clean,$(INCLUDE_CLEAN_RDEP_SUBJECT))
include-clean:: $(INCLUDE_CLEAN_RDEPS) | $(abs_top_builddir)/include
-$(MAKE) -C include -f "$(abs_top_srcdir)/include/Makefile" clean
$(INSTALL_TARGETS) include-install lib-install:
$(MAKE) -C "$(subst -install,,$@)" \
-f "$(abs_top_srcdir)/$(subst -install,,$@)/Makefile" install
.PHONY: clean_install_dir
clean_install_dir::
$(RM) -Rf "$(INSTALL_DIR)"
ifeq ($(filter $(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL) $(BUILD_TREE_UNCONFIGURED)),)
ifneq ($(INSTALL_DIR),/)
CLEAN_TARGETS += clean_install_dir
endif
endif
clean:: $(CLEAN_TARGETS)
$(RM) -f Version
$(foreach tgt,$(MAKE_TARGETS) include-all lib-all $(filter-out clean_install_dir,$(CLEAN_TARGETS)) $(INSTALL_TARGETS) include-install lib-install,$(eval $(call target_to_dir_dep_mapping,$(tgt))))
SRCDIR_INSTALL_SCRIPTS := IDcheck.sh runltp ver_linux
SRCDIR_INSTALL_READONLY := Version
SRCDIR_INSTALL_TARGETS := $(SRCDIR_INSTALL_SCRIPTS) $(SRCDIR_INSTALL_READONLY)
.PHONY: Version
Version:
if git describe >/dev/null 2>&1; then \
git describe > "$@"; \
else \
cp $(top_srcdir)/VERSION "$@"; \
fi
$(INSTALL_DIR)/Version: Version
install -m 00644 "$(top_builddir)/$(@F)" "$@"
$(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)): %:
install -m 00755 "$(top_builddir)/$(@F)" "$@"
$(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_SCRIPTS)): %:
install -m 00755 "$(top_srcdir)/$(@F)" "$@"
ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL))
INSTALL_TARGETS += $(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_TARGETS))
endif
INSTALL_TARGETS += $(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS))
$(INSTALL_TARGETS): $(INSTALL_DIR) $(DESTDIR)/$(bindir)
.PHONY: doc
doc: metadata-all
.PHONY: check
check: $(CHECK_TARGETS)
install: $(INSTALL_TARGETS)
define _test
@set -e; $(top_srcdir)/lib/newlib_tests/runtest.sh -b $(abs_builddir) $(1)
endef
test: lib-all
ifneq ($(build),$(host))
$(error running tests on cross-compile build not supported)
endif
$(call _test)
$(MAKE) test-shell-loader
$(MAKE) test-metadata
test-c: lib-all
ifneq ($(build),$(host))
$(error running tests on cross-compile build not supported)
endif
$(call _test,-c)
test-shell: lib-all
ifneq ($(build),$(host))
$(error running tests on cross-compile build not supported)
endif
$(call _test,-s)
test-shell-loader: lib-all
ifneq ($(build),$(host))
$(error running tests on cross-compile build not supported)
endif
$(top_srcdir)/testcases/lib/run_tests.sh -b $(abs_builddir)
test-metadata: metadata-all
$(MAKE) -C $(abs_srcdir)/metadata test
MODULE_DIRS := $(shell \
dirname $$(grep -l 'include.*module\.mk' $$(find $(abs_srcdir)/testcases/ -type f -name 'Makefile')))
.PHONY: modules modules-clean modules-install
modules:
@$(foreach dir,$(MODULE_DIRS),\
echo "Build $(dir)";\
$(MAKE) -C $(dir) || exit $$?; \
)
modules-clean:
@$(foreach dir,$(MODULE_DIRS),\
echo "Build $(dir)";\
$(MAKE) -C $(dir) clean || exit $$?; \
)
modules-install: modules
@$(foreach dir,$(MODULE_DIRS),\
echo "Build $(dir)";\
$(MAKE) -C $(dir) install || exit $$?; \
)
.PHONY: help
help:
@echo "Please read the Configuration section in $(top_srcdir)/INSTALL"
@exit 1