X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=build-root%2FMakefile;h=0fed520c728ff3a518f4ccf194383c5bae2dcd48;hb=83d8fdabca4287958a532e4784772a95f7478c83;hp=ed25a0cc06d00870beb01eecf6d50b50e3b04c48;hpb=7210e9470eeeb0ff1a259db1f448011da3774d8c;p=vpp.git diff --git a/build-root/Makefile b/build-root/Makefile index ed25a0cc06d..0fed520c728 100644 --- a/build-root/Makefile +++ b/build-root/Makefile @@ -172,7 +172,12 @@ native_libdir = $($(NATIVE_ARCH)_libdir) arch_lib_dir = lib$($(BASIC_ARCH)_libdir) # OS to configure for. configure --host will be set to $(ARCH)-$(OS) -OS = mu-linux +# Allow per-platform overrides + +OS = $(strip $($(PLATFORM)_os)) +ifeq ($(OS),) + OS = mu-linux +endif spu_target = spu native_target = @@ -215,6 +220,11 @@ else endif export MARCH +MTUNE = $(strip $($(PLATFORM)_mtune)) +ifeq ($(MTUNE),) + MTUNE = generic +endif + ###################################################################### # Generic build stuff ###################################################################### @@ -232,28 +242,10 @@ TAG_PREFIX = $(if $(TAG),$(TAG)-) tag_var_with_added_space_fn = $(if $($(TAG)_TAG_$(1)),$($(TAG)_TAG_$(1)) ) # TAG=debug for debugging -debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -march=$(MARCH) -debug_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -march=$(MARCH) - -# TAG=prof for profiling -prof_TAG_CFLAGS = -g -pg -O2 -prof_TAG_LDFLAGS = -g -pg -O2 - -# TAG=o0 -o0_TAG_CFLAGS = -g -O0 -o1_TAG_LDFLAGS = -g -O0 - -# TAG=o1 -o1_TAG_CFLAGS = -g -O1 -o1_TAG_LDFLAGS = -g -O1 - -# TAG=o2 -o2_TAG_CFLAGS = -g -O2 -o2_TAG_LDFLAGS = -g -O2 - -# TAG=o3 -o3_TAG_CFLAGS = -g -O3 -o3_TAG_LDFLAGS = -g -O3 +debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \ + -fstack-protector-all -fPIC +debug_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \ + -fstack-protector-all -fPIC BUILD_PREFIX_package = build-$(TAG_PREFIX) BUILD_PREFIX_tool = build-tool-$(TAG_PREFIX) @@ -313,10 +305,15 @@ BUILD_DEBUG = # Message from build system itself (as opposed to make or shell commands) build_msg_fn = echo "@@@@ $(1) @@@@" +# Allow CCACHE_DIR to be overridden, e.g. in .../build-root/build-config.mk +ifeq ($(CCACHE_DIR),) + CCACHE_DIR=$(MU_BUILD_ROOT_DIR)/.ccache +endif + # Always prefer our own tools to those installed on system. # Note: ccache-bin must be before tool bin. BUILD_ENV = \ - export CCACHE_DIR=$(MU_BUILD_ROOT_DIR)/.ccache ; \ + export CCACHE_DIR=$(CCACHE_DIR) ; \ export PATH=$(TOOL_INSTALL_DIR)/ccache-bin:$(TOOL_INSTALL_DIR)/bin:$${PATH} ; \ export PATH="`echo $${PATH} | sed -e s/[.]://`" ; \ $(if $(not_native),export CONFIG_SITE=$(MU_BUILD_ROOT_DIR)/config.site ;,) \ @@ -506,9 +503,13 @@ DYNAMIC_LINKER=${shell cd $(TOOL_INSTALL_LIB_DIR); echo ld*.so.*} lots_of_slashes_to_pad_names = "/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" # When PLATFORM != native we *always* use our own versions of GLIBC and dynamic linker -CROSS_LDFLAGS = \ - -Wl,--dynamic-linker=$(lots_of_slashes_to_pad_names)$(TOOL_INSTALL_LIB_DIR)/$(DYNAMIC_LINKER) \ - -Wl,-rpath -Wl,$(lots_of_slashes_to_pad_names)$(TOOL_INSTALL_LIB_DIR) +# Allow per-platform overrides +CROSS_LDFLAGS = $(strip $($(PLATFORM)_cross_ldflags)) +ifeq ($(CROSS_LDFLAGS),) + CROSS_LDFLAGS = \ + -Wl,--dynamic-linker=$(lots_of_slashes_to_pad_names)$(TOOL_INSTALL_LIB_DIR)/$(DYNAMIC_LINKER) \ + -Wl,-rpath -Wl,$(lots_of_slashes_to_pad_names)$(TOOL_INSTALL_LIB_DIR) +endif cross_ldflags = $(if $(is_native)$(is_build_tool),,$(CROSS_LDFLAGS) ) @@ -578,7 +579,7 @@ image_extra_dependencies = $($(PLATFORM)_image_extra_dependencies) ### dbarach configure_package_gnu = \ - s=$(call find_source_fn,$(PACKAGE_SOURCE)) ; \ + s=$(call find_source_fn,$(PACKAGE_SOURCE))$(PACKAGE_SUBDIR) ; \ if [ ! -f $$s/configure ] ; then \ autoreconf -i -f $$s ; \ fi ; \ @@ -634,7 +635,8 @@ configure_check_timestamp = \ mkdir -p $(PACKAGE_INSTALL_DIR) ; \ conf="$(TIMESTAMP_DIR)/$(CONFIGURE_TIMESTAMP)" ; \ dirs="$(call package_mk_fn,$(PACKAGE)) \ - $(wildcard $(call find_source_fn,$(PACKAGE_SOURCE))/configure) \ + $(wildcard $(call find_source_fn, \ + $(PACKAGE_SOURCE))$(PACKAGE_SUBDIR)/configure) \ $(MU_BUILD_ROOT_DIR)/config.site" ; \ if [[ $(call find_newer_fn, $${conf}, $${dirs}, $?) ]]; then \ $(configure_package) ; \ @@ -651,16 +653,13 @@ configure_check_timestamp = \ # Package build ###################################################################### -linux_n_cpus = `grep '^processor' /proc/cpuinfo | wc -l` - -MAKE_PARALLEL_JOBS = \ - -j $(shell \ - if [ -f /proc/cpuinfo ] ; then \ - expr 4 '*' $(linux_n_cpus) ; \ - else \ - echo 1 ; \ - fi) - +# /proc/cpuinfo does not exist on platforms without a /proc and on some +# platforms, notably inside containers, it has no content. In those cases +# we assume there's 1 processor; we use 2*ncpu for the -j option. +# NB: GNU Make 4.2 will let us use '$(file