| 1 | VERSION := git-20170908 |
| 2 | |
| 3 | .PHONY: all clean install uninstall |
| 4 | .SUFFIXES: |
| 5 | |
| 6 | include config.mk |
| 7 | |
| 8 | CPPFLAGS += -DVERSION=\"$(VERSION)\" -DHAVE_GIFLIB=$(HAVE_GIFLIB) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF) |
| 9 | DEPFLAGS := -MMD -MP |
| 10 | |
| 11 | LDLIBS := -lImlib2 -lX11 -lXft |
| 12 | |
| 13 | ifneq ($(HAVE_GIFLIB),0) |
| 14 | LDLIBS += -lgif |
| 15 | endif |
| 16 | ifneq ($(HAVE_LIBEXIF),0) |
| 17 | LDLIBS += -lexif |
| 18 | endif |
| 19 | |
| 20 | SRC := autoreload_$(AUTORELOAD).c commands.c image.c main.c options.c thumbs.c util.c window.c |
| 21 | DEP := $(SRC:.c=.d) |
| 22 | OBJ := $(SRC:.c=.o) |
| 23 | |
| 24 | all: config.h sxiv |
| 25 | |
| 26 | $(OBJ): Makefile |
| 27 | |
| 28 | -include $(DEP) |
| 29 | |
| 30 | %.o: %.c |
| 31 | $(CC) $(CFLAGS) $(CPPFLAGS) $(DEPFLAGS) -c -o $@ $< |
| 32 | |
| 33 | config.h: |
| 34 | cp config.def.h $@ |
| 35 | |
| 36 | sxiv: $(OBJ) |
| 37 | $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LDLIBS) |
| 38 | |
| 39 | clean: |
| 40 | rm -f $(OBJ) $(DEP) sxiv |
| 41 | |
| 42 | install: all |
| 43 | mkdir -p $(DESTDIR)$(PREFIX)/bin |
| 44 | cp sxiv $(DESTDIR)$(PREFIX)/bin/ |
| 45 | chmod 755 $(DESTDIR)$(PREFIX)/bin/sxiv |
| 46 | mkdir -p $(DESTDIR)$(MANPREFIX)/man1 |
| 47 | sed "s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" sxiv.1 > $(DESTDIR)$(MANPREFIX)/man1/sxiv.1 |
| 48 | chmod 644 $(DESTDIR)$(MANPREFIX)/man1/sxiv.1 |
| 49 | mkdir -p $(DESTDIR)$(PREFIX)/share/sxiv/exec |
| 50 | cp exec/* $(DESTDIR)$(PREFIX)/share/sxiv/exec/ |
| 51 | chmod 755 $(DESTDIR)$(PREFIX)/share/sxiv/exec/* |
| 52 | |
| 53 | uninstall: |
| 54 | rm -f $(DESTDIR)$(PREFIX)/bin/sxiv |
| 55 | rm -f $(DESTDIR)$(MANPREFIX)/man1/sxiv.1 |
| 56 | rm -rf $(DESTDIR)$(PREFIX)/share/sxiv |