| 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 | -DHAVE_INOTIFY=$(HAVE_INOTIFY) $(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 | |
| 46 | NSXIV_LDLIBS = -lImlib2 -lX11 \ |
| 47 | $(lib_exif_$(HAVE_LIBEXIF)) $(lib_gif_$(HAVE_LIBGIF)) \ |
| 48 | $(lib_webp_$(HAVE_LIBWEBP)) $(lib_fonts_$(HAVE_LIBFONTS)) |
| 49 | |
| 50 | OBJS = autoreload.o commands.o image.o main.o options.o \ |
| 51 | thumbs.o util.o window.o |
| 52 | |
| 53 | .SUFFIXES: |
| 54 | .SUFFIXES: .c .o |
| 55 | |
| 56 | all: nsxiv |
| 57 | |
| 58 | nsxiv: $(OBJS) |
| 59 | @echo "LINK $@" |
| 60 | $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) $(NSXIV_LDLIBS) |
| 61 | |
| 62 | .c.o: |
| 63 | @echo "CC $@" |
| 64 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< |
| 65 | |
| 66 | $(OBJS): Makefile nsxiv.h config.h commands.h |
| 67 | options.o: version.h |
| 68 | window.o: icon/data.h |
| 69 | |
| 70 | config.h: |
| 71 | @echo "GEN $@" |
| 72 | cp config.def.h $@ |
| 73 | |
| 74 | version.h: Makefile .git/index |
| 75 | @echo "GEN $@" |
| 76 | v="$$(git describe 2>/dev/null || true)"; \ |
| 77 | echo "#define VERSION \"$${v:-$(VERSION)}\"" >$@ |
| 78 | |
| 79 | .git/index: |
| 80 | |
| 81 | clean: |
| 82 | rm -f *.o nsxiv version.h |
| 83 | |
| 84 | install-all: install install-desktop install-icon |
| 85 | |
| 86 | install-desktop: |
| 87 | @echo "INSTALL nsxiv.desktop" |
| 88 | mkdir -p $(DESTDIR)$(PREFIX)/share/applications |
| 89 | cp nsxiv.desktop $(DESTDIR)$(PREFIX)/share/applications |
| 90 | |
| 91 | install-icon: |
| 92 | @echo "INSTALL icon" |
| 93 | for f in $(ICONS); do \ |
| 94 | dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \ |
| 95 | mkdir -p "$$dir"; \ |
| 96 | cp "icon/$$f" "$$dir/nsxiv.png"; \ |
| 97 | chmod 644 "$$dir/nsxiv.png"; \ |
| 98 | done |
| 99 | |
| 100 | uninstall-icon: |
| 101 | @echo "REMOVE icon" |
| 102 | for f in $(ICONS); do \ |
| 103 | dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \ |
| 104 | rm -f "$$dir/nsxiv.png"; \ |
| 105 | done |
| 106 | |
| 107 | install: all |
| 108 | @echo "INSTALL bin/nsxiv" |
| 109 | mkdir -p $(DESTDIR)$(PREFIX)/bin |
| 110 | cp nsxiv $(DESTDIR)$(PREFIX)/bin/ |
| 111 | chmod 755 $(DESTDIR)$(PREFIX)/bin/nsxiv |
| 112 | @echo "INSTALL nsxiv.1" |
| 113 | mkdir -p $(DESTDIR)$(MANPREFIX)/man1 |
| 114 | sed "s!EGPREFIX!$(EGPREFIX)!g; s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" nsxiv.1 \ |
| 115 | >$(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 |
| 116 | chmod 644 $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 |
| 117 | @echo "INSTALL share/nsxiv/" |
| 118 | mkdir -p $(DESTDIR)$(EGPREFIX) |
| 119 | cp examples/* $(DESTDIR)$(EGPREFIX) |
| 120 | chmod 755 $(DESTDIR)$(EGPREFIX)/* |
| 121 | |
| 122 | uninstall: uninstall-icon |
| 123 | @echo "REMOVE bin/nsxiv" |
| 124 | rm -f $(DESTDIR)$(PREFIX)/bin/nsxiv |
| 125 | @echo "REMOVE nsxiv.1" |
| 126 | rm -f $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 |
| 127 | @echo "REMOVE nsxiv.desktop" |
| 128 | rm -f $(DESTDIR)$(PREFIX)/share/applications/nsxiv.desktop |
| 129 | @echo "REMOVE share/nsxiv/" |
| 130 | rm -rf $(DESTDIR)$(EGPREFIX) |
| 131 | |