# fotoxx-maps makefile 

CXXFLAGS += -Wall -Wno-format-truncation
PREFIX ?= /usr

# target install directories
BINDIR = $(PREFIX)/bin
SHAREDIR = $(PREFIX)/share/fotoxx-maps
DATADIR = $(SHAREDIR)/data
ICONDIR = $(SHAREDIR)/icons
DOCDIR = $(PREFIX)/share/doc/fotoxx-maps
MANDIR = $(PREFIX)/share/man/man1
APPDATADIR = $(PREFIX)/share/appdata
MENUFILE = $(PREFIX)/share/applications/fotoxx-maps.desktop

CFLAGS = $(CXXFLAGS) -c `pkg-config --cflags gtk+-3.0`
LIBS = `pkg-config --libs gtk+-3.0` -lpthread

fotoxx-maps: fotoxx-maps.o zfuncs.o   
	$(CXX) $(LDFLAGS) -o fotoxx-maps fotoxx-maps.o zfuncs.o $(LIBS)

fotoxx-maps.o: fotoxx-maps.cc
	$(CXX) $(CFLAGS) -o fotoxx-maps.o fotoxx-maps.cc

zfuncs.o: zfuncs.cc zfuncs.h
	$(CXX) $(CFLAGS)  zfuncs.cc  -D PREFIX=\"$(PREFIX)\" -D DOCDIR=\"$(DOCDIR)\"  \

install: fotoxx-maps uninstall
	mkdir -p  $(DESTDIR)$(BINDIR)
	mkdir -p  $(DESTDIR)$(DATADIR)
	mkdir -p  $(DESTDIR)$(ICONDIR)
	mkdir -p  $(DESTDIR)$(DOCDIR)
	mkdir -p  $(DESTDIR)$(MANDIR)
	mkdir -p  $(DESTDIR)$(APPDATADIR)
	mkdir -p  $(DESTDIR)$(PREFIX)/share/applications
	cp -f     fotoxx-maps $(DESTDIR)$(BINDIR)
	cp -f -R  data/* $(DESTDIR)$(DATADIR)
	cp -n -R  doc/* $(DESTDIR)$(DOCDIR)
	gzip -f -9 $(DESTDIR)$(DOCDIR)/changelog
	cp -f -R  appdata/* $(DESTDIR)$(APPDATADIR)
	# man page
	cp -f doc/fotoxx-maps.man fotoxx-maps.1
	gzip -f -9 fotoxx-maps.1
	cp fotoxx-maps.1.gz $(DESTDIR)$(MANDIR)
	rm -f fotoxx-maps.1.gz
	# menu (desktop) file
	cp -f fotoxx-maps.desktop $(DESTDIR)$(MENUFILE)
	cp -f fotoxx-maps.png $(DESTDIR)$(ICONDIR)

uninstall:
	rm -f  $(DESTDIR)$(BINDIR)/fotoxx-maps
	rm -f -R  $(DESTDIR)$(SHAREDIR)
	rm -f -R  $(DESTDIR)$(DOCDIR)
	rm -f  $(DESTDIR)$(MANDIR)/fotoxx-maps.1.gz
	rm -f  $(DESTDIR)$(MENUFILE)
	rm -f  $(DESTDIR)$(APPDATADIR)/fotoxx-maps*

clean:
	rm -f  fotoxx-maps
	rm -f  *.o

