Mercurial > hg > forks > libbpg
annotate Makefile @ 34:5d51fff843eb default tip
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 08 Mar 2020 19:18:48 +0200 |
parents | a6e6f87414ea |
children |
rev | line source |
---|---|
0 | 1 # libbpg Makefile |
2 # | |
3 # Compile options: | |
4 # | |
5 # Enable compilation of Javascript decoder with Emscripten | |
6 #USE_EMCC=y | |
7 # Enable x265 for the encoder | |
8 USE_X265=y | |
9 # Enable the JCTVC code (best quality but slow) for the encoder | |
10 #USE_JCTVC=y | |
24
377dc78a052d
Add EXIF metadata conversion from TIFF files to BPG via libexif.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
11 |
377dc78a052d
Add EXIF metadata conversion from TIFF files to BPG via libexif.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
12 # Use libexif (currently only for converting TIFF metadata to EXIF in BPG) |
377dc78a052d
Add EXIF metadata conversion from TIFF files to BPG via libexif.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
13 USE_LIBEXIF=y |
377dc78a052d
Add EXIF metadata conversion from TIFF files to BPG via libexif.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
14 |
0 | 15 # Compile bpgview (SDL and SDL_image libraries needed) |
16 USE_BPGVIEW=y | |
17 # Enable it to use bit depths > 12 (need more tests to validate encoder) | |
18 #USE_JCTVC_HIGH_BIT_DEPTH=y | |
19 # Enable the cross compilation for Windows | |
20 #CONFIG_WIN32=y | |
21 # Enable for compilation on MacOS X | |
22 #CONFIG_APPLE=y | |
23 # Installation prefix | |
24 prefix=/usr/local | |
25 | |
26 | |
27 ################################# | |
28 | |
29 ifdef CONFIG_WIN32 | |
30 CROSS_PREFIX:=x86_64-w64-mingw32- | |
31 #CROSS_PREFIX=i686-w64-mingw32- | |
32 EXE:=.exe | |
33 else | |
34 CROSS_PREFIX:= | |
35 EXE:= | |
36 endif | |
37 | |
38 CC=$(CROSS_PREFIX)gcc | |
39 CXX=$(CROSS_PREFIX)g++ | |
40 AR=$(CROSS_PREFIX)ar | |
41 EMCC=emcc | |
42 | |
43 PWD:=$(shell pwd) | |
44 | |
2 | 45 LIBSDL_CFLAGS:=$(shell pkg-config --cflags sdl) |
46 LIBSDL_LDFLAGS:=$(shell pkg-config --libs sdl) -lSDL_image | |
47 | |
48 LIBPNG_CFLAGS:=$(shell pkg-config --cflags libpng) | |
49 LIBPNG_LDFLAGS:=$(shell pkg-config --libs libpng) | |
50 | |
51 LIBJPEG_CFLAGS:=$(shell pkg-config --cflags libjpeg) | |
52 LIBJPEG_LDFLAGS:=$(shell pkg-config --libs libjpeg) | |
53 | |
24
377dc78a052d
Add EXIF metadata conversion from TIFF files to BPG via libexif.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
54 ifdef USE_LIBEXIF |
377dc78a052d
Add EXIF metadata conversion from TIFF files to BPG via libexif.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
55 LIBEXIF_CFLAGS:=$(shell pkg-config --cflags libexif) -DHAVE_LIBEXIF |
377dc78a052d
Add EXIF metadata conversion from TIFF files to BPG via libexif.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
56 LIBEXIF_LDFLAGS:=$(shell pkg-config --libs libexif) |
377dc78a052d
Add EXIF metadata conversion from TIFF files to BPG via libexif.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
57 endif |
377dc78a052d
Add EXIF metadata conversion from TIFF files to BPG via libexif.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
58 |
4
bbd61622856a
Initial implementation of TIFF format read support via libtiff.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
59 LIBTIFF_CFLAGS:=$(shell pkg-config --cflags libtiff-4) |
bbd61622856a
Initial implementation of TIFF format read support via libtiff.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
60 LIBTIFF_LDFLAGS:=$(shell pkg-config --libs libtiff-4) |
bbd61622856a
Initial implementation of TIFF format read support via libtiff.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
61 |
34
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
62 CFLAGS:=-O3 -W -Wall -MMD -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -fomit-frame-pointer |
0 | 63 CFLAGS+=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT |
24
377dc78a052d
Add EXIF metadata conversion from TIFF files to BPG via libexif.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
64 CFLAGS+=-I. $(LIBSDL_CFLAGS) $(LIBPNG_CFLAGS) $(LIBJPEG_CFLAGS) $(LIBTIFF_CFLAGS) $(LIBEXIF_CFLAGS) |
0 | 65 CFLAGS+=-DCONFIG_BPG_VERSION=\"$(shell cat VERSION)\" |
66 ifdef USE_JCTVC_HIGH_BIT_DEPTH | |
67 CFLAGS+=-DRExt__HIGH_BIT_DEPTH_SUPPORT | |
68 endif | |
69 | |
70 # Emscriptem config | |
71 EMLDFLAGS:=-s "EXPORTED_FUNCTIONS=['_bpg_decoder_open','_bpg_decoder_decode','_bpg_decoder_get_info','_bpg_decoder_start','_bpg_decoder_get_frame_duration','_bpg_decoder_get_line','_bpg_decoder_close','_malloc','_free']" | |
72 EMLDFLAGS+=-s NO_FILESYSTEM=1 -s NO_BROWSER=1 | |
73 #EMLDFLAGS+=-O1 --pre-js pre.js --post-js post.js | |
74 # Note: the closure compiler is disabled because it adds unwanted global symbols | |
75 EMLDFLAGS+=-O3 --memory-init-file 0 --closure 0 --pre-js pre.js --post-js post.js | |
76 EMCFLAGS:=$(CFLAGS) | |
77 | |
78 LDFLAGS=-g | |
79 ifdef CONFIG_APPLE | |
80 LDFLAGS+=-Wl,-dead_strip | |
81 else | |
82 LDFLAGS+=-Wl,--gc-sections | |
83 endif | |
84 CFLAGS+=-g | |
85 CXXFLAGS=$(CFLAGS) | |
86 | |
87 PROGS=bpgdec$(EXE) bpgenc$(EXE) | |
88 ifdef USE_BPGVIEW | |
89 PROGS+=bpgview$(EXE) | |
90 endif | |
91 ifdef USE_EMCC | |
92 PROGS+=bpgdec.js bpgdec8.js bpgdec8a.js | |
93 endif | |
94 | |
95 all: $(PROGS) | |
96 | |
97 LIBBPG_OBJS:=$(addprefix libavcodec/, \ | |
98 hevc_cabac.o hevc_filter.o hevc.o hevcpred.o hevc_refs.o\ | |
99 hevcdsp.o hevc_mvs.o hevc_ps.o hevc_sei.o\ | |
100 utils.o cabac.o golomb.o videodsp.o ) | |
101 LIBBPG_OBJS+=$(addprefix libavutil/, mem.o buffer.o log2_tab.o frame.o pixdesc.o md5.o ) | |
102 LIBBPG_OBJS+=libbpg.o | |
103 | |
104 LIBBPG_JS_OBJS:=$(patsubst %.o, %.js.o, $(LIBBPG_OBJS)) tmalloc.js.o | |
105 | |
106 LIBBPG_JS8_OBJS:=$(patsubst %.o, %.js8.o, $(LIBBPG_OBJS)) tmalloc.js8.o | |
107 | |
108 LIBBPG_JS8A_OBJS:=$(patsubst %.o, %.js8a.o, $(LIBBPG_OBJS)) tmalloc.js8a.o | |
109 | |
110 $(LIBBPG_OBJS): CFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -D_GNU_SOURCE=1 -DUSE_VAR_BIT_DEPTH -DUSE_PRED | |
111 | |
112 $(LIBBPG_JS_OBJS): EMCFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -D_GNU_SOURCE=1 -DUSE_VAR_BIT_DEPTH | |
113 | |
114 $(LIBBPG_JS8_OBJS): EMCFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -D_GNU_SOURCE=1 | |
115 | |
116 $(LIBBPG_JS8A_OBJS): EMCFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -D_GNU_SOURCE=1 -DUSE_PRED | |
117 | |
118 BPGENC_OBJS:=bpgenc.o | |
119 BPGENC_LIBS:= | |
120 | |
121 ifdef USE_X265 | |
122 | |
123 X265_LIBS:=./x265.out/8bit/libx265.a ./x265.out/10bit/libx265.a ./x265.out/12bit/libx265.a | |
124 BPGENC_OBJS+=x265_glue.o $(X265_LIBS) | |
125 | |
126 bpgenc.o: CFLAGS+=-DUSE_X265 | |
127 x265_glue.o: CFLAGS+=-I./x265/source -I./x265.out/8bit | |
128 x265_glue.o: $(X265_LIBS) | |
129 | |
130 ifdef CONFIG_WIN32 | |
131 CMAKE_OPTS:=-DCMAKE_TOOLCHAIN_FILE=../../x265/build/msys/toolchain-x86_64-w64-mingw32.cmake | |
132 else | |
133 CMAKE_OPTS:= | |
134 endif | |
135 | |
136 x265.out: | |
137 mkdir -p x265.out/8bit x265.out/10bit x265.out/12bit | |
138 cd x265.out/12bit && cmake ../../x265/source $(CMAKE_OPTS) -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON | |
139 cd x265.out/10bit && cmake ../../x265/source $(CMAKE_OPTS) -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN10=ON | |
140 cd x265.out/8bit && cmake ../../x265/source $(CMAKE_OPTS) -DLINKED_10BIT=ON -DLINKED_12BIT=ON -DENABLE_SHARED=OFF -DENABLE_CLI=OFF | |
141 | |
142 # use this target to manually rebuild x265 | |
143 x265_make: | x265.out | |
144 $(MAKE) -C x265.out/12bit | |
145 $(MAKE) -C x265.out/10bit | |
146 $(MAKE) -C x265.out/8bit | |
147 | |
148 x265_clean: | |
149 rm -rf x265.out | |
150 | |
151 $(X265_LIBS): x265_make | |
152 | |
153 else | |
154 | |
155 x265_clean: | |
156 | |
157 endif # USE_X265 | |
158 | |
159 ifdef USE_JCTVC | |
160 JCTVC_OBJS=$(addprefix jctvc/TLibEncoder/, SyntaxElementWriter.o TEncSbac.o \ | |
25 | 161 TEncBinCoderCABACCounter.o TEncGOP.o\ |
162 TEncSampleAdaptiveOffset.o TEncBinCoderCABAC.o TEncAnalyze.o\ | |
163 TEncEntropy.o TEncTop.o SEIwrite.o TEncPic.o TEncRateCtrl.o\ | |
164 WeightPredAnalysis.o TEncSlice.o TEncCu.o NALwrite.o TEncCavlc.o\ | |
165 TEncSearch.o TEncPreanalyzer.o) | |
0 | 166 JCTVC_OBJS+=jctvc/TLibVideoIO/TVideoIOYuv.o |
167 JCTVC_OBJS+=$(addprefix jctvc/TLibCommon/, TComWeightPrediction.o TComLoopFilter.o\ | |
25 | 168 TComBitStream.o TComMotionInfo.o TComSlice.o ContextModel3DBuffer.o\ |
169 TComPic.o TComRdCostWeightPrediction.o TComTU.o TComPicSym.o\ | |
170 TComPicYuv.o TComYuv.o TComTrQuant.o TComInterpolationFilter.o\ | |
171 ContextModel.o TComSampleAdaptiveOffset.o SEI.o TComPrediction.o\ | |
172 TComDataCU.o TComChromaFormat.o Debug.o TComRom.o\ | |
173 TComPicYuvMD5.o TComRdCost.o TComPattern.o TComCABACTables.o) | |
0 | 174 JCTVC_OBJS+=jctvc/libmd5/libmd5.o |
175 JCTVC_OBJS+=jctvc/TAppEncCfg.o jctvc/TAppEncTop.o jctvc/program_options_lite.o | |
176 | |
177 $(JCTVC_OBJS) jctvc_glue.o: CFLAGS+=-I$(PWD)/jctvc -Wno-sign-compare | |
178 | |
179 jctvc/libjctvc.a: $(JCTVC_OBJS) | |
180 $(AR) rcs $@ $^ | |
181 | |
182 BPGENC_OBJS+=jctvc_glue.o jctvc/libjctvc.a | |
183 | |
184 bpgenc.o: CFLAGS+=-DUSE_JCTVC | |
185 endif # USE_JCTVC | |
186 | |
187 | |
188 ifdef CONFIG_WIN32 | |
189 | |
190 BPGDEC_LIBS:=-lpng -lz | |
191 BPGENC_LIBS+=-lpng -ljpeg -lz | |
192 BPGVIEW_LIBS:=-lmingw32 -lSDLmain -lSDL_image -lSDL -mwindows | |
193 | |
194 else | |
195 | |
196 ifdef CONFIG_APPLE | |
197 LIBS:= | |
198 else | |
199 LIBS:=-lrt | |
200 endif # !CONFIG_APPLE | |
2 | 201 |
0 | 202 LIBS+=-lm -lpthread |
34
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
203 BPGDEC_LIBS:=$(LIBPNG_LDFLAGS) $(LIBEXIF_LDFLAGS) $(LIBS) |
24
377dc78a052d
Add EXIF metadata conversion from TIFF files to BPG via libexif.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
204 BPGENC_LIBS+=$(LIBPNG_LDFLAGS) $(LIBJPEG_LDFLAGS) $(LIBTIFF_LDFLAGS) $(LIBEXIF_LDFLAGS) $(LIBS) |
2 | 205 BPGVIEW_LIBS:=$(LIBSDL_LDFLAGS) $(LIBS) |
0 | 206 |
207 endif #!CONFIG_WIN32 | |
208 | |
34
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
209 bpgenc.o: |
0 | 210 |
211 libbpg.a: $(LIBBPG_OBJS) | |
212 $(AR) rcs $@ $^ | |
213 | |
214 bpgdec$(EXE): bpgdec.o libbpg.a | |
215 $(CC) $(LDFLAGS) -o $@ $^ $(BPGDEC_LIBS) | |
216 | |
217 bpgenc$(EXE): $(BPGENC_OBJS) | |
218 $(CXX) $(LDFLAGS) -o $@ $^ $(BPGENC_LIBS) | |
219 | |
220 bpgview$(EXE): bpgview.o libbpg.a | |
221 $(CC) $(LDFLAGS) -o $@ $^ $(BPGVIEW_LIBS) | |
222 | |
223 bpgdec.js: $(LIBBPG_JS_OBJS) post.js | |
224 $(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=33554432 -o $@ $(LIBBPG_JS_OBJS) | |
225 | |
226 bpgdec8.js: $(LIBBPG_JS8_OBJS) post.js | |
227 $(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=33554432 -o $@ $(LIBBPG_JS8_OBJS) | |
228 | |
229 bpgdec8a.js: $(LIBBPG_JS8A_OBJS) post.js | |
230 $(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=33554432 -o $@ $(LIBBPG_JS8A_OBJS) | |
231 | |
232 size: | |
233 strip bpgdec | |
234 size bpgdec libbpg.o libavcodec/*.o libavutil/*.o | sort -n | |
235 gzip < bpgdec | wc | |
236 | |
237 install: bpgenc bpgdec | |
238 install -s -m 755 $^ $(prefix)/bin | |
239 | |
240 CLEAN_DIRS=doc html libavcodec libavutil \ | |
241 jctvc jctvc/TLibEncoder jctvc/TLibVideoIO jctvc/TLibCommon jctvc/libmd5 | |
242 | |
243 clean: x265_clean | |
244 rm -f $(PROGS) *.o *.a *.d *~ $(addsuffix /*.o, $(CLEAN_DIRS)) \ | |
245 $(addsuffix /*.d, $(CLEAN_DIRS)) $(addsuffix /*~, $(CLEAN_DIRS)) \ | |
246 $(addsuffix /*.a, $(CLEAN_DIRS)) | |
247 | |
248 %.o: %.c | |
249 $(CC) $(CFLAGS) -c -o $@ $< | |
250 | |
251 %.o: %.cpp | |
252 $(CXX) $(CXXFLAGS) -c -o $@ $< | |
253 | |
254 %.js.o: %.c | |
255 $(EMCC) $(EMCFLAGS) -c -o $@ $< | |
256 | |
257 %.js8.o: %.c | |
258 $(EMCC) $(EMCFLAGS) -c -o $@ $< | |
259 | |
260 %.js8a.o: %.c | |
261 $(EMCC) $(EMCFLAGS) -c -o $@ $< | |
262 | |
34
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
263 |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
264 BPGENC_OPTS=-keepmetadata -q 24 |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
265 # -c rgb |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
266 |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
267 %.bpg: %.tif bpgenc |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
268 ./bpgenc $(BPGENC_OPTS) $< -o $@ |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
269 |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
270 %.bpg: %.jpg bpgenc |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
271 ./bpgenc $(BPGENC_OPTS) $< -o $@ |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
272 |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
273 %.bpg: %.JPG bpgenc |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
274 ./bpgenc $(BPGENC_OPTS) $< -o $@ |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
275 |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
276 test: $(patsubst %.tif,%.bpg,$(wildcard *.tif)) $(patsubst %.jpg,%.bpg,$(wildcard *.jpg)) $(patsubst %.JPG,%.bpg,$(wildcard *.JPG)) |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
277 |
5d51fff843eb
A "commit dump" of random changes I've made, as I probably won't be touching this code anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
278 |
0 | 279 -include $(wildcard *.d) |
280 -include $(wildcard libavcodec/*.d) | |
281 -include $(wildcard libavutil/*.d) | |
282 -include $(wildcard jctvc/*.d) | |
283 -include $(wildcard jctvc/TLibEncoder/*.d) | |
284 -include $(wildcard jctvc/TLibVideoIO/*.d) | |
285 -include $(wildcard jctvc/TLibCommon/*.d) | |
286 -include $(wildcard jctvc/libmd5/*.d) |