| @@ -1,18 +1,21 @@ |
| 1 | | − | # Include configure options |
| 2 | | − | ifneq (clean,$(filter clean,$(MAKECMDGOALS))) |
| 3 | | − | -include config.mk |
| 4 | | − | endif |
| 5 | | − | |
| 6 | 1 | | # nsxiv version |
| 7 | 2 | | VERSION = 27.1 |
| 8 | 3 | | |
| 9 | 4 | | # PREFIX for install |
| 10 | 5 | | PREFIX ?= /usr/local |
| 11 | | − | MANPREFIX = $(PREFIX)/share/man |
| 12 | | − | DOCPREFIX = $(PREFIX)/share/doc/nsxiv |
| 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 |
| 13 | 11 | | |
| 14 | | − | # autoreload backend: inotify/nop |
| 15 | | − | AUTORELOAD = inotify |
| 12 | + | # autoreload backend: 1 = inotify, 0 = none |
| 13 | + | HAVE_INOTIFY ?= $(OPT_DEP_DEFAULT) |
| 14 | + | |
| 15 | + | # optional dependencies, see README for more info |
| 16 | + | HAVE_LIBGIF ?= $(OPT_DEP_DEFAULT) |
| 17 | + | HAVE_LIBEXIF ?= $(OPT_DEP_DEFAULT) |
| 18 | + | HAVE_LIBWEBP ?= $(OPT_DEP_DEFAULT) |
| 16 | 19 | | |
| 17 | 20 | | # CFLAGS, any optimization flags goes here |
| 18 | 21 | | CFLAGS ?= -std=c99 -Wall -pedantic |
| @@ -20,30 +23,25 @@ CFLAGS ?= -std=c99 -Wall -pedantic |
| 20 | 23 | | # icons that will be installed via `make icon` |
| 21 | 24 | | ICONS = 16x16.png 32x32.png 48x48.png 64x64.png 128x128.png |
| 22 | 25 | | |
| 23 | | − | ifeq ($(HAVE_LIBEXIF), 1) |
| 24 | | − | OPTIONAL_LIBS += -lexif |
| 25 | | − | else |
| 26 | | − | HAVE_LIBEXIF = 0 |
| 27 | | − | endif |
| 28 | | − | ifeq ($(HAVE_LIBGIF), 1) |
| 29 | | − | OPTIONAL_LIBS += -lgif |
| 30 | | − | else |
| 31 | | − | HAVE_LIBGIF = 0 |
| 32 | | − | endif |
| 33 | | − | ifeq ($(HAVE_LIBWEBP), 1) |
| 34 | | − | OPTIONAL_LIBS += -lwebpdemux -lwebp |
| 35 | | − | else |
| 36 | | − | HAVE_LIBWEBP = 0 |
| 37 | | − | endif |
| 38 | | − | |
| 39 | 26 | | CPPFLAGS = -D_XOPEN_SOURCE=700 \ |
| 40 | 27 | | -DHAVE_LIBGIF=$(HAVE_LIBGIF) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF) \ |
| 41 | 28 | | -DHAVE_LIBWEBP=$(HAVE_LIBWEBP) \ |
| 42 | 29 | | -I/usr/include/freetype2 -I$(PREFIX)/include/freetype2 |
| 43 | 30 | | |
| 44 | | − | LDLIBS = -lImlib2 -lX11 -lXft -lfontconfig $(OPTIONAL_LIBS) |
| 45 | | − | |
| 46 | | − | OBJS = autoreload_$(AUTORELOAD).o commands.o image.o main.o options.o \ |
| 31 | + | lib_exif_0 = |
| 32 | + | lib_exif_1 = -lexif |
| 33 | + | lib_gif_0 = |
| 34 | + | lib_gif_1 = -lgif |
| 35 | + | lib_webp_0 = |
| 36 | + | lib_webp_1 = -lwebpdemux -lwebp |
| 37 | + | autoreload_0 = nop |
| 38 | + | autoreload_1 = inotify |
| 39 | + | # using += because certain *BSD distros may need to add additional flags |
| 40 | + | LDLIBS += -lImlib2 -lX11 -lXft -lfontconfig \ |
| 41 | + | $(lib_exif_$(HAVE_LIBEXIF)) $(lib_gif_$(HAVE_LIBGIF)) \ |
| 42 | + | $(lib_webp_$(HAVE_LIBWEBP)) |
| 43 | + | |
| 44 | + | OBJS = autoreload_$(autoreload_$(HAVE_INOTIFY)).o commands.o image.o main.o options.o \ |
| 47 | 45 | | thumbs.o util.o window.o |
| 48 | 46 | | |
| 49 | 47 | | .PHONY: all clean install uninstall install-all install-icon uninstall-icon install-desktop |
| @@ -60,19 +58,10 @@ nsxiv: $(OBJS) |
| 60 | 58 | | @echo "CC $@" |
| 61 | 59 | | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< |
| 62 | 60 | | |
| 63 | | − | $(OBJS): Makefile nsxiv.h commands.lst config.h config.mk |
| 61 | + | $(OBJS): Makefile nsxiv.h commands.lst config.h |
| 64 | 62 | | options.o: version.h |
| 65 | 63 | | window.o: icon/data.h |
| 66 | 64 | | |
| 67 | | − | config.mk: |
| 68 | | − | @echo "GEN $@" |
| 69 | | − | @echo "# 0 = disable, 1 = enable" > config.mk |
| 70 | | − | @for lib in exif gif webp; do \ |
| 71 | | − | if echo "int main(){}" | $(CC) "-l$$lib" -o /dev/null -x c - 2>/dev/null ; then \ |
| 72 | | − | echo "HAVE_LIB$$lib=1" | tr '[:lower:]' '[:upper:]' >> config.mk ; \ |
| 73 | | − | fi \ |
| 74 | | − | done |
| 75 | | − | |
| 76 | 65 | | config.h: |
| 77 | 66 | | @echo "GEN $@" |
| 78 | 67 | | cp config.def.h $@ |
| @@ -85,7 +74,7 @@ version.h: Makefile .git/index |
| 85 | 74 | | .git/index: |
| 86 | 75 | | |
| 87 | 76 | | clean: |
| 88 | | − | $(RM) *.o nsxiv |
| 77 | + | rm -f *.o nsxiv version.h |
| 89 | 78 | | |
| 90 | 79 | | install-all: install install-desktop install-icon |
| 91 | 80 | | |
| @@ -112,14 +101,18 @@ uninstall-icon: |
| 112 | 101 | | |
| 113 | 102 | | install: all |
| 114 | 103 | | @echo "INSTALL bin/nsxiv" |
| 115 | | − | install -Dt $(DESTDIR)$(PREFIX)/bin nsxiv |
| 104 | + | mkdir -p $(DESTDIR)$(PREFIX)/bin |
| 105 | + | cp nsxiv $(DESTDIR)$(PREFIX)/bin/ |
| 106 | + | chmod 755 $(DESTDIR)$(PREFIX)/bin/nsxiv |
| 116 | 107 | | @echo "INSTALL nsxiv.1" |
| 117 | 108 | | mkdir -p $(DESTDIR)$(MANPREFIX)/man1 |
| 118 | | − | sed "s!DOCPREFIX!$(DOCPREFIX)!g; s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" nsxiv.1 \ |
| 109 | + | sed "s!EGPREFIX!$(EGPREFIX)!g; s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" nsxiv.1 \ |
| 119 | 110 | | >$(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 |
| 120 | 111 | | chmod 644 $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 |
| 121 | 112 | | @echo "INSTALL share/nsxiv/" |
| 122 | | − | install -Dt $(DESTDIR)$(DOCPREFIX)/examples examples/* |
| 113 | + | mkdir -p $(DESTDIR)$(EGPREFIX) |
| 114 | + | cp examples/* $(DESTDIR)$(EGPREFIX) |
| 115 | + | chmod 755 $(DESTDIR)$(EGPREFIX)/* |
| 123 | 116 | | |
| 124 | 117 | | uninstall: uninstall-icon |
| 125 | 118 | | @echo "REMOVE bin/nsxiv" |
| @@ -129,5 +122,5 @@ uninstall: uninstall-icon |
| 129 | 122 | | @echo "REMOVE nsxiv.desktop" |
| 130 | 123 | | rm -f $(DESTDIR)$(PREFIX)/share/applications/nsxiv.desktop |
| 131 | 124 | | @echo "REMOVE share/nsxiv/" |
| 132 | | − | rm -rf $(DESTDIR)$(DOCPREFIX) |
| 125 | + | rm -rf $(DESTDIR)$(EGPREFIX) |
| 133 | 126 | | |