| 1 | .POSIX: |
| 2 | |
| 3 | include config.mk |
| 4 | |
| 5 | inc_fonts_0 = |
| 6 | inc_fonts_1 = -I/usr/include/freetype2 -I$(PREFIX)/include/freetype2 |
| 7 | lib_fonts_0 = |
| 8 | lib_fonts_1 = -lXft -lfontconfig |
| 9 | lib_exif_0 = |
| 10 | lib_exif_1 = -lexif |
| 11 | lib_gif_0 = |
| 12 | lib_gif_1 = -lgif |
| 13 | lib_webp_0 = |
| 14 | lib_webp_1 = -lwebpdemux -lwebp |
| 15 | |
| 16 | nsxiv_cppflags = -D_XOPEN_SOURCE=700 \ |
| 17 | -DHAVE_LIBGIF=$(HAVE_LIBGIF) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF) \ |
| 18 | -DHAVE_LIBWEBP=$(HAVE_LIBWEBP) -DHAVE_LIBFONTS=$(HAVE_LIBFONTS) \ |
| 19 | -DHAVE_INOTIFY=$(HAVE_INOTIFY) $(inc_fonts_$(HAVE_LIBFONTS)) \ |
| 20 | $(CPPFLAGS) |
| 21 | |
| 22 | nsxiv_ldlibs = -lImlib2 -lX11 \ |
| 23 | $(lib_exif_$(HAVE_LIBEXIF)) $(lib_gif_$(HAVE_LIBGIF)) \ |
| 24 | $(lib_webp_$(HAVE_LIBWEBP)) $(lib_fonts_$(HAVE_LIBFONTS)) \ |
| 25 | $(LDLIBS) |
| 26 | |
| 27 | objs = autoreload.o commands.o image.o main.o options.o \ |
| 28 | thumbs.o util.o window.o |
| 29 | |
| 30 | .SUFFIXES: |
| 31 | .SUFFIXES: .c .o |
| 32 | |
| 33 | all: nsxiv |
| 34 | |
| 35 | nsxiv: $(objs) |
| 36 | @echo "LINK $@" |
| 37 | $(CC) $(LDFLAGS) -o $@ $(objs) $(nsxiv_ldlibs) |
| 38 | |
| 39 | .c.o: |
| 40 | @echo "CC $@" |
| 41 | $(CC) $(CFLAGS) $(nsxiv_cppflags) -c -o $@ $< |
| 42 | |
| 43 | $(objs): Makefile config.mk nsxiv.h config.h commands.h |
| 44 | options.o: version.h |
| 45 | window.o: icon/data.h utf8.h |
| 46 | |
| 47 | config.h: |
| 48 | @echo "GEN $@" |
| 49 | cp config.def.h $@ |
| 50 | |
| 51 | version.h: config.mk .git/index |
| 52 | @echo "GEN $@" |
| 53 | v="$$(git describe 2>/dev/null || true)"; \ |
| 54 | echo "#define VERSION \"$${v:-$(VERSION)}\"" >$@ |
| 55 | |
| 56 | .git/index: |
| 57 | |
| 58 | dump_cppflags: |
| 59 | @echo $(nsxiv_cppflags) |
| 60 | |
| 61 | clean: |
| 62 | rm -f *.o nsxiv version.h |
| 63 | |
| 64 | install-all: install install-desktop install-icon |
| 65 | |
| 66 | install-desktop: |
| 67 | @echo "INSTALL nsxiv.desktop" |
| 68 | mkdir -p $(DESTDIR)$(PREFIX)/share/applications |
| 69 | cp etc/nsxiv.desktop $(DESTDIR)$(PREFIX)/share/applications |
| 70 | |
| 71 | install-icon: |
| 72 | @echo "INSTALL icon" |
| 73 | for f in $(ICONS); do \ |
| 74 | dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \ |
| 75 | mkdir -p "$$dir"; \ |
| 76 | cp "icon/$$f" "$$dir/nsxiv.png"; \ |
| 77 | chmod 644 "$$dir/nsxiv.png"; \ |
| 78 | done |
| 79 | |
| 80 | uninstall-icon: |
| 81 | @echo "REMOVE icon" |
| 82 | for f in $(ICONS); do \ |
| 83 | dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \ |
| 84 | rm -f "$$dir/nsxiv.png"; \ |
| 85 | done |
| 86 | |
| 87 | install: all |
| 88 | @echo "INSTALL bin/nsxiv" |
| 89 | mkdir -p $(DESTDIR)$(PREFIX)/bin |
| 90 | cp nsxiv $(DESTDIR)$(PREFIX)/bin/ |
| 91 | chmod 755 $(DESTDIR)$(PREFIX)/bin/nsxiv |
| 92 | @echo "INSTALL nsxiv.1" |
| 93 | mkdir -p $(DESTDIR)$(MANPREFIX)/man1 |
| 94 | sed "s!EGPREFIX!$(EGPREFIX)!g; s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" \ |
| 95 | etc/nsxiv.1 >$(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 |
| 96 | chmod 644 $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 |
| 97 | @echo "INSTALL share/nsxiv/" |
| 98 | mkdir -p $(DESTDIR)$(EGPREFIX) |
| 99 | cp etc/examples/* $(DESTDIR)$(EGPREFIX) |
| 100 | chmod 755 $(DESTDIR)$(EGPREFIX)/* |
| 101 | |
| 102 | uninstall: uninstall-icon |
| 103 | @echo "REMOVE bin/nsxiv" |
| 104 | rm -f $(DESTDIR)$(PREFIX)/bin/nsxiv |
| 105 | @echo "REMOVE nsxiv.1" |
| 106 | rm -f $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 |
| 107 | @echo "REMOVE nsxiv.desktop" |
| 108 | rm -f $(DESTDIR)$(PREFIX)/share/applications/nsxiv.desktop |
| 109 | @echo "REMOVE share/nsxiv/" |
| 110 | rm -rf $(DESTDIR)$(EGPREFIX) |
| 111 | |