Krolyxon
Commit 4a282da

Branches

Refs →

nsxivMakefile

132 lines · 3.4 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_LIBFONTS ?= $(OPT_DEP_DEFAULT)
17HAVE_LIBGIF ?= $(OPT_DEP_DEFAULT)
18HAVE_LIBEXIF ?= $(OPT_DEP_DEFAULT)
19HAVE_LIBWEBP ?= $(OPT_DEP_DEFAULT)
20
21# CFLAGS, any optimization flags goes here
22CFLAGS ?= -std=c99 -Wall -pedantic
23
24# icons that will be installed via `make icon`
25ICONS = 16x16.png 32x32.png 48x48.png 64x64.png 128x128.png
26
27inc_fonts_0 =
28inc_fonts_1 = -I/usr/include/freetype2 -I$(PREFIX)/include/freetype2
29
30CPPFLAGS = -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
35lib_fonts_0 =
36lib_fonts_1 = -lXft -lfontconfig
37lib_exif_0 =
38lib_exif_1 = -lexif
39lib_gif_0 =
40lib_gif_1 = -lgif
41lib_webp_0 =
42lib_webp_1 = -lwebpdemux -lwebp
43autoreload_0 = nop
44autoreload_1 = inotify
45# using += because certain *BSD distros may need to add additional flags
46LDLIBS += -lImlib2 -lX11 \
47 $(lib_exif_$(HAVE_LIBEXIF)) $(lib_gif_$(HAVE_LIBGIF)) \
48 $(lib_webp_$(HAVE_LIBWEBP)) $(lib_fonts_$(HAVE_LIBFONTS))
49
50OBJS = 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
57all: nsxiv
58
59nsxiv: $(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
68options.o: version.h
69window.o: icon/data.h
70
71config.h:
72 @echo "GEN $@"
73 cp config.def.h $@
74
75version.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
82clean:
83 rm -f *.o nsxiv version.h
84
85install-all: install install-desktop install-icon
86
87install-desktop:
88 @echo "INSTALL nsxiv.desktop"
89 mkdir -p $(DESTDIR)$(PREFIX)/share/applications
90 cp nsxiv.desktop $(DESTDIR)$(PREFIX)/share/applications
91
92install-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
101uninstall-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
108install: 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
123uninstall: 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