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