K-means weightp
[x264-7mod.git] / Makefile
blob1518c25cc11afc3ecb87fe88c9ab8550f622a565
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/mc.c common/predict.c common/pixel.c common/macroblock.c \
17 common/frame.c common/dct.c common/cpu.c common/cabac.c \
18 common/common.c common/osdep.c common/rectangle.c \
19 common/set.c common/quant.c common/deblock.c common/vlc.c \
20 common/mvpred.c common/bitstream.c \
21 encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
22 encoder/set.c encoder/macroblock.c encoder/cabac.c \
23 encoder/cavlc.c encoder/encoder.c encoder/lookahead.c
25 SRCCLI = x264.c input/input.c input/timecode.c input/raw.c input/y4m.c \
26 output/raw.c output/matroska.c output/matroska_ebml.c \
27 output/flv.c output/flv_bytestream.c filters/filters.c \
28 filters/video/video.c filters/video/source.c filters/video/internal.c \
29 filters/video/resize.c filters/video/cache.c filters/video/fix_vfr_pts.c \
30 filters/video/select_every.c filters/video/crop.c filters/video/depth.c \
31 filters/video/hqdn3d.c filters/video/pad.c filters/video/vflip.c
33 SRCSO =
34 OBJS =
35 OBJSO =
36 OBJCLI =
38 OBJCHK = tools/checkasm.o
40 OBJEXAMPLE = example.o
42 CONFIG := $(shell cat config.h)
44 # GPL-only files
45 ifneq ($(findstring HAVE_GPL 1, $(CONFIG)),)
46 SRCCLI += filters/video/yadif.c filters/video/yadif_filter_line.c
48 ifeq ($(ARCH),X86)
49 SRCCLI += filters/video/x86/yadif_filter_line.c
50 endif
52 endif
54 # Optional module sources
55 ifneq ($(findstring HAVE_AVS 1, $(CONFIG)),)
56 SRCCLI += input/avs.c
57 endif
59 ifeq ($(SYS),WINDOWS)
60 SRCCLI += filters/video/subtitles.c
61 endif
63 ifneq ($(findstring HAVE_THREAD 1, $(CONFIG)),)
64 SRCCLI += input/thread.c
65 SRCS += common/threadpool.c
66 endif
68 ifneq ($(findstring HAVE_WIN32THREAD 1, $(CONFIG)),)
69 SRCS += common/win32thread.c
70 endif
72 ifneq ($(findstring HAVE_LAVF 1, $(CONFIG)),)
73 SRCCLI += input/lavf.c
74 endif
76 ifneq ($(findstring HAVE_FFMS 1, $(CONFIG)),)
77 SRCCLI += input/ffms.c
78 endif
80 ifneq ($(findstring HAVE_GPAC 1, $(CONFIG)),)
81 SRCCLI += output/mp4.c
82 endif
84 ifneq ($(findstring HAVE_LSMASH 1, $(CONFIG)),)
85 SRCCLI += output/mp4_lsmash.c
86 endif
88 ifneq ($(findstring HAVE_AVI_OUTPUT 1, $(CONFIG)),)
89 SRCCLI += output/avi.c
90 endif
92 # MMX/SSE optims
93 ifneq ($(AS),)
94 X86SRC0 = const-a.asm cabac-a.asm dct-a.asm deblock-a.asm mc-a.asm \
95 mc-a2.asm pixel-a.asm predict-a.asm quant-a.asm \
96 cpu-a.asm dct-32.asm bitstream-a.asm
97 ifneq ($(findstring HIGH_BIT_DEPTH, $(CONFIG)),)
98 X86SRC0 += sad16-a.asm
99 else
100 X86SRC0 += sad-a.asm
101 endif
102 X86SRC = $(X86SRC0:%=common/x86/%)
104 ifeq ($(SYS_ARCH),X86)
105 ARCH_X86 = yes
106 ASMSRC = $(X86SRC) common/x86/pixel-32.asm
107 endif
109 ifeq ($(SYS_ARCH),X86_64)
110 ARCH_X86 = yes
111 ASMSRC = $(X86SRC:-32.asm=-64.asm) common/x86/trellis-64.asm
112 endif
114 ifdef ARCH_X86
115 SRCS += common/x86/mc-c.c common/x86/predict-c.c
116 OBJASM = $(ASMSRC:%.asm=%.o)
117 $(OBJASM): common/x86/x86inc.asm common/x86/x86util.asm
118 OBJCHK += tools/checkasm-a.o
119 endif
120 endif
122 # AltiVec optims
123 ifeq ($(SYS_ARCH),PPC)
124 ifneq ($(AS),)
125 SRCS += common/ppc/mc.c common/ppc/pixel.c common/ppc/dct.c \
126 common/ppc/quant.c common/ppc/deblock.c \
127 common/ppc/predict.c
128 endif
129 endif
131 # NEON optims
132 ifeq ($(SYS_ARCH),ARM)
133 ifneq ($(AS),)
134 ASMSRC += common/arm/cpu-a.S common/arm/pixel-a.S common/arm/mc-a.S \
135 common/arm/dct-a.S common/arm/quant-a.S common/arm/deblock-a.S \
136 common/arm/predict-a.S common/arm/bitstream-a.S
137 SRCS += common/arm/mc-c.c common/arm/predict-c.c
138 OBJASM = $(ASMSRC:%.S=%.o)
139 OBJCHK += tools/checkasm-arm.o
140 endif
141 endif
143 # AArch64 NEON optims
144 ifeq ($(SYS_ARCH),AARCH64)
145 ifneq ($(AS),)
146 ASMSRC += common/aarch64/bitstream-a.S \
147 common/aarch64/cabac-a.S \
148 common/aarch64/dct-a.S \
149 common/aarch64/deblock-a.S \
150 common/aarch64/mc-a.S \
151 common/aarch64/pixel-a.S \
152 common/aarch64/predict-a.S \
153 common/aarch64/quant-a.S
154 SRCS += common/aarch64/asm-offsets.c \
155 common/aarch64/mc-c.c \
156 common/aarch64/predict-c.c
157 OBJASM = $(ASMSRC:%.S=%.o)
158 OBJCHK += tools/checkasm-aarch64.o
159 endif
160 endif
162 # MSA optims
163 ifeq ($(SYS_ARCH),MIPS)
164 ifneq ($(findstring HAVE_MSA 1, $(CONFIG)),)
165 SRCS += common/mips/mc-c.c common/mips/dct-c.c \
166 common/mips/deblock-c.c common/mips/pixel-c.c \
167 common/mips/predict-c.c common/mips/quant-c.c
168 endif
169 endif
171 ifneq ($(HAVE_GETOPT_LONG),1)
172 SRCCLI += extras/getopt.c
173 endif
175 ifeq ($(SYS),WINDOWS)
176 OBJCLI += $(if $(RC), x264res.o)
177 ifneq ($(SONAME),)
178 SRCSO += x264dll.c
179 OBJSO += $(if $(RC), x264res.dll.o)
180 endif
181 endif
183 ifeq ($(HAVE_OPENCL),yes)
184 common/oclobj.h: common/opencl/x264-cl.h $(wildcard $(SRCPATH)/common/opencl/*.cl)
185 cat $^ | $(SRCPATH)/tools/cltostr.sh $@
186 GENERATED += common/oclobj.h
187 SRCS += common/opencl.c encoder/slicetype-cl.c
188 endif
190 OBJS += $(SRCS:%.c=%.o)
191 OBJCLI += $(SRCCLI:%.c=%.o)
192 OBJSO += $(SRCSO:%.c=%.o)
194 .PHONY: all default fprofiled clean distclean install install-* uninstall cli lib-* etags
196 cli: x264$(EXE)
197 lib-static: $(LIBX264)
198 lib-shared: $(SONAME)
200 $(LIBX264): $(GENERATED) .depend $(OBJS) $(OBJASM)
201 rm -f $(LIBX264)
202 $(AR)$@ $(OBJS) $(OBJASM)
203 $(if $(RANLIB), $(RANLIB) $@)
205 $(SONAME): $(GENERATED) .depend $(OBJS) $(OBJASM) $(OBJSO)
206 $(LD)$@ $(OBJS) $(OBJASM) $(OBJSO) $(SOFLAGS) $(LDFLAGS)
208 ifneq ($(EXE),)
209 .PHONY: x264 checkasm example
210 x264: x264$(EXE)
211 checkasm: checkasm$(EXE)
212 example: example$(EXE)
213 endif
215 x264$(EXE): $(GENERATED) .depend $(OBJCLI) $(CLI_LIBX264)
216 $(LD)$@ $(OBJCLI) $(CLI_LIBX264) $(LDFLAGSCLI) $(LDFLAGS)
218 checkasm$(EXE): $(GENERATED) .depend $(OBJCHK) $(LIBX264)
219 $(LD)$@ $(OBJCHK) $(LIBX264) $(LDFLAGS)
221 example$(EXE): $(GENERATED) .depend $(OBJEXAMPLE) $(LIBX264)
222 $(LD)$@ $(OBJEXAMPLE) $(LIBX264) $(LDFLAGS)
224 $(OBJS) $(OBJASM) $(OBJSO) $(OBJCLI) $(OBJCHK) $(OBJEXAMPLE): .depend
226 %.o: %.asm common/x86/x86inc.asm common/x86/x86util.asm
227 $(AS) $(ASFLAGS) -o $@ $<
228 -@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile
230 %.o: %.S
231 $(AS) $(ASFLAGS) -o $@ $<
232 -@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile
234 %.dll.o: %.rc x264.h
235 $(RC) $(RCFLAGS)$@ -DDLL $<
237 %.o: %.rc x264.h
238 $(RC) $(RCFLAGS)$@ $<
240 .depend: config.mak
241 @rm -f .depend
242 @echo 'dependency file generation...'
243 ifeq ($(COMPILER),CL)
244 @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO)), $(SRCPATH)/tools/msvsdepend.sh "$(CC)" "$(CFLAGS)" "$(SRC)" "$(SRC:$(SRCPATH)/%.c=%.o)" 1>> .depend;)
245 else
246 @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%.o) $(DEPMM) 1>> .depend;)
247 endif
249 config.mak:
250 ./configure
252 depend: .depend
253 ifneq ($(wildcard .depend),)
254 include .depend
255 endif
257 SRC2 = $(SRCS) $(SRCCLI)
258 # These should cover most of the important codepaths
259 OPT0 = --crf 30 -b1 -m1 -r1 --me dia --no-cabac --direct temporal --ssim --no-weightb
260 OPT1 = --crf 16 -b2 -m3 -r3 --me hex --no-8x8dct --direct spatial --no-dct-decimate -t0 --slice-max-mbs 50
261 OPT2 = --crf 26 -b4 -m5 -r2 --me hex --cqm jvt --nr 100 --psnr --no-mixed-refs --b-adapt 2 --slice-max-size 1500
262 OPT3 = --crf 18 -b3 -m9 -r5 --me umh -t1 -A all --b-pyramid normal --direct auto --no-fast-pskip --no-mbtree
263 OPT4 = --crf 22 -b3 -m7 -r4 --me esa -t2 -A all --psy-rd 1.0:1.0 --slices 4 --fgo 8 --fade-compensate 0.5 --aq2-strength 0.5 --aq3-mode 2 --weightp 3
264 OPT5 = --frames 50 --crf 24 -b3 -m10 -r3 --me tesa -t2
265 OPT6 = --frames 50 -q0 -m9 -r2 --me hex -Aall
266 OPT7 = --frames 50 -q0 -m2 -r1 --me hex --no-cabac
268 ifeq (,$(VIDS))
269 fprofiled:
270 @echo 'usage: make fprofiled VIDS="infile1 infile2 ..."'
271 @echo 'where infiles are anything that x264 understands,'
272 @echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
273 else
274 fprofiled:
275 $(MAKE) clean
276 $(MAKE) x264$(EXE) CFLAGS="$(CFLAGS) $(PROF_GEN_CC)" LDFLAGS="$(LDFLAGS) $(PROF_GEN_LD)"
277 $(foreach V, $(VIDS), $(foreach I, 0 1 2 3 4 5 6 7, ./x264$(EXE) $(OPT$I) --threads 1 $(V) -o $(DEVNULL) ;))
278 ifeq ($(COMPILER),CL)
279 # Because Visual Studio timestamps the object files within the PGD, it fails to build if they change - only the executable should be deleted
280 rm -f x264$(EXE)
281 else
282 rm -f $(SRC2:%.c=%.o)
283 endif
284 $(MAKE) CFLAGS="$(CFLAGS) $(PROF_USE_CC)" LDFLAGS="$(LDFLAGS) $(PROF_USE_LD)"
285 rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock *.pgd *.pgc
286 endif
288 clean:
289 rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(OBJSO) $(SONAME) *.a *.lib *.exp *.pdb x264 x264.exe .depend TAGS
290 rm -f checkasm checkasm.exe $(OBJCHK) $(GENERATED) x264_lookahead.clbin
291 rm -f example example.exe $(OBJEXAMPLE)
292 rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock *.pgd *.pgc
294 distclean: clean
295 rm -f config.mak x264_config.h config.h config.log x264.pc x264.def
296 rm -rf conftest*
298 install-cli: cli
299 $(INSTALL) -d $(DESTDIR)$(bindir)
300 $(INSTALL) x264$(EXE) $(DESTDIR)$(bindir)
302 install-lib-dev:
303 $(INSTALL) -d $(DESTDIR)$(includedir)
304 $(INSTALL) -d $(DESTDIR)$(libdir)
305 $(INSTALL) -d $(DESTDIR)$(libdir)/pkgconfig
306 $(INSTALL) -m 644 $(SRCPATH)/x264.h $(DESTDIR)$(includedir)
307 $(INSTALL) -m 644 x264_config.h $(DESTDIR)$(includedir)
308 $(INSTALL) -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
310 install-lib-static: lib-static install-lib-dev
311 $(INSTALL) -m 644 $(LIBX264) $(DESTDIR)$(libdir)
312 $(if $(RANLIB), $(RANLIB) $(DESTDIR)$(libdir)/$(LIBX264))
314 install-lib-shared: lib-shared install-lib-dev
315 ifneq ($(IMPLIBNAME),)
316 $(INSTALL) -d $(DESTDIR)$(bindir)
317 $(INSTALL) -m 755 $(SONAME) $(DESTDIR)$(bindir)
318 $(INSTALL) -m 644 $(IMPLIBNAME) $(DESTDIR)$(libdir)
319 else ifneq ($(SONAME),)
320 ln -f -s $(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
321 $(INSTALL) -m 755 $(SONAME) $(DESTDIR)$(libdir)
322 endif
324 uninstall:
325 rm -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(includedir)/x264_config.h $(DESTDIR)$(libdir)/libx264.a
326 rm -f $(DESTDIR)$(bindir)/x264$(EXE) $(DESTDIR)$(libdir)/pkgconfig/x264.pc
327 ifneq ($(IMPLIBNAME),)
328 rm -f $(DESTDIR)$(bindir)/$(SONAME) $(DESTDIR)$(libdir)/$(IMPLIBNAME)
329 else ifneq ($(SONAME),)
330 rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
331 endif
333 etags: TAGS
335 TAGS:
336 etags $(SRCS)