Makefile: make it packaging friendly

This commit is contained in:
Jan Chren (rindeal) 2019-10-19 00:14:10 +02:00 committed by Stefan Haustein
parent 97ac9f02f9
commit 4743f30485

View file

@ -1,22 +1,32 @@
# set CXX to g++ if not set PROGNAME = tiv
CXX ?= g++
# append necessary arguments OBJECTS = tiv.o
override CPPFLAGS += -std=c++17 -Wall -fpermissive -fexceptions -O2
override LDFLAGS += -lstdc++fs -pthread -s
all: tiv CXX ?= g++
CXXFLAGS ?= -O2 -fpermissive
INSTALL ?= install
INSTALL_PROGRAM ?= $(INSTALL) -D
tiv.o: tiv.cpp CImg.h # https://www.gnu.org/prep/standards/html_node/Directory-Variables.html#Directory-Variables
$(CXX) $(CPPFLAGS) -c tiv.cpp -o $@ prefix ?= /usr/local
exec_prefix ?= $(prefix)
bindir ?= $(exec_prefix)/bin
tiv : tiv.o override CXXFLAGS += -std=c++17 -Wall -fexceptions
$(CXX) $^ -o $@ $(LDFLAGS) override LDFLAGS += -pthread
override LDLIBS += -lstdc++fs
all: $(PROGNAME)
tiv.o: CImg.h
$(PROGNAME): $(OBJECTS)
$(CXX) $(LDFLAGS) $^ -o $@ $(LOADLIBES) $(LDLIBS)
.PHONY: all install clean
install: all install: all
test -d $(DESTDIR)/usr/local/bin || mkdir -p $(DESTDIR)/usr/local/bin $(INSTALL_PROGRAM) $(PROGNAME) $(DESTDIR)$(bindir)/$(PROGNAME)
cp tiv $(DESTDIR)/usr/local/bin/tiv
clean: clean:
rm -f tiv tiv.o $(RM) -f $(PROGNAME) *.o
.PHONY: all install clean