Krolyxon
Commit 5155d52

Branches

Refs →

nsxivMakefile

95 lines · 2.1 KB · Makefile

1# Works best with GNU make 3.80 or later
2
3VERSION = git-20171012
4
5srcdir = .
6
7PREFIX = /usr/local
8MANPREFIX = $(PREFIX)/share/man
9
10CC ?= gcc
11CFLAGS += -std=c99 -Wall -pedantic
12CPPFLAGS += -I/usr/include/freetype2 -D_XOPEN_SOURCE=700
13DEPFLAGS = -MMD -MP
14LDFLAGS +=
15
16# autoreload backend: inotify/nop
17AUTORELOAD = inotify
18
19# enable features requiring giflib (-lgif)
20HAVE_GIFLIB = 1
21
22# enable features requiring libexif (-lexif)
23HAVE_LIBEXIF = 1
24
25REQ_CPPFLAGS = -I. -DVERSION=\"$(VERSION)\" \
26 -DHAVE_GIFLIB=$(HAVE_GIFLIB) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF)
27ALL_CPPFLAGS = $(REQ_CPPFLAGS) $(CPPFLAGS)
28
29LIB_EXIF_0 =
30LIB_EXIF_1 = -lexif
31LIB_GIF_0 =
32LIB_GIF_1 = -lgif
33LDLIBS = -lImlib2 -lX11 -lXft \
34 $(LIB_EXIF_$(HAVE_LIBEXIF)) $(LIB_GIF_$(HAVE_GIFLIB))
35
36-include config.mk
37
38SRCS = autoreload_$(AUTORELOAD).c commands.c image.c main.c options.c \
39 thumbs.c util.c window.c
40OBJS = $(SRCS:.c=.o)
41DEPS = $(SRCS:.c=.d)
42
43all: sxiv
44
45.PHONY: all clean install uninstall
46.SUFFIXES:
47.SUFFIXES: .c .o
48$(V).SILENT:
49
50sxiv: $(OBJS)
51 @echo "LINK $@"
52 $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
53
54$(OBJS): config.h $(srcdir)/Makefile
55
56.c.o:
57 @echo "CC $@"
58 $(CC) $(ALL_CPPFLAGS) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
59
60%.o: $(srcdir)/%.c
61 @echo "CC $@"
62 $(CC) $(ALL_CPPFLAGS) $(DEPFLAGS) $(CFLAGS) -c -o $@ $(srcdir)/$(@:.o=.c)
63
64config.h:
65 @echo "GEN $@"
66 cp $(srcdir)/config.def.h $@
67
68clean:
69 rm -f $(OBJS) $(DEPS) sxiv
70
71install: all
72 @echo "INSTALL bin/sxiv"
73 mkdir -p $(DESTDIR)$(PREFIX)/bin
74 cp sxiv $(DESTDIR)$(PREFIX)/bin/
75 chmod 755 $(DESTDIR)$(PREFIX)/bin/sxiv
76 @echo "INSTALL sxiv.1"
77 mkdir -p $(DESTDIR)$(MANPREFIX)/man1
78 sed "s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" sxiv.1 \
79 >$(DESTDIR)$(MANPREFIX)/man1/sxiv.1
80 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
81 @echo "INSTALL share/sxiv/"
82 mkdir -p $(DESTDIR)$(PREFIX)/share/sxiv/exec
83 cp exec/* $(DESTDIR)$(PREFIX)/share/sxiv/exec/
84 chmod 755 $(DESTDIR)$(PREFIX)/share/sxiv/exec/*
85
86uninstall:
87 @echo "REMOVE bin/sxiv"
88 rm -f $(DESTDIR)$(PREFIX)/bin/sxiv
89 @echo "REMOVE sxiv.1"
90 rm -f $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
91 @echo "REMOVE share/sxiv/"
92 rm -rf $(DESTDIR)$(PREFIX)/share/sxiv
93
94-include $(DEP)
95