| 1 | .POSIX: |
| 2 | |
| 3 | # nsxiv version |
| 4 | VERSION = 29 |
| 5 | |
| 6 | # PREFIX for install |
| 7 | PREFIX = /usr/local |
| 8 | MANPREFIX = $(PREFIX)/share/man |
| 9 | EGPREFIX = $(PREFIX)/share/doc/nsxiv/examples |
| 10 | |
| 11 | # default value for optional dependencies. 1 = enabled, 0 = disabled |
| 12 | OPT_DEP_DEFAULT = 1 |
| 13 | |
| 14 | # autoreload backend: 1 = inotify, 0 = none |
| 15 | HAVE_INOTIFY = $(OPT_DEP_DEFAULT) |
| 16 | |
| 17 | # optional dependencies, see README for more info |
| 18 | HAVE_LIBFONTS = $(OPT_DEP_DEFAULT) |
| 19 | HAVE_LIBGIF = $(OPT_DEP_DEFAULT) |
| 20 | HAVE_LIBEXIF = $(OPT_DEP_DEFAULT) |
| 21 | HAVE_LIBWEBP = $(OPT_DEP_DEFAULT) |
| 22 | |
| 23 | # CFLAGS, any optimization flags goes here |
| 24 | CFLAGS = -std=c99 -Wall -pedantic |
| 25 | |
| 26 | # icons that will be installed via `make icon` |
| 27 | ICONS = 16x16.png 32x32.png 48x48.png 64x64.png 128x128.png |
| 28 | |
| 29 | inc_fonts_0 = |
| 30 | inc_fonts_1 = -I/usr/include/freetype2 -I$(PREFIX)/include/freetype2 |
| 31 | |
| 32 | CPPFLAGS = -D_XOPEN_SOURCE=700 \ |
| 33 | -DHAVE_LIBGIF=$(HAVE_LIBGIF) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF) \ |
| 34 | -DHAVE_LIBWEBP=$(HAVE_LIBWEBP) -DHAVE_LIBFONTS=$(HAVE_LIBFONTS) \ |
| 35 | $(inc_fonts_$(HAVE_LIBFONTS)) |
| 36 | |
| 37 | lib_fonts_0 = |
| 38 | lib_fonts_1 = -lXft -lfontconfig |
| 39 | lib_exif_0 = |
| 40 | lib_exif_1 = -lexif |
| 41 | lib_gif_0 = |
| 42 | lib_gif_1 = -lgif |
| 43 | lib_webp_0 = |
| 44 | lib_webp_1 = -lwebpdemux -lwebp |
| 45 | autoreload_0 = nop |
| 46 | autoreload_1 = inotify |
| 47 | |
| 48 | NSXIV_LDLIBS = -lImlib2 -lX11 \ |
| 49 | $(lib_exif_$(HAVE_LIBEXIF)) $(lib_gif_$(HAVE_LIBGIF)) \ |
| 50 | $(lib_webp_$(HAVE_LIBWEBP)) $(lib_fonts_$(HAVE_LIBFONTS)) |
| 51 | |
| 52 | OBJS = autoreload_$(autoreload_$(HAVE_INOTIFY)).o commands.o image.o main.o options.o \ |
| 53 | thumbs.o util.o window.o |
| 54 | |
| 55 | .SUFFIXES: |
| 56 | .SUFFIXES: .c .o |
| 57 | |
| 58 | all: nsxiv |
| 59 | |
| 60 | nsxiv: $(OBJS) |
| 61 | @echo "LINK $@" |
| 62 | $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) $(NSXIV_LDLIBS) |
| 63 | |
| 64 | .c.o: |
| 65 | @echo "CC $@" |
| 66 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< |
| 67 | |
| 68 | $(OBJS): Makefile nsxiv.h config.h commands.h |
| 69 | options.o: version.h |
| 70 | window.o: icon/data.h |
| 71 | |
| 72 | config.h: |
| 73 | @echo "GEN $@" |
| 74 | cp config.def.h $@ |
| 75 | |
| 76 | version.h: Makefile .git/index |
| 77 | @echo "GEN $@" |
| 78 | v="$$(git describe 2>/dev/null || true)"; \ |
| 79 | echo "#define VERSION \"$${v:-$(VERSION)}\"" >$@ |
| 80 | |
| 81 | .git/index: |
| 82 | |
| 83 | clean: |
| 84 | rm -f *.o nsxiv version.h |
| 85 | |
| 86 | install-all: install install-desktop install-icon |
| 87 | |
| 88 | install-desktop: |
| 89 | @echo "INSTALL nsxiv.desktop" |
| 90 | mkdir -p $(DESTDIR)$(PREFIX)/share/applications |
| 91 | cp nsxiv.desktop $(DESTDIR)$(PREFIX)/share/applications |
| 92 | |
| 93 | install-icon: |
| 94 | @echo "INSTALL icon" |
| 95 | for f in $(ICONS); do \ |
| 96 | dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \ |
| 97 | mkdir -p "$$dir"; \ |
| 98 | cp "icon/$$f" "$$dir/nsxiv.png"; \ |
| 99 | chmod 644 "$$dir/nsxiv.png"; \ |
| 100 | done |
| 101 | |
| 102 | uninstall-icon: |
| 103 | @echo "REMOVE icon" |
| 104 | for f in $(ICONS); do \ |
| 105 | dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \ |
| 106 | rm -f "$$dir/nsxiv.png"; \ |
| 107 | done |
| 108 | |
| 109 | install: all |
| 110 | @echo "INSTALL bin/nsxiv" |
| 111 | mkdir -p $(DESTDIR)$(PREFIX)/bin |
| 112 | cp nsxiv $(DESTDIR)$(PREFIX)/bin/ |
| 113 | chmod 755 $(DESTDIR)$(PREFIX)/bin/nsxiv |
| 114 | @echo "INSTALL nsxiv.1" |
| 115 | mkdir -p $(DESTDIR)$(MANPREFIX)/man1 |
| 116 | sed "s!EGPREFIX!$(EGPREFIX)!g; s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" nsxiv.1 \ |
| 117 | >$(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 |
| 118 | chmod 644 $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 |
| 119 | @echo "INSTALL share/nsxiv/" |
| 120 | mkdir -p $(DESTDIR)$(EGPREFIX) |
| 121 | cp examples/* $(DESTDIR)$(EGPREFIX) |
| 122 | chmod 755 $(DESTDIR)$(EGPREFIX)/* |
| 123 | |
| 124 | uninstall: uninstall-icon |
| 125 | @echo "REMOVE bin/nsxiv" |
| 126 | rm -f $(DESTDIR)$(PREFIX)/bin/nsxiv |
| 127 | @echo "REMOVE nsxiv.1" |
| 128 | rm -f $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 |
| 129 | @echo "REMOVE nsxiv.desktop" |
| 130 | rm -f $(DESTDIR)$(PREFIX)/share/applications/nsxiv.desktop |
| 131 | @echo "REMOVE share/nsxiv/" |
| 132 | rm -rf $(DESTDIR)$(EGPREFIX) |
| 133 | |