ebuild: fix the distclean target
[vpp.git] / build-root / Makefile
index f2f7780..cc66eed 100644 (file)
@@ -165,6 +165,7 @@ BASIC_ARCH = \
 # x86_64 can be either 32/64.  set BIACH=32 to get 32 bit libraries.
 BIARCH = 64
 
+aarch64_libdir = 64
 x86_64_libdir = $(BIARCH)
 native_libdir = $($(NATIVE_ARCH)_libdir)
 
@@ -189,7 +190,7 @@ ARCH_TARGET_tmp = $(call ifdef_fn,$(ARCH)_target,$(ARCH)-$(OS))
 TARGET = $(call ifdef_fn,$(PLATFORM)_target,$(ARCH_TARGET_tmp))
 TARGET_PREFIX = $(if $(not_native),$(TARGET)-,)
 
-# CPU microarchitecture detection. 
+# CPU microarchitecture detection.
 # Either set <platform>_march in build-data/platforms/<platform>.mk,
 # or detect and use the build-host instruction set
 
@@ -235,7 +236,7 @@ PACKAGE = $*
 # Build/install tags.  This lets you have different CFLAGS/CPPFLAGS/LDFLAGS
 # for e.g. debug versus optimized compiles.  Each tag has its own set of build/install
 # areas.
-TAG = 
+TAG =
 TAG_PREFIX = $(if $(TAG),$(TAG)-)
 
 # yes you need the space
@@ -244,6 +245,8 @@ tag_var_with_added_space_fn = $(if $($(TAG)_TAG_$(1)),$($(TAG)_TAG_$(1)) )
 # TAG=debug for debugging
 debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \
                   -fstack-protector-all -fPIC
+debug_TAG_CXXFLAGS = -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
 
@@ -257,13 +260,7 @@ tool_or_package_fn = $(if $(is_build_tool),tool,package)
 
 # Directory where packages are built & installed
 BUILD_DIR = $(MU_BUILD_ROOT_DIR)/$(BUILD_PREFIX_$(call tool_or_package_fn))$(ARCH)
-
-## BURT
-# we will deprecate INSTALL_DIR shortly for DFLT_INSTALL_DIR
 INSTALL_DIR = $(MU_BUILD_ROOT_DIR)/$(INSTALL_PREFIX)$(ARCH)
-# DFLT_INSTALL_DIR used in platforms.mk for $(PLATFORM)_DESTDIR_BASE
-DFLT_INSTALL_DIR := $(MU_BUILD_ROOT_DIR)/$(INSTALL_PREFIX)$(ARCH)
-## BURT
 
 PLATFORM_IMAGE_DIR = $(MU_BUILD_ROOT_DIR)/$(IMAGES_PREFIX)$(PLATFORM)
 
@@ -312,12 +309,18 @@ endif
 
 # Always prefer our own tools to those installed on system.
 # Note: ccache-bin must be before tool bin.
+#
+# Removed LD_LIBRARY_PATH from BUILD_ENV (drb, 10/31/17):
+# export LD_LIBRARY_PATH=$(TOOL_INSTALL_DIR)/lib64:$(TOOL_INSTALL_DIR)/lib
+#   Reported to cause trouble. Only of historical interest, since we no longer
+#   build a full tool chain from source.
+
 BUILD_ENV =                                                                            \
     export CCACHE_DIR=$(CCACHE_DIR) ;                                  \
-    export PATH=$(TOOL_INSTALL_DIR)/ccache-bin:$(TOOL_INSTALL_DIR)/bin:$${PATH} ;      \
+    export PATH=$(wildcard /usr/lib*/ccache):$(TOOL_INSTALL_DIR)/bin:$${PATH} ;                \
+    $(if $(call configure_var_fn,PATH), export PATH=$${PATH}:$(call configure_var_fn,PATH);,)  \
     export PATH="`echo $${PATH} | sed -e s/[.]://`" ;                                  \
     $(if $(not_native),export CONFIG_SITE=$(MU_BUILD_ROOT_DIR)/config.site ;,) \
-    export LD_LIBRARY_PATH=$(TOOL_INSTALL_DIR)/lib64:$(TOOL_INSTALL_DIR)/lib ;         \
     set -eu$(BUILD_DEBUG) ;                                                            \
     set -o pipefail
 
@@ -330,16 +333,6 @@ package_dir_fn = \
 
 package_mk_fn = $(call package_dir_fn,$(1))/$(1).mk
 
-### BURT
-
-#next version
-#pkgPhaseDependMacro = $(foreach x,configure build install,                  \
-                       $(eval $(1)_$(x)_depend := $($(1)_depend:%=%-$(x))))
-#version equivalent to original code
-pkgPhaseDependMacro = $(eval $(1)_configure_depend := $($(1)_depend:%=%-install))
-
-### BURT
-
 # Pick up built-root/pre-package-include.mk for all source directories
 $(foreach d,$(SOURCE_PATH_BUILD_ROOT_DIRS),    \
   $(eval -include $(d)/pre-package-include.mk))
