1 diff -urN a/Makefile b/Makefile
2 --- a/Makefile 1969-12-31 17:00:00.000000000 -0700
3 +++ b/Makefile 2019-10-14 10:54:47.354841430 -0600
6 +_ARCH := $(shell uname -m)
7 +ARCH_I32 := $(shell expr "x$(_ARCH)" : 'xi[346]86.*')
8 +ARCH_X64 := $(shell expr "x$(_ARCH)" : 'x..._64*')
10 +ifneq ($(ARCH_I32),0)
15 +ifneq ($(ARCH_X64),0)
25 +INCDIR=$(PREFIX)/include
26 +# make Q="" for verbose
28 +OBJDIR?=$(BUILD)/static
29 +NASM_BLD=$(OBJDIR)/nasm
30 +ENTRY_BLD=$(OBJDIR)/entry
31 +SRC_BLD=$(OBJDIR)/src
32 +BIT8_BLD=$(OBJDIR)/bits8
33 +BIT16_BLD=$(OBJDIR)/bits16
34 +TOOLS_BLD=$(BUILD)/tools
35 +TESTS_BLD=$(BUILD)/tests
37 +STATIC_LIB=$(BUILD)/src/libdav1d.a
38 +SHARED_LIB=$(BUILD)/src/libdav1d.so
39 +DEFS= -DNDEBUG -D_FILE_OFFSET_BITS=64 -D_POSIX_C_SOURCE=200112L
40 +FUZZ= -DDAV1D_MT_FUZZING
42 +BLD_INCL= $(DEFS) -I. -Isrc -Iinclude/dav1d -Iinclude \
43 + -I$(BUILD) -I$(BUILD)/include -I$(BUILD)/include/dav1d
44 +TOOLS_INCL= $(DEFS) -Itools -I. -I$(BUILD) -I$(BUILD)/tools \
45 + -Iinclude -Iinclude/dav1d -I$(BUILD)/include/dav1d \
46 + -I$(BUILD)/include -I/usr/include/SDL2
50 +MAKE_P:=$(MAKE) -j NP=""
53 + $(MAKE_P) $(STATIC_LIB) OBJDIR=$(BUILD)/static
54 + $(MAKE_P) $(SHARED_LIB) OBJDIR=$(BUILD)/shared
56 +# $(MAKE_P) $(TOOLS) OBJDIR=$(BUILD)/static
57 +# $(MAKE_P) $(TESTS) OBJDIR=$(BUILD)/static
61 + -D_FILE_OFFSET_BITS=64 \
62 + -D_POSIX_C_SOURCE=200112L \
71 + -fvisibility=hidden \
74 + -Wno-maybe-uninitialized \
75 + -Wno-missing-field-initializers \
76 + -Wno-unused-parameter \
77 + -Werror=missing-prototypes \
78 + -fomit-frame-pointer \
81 + -mpreferred-stack-boundary=5 \
82 + -MD -MQ $@ -MF $@.d \
85 + -Wl,--no-undefined \
91 + -Wl,-soname,libdav1d.so.2 \
95 +CC_CC=$(Q)cc $(CC_OPTS) $(CFLAGS)
96 +NASM=$(Q)/usr/bin/nasm
97 +any=$(foreach i,$(2),$(1)/$(i))
100 +NASM_OBJS=$(call any,$(NASM_BLD), \
108 + looprestoration.obj \
111 + looprestoration_ssse3.obj \
112 + loopfilter_ssse3.obj \
117 +$(NASM_BLD)/%.obj: src/x86/%.asm
118 + $(NASM) -f $(ASM_ARCH) \
119 + -I src/ -I $(BUILD)/ -MQ $@ -MF $@.ndep \
123 +ENTRY_OBJS=$(call any,$(ENTRY_BLD), \
126 +$(ENTRY_BLD)/%.c.o: src/%.c
127 + $(CC_CC) -Iinclude -Ibuild/include/dav1d -Isrc/entry $(BLD_INCL) \
128 + -mincoming-stack-boundary=4 -o $@ -c $<
131 +SRC_OBJS=$(call any,$(SRC_BLD), \
152 +$(SRC_BLD)/%.o: src/%.c
153 + $(CC_CC) $(BLD_INCL) -pthread -o $@ -c $<
154 +$(SRC_BLD)/x86/%.c.o: src/x86/%.c
155 + $(CC_CC) $(BLD_INCL) -o $@ -c $<
160 + cdef_apply_tmpl.o \
162 + film_grain_tmpl.o \
164 + ipred_prepare_tmpl.o \
167 + loopfilter_tmpl.o \
168 + looprestoration_tmpl.o \
172 + x86/cdef_init_tmpl.c.o \
173 + x86/film_grain_init_tmpl.c.o \
174 + x86/ipred_init_tmpl.c.o \
175 + x86/itx_init_tmpl.c.o \
176 + x86/loopfilter_init_tmpl.c.o \
177 + x86/looprestoration_init_tmpl.c.o \
178 + x86/mc_init_tmpl.c.o \
180 +BIT8_OBJS=$(call any,$(BIT8_BLD),$(BITS_OBJS))
181 +$(BIT8_BLD)/x86/%.c.o: src/x86/%.c
182 + $(CC_CC) $(BLD_INCL) -DBITDEPTH=8 -o $@ -c $<
183 +$(BIT8_BLD)/%.o: src/%.c
184 + $(CC_CC) $(BLD_INCL) -DBITDEPTH=8 -o $@ -c $<
186 +BIT16_OBJS=$(call any,$(BIT16_BLD),$(BITS_OBJS))
187 +$(BIT16_BLD)/x86/%.c.o: src/x86/%.c
188 + $(CC_CC) $(BLD_INCL) -DBITDEPTH=16 -o $@ -c $<
189 +$(BIT16_BLD)/%.o: src/%.c
190 + $(CC_CC) $(BLD_INCL) -DBITDEPTH=16 -o $@ -c $<
193 + echo > $@ "#pragma once"
194 + echo >> $@ "#define ARCH_AARCH64 0"
195 + echo >> $@ "#define ARCH_ARM 0"
196 + echo >> $@ "#define ARCH_PPC64LE 0"
197 + echo >> $@ "#define ARCH_X86 1"
198 + echo >> $@ "#define ARCH_X86_32 $(ARCH_X86_32)"
199 + echo >> $@ "#define ARCH_X86_64 $(ARCH_X86_64)"
200 + echo >> $@ "#define CONFIG_16BPC 1"
201 + echo >> $@ "#define CONFIG_8BPC 1"
202 + echo >> $@ "#define CONFIG_LOG 1"
203 + echo >> $@ "#define ENDIANNESS_BIG 0"
204 + echo >> $@ "#define HAVE_ASM 1"
205 + echo >> $@ "#define HAVE_POSIX_MEMALIGN 1"
206 + echo >> $@ "#define HAVE_UNISTD_H 1"
207 + echo >> $@ "#define STACK_ALIGNMENT 32"
209 +$(BUILD)/config.asm:
210 + echo > $@ "%define ARCH_X86_32 $(ARCH_X86_32)"
211 + echo >> $@ "%define ARCH_X86_64 $(ARCH_X86_64)"
212 + echo >> $@ "%define PIC 1"
213 + echo >> $@ "%define STACK_ALIGNMENT 32"
215 +$(BUILD)/include/vcs_version.h:
216 + mkdir -p $(BUILD)/include
217 + echo > $@ "#define DAV1D_VERSION \"0.5.0\""
219 +$(BUILD)/include/dav1d/version.h:
220 + mkdir -p $(BUILD)/include/dav1d
221 + echo > $@ "#ifndef DAV1D_VERSION_H"
222 + echo >> $@ "#define DAV1D_VERSION_H"
223 + echo >> $@ "#define DAV1D_API_VERSION_MAJOR 2"
224 + echo >> $@ "#define DAV1D_API_VERSION_MINOR 0"
225 + echo >> $@ "#define DAV1D_API_VERSION_PATCH 0"
226 + echo >> $@ "#endif /* DAV1D_VERSION_H */"
228 +$(TOOLS_BLD)/cli_config.h:
229 + mkdir -p $(TOOLS_BLD)
230 + echo > $@ "#pragma once"
231 + echo >> $@ "#define HAVE_CLOCK_GETTIME 1"
235 + make meson_dirs OBJDIR=$(BUILD)/static
236 + make meson_dirs OBJDIR=$(BUILD)/shared
237 + ln -sf ./include/compat/gcc/stdatomic.h .
240 +meson_dirs: $(OBJDIR) \
241 + $(BUILD)/config.h $(BUILD)/config.asm \
242 + $(BUILD)/include/vcs_version.h \
243 + $(BUILD)/include/dav1d/version.h \
244 + $(TOOLS_BLD)/cli_config.h \
246 +LIB_OBJS=$(ENTRY_OBJS) $(NASM_OBJS) $(SRC_OBJS) $(BIT8_OBJS) $(BIT16_OBJS)
248 +$(STATIC_LIB): DIR?=static
249 +$(STATIC_LIB): $(LIB_OBJS)
251 + gcc-ar csrD $@ $(LIB_OBJS)
253 +$(SHARED_LIB): DIR?=shared
254 +$(SHARED_LIB): $(LIB_OBJS)
256 + cc -o $@ $(LIB_OBJS) $(SHA_OPTS)
259 +DAV1D_OBJS=$(call any,$(TOOLS_BLD),\
261 + dav1d_cli_parse.o \
271 +DAV1DPLAY_OBJS=$(call any,$(TOOLS_BLD),\
277 +$(TOOLS_BLD)/%.o: tools/%.c
278 + $(CC_CC) $(TOOLS_INCL) -o $@ -c $<
280 +DAV1D=$(TOOLS_BLD)/dav1d
281 +$(DAV1D): $(DAV1D_OBJS)
282 + $(CC_CC) -pthread -I$(BUILD) -o $@ $(DAV1D_OBJS) $(STATIC_LIB)
284 +DAV1DPLAY=$(TOOLS_BLD)/dav1dplay
285 +$(DAV1DPLAY): $(DAV1DPLAY_OBJS)
286 + $(CC_CC) -pthread -o $(TOOLS_BLD)/dav1dplay $(DAV1DPLAY_OBJS) $(STATIC_LIB) -lSDL2
288 +TOOLS=$(DAV1D) $(DAV1DPLAY)
293 +TESTS_CHKASM=tests/checkasm
294 +TESTS_CHKASM_BLD=$(TESTS_BLD)/checkasm
295 +CHKASM_BIT8=$(TESTS_CHKASM_BLD)/bit8
296 +CHKASM_BIT16=$(TESTS_CHKASM_BLD)/bit16
302 + looprestoration.o \
305 +CHKASM_BIT8_OBJS=$(call any,$(CHKASM_BIT8),$(CHKASM_BITS))
306 +CHKASM_BIT16_OBJS=$(call any,$(CHKASM_BIT16),$(CHKASM_BITS))
308 +TESTS_CHKASM_OBJS= \
309 + $(TESTS_CHKASM_BLD)/checkasm.o \
310 + $(TESTS_CHKASM_BLD)/msac.o \
311 + $(CHKASM_BIT8_OBJS) $(CHKASM_BIT16_OBJS) \
312 + $(TESTS_CHKASM_BLD)/x86/checkasm.obj \
314 +$(TESTS_CHKASM_BLD)/%.o: $(TESTS_CHKASM)/%.c
315 + $(CC_CC) $(BLD_INCL) -o $@ -c $<
316 +$(CHKASM_BIT8)/%.o: $(TESTS_CHKASM)/%.c
317 + $(CC_CC) $(BLD_INCL) -DBITDEPTH=8 -o $@ -c $<
318 +$(CHKASM_BIT16)/%.o: $(TESTS_CHKASM)/%.c
319 + $(CC_CC) $(BLD_INCL) -DBITDEPTH=16 -o $@ -c $<
320 +$(TESTS_CHKASM_BLD)/x86/%.obj: $(TESTS_CHKASM)/x86/%.asm
321 + @$(NASM) -f $(ASM_ARCH) \
322 + -I src/ -I $(BUILD)/ -MQ $@ -MF $@.ndep \
325 +CHECKASM=$(TESTS_BLD)/checkasm/checkasm
326 +$(CHECKASM): $(TESTS_CHKASM_OBJS) $(STATIC_LIB)
327 + $(CC_CC) -pthread -o $@ $(TESTS_CHKASM_OBJS) $(STATIC_LIB) -lm
329 +TESTS_FUZZER=tests/libfuzzer
330 +TESTS_FUZZER_BLD=$(TESTS_BLD)/libfuzzer
331 +TESTS_FUZZER_OBJS= \
332 + $(TESTS_FUZZER_BLD)/main.o \
333 + $(TESTS_FUZZER_BLD)/dav1d_fuzzer.o \
335 +$(TESTS_FUZZER_BLD)/%.o: $(TESTS_FUZZER)/%.c
336 + $(CC_CC) $(BLD_INCL) -o $@ -c $<
338 +DAV1D_FUZZER=$(TESTS_BLD)/dav1d_fuzzer
339 +$(DAV1D_FUZZER): $(TESTS_FUZZER_OBJS) $(STATIC_LIB)
340 + $(CC_CC) -pthread -o $@ $(TESTS_FUZZER_OBJS) $(STATIC_LIB)
342 +TESTS=$(CHECKASM) $(DAV1D_FUZZER)
347 + mkdir -p $@/include/dav1d \
348 + $(BUILD)/src $(BUILD)/include \
349 + $(ENTRY_BLD) $(NASM_BLD) \
350 + $(SRC_BLD)/x86 $(BIT8_BLD)/x86 $(BIT16_BLD)/x86 \
351 + $(TOOLS_BLD) $(TOOLS_BLD)/input $(TOOLS_BLD)/output \
352 + $(TESTS_CHKASM_BLD)/bit8 $(TESTS_CHKASM_BLD)/bit16 \
353 + $(TESTS_CHKASM_BLD)/x86 $(TESTS_FUZZER_BLD) \
359 + mkdir -p $(DESTDIR)$(LIBDIR)
360 + cp -a $(STATIC_LIB) $(DESTDIR)$(LIBDIR)
361 + cp -a $(SHARED_LIB) $(DESTDIR)$(LIBDIR)
362 + mkdir -p $(DESTDIR)$(INCDIR)
363 + cp -a include/dav1d $(DESTDIR)$(INCDIR)
364 + rm -f $(DESTDIR)$(INCDIR)/dav1d/meson.build
365 + rm -f $(DESTDIR)$(INCDIR)/dav1d/version.h.in
366 + cp -a $(BUILD)/include/dav1d/version.h $(DESTDIR)$(INCDIR)/version.h