Remove compatibility workarounds
[x264.git] / Makefile
blob190048baa829527ada14b91c27d474c0ddbfbdb8
1 # Makefile
3 include config.mak
5 vpath %.c $(SRCPATH)
6 vpath %.h $(SRCPATH)
7 vpath %.S $(SRCPATH)
8 vpath %.asm $(SRCPATH)
9 vpath %.rc $(SRCPATH)
11 GENERATED =
13 all: default
14 default:
16 SRCS = common/osdep.c common/base.c common/cpu.c common/tables.c \
17 encoder/api.c
19 SRCS_X = common/mc.c common/predict.c common/pixel.c common/macroblock.c \
20 common/frame.c common/dct.c common/cabac.c \
21 common/common.c common/rectangle.c \
22 common/set.c common/quant.c common/deblock.c common/vlc.c \
23 common/mvpred.c common/bitstream.c \
24 encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
25 encoder/set.c encoder/macroblock.c encoder/cabac.c \
26 encoder/cavlc.c encoder/encoder.c encoder/lookahead.c
28 SRCS_8 =
30 SRCCLI = x264.c autocomplete.c input/input.c input/timecode.c input/raw.c \
31 input/y4m.c output/raw.c output/matroska.c output/matroska_ebml.c \
32 output/flv.c output/flv_bytestream.c filters/filters.c \
33 filters/video/video.c filters/video/source.c filters/video/internal.c \
34 filters/video/resize.c filters/video/fix_vfr_pts.c \
35 filters/video/select_every.c filters/video/crop.c
37 SRCCLI_X = filters/video/cache.c filters/video/depth.c
39 SRCSO =
41 SRCCHK_X = tools/checkasm.c
43 SRCEXAMPLE = example.c
45 OBJS =
46 OBJASM =
47 OBJSO =
48 OBJCLI =
49 OBJCHK =
50 OBJCHK_8 =
51 OBJCHK_10 =
52 OBJEXAMPLE =
54 CONFIG := $(shell cat config.h)
56 # Optional module sources
57 ifneq ($(findstring HAVE_AVS 1, $(CONFIG)),)
58 SRCCLI += input/avs.c
59 endif
61 ifneq ($(findstring HAVE_THREAD 1, $(CONFIG)),)
62 SRCS_X += common/threadpool.c
63 SRCCLI_X += input/thread.c
64 endif
66 ifneq ($(findstring HAVE_WIN32THREAD 1, $(CONFIG)),)
67 SRCS += common/win32thread.c
68 endif
70 ifneq ($(findstring HAVE_LAVF 1, $(CONFIG)),)
71 SRCCLI += input/lavf.c
72 endif
74 ifneq ($(findstring HAVE_FFMS 1, $(CONFIG)),)
75 SRCCLI += input/ffms.c
76 endif
78 ifneq ($(findstring HAVE_GPAC 1, $(CONFIG)),)
79 SRCCLI += output/mp4.c
80 endif
82 ifneq ($(findstring HAVE_LSMASH 1, $(CONFIG)),)
83 SRCCLI += output/mp4_lsmash.c
84 endif
86 ifneq ($(AS),)
88 # MMX/SSE optims
89 SRCASM_X =
90 ifeq ($(SYS_ARCH),X86)
91 ARCH_X86 = yes
92 SRCASM_X += common/x86/dct-32.asm \
93 common/x86/pixel-32.asm
94 endif
95 ifeq ($(SYS_ARCH),X86_64)
96 ARCH_X86 = yes
97 SRCASM_X += common/x86/dct-64.asm \
98 common/x86/trellis-64.asm
99 endif
101 ifdef ARCH_X86
102 SRCASM_X += common/x86/bitstream-a.asm \
103 common/x86/const-a.asm \
104 common/x86/cabac-a.asm \
105 common/x86/dct-a.asm \
106 common/x86/deblock-a.asm \
107 common/x86/mc-a.asm \
108 common/x86/mc-a2.asm \
109 common/x86/pixel-a.asm \
110 common/x86/predict-a.asm \
111 common/x86/quant-a.asm
112 SRCS_X += common/x86/mc-c.c \
113 common/x86/predict-c.c
115 OBJASM += common/x86/cpu-a.o
116 ifneq ($(findstring HAVE_BITDEPTH8 1, $(CONFIG)),)
117 OBJASM += $(SRCASM_X:%.asm=%-8.o) common/x86/sad-a-8.o
118 endif
119 ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
120 OBJASM += $(SRCASM_X:%.asm=%-10.o) common/x86/sad16-a-10.o
121 endif
123 OBJCHK += tools/checkasm-a.o
124 endif
126 # AltiVec optims
127 ifeq ($(SYS_ARCH),PPC)
128 SRCS_X += common/ppc/dct.c \
129 common/ppc/deblock.c \
130 common/ppc/mc.c \
131 common/ppc/pixel.c \
132 common/ppc/predict.c \
133 common/ppc/quant.c
134 endif
136 # NEON optims
137 ifeq ($(SYS_ARCH),ARM)
138 SRCASM_X = common/arm/bitstream-a.S \
139 common/arm/dct-a.S \
140 common/arm/deblock-a.S \
141 common/arm/mc-a.S \
142 common/arm/pixel-a.S \
143 common/arm/predict-a.S \
144 common/arm/quant-a.S
145 SRCS_X += common/arm/mc-c.c \
146 common/arm/predict-c.c
148 OBJASM += common/arm/cpu-a.o
149 ifneq ($(findstring HAVE_BITDEPTH8 1, $(CONFIG)),)
150 OBJASM += $(SRCASM_X:%.S=%-8.o)
151 endif
152 ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
153 OBJASM += $(SRCASM_X:%.S=%-10.o)
154 endif
156 OBJCHK += tools/checkasm-arm.o
157 endif
159 # AArch64 NEON optims
160 ifeq ($(SYS_ARCH),AARCH64)
161 SRCASM_X = common/aarch64/bitstream-a.S \
162 common/aarch64/cabac-a.S \
163 common/aarch64/dct-a.S \
164 common/aarch64/deblock-a.S \
165 common/aarch64/mc-a.S \
166 common/aarch64/pixel-a.S \
167 common/aarch64/predict-a.S \
168 common/aarch64/quant-a.S
169 SRCS_X += common/aarch64/asm-offsets.c \
170 common/aarch64/mc-c.c \
171 common/aarch64/predict-c.c
173 OBJASM +=
174 ifneq ($(findstring HAVE_BITDEPTH8 1, $(CONFIG)),)
175 OBJASM += $(SRCASM_X:%.S=%-8.o)
176 endif
177 ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
178 OBJASM += $(SRCASM_X:%.S=%-10.o)
179 endif
181 OBJCHK += tools/checkasm-aarch64.o
182 endif
184 # MSA optims
185 ifeq ($(SYS_ARCH),MIPS)
186 ifneq ($(findstring HAVE_MSA 1, $(CONFIG)),)
187 SRCS_X += common/mips/dct-c.c \
188 common/mips/deblock-c.c \
189 common/mips/mc-c.c \
190 common/mips/pixel-c.c \
191 common/mips/predict-c.c \
192 common/mips/quant-c.c
193 endif
194 endif
196 endif
198 ifneq ($(HAVE_GETOPT_LONG),1)
199 SRCCLI += extras/getopt.c
200 endif
202 ifeq ($(SYS),WINDOWS)
203 OBJCLI += $(if $(RC), x264res.o)
204 ifneq ($(SONAME),)
205 SRCSO += x264dll.c
206 OBJSO += $(if $(RC), x264res.dll.o)
207 endif
208 endif
210 ifeq ($(HAVE_OPENCL),yes)
211 common/oclobj.h: common/opencl/x264-cl.h $(wildcard $(SRCPATH)/common/opencl/*.cl)
212 cat $^ | $(SRCPATH)/tools/cltostr.sh $@
213 GENERATED += common/oclobj.h
214 SRCS_8 += common/opencl.c encoder/slicetype-cl.c
215 endif
217 OBJS += $(SRCS:%.c=%.o)
218 OBJCLI += $(SRCCLI:%.c=%.o)
219 OBJSO += $(SRCSO:%.c=%.o)
220 OBJEXAMPLE += $(SRCEXAMPLE:%.c=%.o)
222 ifneq ($(findstring HAVE_BITDEPTH8 1, $(CONFIG)),)
223 OBJS += $(SRCS_X:%.c=%-8.o) $(SRCS_8:%.c=%-8.o)
224 OBJCLI += $(SRCCLI_X:%.c=%-8.o)
225 OBJCHK_8 += $(SRCCHK_X:%.c=%-8.o)
226 checkasm: checkasm8$(EXE)
227 endif
228 ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
229 OBJS += $(SRCS_X:%.c=%-10.o)
230 OBJCLI += $(SRCCLI_X:%.c=%-10.o)
231 OBJCHK_10 += $(SRCCHK_X:%.c=%-10.o)
232 checkasm: checkasm10$(EXE)
233 endif
235 .PHONY: all default fprofiled clean distclean install install-* uninstall cli lib-* checkasm etags
237 cli: x264$(EXE)
238 lib-static: $(LIBX264)
239 lib-shared: $(SONAME)
241 $(LIBX264): $(GENERATED) .depend $(OBJS) $(OBJASM)
242 rm -f $(LIBX264)
243 $(AR)$@ $(OBJS) $(OBJASM)
244 $(if $(RANLIB), $(RANLIB) $@)
246 $(SONAME): $(GENERATED) .depend $(OBJS) $(OBJASM) $(OBJSO)
247 $(LD)$@ $(OBJS) $(OBJASM) $(OBJSO) $(SOFLAGS) $(LDFLAGS)
249 ifneq ($(EXE),)
250 .PHONY: x264 checkasm8 checkasm10 example
251 x264: x264$(EXE)
252 checkasm8: checkasm8$(EXE)
253 checkasm10: checkasm10$(EXE)
254 example: example$(EXE)
255 endif
257 x264$(EXE): $(GENERATED) .depend $(OBJCLI) $(CLI_LIBX264)
258 $(LD)$@ $(OBJCLI) $(CLI_LIBX264) $(LDFLAGSCLI) $(LDFLAGS)
260 checkasm8$(EXE): $(GENERATED) .depend $(OBJCHK) $(OBJCHK_8) $(LIBX264)
261 $(LD)$@ $(OBJCHK) $(OBJCHK_8) $(LIBX264) $(LDFLAGS)
263 checkasm10$(EXE): $(GENERATED) .depend $(OBJCHK) $(OBJCHK_10) $(LIBX264)
264 $(LD)$@ $(OBJCHK) $(OBJCHK_10) $(LIBX264) $(LDFLAGS)
266 example$(EXE): $(GENERATED) .depend $(OBJEXAMPLE) $(LIBX264)
267 $(LD)$@ $(OBJEXAMPLE) $(LIBX264) $(LDFLAGS)
269 $(OBJS) $(OBJASM) $(OBJSO) $(OBJCLI) $(OBJCHK) $(OBJCHK_8) $(OBJCHK_10) $(OBJEXAMPLE): .depend
271 %.o: %.c
272 $(CC) $(CFLAGS) -c $< $(CC_O)
274 %-8.o: %.c
275 $(CC) $(CFLAGS) -c $< $(CC_O) -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8
277 %-10.o: %.c
278 $(CC) $(CFLAGS) -c $< $(CC_O) -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10
280 %.o: %.asm common/x86/x86inc.asm common/x86/x86util.asm
281 $(AS) $(ASFLAGS) -o $@ $<
282 -@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile
284 %-8.o: %.asm common/x86/x86inc.asm common/x86/x86util.asm
285 $(AS) $(ASFLAGS) -o $@ $< -DBIT_DEPTH=8 -Dprivate_prefix=x264_8
286 -@ $(if $(STRIP), $(STRIP) -x $@)
288 %-10.o: %.asm common/x86/x86inc.asm common/x86/x86util.asm
289 $(AS) $(ASFLAGS) -o $@ $< -DBIT_DEPTH=10 -Dprivate_prefix=x264_10
290 -@ $(if $(STRIP), $(STRIP) -x $@)
292 %.o: %.S
293 $(AS) $(ASFLAGS) -o $@ $<
294 -@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile
296 %-8.o: %.S
297 $(AS) $(ASFLAGS) -o $@ $< -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8
298 -@ $(if $(STRIP), $(STRIP) -x $@)
300 %-10.o: %.S
301 $(AS) $(ASFLAGS) -o $@ $< -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10
302 -@ $(if $(STRIP), $(STRIP) -x $@)
304 %.dll.o: %.rc x264.h
305 $(RC) $(RCFLAGS)$@ -DDLL $<
307 %.o: %.rc x264.h
308 $(RC) $(RCFLAGS)$@ $<
310 .depend: config.mak
311 @rm -f .depend
312 @echo 'dependency file generation...'
313 ifeq ($(COMPILER),CL)
314 @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO) $(SRCEXAMPLE)), $(SRCPATH)/tools/msvsdepend.sh "$(CC)" "$(CFLAGS)" "$(SRC)" "$(SRC:$(SRCPATH)/%.c=%.o)" 1>> .depend;)
315 ifneq ($(findstring HAVE_BITDEPTH8 1, $(CONFIG)),)
316 @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS_X) $(SRCS_8) $(SRCCLI_X) $(SRCCHK_X)), $(SRCPATH)/tools/msvsdepend.sh "$(CC)" "$(CFLAGS)" "$(SRC)" "$(SRC:$(SRCPATH)/%.c=%-8.o)" 1>> .depend;)
317 endif
318 ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
319 @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS_X) $(SRCCLI_X) $(SRCCHK_X)), $(SRCPATH)/tools/msvsdepend.sh "$(CC)" "$(CFLAGS)" "$(SRC)" "$(SRC:$(SRCPATH)/%.c=%-10.o)" 1>> .depend;)
320 endif
321 else
322 @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO) $(SRCEXAMPLE)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%.o) $(DEPMM) 1>> .depend;)
323 ifneq ($(findstring HAVE_BITDEPTH8 1, $(CONFIG)),)
324 @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS_X) $(SRCS_8) $(SRCCLI_X) $(SRCCHK_X)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%-8.o) $(DEPMM) 1>> .depend;)
325 endif
326 ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
327 @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS_X) $(SRCCLI_X) $(SRCCHK_X)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%-10.o) $(DEPMM) 1>> .depend;)
328 endif
329 endif
331 config.mak:
332 ./configure
334 depend: .depend
335 ifneq ($(wildcard .depend),)
336 include .depend
337 endif
339 OBJPROF = $(OBJS) $(OBJCLI)
340 # These should cover most of the important codepaths
341 OPT0 = --crf 30 -b1 -m1 -r1 --me dia --no-cabac --direct temporal --ssim --no-weightb
342 OPT1 = --crf 16 -b2 -m3 -r3 --me hex --no-8x8dct --direct spatial --no-dct-decimate -t0 --slice-max-mbs 50
343 OPT2 = --crf 26 -b4 -m5 -r2 --me hex --cqm jvt --nr 100 --psnr --no-mixed-refs --b-adapt 2 --slice-max-size 1500
344 OPT3 = --crf 18 -b3 -m9 -r5 --me umh -t1 -A all --b-pyramid normal --direct auto --no-fast-pskip --no-mbtree
345 OPT4 = --crf 22 -b3 -m7 -r4 --me esa -t2 -A all --psy-rd 1.0:1.0 --slices 4
346 OPT5 = --frames 50 --crf 24 -b3 -m10 -r3 --me tesa -t2
347 OPT6 = --frames 50 -q0 -m9 -r2 --me hex -Aall
348 OPT7 = --frames 50 -q0 -m2 -r1 --me hex --no-cabac
350 ifeq (,$(VIDS))
351 fprofiled:
352 @echo 'usage: make fprofiled VIDS="infile1 infile2 ..."'
353 @echo 'where infiles are anything that x264 understands,'
354 @echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
355 else
356 fprofiled: clean
357 $(MAKE) x264$(EXE) CFLAGS="$(CFLAGS) $(PROF_GEN_CC)" LDFLAGS="$(LDFLAGS) $(PROF_GEN_LD)"
358 $(foreach V, $(VIDS), $(foreach I, 0 1 2 3 4 5 6 7, ./x264$(EXE) $(OPT$I) --threads 1 $(V) -o $(DEVNULL) ;))
359 ifeq ($(COMPILER),CL)
360 # Because Visual Studio timestamps the object files within the PGD, it fails to build if they change - only the executable should be deleted
361 rm -f x264$(EXE)
362 else
363 rm -f $(OBJPROF)
364 endif
365 $(MAKE) CFLAGS="$(CFLAGS) $(PROF_USE_CC)" LDFLAGS="$(LDFLAGS) $(PROF_USE_LD)"
366 rm -f $(OBJPROF:%.o=%.gcda) $(OBJPROF:%.o=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock *.pgd *.pgc
367 endif
369 clean:
370 rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(OBJSO) $(GENERATED) .depend TAGS
371 rm -f $(SONAME) *.a *.lib *.exp *.pdb x264$(EXE) x264_lookahead.clbin
372 rm -f checkasm8$(EXE) checkasm10$(EXE) $(OBJCHK) $(OBJCHK_8) $(OBJCHK_10)
373 rm -f example$(EXE) $(OBJEXAMPLE)
374 rm -f $(OBJPROF:%.o=%.gcda) $(OBJPROF:%.o=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock *.pgd *.pgc
376 distclean: clean
377 rm -f config.mak x264_config.h config.h config.log x264.pc x264.def
378 rm -rf conftest*
380 install-cli: cli
381 $(INSTALL) -d $(DESTDIR)$(bindir)
382 $(INSTALL) x264$(EXE) $(DESTDIR)$(bindir)
384 install-lib-dev:
385 $(INSTALL) -d $(DESTDIR)$(includedir) $(DESTDIR)$(libdir)/pkgconfig
386 $(INSTALL) -m 644 $(SRCPATH)/x264.h x264_config.h $(DESTDIR)$(includedir)
387 $(INSTALL) -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
389 install-lib-static: lib-static install-lib-dev
390 $(INSTALL) -d $(DESTDIR)$(libdir)
391 $(INSTALL) -m 644 $(LIBX264) $(DESTDIR)$(libdir)
392 $(if $(RANLIB), $(RANLIB) $(DESTDIR)$(libdir)/$(LIBX264))
394 install-lib-shared: lib-shared install-lib-dev
395 $(INSTALL) -d $(DESTDIR)$(libdir)
396 ifneq ($(IMPLIBNAME),)
397 $(INSTALL) -d $(DESTDIR)$(bindir)
398 $(INSTALL) -m 755 $(SONAME) $(DESTDIR)$(bindir)
399 $(INSTALL) -m 644 $(IMPLIBNAME) $(DESTDIR)$(libdir)
400 else ifneq ($(SONAME),)
401 ln -f -s $(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
402 $(INSTALL) -m 755 $(SONAME) $(DESTDIR)$(libdir)
403 endif
405 uninstall:
406 rm -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(includedir)/x264_config.h $(DESTDIR)$(libdir)/libx264.a
407 rm -f $(DESTDIR)$(bindir)/x264$(EXE) $(DESTDIR)$(libdir)/pkgconfig/x264.pc
408 ifneq ($(IMPLIBNAME),)
409 rm -f $(DESTDIR)$(bindir)/$(SONAME) $(DESTDIR)$(libdir)/$(IMPLIBNAME)
410 else ifneq ($(SONAME),)
411 rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
412 endif
414 etags TAGS:
415 etags $(SRCS) $(SRCS_X) $(SRCS_8)