From bc214f7c8388d361b77c29e3442aaee3e90e7249 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 27 Aug 2021 16:57:34 +0100 Subject: [PATCH] Fully working cross compilation. Change default target from mvp to crossraspberry --- GNUmakefile | 79 +++++++++++++++++++++++++++---------------------- select-platform | 2 +- 2 files changed, 44 insertions(+), 37 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 40b1728..4bd26ef 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,16 +1,20 @@ -# valid platforms are mvp, raspberry and crossraspberry vomp_platform=$(shell ./select-platform) -#vomp_platform=crossraspberry -$(info selected $(vomp_platform)) +# vomp_platform variable sets up the build on different platforms +# valid platforms are: +# mvp - cross compile for MVP +# 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)) vomp_options= # uncomment the line below if you want to build vomp application without a reboot option, automatically set for windows! #vomp_options+= -DVOMP_HAS_EXIT - ifeq ($(vomp_platform),mvp) -$(info MVP crosscompiler) include ../crosstool/cross-var CC=$(CROSS)gcc STRIP=$(CROSS)strip @@ -19,7 +23,6 @@ LD=$(CROSS)g++ endif ifeq ($(vomp_platform),raspberry) -$(info raspberry normal compiler) CC=gcc STRIP=strip CXX=g++ @@ -27,12 +30,15 @@ LD=g++ vomp_options += -DIPV6 endif +# Debian 10 x64 +# apt install g++-arm-linux-gnueabihf +# Set vomp_platform=crossraspberry above ifeq ($(vomp_platform),crossraspberry) -$(info raspberry cross compiler) -CC=arm-linux-gnueabi-gcc-4.7 -STRIP=arm-linux-gnueabi-strip -CXX=arm-linux-gnueabi-g++-4.7 -LD=arm-linux-gnueabi-g++-4.7 +CROSS_PREFIX=arm-linux-gnueabihf- +CC=$(CROSS_PREFIX)gcc +STRIP=$(CROSS_PREFIX)strip +CXX=$(CROSS_PREFIX)g++ +LD=$(CROSS_PREFIX)g++ endif @@ -41,7 +47,6 @@ CXXFLAGS_REL = -O3 -Wall -Wshadow -D_GNU_SOURCE $(INCLUDES) $(vomp_options) LIBPATHS = -$(info Setting up objects) # This is the only thing windows and linux share include objects.mk OBJECTSWIN = threadwin.o remotewin.o ledwin.o mtdwin.o videowin.o audiowin.o osdwin.o surfacewin.o @@ -73,48 +78,49 @@ PICTURES += -Wl,--format=default ifeq ($(vomp_platform),mvp) -$(info MVP flags) LDFLAGS = -Wall -static LIBS = -lpthread -lrt - OBJECTS += wwss.o main.o threadp.o remotemvp.o ledmvp.o mtdmvp.o videomvp.o audiomvp.o osdmvp.o \ - surfacemvp.o fonts/helvB24.o fonts/helvB18.o wjpegcomplex.o vmedialist.o vcolourtuner.o \ + surfacemvp.o fonts/helvB24.o fonts/helvB18.o wjpegcomplex.o vmedialist.o vcolourtuner.o \ audioplayer.o demuxeraudio.o \ vmediaview.o vvideomedia.o imagereader.o media.o mediaoptions.o mediaplayer.o serialize.o \ - localmediafile.o playermedia.o demuxermedia.o mediafile.o osdvector.o surfacevector.o + localmediafile.o playermedia.o demuxermedia.o mediafile.o osdvector.o surfacevector.o TIOBJECT = ticonfig.o CROSSLIBS = ../jpeg/jpeg-6b/libjpeg.a INCLUDES = -I../jpeg/jpeg-6b -DVOMP_PLATTFORM_MVP endif + ifeq ($(vomp_platform),raspberry) -$(info Raspberry pi flags) LDFLAGS = -Wall $(PICTURES) -LIBS = -L/opt/vc/lib -lpthread -lrt -lbrcmEGL -lbrcmOpenVG -lopenmaxil -lbcm_host -lavformat -lavcodec -lavutil -lavresample - +LIBS = -L/opt/vc/lib -lpthread -lrt -lbrcmEGL -lbrcmOpenVG -lopenmaxil -lbcm_host -lavformat -lavcodec -lavutil -lavresample OBJECTS += main.o threadp.o osdvector.o surfacevector.o osdopenvg.o ledraspberry.o mtdraspberry.o videoomx.o audioomx.o imageomx.o wjpegsimple.o remotelinux.o signal.o LIBS+= -ldl -lfontconfig -lfreetype -L/usr/lib/arm-linux-gnueabihf -lMagick++-6.Q16 CROSSLIBS = -INCLUDES = -DVOMP_PLATTFORM_RASPBERRY -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 -CXXFLAGS_DEV += -D__STDC_CONSTANT_MACROS -CXXFLAGS_REL += -D__STDC_CONSTANT_MACROS +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 +CXXFLAGS_DEV += -DVOMP_PLATTFORM_RASPBERRY -D__STDC_CONSTANT_MACROS +CXXFLAGS_REL += -DVOMP_PLATTFORM_RASPBERRY -D__STDC_CONSTANT_MACROS endif -ifeq ($(vomp_platform),crossraspberry) -$(info Raspberry pi flags cross compiler) -LDFLAGS = -Wall $(PICTURES) -Wl,--verbose -Xlinker --rpath-link=rpi-root/usr/lib/arm-linux-gnueabihf -Xlinker --rpath-link=rpi-root/lib/arm-linux-gnueabihf -Xlinker --rpath-link=rpi-root/opt/vc/lib -LIBS = -Lrpi-root/opt/vc/lib -Lrpi-root/lib -Lrpi-root/usr/lib -Lrpi-root/lib/arm-linux-gnueabihf -Lrpi-root/usr/lib/arm-linux-gnueabihf -Lrpi-root/usr/local/lib -lpthread -lrt -lEGL -lOpenVG -lopenmaxil -lbcm_host -lavformat -lavcodec -lavutil -lavresample -ldl -lfontconfig -OBJECTS += main.o threadp.o osdvector.o surfacevector.o osdopenvg.o ledraspberry.o mtdraspberry.o videoomx.o audioomx.o imageomx.o wjpegsimple.o remotelinux.o signal.o -LIBS+= -lfreetype -lMagick++-6.Q16 +ifeq ($(vomp_platform),crossraspberry) +LDFLAGS = -Wall $(PICTURES) --sysroot=/pi-root \ + -Wl,-rpath-link,/pi-root/opt/vc/lib -Wl,-rpath-link,/pi-root/usr/lib/arm-linux-gnueabihf \ + -L=/opt/vc/lib -L=/usr/lib/arm-linux-gnueabihf +LIBS = -lpthread -lstdc++ -lrt -lbrcmEGL -lbrcmOpenVG -lopenmaxil -lbcm_host -lavformat -lavcodec \ + -lavutil -lavresample -lm -ldl -lfontconfig -lfreetype -lMagick++-6.Q16 -lMagickWand-6.Q16 -lMagickCore-6.Q16 +OBJECTS += main.o threadp.o osdvector.o surfacevector.o osdopenvg.o ledraspberry.o mtdraspberry.o videoomx.o audioomx.o imageomx.o wjpegsimple.o remotelinux.o signal.o CROSSLIBS = -INCLUDES = -DVOMP_PLATTFORM_RASPBERRY -Irpi-root/opt/vc/include -Irpi-root/opt/vc/include/interface/vcos/pthreads -Irpi-root/usr/include -Irpi-root/usr/include/freetype2 -Irpi-root/usr/include/ImageMagick-6 -Irpi-root/usr/include/ImageMagick -Irpi-root/usr/include/arm-linux-gnueabihf/ImageMagick-6 -CXXFLAGS_DEV += -D__STDC_CONSTANT_MACROS -mfloat-abi=hard -CXXFLAGS_REL += -D__STDC_CONSTANT_MACROS -mfloat-abi=hard +INCLUDES = --sysroot=/pi-root -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 + +CXXFLAGS_DEV += -DVOMP_PLATTFORM_RASPBERRY -mtune=cortex-a7 -D__STDC_CONSTANT_MACROS -mfloat-abi=hard -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 +CXXFLAGS_REL += -DVOMP_PLATTFORM_RASPBERRY -D__STDC_CONSTANT_MACROS -mfloat-abi=hard -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 endif + + .PHONY: clean fresh all install strip default: dev @@ -154,11 +160,12 @@ dev: vompclient release: CXXFLAGS := $(CXXFLAGS_REL) release: clean vompclient strip -deps: GNUmakefile - $(CC) -MM $(INCLUDES) $(OBJECTS:%.o=%.cc) > deps - --include deps - clean: rm -f *.o deps vompclient *~ fonts/*.o fonts/*~ teletxt/*.o +deps: GNUmakefile + $(CC) -MM $(INCLUDES) $(OBJECTS:%.o=%.cc) > deps + +ifneq ($(MAKECMDGOALS),clean) +include deps +endif diff --git a/select-platform b/select-platform index f74cc4d..8051559 100755 --- a/select-platform +++ b/select-platform @@ -7,5 +7,5 @@ elif grep -q BCM2709 /proc/cpuinfo ; then elif grep -q BCM2835 /proc/cpuinfo ; then echo "raspberry" else - echo "mvp" + echo "crossraspberry" fi -- 2.39.5