Krolyxon
Commit 3724d3f

Branches

Refs →

nsxivMakefile

69 lines · 1.6 KB · Makefile

1VERSION := git-20170517
2
3PREFIX := /usr/local
4MANPREFIX := $(PREFIX)/share/man
5
6CC ?= gcc
7CFLAGS += -std=c99 -Wall -pedantic
8CPPFLAGS += -I/usr/include/freetype2 -D_XOPEN_SOURCE=700
9LDFLAGS +=
10LIBS := -lImlib2 -lX11 -lXft
11
12# optional dependencies:
13# giflib: gif animations
14ifndef NO_GIFLIB
15 CPPFLAGS += -DHAVE_GIFLIB
16 LIBS += -lgif
17endif
18# libexif: jpeg auto-orientation, exif thumbnails
19ifndef NO_LIBEXIF
20 CPPFLAGS += -DHAVE_LIBEXIF
21 LIBS += -lexif
22endif
23
24.PHONY: clean install uninstall
25
26SRC := commands.c image.c main.c options.c thumbs.c util.c window.c
27# conditionally compile in autoreload-backend; usage: `make AUTORELOAD=nop`
28ifeq ($(AUTORELOAD),nop)
29 SRC += autoreload_nop.c
30else
31 SRC += autoreload_inotify.c
32endif
33
34DEP := $(SRC:.c=.d)
35OBJ := $(SRC:.c=.o)
36
37all: config.h sxiv
38
39$(OBJ): Makefile
40
41-include $(DEP)
42
43%.o: %.c
44 $(CC) $(CFLAGS) $(CPPFLAGS) -DVERSION=\"$(VERSION)\" -MMD -MP -c -o $@ $<
45
46config.h:
47 cp config.def.h $@
48
49sxiv: $(OBJ)
50 $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
51
52clean:
53 rm -f $(OBJ) $(DEP) sxiv
54
55install: all
56 mkdir -p $(DESTDIR)$(PREFIX)/bin
57 cp sxiv $(DESTDIR)$(PREFIX)/bin/
58 chmod 755 $(DESTDIR)$(PREFIX)/bin/sxiv
59 mkdir -p $(DESTDIR)$(MANPREFIX)/man1
60 sed "s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" sxiv.1 > $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
61 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
62 mkdir -p $(DESTDIR)$(PREFIX)/share/sxiv/exec
63 cp exec/* $(DESTDIR)$(PREFIX)/share/sxiv/exec/
64 chmod 755 $(DESTDIR)$(PREFIX)/share/sxiv/exec/*
65
66uninstall:
67 rm -f $(DESTDIR)$(PREFIX)/bin/sxiv
68 rm -f $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
69 rm -rf $(DESTDIR)$(PREFIX)/share/sxiv