Makefile: make it packaging friendly
This commit is contained in:
parent
97ac9f02f9
commit
4743f30485
1 changed files with 24 additions and 14 deletions
|
@ -1,22 +1,32 @@
|
||||||
# set CXX to g++ if not set
|
PROGNAME = tiv
|
||||||
|
|
||||||
|
OBJECTS = tiv.o
|
||||||
|
|
||||||
CXX ?= g++
|
CXX ?= g++
|
||||||
|
CXXFLAGS ?= -O2 -fpermissive
|
||||||
|
INSTALL ?= install
|
||||||
|
INSTALL_PROGRAM ?= $(INSTALL) -D
|
||||||
|
|
||||||
# append necessary arguments
|
# https://www.gnu.org/prep/standards/html_node/Directory-Variables.html#Directory-Variables
|
||||||
override CPPFLAGS += -std=c++17 -Wall -fpermissive -fexceptions -O2
|
prefix ?= /usr/local
|
||||||
override LDFLAGS += -lstdc++fs -pthread -s
|
exec_prefix ?= $(prefix)
|
||||||
|
bindir ?= $(exec_prefix)/bin
|
||||||
|
|
||||||
all: tiv
|
override CXXFLAGS += -std=c++17 -Wall -fexceptions
|
||||||
|
override LDFLAGS += -pthread
|
||||||
|
override LDLIBS += -lstdc++fs
|
||||||
|
|
||||||
tiv.o: tiv.cpp CImg.h
|
all: $(PROGNAME)
|
||||||
$(CXX) $(CPPFLAGS) -c tiv.cpp -o $@
|
|
||||||
|
|
||||||
tiv : tiv.o
|
tiv.o: CImg.h
|
||||||
$(CXX) $^ -o $@ $(LDFLAGS)
|
|
||||||
|
$(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
|
||||||
|
|
Loading…
Reference in a new issue