-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (69 loc) · 2.28 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
-include config.mk
BIN ?= pngquant
BINPREFIX ?= $(DESTDIR)$(PREFIX)/bin
MANPREFIX ?= $(DESTDIR)$(PREFIX)/share/man
OBJS = pngquant.o rwpng.o
COCOA_OBJS = rwpng_cocoa.o
ifeq (1, $(COCOA_READER))
OBJS += $(COCOA_OBJS)
endif
STATICLIB = lib/libimagequant.a
SHAREDLIB = lib/libimagequant.so
DISTFILES = *.[chm] pngquant.1 Makefile configure README.md INSTALL CHANGELOG COPYRIGHT
TARNAME = pngquant-$(VERSION)
TARFILE = $(TARNAME)-src.tar.gz
LIBDISTFILES = lib/*.[ch] lib/COPYRIGHT lib/README.md lib/configure lib/Makefile
TESTBIN = test/test
all: $(BIN)
staticlib: $(STATICLIB)
$(STATICLIB): config.mk $(LIBDISTFILES)
$(MAKE) -C lib static
sharedlib: lib/libimagequant.h
$(MAKE) -C lib shared
$(SHAREDLIB): config.mk sharedlib
$(OBJS): $(wildcard *.h) config.mk
rwpng_cocoa.o: rwpng_cocoa.m
$(CC) -Wno-enum-conversion -c $(CFLAGS) -o $@ $< &> /dev/null || clang -Wno-enum-conversion -c -O3 -o $@ $<
$(BIN): $(OBJS) $(STATICLIB)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@
$(TESTBIN): test/test.o $(STATICLIB)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@
test: $(BIN) $(TESTBIN)
./test/test.sh ./test $(BIN) $(TESTBIN)
bin.shared: $(OBJS) $(SHAREDLIB)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $(BIN)
testbin.shared: test/test.o $(SHAREDLIB)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $(TESTBIN)
test.shared: bin.shared testbin.shared
./test/test.sh ./test $(BIN) $(TESTBIN)
dist: $(TARFILE)
$(TARFILE): $(DISTFILES)
rm -rf $(TARFILE) $(TARNAME)
mkdir -p $(TARNAME)/lib
cp $(DISTFILES) $(TARNAME)
cp $(LIBDISTFILES) $(TARNAME)/lib
tar -czf $(TARFILE) --numeric-owner --exclude='._*' $(TARNAME)
rm -rf $(TARNAME)
-shasum $(TARFILE)
install: $(BIN) $(BIN).1
-mkdir -p '$(BINPREFIX)'
-mkdir -p '$(MANPREFIX)/man1'
install -m 0755 -p '$(BIN)' '$(BINPREFIX)/$(BIN)'
install -m 0644 -p '$(BIN).1' '$(MANPREFIX)/man1/'
uninstall:
rm -f '$(BINPREFIX)/$(BIN)'
rm -f '$(MANPREFIX)/man1/$(BIN).1'
clean:
$(MAKE) -C lib clean
rm -f '$(BIN)' $(OBJS) $(COCOA_OBJS) $(STATICLIB) $(TARFILE)
distclean: clean
$(MAKE) -C lib distclean
rm -f config.mk pngquant-*-src.tar.gz
config.mk: lib/libimagequant.h
ifeq ($(filter %clean %distclean, $(MAKECMDGOALS)), )
./configure
endif
lib/libimagequant.h:
git submodule init && git submodule update || true
.PHONY: all clean dist distclean dll install uninstall test staticlib
.DELETE_ON_ERROR: