| 1 | version = 25 |
| 2 | |
| 3 | srcdir = . |
| 4 | VPATH = $(srcdir) |
| 5 | |
| 6 | PREFIX = /usr/local |
| 7 | MANPREFIX = $(PREFIX)/share/man |
| 8 | |
| 9 | # autoreload backend: inotify/nop |
| 10 | AUTORELOAD = inotify |
| 11 | |
| 12 | # enable features requiring giflib (-lgif) |
| 13 | HAVE_GIFLIB = 1 |
| 14 | |
| 15 | # enable features requiring libexif (-lexif) |
| 16 | HAVE_LIBEXIF = 1 |
| 17 | |
| 18 | cflags = -std=c99 -Wall -pedantic $(CFLAGS) |
| 19 | cppflags = -I. $(CPPFLAGS) -D_XOPEN_SOURCE=700 -DHAVE_GIFLIB=$(HAVE_GIFLIB) \ |
| 20 | -DHAVE_LIBEXIF=$(HAVE_LIBEXIF) -I/usr/include/freetype2 |
| 21 | |
| 22 | lib_exif_0 = |
| 23 | lib_exif_1 = -lexif |
| 24 | lib_gif_0 = |
| 25 | lib_gif_1 = -lgif |
| 26 | ldlibs = $(LDLIBS) -lImlib2 -lX11 -lXft -lfontconfig \ |
| 27 | $(lib_exif_$(HAVE_LIBEXIF)) $(lib_gif_$(HAVE_GIFLIB)) |
| 28 | |
| 29 | objs = autoreload_$(AUTORELOAD).o commands.o image.o main.o options.o \ |
| 30 | thumbs.o util.o window.o |
| 31 | |
| 32 | all: sxiv |
| 33 | |
| 34 | .PHONY: all clean install uninstall |
| 35 | .SUFFIXES: |
| 36 | .SUFFIXES: .c .o |
| 37 | $(V).SILENT: |
| 38 | |
| 39 | sxiv: $(objs) |
| 40 | @echo "LINK $@" |
| 41 | $(CC) $(LDFLAGS) -o $@ $(objs) $(ldlibs) |
| 42 | |
| 43 | $(objs): Makefile sxiv.h commands.lst config.h |
| 44 | options.o: version.h |
| 45 | window.o: icon/data.h |
| 46 | |
| 47 | .c.o: |
| 48 | @echo "CC $@" |
| 49 | $(CC) $(cflags) $(cppflags) -c -o $@ $< |
| 50 | |
| 51 | config.h: |
| 52 | @echo "GEN $@" |
| 53 | cp $(srcdir)/config.def.h $@ |
| 54 | |
| 55 | version.h: Makefile .git/index |
| 56 | @echo "GEN $@" |
| 57 | v="$$(cd $(srcdir); git describe 2>/dev/null)"; \ |
| 58 | echo "#define VERSION \"$${v:-$(version)}\"" >$@ |
| 59 | |
| 60 | .git/index: |
| 61 | |
| 62 | clean: |
| 63 | rm -f *.o sxiv |
| 64 | |
| 65 | install: all |
| 66 | @echo "INSTALL bin/sxiv" |
| 67 | mkdir -p $(DESTDIR)$(PREFIX)/bin |
| 68 | cp sxiv $(DESTDIR)$(PREFIX)/bin/ |
| 69 | chmod 755 $(DESTDIR)$(PREFIX)/bin/sxiv |
| 70 | @echo "INSTALL sxiv.1" |
| 71 | mkdir -p $(DESTDIR)$(MANPREFIX)/man1 |
| 72 | sed "s!PREFIX!$(PREFIX)!g; s!VERSION!$(version)!g" sxiv.1 \ |
| 73 | >$(DESTDIR)$(MANPREFIX)/man1/sxiv.1 |
| 74 | chmod 644 $(DESTDIR)$(MANPREFIX)/man1/sxiv.1 |
| 75 | @echo "INSTALL share/sxiv/" |
| 76 | mkdir -p $(DESTDIR)$(PREFIX)/share/sxiv/exec |
| 77 | cp exec/* $(DESTDIR)$(PREFIX)/share/sxiv/exec/ |
| 78 | chmod 755 $(DESTDIR)$(PREFIX)/share/sxiv/exec/* |
| 79 | |
| 80 | uninstall: |
| 81 | @echo "REMOVE bin/sxiv" |
| 82 | rm -f $(DESTDIR)$(PREFIX)/bin/sxiv |
| 83 | @echo "REMOVE sxiv.1" |
| 84 | rm -f $(DESTDIR)$(MANPREFIX)/man1/sxiv.1 |
| 85 | @echo "REMOVE share/sxiv/" |
| 86 | rm -rf $(DESTDIR)$(PREFIX)/share/sxiv |
| 87 | |