Krolyxon
Commit 7f71ddf

Branches

Refs →

nsxivMakefile

133 lines · 3.3 KB · Makefile

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