@@ -375,7 +368,7 @@ CROSS_TOOLS_$(IS_LINUX) += glibc gcc
 NATIVE_TOOLS = findutils make
 
 # basic tools needed for build system
-NATIVE_TOOLS += git automake autoconf libtool texinfo bison flex tar
+NATIVE_TOOLS += git automake autoconf libtool texinfo tar
 
 # needed to compile gcc
 NATIVE_TOOLS += mpfr gmp mpc
@@ -547,6 +540,8 @@ configure_ldflags_fn = \
 CONFIGURE_ENV =                                                                \
     $(if $(call configure_var_fn,CPPFLAGS),                            \
         CPPFLAGS="$(CPPFLAGS) $(call configure_var_fn,CPPFLAGS)")      \
+    $(if $(call configure_var_fn,CXXFLAGS),                            \
+        CXXFLAGS="$(CXXFLAGS) $(call configure_var_fn,CXXFLAGS)")      \
     $(if $(call configure_var_fn,CFLAGS),                              \
         CFLAGS="$(CFLAGS) $(call configure_var_fn,CFLAGS)")            \
     $(if $(call configure_var_fn,CCASFLAGS),                           \
@@ -555,7 +550,6 @@ CONFIGURE_ENV =                                                             \
         LDFLAGS="$(LDFLAGS) $(call configure_ldflags_fn)")             \
     $(if $($(PACKAGE)_configure_env),$($(PACKAGE)_configure_env))
 
-### BURT
 # only partially used now (used in a few .mk files)
 ifeq ($(is_build_tool),yes)
 prefix     = $(PACKAGE_INSTALL_DIR)
@@ -573,10 +567,6 @@ libexecdir = $($(PLATFORM)_LIBEXECDIR)
 destdirMacro  = $($(PLATFORM)_DESTDIR_BASE)$(ppdMacro)
 DESTDIR  = $(call destdirMacro,$(PACKAGE))
 endif
-### BURT
-### dbarach
-image_extra_dependencies = $($(PLATFORM)_image_extra_dependencies)
-### dbarach
 
 configure_package_gnu =                                                \
   s=$(call find_source_fn,$(PACKAGE_SOURCE))$(PACKAGE_SUBDIR) ;        \
@@ -627,7 +617,7 @@ check_platform =                                                            \
             try make PLATFORM=$(PLATFORM) install-tools) ;                     \
     exit 1 ;                                                                   \
   fi
-    
+
 configure_check_timestamp =                                            \
   @$(BUILD_ENV) ;                                                      \
   $(check_platform) ;                                                  \
@@ -635,6 +625,10 @@ configure_check_timestamp =                                                \
   mkdir -p $(PACKAGE_INSTALL_DIR) ;                                    \
   conf="$(TIMESTAMP_DIR)/$(CONFIGURE_TIMESTAMP)" ;                     \
   dirs="$(call package_mk_fn,$(PACKAGE))                               \
+       $(SOURCE_PATH_BUILD_DATA_DIRS)/platforms/$(PLATFORM).mk         \
+       $(wildcard $(call find_source_fn,$(PACKAGE_SOURCE))/cmake)      \
+       $(shell find $(call find_source_fn,$(PACKAGE_SOURCE))           \
+                       -name CMakeLists.txt)                           \
        $(wildcard $(call find_source_fn,                               \
                     $(PACKAGE_SOURCE))$(PACKAGE_SUBDIR)/configure)     \
        $(MU_BUILD_ROOT_DIR)/config.site" ;                             \
@@ -653,17 +647,16 @@ 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 2 '*' $(linux_n_cpus) ;             \
-    else                                       \
-      echo 1 ;                                 \
-    fi)
-
-MAKE_PARALLEL_FLAGS = $(if $($(PACKAGE)_make_parallel_fails),,$(MAKE_PARALLEL_JOBS))
+# /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 </proc/cpuinfo)' to both test
+# for file presence and content; for now this will have to do.
+ifndef MAKE_PARALLEL_JOBS
+MAKE_PARALLEL_JOBS = $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo), \
+       $(shell grep -c ^processor /proc/cpuinfo), 2)
+endif
+MAKE_PARALLEL_FLAGS ?= $(if $($(PACKAGE)_make_parallel_fails),,-j $(MAKE_PARALLEL_JOBS))
 
 # Make command shorthand for packages & tools.
 PACKAGE_MAKE =                                 \
@@ -810,7 +803,7 @@ pull-all:
        make PLATFORM=$(PLATFORM) $(patsubst %,%-pull-all,$(ROOT_PACKAGES))
 
 .PHONY: %-diff
-%-diff:                                                                        
+%-diff:
        @$(BUILD_ENV) ;                                                 \
        d=$(call find_source_fn,$(PACKAGE_SOURCE)) ;                    \
        $(call build_msg_fn,Git diff $(PACKAGE)) ;                      \
@@ -819,12 +812,12 @@ pull-all:
         else                                                           \
         $(call build_msg_fn, $(PACKAGE) not a git directory) ;         \
        fi
-            
+
 
 
 # generate diffs for everything in source path
 .PHONY: diff-all
