Handle CPU flags from autotools project 82/9382/3
authorDamjan Marion <damarion@cisco.com>
Fri, 10 Nov 2017 19:26:50 +0000 (20:26 +0100)
committerFlorin Coras <florin.coras@gmail.com>
Sat, 11 Nov 2017 00:18:25 +0000 (00:18 +0000)
Change-Id: Id085c1e3cbc7bf03df02755f9e35896cdb57e9e3
Signed-off-by: Damjan Marion <damarion@cisco.com>
build-data/platforms/vpp.mk
src/Makefile.am
src/configure.ac
src/plugins/Makefile.am
src/vpp-api/java/Makefile.am
src/vpp-api/vapi/Makefile.am

index f764a1f..9f01a65 100644 (file)
 MACHINE=$(shell uname -m)
 
 vpp_arch = native
-ifeq ($(MACHINE),$(filter $(MACHINE),x86_64 i686))
-vpp_march = corei7                     # Nehalem Instruction set
-vpp_mtune = corei7-avx                 # Optimize for Sandy Bridge
-else ifeq ($(MACHINE),aarch64)
 ifeq ($(TARGET_PLATFORM),thunderx)
-vpp_march = armv8-a+crc
-vpp_mtune = thunderx
 vpp_dpdk_target = arm64-thunderx-linuxapp-gcc
-else
-vpp_march = native
-vpp_mtune = generic
-endif
 endif
 vpp_native_tools = vppapigen
 
@@ -56,28 +46,20 @@ endif
 # uncomment the following...
 # vpp_configure_args_vpp += --disable-vom
 
-vpp_debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \
+vpp_debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 \
        -fstack-protector-all -fPIC -Werror
-vpp_debug_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \
+vpp_debug_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 \
        -fstack-protector-all -fPIC -Werror
 
-vpp_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) -mtune=$(MTUNE) \
-       -fstack-protector -fPIC -Werror
-vpp_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) -mtune=$(MTUNE) \
-       -fstack-protector -fPIC -Werror
-
-vpp_clang_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) -mtune=$(MTUNE) \
-       -fstack-protector -fPIC -Werror
-vpp_clang_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) -mtune=$(MTUNE) \
-       -fstack-protector -fPIC -Werror
-
-vpp_gcov_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -march=$(MARCH) \
-       -fPIC -Werror -fprofile-arcs -ftest-coverage
-vpp_gcov_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -march=$(MARCH) \
-       -fPIC -Werror -coverage
-
-vpp_coverity_TAG_CFLAGS = -g -O2 -march=$(MARCH) -mtune=$(MTUNE) \
-       -fPIC -Werror -D__COVERITY__
-vpp_coverity_TAG_LDFLAGS = -g -O2 -march=$(MARCH) -mtune=$(MTUNE) \
-       -fPIC -Werror -D__COVERITY__ 
+vpp_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -fstack-protector -fPIC -Werror
+vpp_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -fstack-protector -fPIC -Werror
+
+vpp_clang_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -fstack-protector -fPIC -Werror
+vpp_clang_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -fstack-protector -fPIC -Werror
+
+vpp_gcov_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -fPIC -Werror -fprofile-arcs -ftest-coverage
+vpp_gcov_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -fPIC -Werror -coverage
+
+vpp_coverity_TAG_CFLAGS = -g -O2 -fPIC -Werror -D__COVERITY__
+vpp_coverity_TAG_LDFLAGS = -g -O2 -fPIC -Werror -D__COVERITY__
 
index 6f146fe..04b6c5c 100644 (file)
@@ -19,7 +19,7 @@ AUTOMAKE_OPTIONS = foreign subdir-objects
 ACLOCAL_AMFLAGS = -I m4
 AM_LIBTOOLFLAGS = --quiet
 
-AM_CFLAGS = -Wall
+AM_CFLAGS = @CPU_FLAGS@ -Wall
 AM_CXXFLAGS = -Wall -std=gnu++11
 
 SUBDIRS = .
index 8b79cff..ee4985b 100644 (file)
@@ -160,6 +160,17 @@ AC_ARG_WITH(pre-data,
                *) with_pre_data="pre-data-not-set" ;;
             esac], [with_pre_data=128])
 
+###############################################################################
+# Target CPU flags
+###############################################################################
+
+AS_CASE([$build_cpu],
+       [x86_64], [CPU_FLAGS="-march=corei7 -mtune=corei7-avx"],
+       [aarch64], [CPU_FLAGS="-march=armv8-a+crc"],
+       [CPU_FLAGS=""],
+)
+AC_SUBST([CPU_FLAGS])
+
 ###############################################################################
 # Substitutions and defines
 ###############################################################################
index bd77c45..97f2f88 100644 (file)
@@ -14,7 +14,7 @@
 
 AUTOMAKE_OPTIONS = foreign subdir-objects
 
-AM_CFLAGS = -Wall -I${top_srcdir} -I${top_builddir}
+AM_CFLAGS = @CPU_FLAGS@ -Wall -I${top_srcdir} -I${top_builddir}
 AM_LDFLAGS = -module -shared -avoid-version
 AM_LIBTOOLFLAGS = --quiet
 SUFFIXES = .api.h .api .api.json
index 637bb77..1ce6dff 100644 (file)
@@ -15,7 +15,7 @@ AUTOMAKE_OPTIONS = foreign
 ACLOCAL_AMFLAGS = -I m4
 AM_LIBTOOLFLAGS = --quiet
 
-AM_CFLAGS = -Wall -I${top_srcdir} -I${top_builddir} \
+AM_CFLAGS = @CPU_FLAGS@ -Wall -I${top_srcdir} -I${top_builddir} \
   -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux \
   -I@top_srcdir@/plugins -I@top_builddir@/plugins
 
index 74b2b47..07ef46e 100644 (file)
@@ -15,7 +15,7 @@ AUTOMAKE_OPTIONS = foreign
 ACLOCAL_AMFLAGS = -I m4
 AM_LIBTOOLFLAGS = --quiet
 
-AM_CFLAGS = -Wall -I${top_srcdir} -I${top_builddir} -I. -I$(top_srcdir)/vpp-api/
+AM_CFLAGS = @CPU_FLAGS@ -Wall -I${top_srcdir} -I${top_builddir} -I. -I$(top_srcdir)/vpp-api/
 
 AM_LDFLAGS = -shared -avoid-version -rpath /none -no-undefined