Krolyxon
Commit 6ce94e3

Branches

Refs →

nsxivMakefile

126 lines · 3.3 KB · Makefile

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