forked from kornelski/pngquant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
103 lines (75 loc) · 2.78 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
99
100
101
102
103
# Makefile for pngquant
VERSION = $(shell grep 'define PNGQUANT_VERSION' pngquant.c | grep -Eo '[12]\.[0-9.]*')
# This changes default "cc" to "gcc", but still allows customization of the CC variable
# if this line causes problems with non-GNU make, just remove it:
CC := $(patsubst cc,gcc,$(CC))
BIN ?= pngquant
PREFIX ?= /usr/local
BINPREFIX = $(PREFIX)/bin
# Alternatively, build libpng and zlib in these directories:
CUSTOMLIBPNG ?= ../libpng
CUSTOMZLIB ?= ../zlib
CFLAGSOPT ?= -DNDEBUG -O3 -ffast-math -funroll-loops -fomit-frame-pointer
CFLAGS ?= -Wall -Wno-unknown-pragmas -I. -I/usr/local/include/ -I/usr/include/ $(CFLAGSOPT)
CFLAGS += -std=c99 $(CFLAGSADD)
LDFLAGS ?= -L/usr/local/lib/ -L/usr/lib/
ifneq "$(wildcard /usr/X11/lib/)" ""
LDFLAGS += -L/usr/X11/lib/
CFLAGS += -I/usr/X11/include/
endif
ifneq "$(wildcard /opt/local/lib)" ""
LDFLAGS += -L/opt/local/lib
CFLAGS += -I/opt/local/include/libpng15
endif
ifneq "$(wildcard $(CUSTOMLIBPNG))" ""
LDFLAGS += -L$(CUSTOMLIBPNG) -L$(CUSTOMLIBPNG)/lib
CFLAGS += -I$(CUSTOMLIBPNG) -I$(CUSTOMLIBPNG)/include
endif
ifneq "$(wildcard $(CUSTOMZLIB))" ""
LDFLAGS += -L$(CUSTOMZLIB) -L$(CUSTOMZLIB)/lib
CFLAGS += -I$(CUSTOMZLIB) -I$(CUSTOMZLIB)/include
endif
LDFLAGS += -lpng -lz -lm lib/libimagequant.a -lm $(LDFLAGSADD)
OBJS = pngquant.o rwpng.o
COCOA_OBJS = rwpng_cocoa.o
DISTLIBFILES = lib/*.[ch] lib/Makefile lib/COPYRIGHT lib/MANUAL.md
DISTFILES = $(OBJS:.o=.c) *.[hm] pngquant.1 Makefile README.md INSTALL CHANGELOG COPYRIGHT
TARNAME = pngquant-$(VERSION)
TARFILE = $(TARNAME)-src.tar.bz2
ifdef USE_COCOA
CFLAGS += -mmacosx-version-min=10.6 -DUSE_COCOA=1
LDLAGS += -mmacosx-version-min=10.6
OBJS += $(COCOA_OBJS)
FRAMEWORKS += -framework Cocoa
endif
BUILD_CONFIGURATION="$(CC) $(CFLAGS) $(LDFLAGS)"
all: $(BIN)
lib/libimagequant.a::
$(MAKE) -C lib static
openmp::
$(MAKE) CFLAGSADD="$(CFLAGSADD) -fopenmp" OPENMPFLAGS="-Bstatic -lgomp" -j8 $(MKFLAGS)
$(BIN): $(OBJS) lib/libimagequant.a
$(CC) $(OBJS) $(LDFLAGS) $(OPENMPFLAGS) $(FRAMEWORKS) -o $@
rwpng_cocoa.o: rwpng_cocoa.m
clang -c $(CFLAGS) -o $@ $<
$(OBJS): rwpng.h build_configuration
install: $(BIN)
install -m 0755 -p $(BIN) $(DESTDIR)$(BINPREFIX)/$(BIN)
uninstall:
rm -f $(DESTDIR)$(BINPREFIX)/$(BIN)
dist: $(TARFILE)
$(TARFILE): $(DISTFILES)
rm -rf $(TARFILE) $(TARNAME)
mkdir -p $(TARNAME)/lib
cp $(DISTFILES) $(TARNAME)
cp $(DISTLIBFILES) $(TARNAME)/lib
tar -cjf $(TARFILE) --numeric-owner --exclude='._*' $(TARNAME)
rm -rf $(TARNAME)
shasum $(TARFILE)
clean:
rm -f $(BIN) $(OBJS) $(COCOA_OBJS) $(TARFILE) build_configuration
$(MAKE) -C lib clean
build_configuration::
@test -f build_configuration && test $(BUILD_CONFIGURATION) = "`cat build_configuration`" || echo > build_configuration $(BUILD_CONFIGURATION)
.PHONY: all openmp install uninstall dist clean
.DELETE_ON_ERROR: