From b147fb07d508f90dd327d23eb40470e97bf77102 Mon Sep 17 00:00:00 2001 From: marvell Date: Wed, 23 Jun 2021 20:04:11 +0530 Subject: [PATCH 1/2] Ported to armhf cross-compilation --- meta/Makefile | 22 +++++++++++++++------- test/Makefile | 8 +++++++- test/basic_router/Makefile | 7 ++++++- test/sai_ut/Makefile | 5 +++++ test/saithrift/Makefile | 5 +++++ 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/meta/Makefile b/meta/Makefile index a64f3e655..0015b1d8a 100644 --- a/meta/Makefile +++ b/meta/Makefile @@ -68,6 +68,14 @@ $(foreach bin,$(BINS),$(if $(shell which $(bin)),,$(error "Missing $(bin) in PAT CFLAGS += -I../inc -I../experimental $(WARNINGS) +ifeq ($(CROSS_BUILD_ENVIRON),y) +CC=$(CROSS_CC) +CXX=$(CROSS_CXX) +else +CC=gcc +CXX=g++ +endif + DEPS = $(wildcard ../inc/*.h) $(wildcard ../experimental/*.h) XMLDEPS = $(wildcard xml/*.xml) @@ -83,7 +91,7 @@ all: toolsversions saisanitycheck saimetadatatest saiserializetest saidepgraph.s toolsversions: @make -v | grep -i make - @gcc --version | grep gcc + @$(CC) --version | grep gcc @perl --version | grep version @aspell --version @dot -V @@ -104,22 +112,22 @@ saimetadatatest.c saimetadata.c saimetadata.h: xml $(XMLDEPS) parse.pl $(CONSTHE HEADERS = saimetadata.h $(CONSTHEADERS) %.o: %.c $(HEADERS) - gcc -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(CFLAGS) %.o: %.cpp $(HEADERS) - gcc -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(CFLAGS) saisanitycheck: saisanitycheck.o $(OBJ) - gcc -o $@ $^ + $(CC) -o $@ $^ saimetadatatest: saimetadatatest.o $(OBJ) - gcc -o $@ $^ + $(CC) -o $@ $^ saiserializetest: saiserializetest.o $(OBJ) - gcc -o $@ $^ + $(CC) -o $@ $^ saidepgraphgen: saidepgraphgen.o $(OBJ) - g++ -o $@ $^ + $(CXX) -o $@ $^ %.o.symbols: %.o nm $^ | ./checksymbols.pl diff --git a/test/Makefile b/test/Makefile index bc6acf347..ece98a182 100644 --- a/test/Makefile +++ b/test/Makefile @@ -15,7 +15,13 @@ # assistance with these files: Intel Corporation, Mellanox Technologies Ltd, # Dell Products, L.P., Facebook, Inc # -CXX = g++ + +ifeq ($(CROSS_BUILD_ENVIRON),y) +CXX=$(CROSS_CXX) +else +CXX=g++ +endif + LIBS = -lpthread LDIR = ./lib diff --git a/test/basic_router/Makefile b/test/basic_router/Makefile index 25586096b..ed06e2817 100644 --- a/test/basic_router/Makefile +++ b/test/basic_router/Makefile @@ -21,7 +21,12 @@ #Broadcom, Mellonox, Barefoot -CXX = g++ +ifeq ($(CROSS_BUILD_ENVIRON),y) +CXX=$(CROSS_CXX) +else +CXX=g++ +endif + LIBS = -lpthread -lsai SAI_IDIR = /usr/include/sai diff --git a/test/sai_ut/Makefile b/test/sai_ut/Makefile index 737134d4b..d38830df1 100644 --- a/test/sai_ut/Makefile +++ b/test/sai_ut/Makefile @@ -55,8 +55,13 @@ stp_EXEC = sai_ut_stp EXEC_ALL = $(BDIR)/$(vr_EXEC) $(BDIR)/$(rif_EXEC) $(BDIR)/$(nh_EXEC) $(BDIR)/$(nhg_EXEC) $(BDIR)/$(nbr_EXEC) $(BDIR)/$(route_EXEC) $(BDIR)/$(fdb_EXEC) $(BDIR)/$(vlan_EXEC) $(BDIR)/$(lag_EXEC) $(BDIR)/$(stp_EXEC) # what to use for compiling +ifeq ($(CROSS_BUILD_ENVIRON),y) +CXX=$(CROSS_CXX) +AR=$(CROSS_AR) +else CXX=g++ AR=ar +endif # include dir for unit-tests INCLUDEFLAGS = ${SAI_INCLUDE_FLAGS} -I$(GTEST_DIR)/include diff --git a/test/saithrift/Makefile b/test/saithrift/Makefile index 516d8b165..46e1474b9 100644 --- a/test/saithrift/Makefile +++ b/test/saithrift/Makefile @@ -1,4 +1,9 @@ +ifeq ($(CROSS_BUILD_ENVIRON),y) +CXX=$(CROSS_CXX) +else CXX=g++ +endif + SAI_PREFIX = /usr SAI_HEADER_DIR ?= $(SAI_PREFIX)/include/sai SAI_HEADERS = $(SAI_HEADER_DIR)/sai*.h From 6fdbf4b2f62eb727ac65a6f88a8d5456196c3ba7 Mon Sep 17 00:00:00 2001 From: marvell Date: Mon, 28 Jun 2021 16:22:02 +0530 Subject: [PATCH 2/2] Fixed indentation --- meta/Makefile | 8 ++++---- test/Makefile | 4 ++-- test/basic_router/Makefile | 4 ++-- test/sai_ut/Makefile | 8 ++++---- test/saithrift/Makefile | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/meta/Makefile b/meta/Makefile index 0015b1d8a..3808b45a5 100644 --- a/meta/Makefile +++ b/meta/Makefile @@ -69,11 +69,11 @@ $(foreach bin,$(BINS),$(if $(shell which $(bin)),,$(error "Missing $(bin) in PAT CFLAGS += -I../inc -I../experimental $(WARNINGS) ifeq ($(CROSS_BUILD_ENVIRON),y) -CC=$(CROSS_CC) -CXX=$(CROSS_CXX) + CC=$(CROSS_CC) + CXX=$(CROSS_CXX) else -CC=gcc -CXX=g++ + CC=gcc + CXX=g++ endif DEPS = $(wildcard ../inc/*.h) $(wildcard ../experimental/*.h) diff --git a/test/Makefile b/test/Makefile index ece98a182..ae61562d9 100644 --- a/test/Makefile +++ b/test/Makefile @@ -17,9 +17,9 @@ # ifeq ($(CROSS_BUILD_ENVIRON),y) -CXX=$(CROSS_CXX) + CXX=$(CROSS_CXX) else -CXX=g++ + CXX=g++ endif LIBS = -lpthread diff --git a/test/basic_router/Makefile b/test/basic_router/Makefile index ed06e2817..6ccb4b826 100644 --- a/test/basic_router/Makefile +++ b/test/basic_router/Makefile @@ -22,9 +22,9 @@ #Broadcom, Mellonox, Barefoot ifeq ($(CROSS_BUILD_ENVIRON),y) -CXX=$(CROSS_CXX) + CXX=$(CROSS_CXX) else -CXX=g++ + CXX=g++ endif LIBS = -lpthread -lsai diff --git a/test/sai_ut/Makefile b/test/sai_ut/Makefile index d38830df1..14548be02 100644 --- a/test/sai_ut/Makefile +++ b/test/sai_ut/Makefile @@ -56,11 +56,11 @@ EXEC_ALL = $(BDIR)/$(vr_EXEC) $(BDIR)/$(rif_EXEC) $(BDIR)/$(nh_EXEC) $(BDIR)/$(n # what to use for compiling ifeq ($(CROSS_BUILD_ENVIRON),y) -CXX=$(CROSS_CXX) -AR=$(CROSS_AR) + CXX=$(CROSS_CXX) + AR=$(CROSS_AR) else -CXX=g++ -AR=ar + CXX=g++ + AR=ar endif # include dir for unit-tests diff --git a/test/saithrift/Makefile b/test/saithrift/Makefile index 46e1474b9..b4db3a469 100644 --- a/test/saithrift/Makefile +++ b/test/saithrift/Makefile @@ -1,7 +1,7 @@ ifeq ($(CROSS_BUILD_ENVIRON),y) -CXX=$(CROSS_CXX) + CXX=$(CROSS_CXX) else -CXX=g++ + CXX=g++ endif SAI_PREFIX = /usr