From e5dea2aee035de48d27b7e1992b34ef59fc57031 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 27 Aug 2021 18:40:00 +0100 Subject: [PATCH] Fully working cross compilation --- GNUmakefile | 60 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 9e367fb..62b9f52 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -5,14 +5,21 @@ include objects.mk -# valid platforms are raspberry and crossraspberry vomp_platform=$(shell ./select-platform) -$(info selected $(vomp_platform)) +# vomp_platform variable sets up the build on different platforms +# valid platforms are: +# raspberry - native compile for & on Raspberry Pi +# crossraspberry - cross compile for Raspberry Pi +# Override auto select here: +# vomp_platform= + +$(info Build system selected: $(vomp_platform)) + # uncomment the line below if you want to build vomp application without a reboot option, automatically set for windows! -#vomp_options+= -DVOMP_HAS_EXIT +#VOMP_OPTIONS+= -DVOMP_HAS_EXIT -CROSSROOT= +CROSSROOT=/pi-root ifndef VERBOSE Q = @ @@ -55,36 +62,45 @@ LD=g++ LDFLAGS = -fuse-ld=gold $(PICTURES) #-fuse-ld=gold -vomp_options += -DIPV4 -DIPV6 +VOMP_OPTIONS += -DIPV4 -DIPV6 LIBPATHS = -L/opt/vc/lib -L/usr/lib/arm-linux-gnueabihf LIBS = -lpthread -lrt -lbrcmEGL -lbrcmOpenVG -lopenmaxil -lbcm_host -lavformat -lavcodec -lavutil -lswresample LIBS += -ldl -lfontconfig -lfreetype -lMagick++-6.Q16 OBJECTS = $(OBJ_COMMON) $(OBJ_RASPBERRY) -CROSSLIBS = INCLUDES = -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/usr/include/freetype2 -I/usr/include/ImageMagick -I/usr/include/ImageMagick-6 -I/usr/include/arm-linux-gnueabihf/ImageMagick-6 PLATFORM = -DVOMP_PLATFORM_RASPBERRY CXXFLAGS_EXTRA = -Wno-psabi endif + + +# Debian 10 x64 +# apt install g++-arm-linux-gnueabihf +# Set vomp_platform=crossraspberry above ifeq ($(vomp_platform),crossraspberry) -$(info Raspberry Pi cross compiler) -CC=arm-linux-gnueabihf-gcc -STRIP=arm-linux-gnueabihf-strip -CXX=arm-linux-gnueabihf-g++ -LD=arm-linux-gnueabihf-g++ -LDFLAGS = $(PICTURES) -Xlinker --sysroot=$(CROSSROOT) -Xlinker --rpath-link=$(CROSSROOT)/usr/lib/gcc/arm-linux-gnueabihf/8 -Xlinker --rpath-link=$(CROSSROOT)/usr/lib/arm-linux-gnueabihf -Xlinker --rpath-link=$(CROSSROOT)/lib/arm-linux-gnueabihf -Xlinker --rpath-link=$(CROSSROOT)/opt/vc/lib -LIBPATHS = -L$(CROSSROOT)/usr/lib/gcc/arm-linux-gnueabihf/8 -L$(CROSSROOT)/opt/vc/lib -L$(CROSSROOT)/lib -L$(CROSSROOT)/usr/lib -L$(CROSSROOT)/lib/arm-linux-gnueabihf -L$(CROSSROOT)/usr/lib/arm-linux-gnueabihf -L$(CROSSROOT)/usr/local/lib -LIBS = -lpthread -lrt -lbrcmEGL -lbrcmOpenVG -lopenmaxil -lbcm_host -lavformat -lavcodec -lavutil -lswresample -LIBS += -ldl -lfontconfig -lfreetype -lMagick++-6.Q16 -lm +VOMP_OPTIONS += -DIPV4 -DIPV6 +CROSS_PREFIX=arm-linux-gnueabihf- +CC=$(CROSS_PREFIX)gcc +STRIP=$(CROSS_PREFIX)strip +CXX=$(CROSS_PREFIX)g++ +LD=$(CROSS_PREFIX)g++ + +LDFLAGS = -Wall $(PICTURES) --sysroot=$(CROSSROOT) \ + -Wl,-rpath-link,$(CROSSROOT)/opt/vc/lib -Wl,-rpath-link,$(CROSSROOT)/usr/lib/arm-linux-gnueabihf \ + -L=/opt/vc/lib -L=/usr/lib/arm-linux-gnueabihf +LIBPATHS = +LIBS = -lpthread -lstdc++ -lrt -lbrcmEGL -lbrcmOpenVG -lopenmaxil -lbcm_host -lavformat -lavcodec \ + -lavutil -lswresample -lm -ldl -lfontconfig -lfreetype -lMagick++-6.Q16 -lMagickWand-6.Q16 -lMagickCore-6.Q16 OBJECTS = $(OBJ_COMMON) $(OBJ_RASPBERRY) -CROSSLIBS = -INCLUDES = -I$(CROSSROOT)/opt/vc/include -I$(CROSSROOT)/opt/vc/include/interface/vcos/pthreads -I$(CROSSROOT)/usr/include -I$(CROSSROOT)/usr/include/arm-linux-gnueabihf -I$(CROSSROOT)/usr/include/freetype2 -I$(CROSSROOT)/usr/include/ImageMagick-6 -I$(CROSSROOT)/usr/include/ImageMagick -I$(CROSSROOT)/usr/include/arm-linux-gnueabihf/ImageMagick-6 +INCLUDES = --sysroot=$(CROSSROOT) -I=/usr/include/arm-linux-gnueabihf -I=/opt/vc/include -I=/usr/include/freetype2 -I=/usr/include/arm-linux-gnueabihf/ImageMagick-6 -I=/usr/include/ImageMagick-6 PLATFORM = -DVOMP_PLATFORM_RASPBERRY -CXXFLAGS_EXTRA = -mfloat-abi=hard +CXXFLAGS_EXTRA = -mtune=cortex-a7 -mfloat-abi=hard -fopenmp endif -CXXFLAGS_DEV = -g -O0 -Wall -Wextra -Wshadow -Werror=return-type -Wmissing-declarations -Winit-self -Woverloaded-virtual -Wold-style-cast -Wconversion -std=c++14 $(CXXFLAGS_EXTRA) -DDEV -D_GNU_SOURCE $(PLATFORM) $(vomp_options) $(INCLUDES) -CXXFLAGS_REL = -O3 -Wall -Werror -std=c++14 $(CXXFLAGS_EXTRA) -D_GNU_SOURCE $(PLATFORM) $(vomp_options) $(INCLUDES) +CXXFLAGS_DEV = -g -O0 -Wall -Wextra -Wshadow -Werror=return-type -Wmissing-declarations -Winit-self -Woverloaded-virtual -Wold-style-cast -Wconversion -std=c++14 $(CXXFLAGS_EXTRA) -DDEV -D_GNU_SOURCE -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 $(PLATFORM) $(VOMP_OPTIONS) $(INCLUDES) +CXXFLAGS_REL = -O3 -Wall -Werror -std=c++14 $(CXXFLAGS_EXTRA) -D_GNU_SOURCE -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 $(PLATFORM) $(VOMP_OPTIONS) $(INCLUDES) + + .PHONY: clean fresh all install strip @@ -95,9 +111,9 @@ fresh: clean default @echo CC $@ $(Q)$(CXX) $(CXXFLAGS) -c -o $@ $< -vompclient: $(OBJECTS) $(CROSSLIBS) +vompclient: $(OBJECTS) @echo LD vompclient - $(Q)$(LD) $(LDFLAGS) $(LIBPATHS) -o vompclient $(OBJECTS) $(CROSSLIBS) $(LIBS) + $(Q)$(LD) $(LDFLAGS) $(LIBPATHS) -o vompclient $(OBJECTS) $(LIBS) strip: @echo STRIP vompclient -- 2.39.5