From 9734ff585d23fa64d88089dfb35acafc3d117f42 Mon Sep 17 00:00:00 2001 From: Thomas Kupper Date: Sat, 23 Mar 2019 13:18:48 +0100 Subject: [PATCH] Extend Makefile for cross-compiling --- src/main/cpp/Makefile | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/cpp/Makefile b/src/main/cpp/Makefile index 8169697..bf4cb82 100644 --- a/src/main/cpp/Makefile +++ b/src/main/cpp/Makefile @@ -1,15 +1,22 @@ -CXX=g++ +# set CXX to g++ if not set +CXX ?= g++ -default: tiv +# append necessary arguments +override CPPFLAGS += -std=c++17 -Wall -fpermissive -fexceptions -O2 +override LDFLAGS += -lstdc++fs -pthread -s + +all: tiv tiv.o: tiv.cpp CImg.h - $(CXX) -std=c++17 -Wall -fpermissive -fexceptions -O2 -c tiv.cpp -o tiv.o + $(CXX) $(CPPFLAGS) -c tiv.cpp -o $@ tiv : tiv.o - $(CXX) tiv.o -o tiv -lstdc++fs -pthread -s + $(CXX) $^ -o $@ $(LDFLAGS) -install: tiv - cp tiv /usr/local/bin/tiv +.PHONY: all install clean +install: all + test -d $(DESTDIR)/usr/local/bin || mkdir -p $(DESTDIR)/usr/local/bin + cp tiv $(DESTDIR)/usr/local/bin/tiv clean: - rm -f tiv tiv.o + rm -f tiv tiv.o