-diff-all:                                                              
+diff-all:
        @$(BUILD_ENV) ;                                                 \
        $(call build_msg_fn,Generate diffs) ;                           \
        for r in $(ABSOLUTE_SOURCE_PATH); do                            \
@@ -922,7 +915,7 @@ basic_system_image_install =                                \
   mkdir -p bin lib mnt proc root sbin sys tmp etc ;    \
   mkdir -p usr usr/{bin,sbin} usr/lib ;                        \
   mkdir -p var var/{lib,lock,log,run,tmp} ;            \
-  mkdir -p var/lock/subsys var/lib/urandom 
+  mkdir -p var/lock/subsys var/lib/urandom
 
 .PHONY: basic_system-image_install
 basic_system-image_install: # linuxrc-install
@@ -932,7 +925,7 @@ basic_system-image_install: # linuxrc-install
 ROOT_PACKAGES = $(if $($(PLATFORM)_root_packages),$($(PLATFORM)_root_packages),$(default_root_packages))
 
 .PHONY: install-packages
-install-packages: $(patsubst %,%-find-source,$(ROOT_PACKAGES)) 
+install-packages: $(patsubst %,%-find-source,$(ROOT_PACKAGES))
        @$(BUILD_ENV) ;                                                         \
        set -eu$(BUILD_DEBUG) ;                                                 \
        d=$(MU_BUILD_ROOT_DIR)/packages-$(PLATFORM) ;                           \
@@ -943,11 +936,7 @@ install-packages: $(patsubst %,%-find-source,$(ROOT_PACKAGES))
              basic_system                                                      \
              $(ROOT_PACKAGES)) || exit 1;                                      \
        $(call build_msg_fn, Relocating ELF executables to run in $${d}) ;      \
-       find $${d} -type f                                                      \
-           -exec elftool quiet in '{}' out '{}'                                \
-               set-interpreter                                                 \
-                   $${d}/$(arch_lib_dir)/$(DYNAMIC_LINKER)                     \
-               set-rpath $${d}/$(arch_lib_dir):$${d}/lib ';' ;                 \
+       scripts/set-rpath $${d} $${d}/$(arch_lib_dir) ;                         \
        : strip symbols from files ;                                            \
        if [ $${strip_symbols:-no} = 'yes' ] ; then                             \
            $(call build_msg_fn, Stripping symbols from files) ;                \
@@ -958,7 +947,7 @@ install-packages: $(patsubst %,%-find-source,$(ROOT_PACKAGES))
                    >& /dev/null ;                                              \
        else                                                                    \
            $(call build_msg_fn, NOT stripping symbols) ;                       \
-       fi 
+       fi
 
 # readonly root squashfs image
 # Note: $(call build_msg_fn) does not seem to work inside of fakeroot so we use echo
@@ -982,11 +971,7 @@ $(PLATFORM_IMAGE_DIR)/ro.img ro-image: $(patsubst %,%-find-source,$(ROOT_PACKAGE
          : make dev directory ;                                        \
          $(linuxrc_makedev) ;                                          \
          echo @@@@ Relocating ELF executables to run in / @@@@ ;       \
-         find $${d} -type f                                            \
-             -exec elftool quiet in '{}' out '{}'                      \
-               set-interpreter                                         \
-                   /$(arch_lib_dir)/$(DYNAMIC_LINKER)                  \
-               set-rpath /$(arch_lib_dir):/lib ';' ;                   \
+         scripts/set-rpath /$(arch_lib_dir):/lib ;                     \
          : strip symbols from files ;                                  \
          if [ '$${strip_symbols:-yes}' = 'yes' ] ; then                \
              echo @@@@ Stripping symbols from files @@@@ ;             \
@@ -1102,7 +1087,7 @@ ccache-install:
        $(MAKE) -C $(MU_BUILD_ROOT_DIR) ccache-build
        mkdir -p $(TOOL_INSTALL_DIR)/ccache-bin
        ln -sf $(MU_BUILD_ROOT_DIR)/build-tool-native/ccache/ccache \
-               $(TOOL_INSTALL_DIR)/ccache-bin/$(TARGET_PREFIX)gcc 
+               $(TOOL_INSTALL_DIR)/ccache-bin/$(TARGET_PREFIX)gcc
 
 TOOL_MAKE = $(MAKE) is_build_tool=yes
 
@@ -1166,7 +1151,4 @@ distclean:
        rm -rf $(MU_BUILD_ROOT_DIR)/*.deb
        rm -rf $(MU_BUILD_ROOT_DIR)/*.rpm
        rm -rf $(MU_BUILD_ROOT_DIR)/*.changes
-       rm -rf $(MU_BUILD_ROOT_DIR)/python
-       if [ -e /usr/bin/dh ];then (cd $(MU_BUILD_ROOT_DIR)/deb/;debian/rules clean); fi
-       rm -f $(MU_BUILD_ROOT_DIR)/deb/debian/*.install
-       rm -f $(MU_BUILD_ROOT_DIR)/deb/debian/changelog
+       rm -rf $(MU_BUILD_ROOT_DIR)/*.buildinfo