-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
220 lines (186 loc) · 5.53 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# This makefile is a simpler alternative to the CMake build system, for simple
# local building of the libraries and tools.
# It will not install the libraries system-wide, but just create the 'sjpeg',
# and 'vjpeg' tools in the examples/ directory, along with the static
# library 'src/libsjpeg.a'.
#
# To build the library and examples, use 'make' from this top directory.
#### Customizable part ####
VERSION=1.0
ARCHIVE_FILE=sjpeg-$(VERSION).tar.gz
EXTRA_FLAGS= -DSJPEG_HAVE_PNG -DSJPEG_HAVE_JPEG
UTILS_LIBS= -lpng -ljpeg
# we use C++-11
EXTRA_FLAGS += -std=c++11
# OpenGL and GLUT
ifeq ($(strip $(shell uname)), Darwin)
EXTRA_FLAGS += -I/opt/local/include
EXTRA_FLAGS += -Wno-deprecated-declarations
EXTRA_LIBS += -L/opt/local/lib
GL_LIBS = -framework GLUT -framework OpenGL
EXTRA_FLAGS += -DHAVE_GLUT_GLUT_H
else
EXTRA_FLAGS += -I/usr/local/include
EXTRA_LIBS += -L/usr/local/lib
GL_LIBS = -lglut -lGL
EXTRA_FLAGS += -DHAVE_GL_GLUT_H
endif
# Uncomment for build for 32bit platform
# Alternatively, you can just use the command
# 'make EXTRA_FLAGS=-m32' to that effect.
# EXTRA_FLAGS += -m32
# Extra strictness flags
EXTRA_FLAGS += -Wextra
EXTRA_FLAGS += -Wunused
EXTRA_FLAGS += -Wshadow
EXTRA_FLAGS += -Wformat-security -Wformat-nonliteral
# EXTRA_FLAGS += -Wvla
# SSE4.1-specific flags:
ifeq ($(HAVE_SSE41), 1)
EXTRA_FLAGS += -DSJPEG_HAVE_SSE41
src/%_sse41.o: EXTRA_FLAGS += -msse4.1
endif
# AVX2-specific flags:
ifeq ($(HAVE_AVX2), 1)
EXTRA_FLAGS += -DSJPEG_HAVE_AVX2
src/%_avx2.o: EXTRA_FLAGS += -mavx2
endif
# NEON-specific flags:
# EXTRA_FLAGS += -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8
# -> seems to make the overall lib slower: -fno-split-wide-types
#### Nothing should normally be changed below this line ####
AR = ar
ARFLAGS = r
CXX = g++
CXXFLAGS = -Isrc/ -Wall $(EXTRA_FLAGS)
ifeq ($(DEBUG), 1)
CXXFLAGS += -g
else
CXXFLAGS += -O3 -DNDEBUG
endif
INSTALL = install
GROFF = /usr/bin/groff
COL = /usr/bin/col
LDFLAGS = $(EXTRA_LIBS) $(EXTRA_FLAGS) -lm
SJPEG_OBJS = \
src/bit_writer.o \
src/colors_rgb.o \
src/dichotomy.o \
src/enc.o \
src/fdct.o \
src/headers.o \
src/jpeg_tools.o \
src/score_7.o \
src/yuv_convert.o \
UTILS_OBJS = \
examples/utils.o \
HDRS_INSTALLED = \
src/sjpeg.h \
HDRS = \
examples/utils.h \
src/sjpegi.h \
src/bit_writer.h \
$(HDRS_INSTALLED) \
OUT_LIBS = src/libsjpeg.a examples/libutils.a
OUT_EXAMPLES = examples/sjpeg
OUT_EXAMPLES += examples/vjpeg
OUTPUT = $(OUT_LIBS) $(OUT_EXAMPLES)
ex: $(OUT_EXAMPLES)
all: ex
%.o: %.cc $(HDRS)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
examples/libutils.a: $(UTILS_OBJS)
src/libsjpeg.a: $(SJPEG_OBJS)
%.a:
$(AR) $(ARFLAGS) $@ $^
examples/sjpeg: examples/sjpeg.o
examples/sjpeg: examples/libutils.a
examples/sjpeg: src/libsjpeg.a
examples/sjpeg: EXTRA_LIBS += $(UTILS_LIBS)
examples/vjpeg: examples/vjpeg.o
examples/vjpeg: examples/libutils.a
examples/vjpeg: src/libsjpeg.a
examples/vjpeg: EXTRA_LIBS += $(UTILS_LIBS)
# warning! -lpthread must be declared first, before GL_LIBS:
examples/vjpeg: EXTRA_LIBS += -lpthread $(GL_LIBS)
examples/vjpeg: EXTRA_FLAGS += -DSJPEG_HAVE_OPENGL
$(OUT_EXAMPLES):
$(CXX) -o $@ $^ $(LDFLAGS)
test: test_cmd test_png_jpg
test_cmd: $(OUT_EXAMPLES)
cd tests && ./test_cmd.sh
test_png_jpg: $(OUT_EXAMPLES)
cd tests && ./test_png_jpg.sh
dist: DESTDIR := dist
dist: all
$(INSTALL) -m755 -d $(DESTDIR)/include/ \
$(DESTDIR)/bin $(DESTDIR)/doc $(DESTDIR)/lib
$(INSTALL) -m755 -s $(OUT_EXAMPLES) $(DESTDIR)/bin
$(INSTALL) -m644 $(HDRS_INSTALLED) $(DESTDIR)/include
$(INSTALL) -m644 src/libsjpeg.a $(DESTDIR)/lib
umask 022; \
for m in man/sjpeg.1 man/vjpeg.1; do \
basenam=$$(basename $$m .1); \
$(GROFF) -t -e -man -T utf8 $$m \
| $(COL) -bx >$(DESTDIR)/doc/$${basenam}.txt; \
$(GROFF) -t -e -man -T html $$m \
| $(COL) -bx >$(DESTDIR)/doc/$${basenam}.html; \
done
clean:
$(RM) $(OUTPUT) *~ \
examples/*.o examples/*~ man/*~ src/*.o src/*~ tests/*~ \
examples/*.lo src/*.lo
DIST_FILES= \
Application.mk \
Android.mk \
AUTHORS \
ChangeLog \
COPYING \
INSTALL \
Makefile \
NEWS \
README \
CMakeLists.txt \
cmake/android.cmake \
cmake/cpu.cmake \
cmake/sjpegConfig.cmake.in \
appveyor.yml \
src/libsjpeg.pc.in \
src/bit_writer.cc \
src/bit_writer.h \
src/colors_rgb.cc \
src/dichotomy.cc \
src/enc.cc \
src/fdct.cc \
src/headers.cc \
src/jpeg_tools.cc \
src/md5sum.h \
src/score_7.cc \
src/sjpeg.h \
src/sjpegi.h \
src/yuv_convert.cc \
man/sjpeg.1 \
man/vjpeg.1 \
examples/Android.mk \
examples/sjpeg.cc \
examples/vjpeg.cc \
examples/utils.h \
examples/utils.cc \
tests/test_cmd.sh \
tests/test_png_jpg.sh \
tests/testdata/source1.png \
tests/testdata/source1.itl.png \
tests/testdata/source2.jpg \
tests/testdata/source3.jpg \
tests/testdata/source4.ppm \
tests/testdata/test_exif_xmp.png \
tests/testdata/test_icc.jpg \
pak: clean
ifeq ($(strip $(shell uname)), Darwin)
COPYFILE_DISABLE=1 tar -s ,.*,sjpeg-$(VERSION)\/~,p -czf $(ARCHIVE_FILE) $(DIST_FILES)
else
tar --transform="s#^#sjpeg-1.0/#" -czf $(ARCHIVE_FILE) $(DIST_FILES)
endif
@echo "GENERATED ARCHIVE: $(ARCHIVE_FILE)"
.PHONY: all clean dist ex pak
.SUFFIXES: