Krolyxon
Commit 9e52ae7

Branches

Refs →

nsxivMakefile

65 lines · 1.6 KB · Makefile

1VERSION = git-20110923
2
3CC = gcc
4CFLAGS = -Wall -pedantic -O2
5LDFLAGS =
6LIBS = -lX11 -lImlib2
7
8PREFIX = /usr/local
9MANPREFIX = $(PREFIX)/share/man
10
11SRC = commands.c image.c main.c options.c thumbs.c util.c window.c
12OBJ = $(SRC:.c=.o)
13
14all: options sxiv
15
16options:
17 @echo "sxiv build options:"
18 @echo "CC = $(CC)"
19 @echo "CFLAGS = $(CFLAGS)"
20 @echo "LDFLAGS = $(LDFLAGS)"
21 @echo "PREFIX = $(PREFIX)"
22
23.c.o:
24 @echo "CC $<"
25 @$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<
26
27$(OBJ) config: Makefile config.h
28
29config: config.c
30 @$(CC) $(CFLAGS) -o $@ $@.c
31
32config.h:
33 @echo "creating $@ from config.def.h"
34 @cp config.def.h $@
35
36sxiv: $(OBJ) config
37 @echo "CC -o $@"
38 @$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $$(./config -l)
39
40clean:
41 @echo "cleaning"
42 @rm -f $(OBJ) config sxiv sxiv-$(VERSION).tar.gz
43
44dist: clean
45 @echo "creating dist tarball"
46 @mkdir -p sxiv-$(VERSION)
47 @cp LICENSE Makefile README.md config.def.h sxiv.1 $(SRC) config.c \
48 sxiv-$(VERSION)
49 @tar -cf sxiv-$(VERSION).tar sxiv-$(VERSION)
50 @gzip sxiv-$(VERSION).tar
51 @rm -rf sxiv-$(VERSION)
52
53install: all
54 @echo "installing executable file to $(DESTDIR)$(PREFIX)/bin"
55 @install -D -m 755 sxiv $(DESTDIR)$(PREFIX)/bin/sxiv
56 @echo "installing manual page to $(DESTDIR)$(MANPREFIX)/man1"
57 @mkdir -p $(DESTDIR)$(MANPREFIX)/man1
58 @sed "s/VERSION/$(VERSION)/g" sxiv.1 > $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
59 @chmod 644 $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
60
61uninstall:
62 @echo "removing executable file from $(DESTDIR)$(PREFIX)/bin"
63 @rm -f $(DESTDIR)$(PREFIX)/bin/sxiv
64 @echo "removing manual page from $(DESTDIR)$(MANPREFIX)/man1"
65 @rm -f $(DESTDIR)$(MANPREFIX)/man1/sxiv.1