]> git.sesse.net Git - x264/blob - Makefile
Fix weightp on ARM + PPC
[x264] / Makefile
1 # Makefile
2
3 include config.mak
4
5 all: default
6
7 SRCS = common/mc.c common/predict.c common/pixel.c common/macroblock.c \
8        common/frame.c common/dct.c common/cpu.c common/cabac.c \
9        common/common.c common/mdate.c common/set.c \
10        common/quant.c common/vlc.c \
11        encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
12        encoder/set.c encoder/macroblock.c encoder/cabac.c \
13        encoder/cavlc.c encoder/encoder.c encoder/lookahead.c
14
15 SRCCLI = x264.c input/yuv.c input/y4m.c output/raw.c \
16          output/matroska.c output/matroska_ebml.c
17
18 MUXERS := $(shell grep -E "(IN|OUT)PUT" config.h)
19
20 # Optional muxer module sources
21 ifneq ($(findstring AVIS_INPUT, $(MUXERS)),)
22 SRCCLI += input/avis.c
23 endif
24
25 ifneq ($(findstring HAVE_PTHREAD, $(CFLAGS)),)
26 SRCCLI += input/thread.c
27 endif
28
29 ifneq ($(findstring MP4_OUTPUT, $(MUXERS)),)
30 SRCCLI += output/mp4.c
31 endif
32
33 # Visualization sources
34 ifeq ($(VIS),yes)
35 SRCS   += common/visualize.c common/display-x11.c
36 endif
37
38 # MMX/SSE optims
39 ifneq ($(AS),)
40 X86SRC0 = cabac-a.asm dct-a.asm deblock-a.asm mc-a.asm mc-a2.asm \
41           pixel-a.asm predict-a.asm quant-a.asm sad-a.asm \
42           cpu-a.asm dct-32.asm
43 X86SRC = $(X86SRC0:%=common/x86/%)
44
45 ifeq ($(ARCH),X86)
46 ARCH_X86 = yes
47 ASMSRC   = $(X86SRC) common/x86/pixel-32.asm
48 endif
49
50 ifeq ($(ARCH),X86_64)
51 ARCH_X86 = yes
52 ASMSRC   = $(X86SRC:-32.asm=-64.asm)
53 ASFLAGS += -DARCH_X86_64
54 endif
55
56 ifdef ARCH_X86
57 ASFLAGS += -Icommon/x86/
58 SRCS   += common/x86/mc-c.c common/x86/predict-c.c
59 OBJASM  = $(ASMSRC:%.asm=%.o)
60 $(OBJASM): common/x86/x86inc.asm common/x86/x86util.asm
61 checkasm: tools/checkasm-a.o
62 endif
63 endif
64
65 # AltiVec optims
66 ifeq ($(ARCH),PPC)
67 SRCS += common/ppc/mc.c common/ppc/pixel.c common/ppc/dct.c \
68         common/ppc/quant.c common/ppc/deblock.c \
69         common/ppc/predict.c
70 endif
71
72 # NEON optims
73 ifeq ($(ARCH),ARM)
74 ifneq ($(AS),)
75 ASMSRC += common/arm/cpu-a.S common/arm/pixel-a.S common/arm/mc-a.S \
76           common/arm/dct-a.S common/arm/quant-a.S common/arm/deblock-a.S \
77           common/arm/predict-a.S
78 SRCS   += common/arm/mc-c.c common/arm/predict-c.c
79 OBJASM  = $(ASMSRC:%.S=%.o)
80 endif
81 endif
82
83 # VIS optims
84 ifeq ($(ARCH),UltraSparc)
85 ASMSRC += common/sparc/pixel.asm
86 OBJASM  = $(ASMSRC:%.asm=%.o)
87 endif
88
89 ifneq ($(HAVE_GETOPT_LONG),1)
90 SRCS += extras/getopt.c
91 endif
92
93 OBJS = $(SRCS:%.c=%.o)
94 OBJCLI = $(SRCCLI:%.c=%.o)
95 DEP  = depend
96
97 .PHONY: all default fprofiled clean distclean install uninstall dox test testclean
98
99 default: $(DEP) x264$(EXE)
100
101 libx264.a: .depend $(OBJS) $(OBJASM)
102         $(AR) rc libx264.a $(OBJS) $(OBJASM)
103         $(RANLIB) libx264.a
104
105 $(SONAME): .depend $(OBJS) $(OBJASM)
106         $(CC) -shared -o $@ $(OBJS) $(OBJASM) $(SOFLAGS) $(LDFLAGS)
107
108 x264$(EXE): $(OBJCLI) libx264.a 
109         $(CC) -o $@ $+ $(LDFLAGS)
110
111 checkasm: tools/checkasm.o libx264.a
112         $(CC) -o $@ $+ $(LDFLAGS)
113
114 %.o: %.asm
115         $(AS) $(ASFLAGS) -o $@ $<
116         -@ $(STRIP) -x $@ # delete local/anonymous symbols, so they don't show up in oprofile
117
118 %.o: %.S
119         $(AS) $(ASFLAGS) -o $@ $<
120         -@ $(STRIP) -x $@ # delete local/anonymous symbols, so they don't show up in oprofile
121
122 .depend: config.mak
123         rm -f .depend
124         $(foreach SRC, $(SRCS) $(SRCCLI), $(CC) $(CFLAGS) $(ALTIVECFLAGS) $(SRC) -MT $(SRC:%.c=%.o) -MM -g0 1>> .depend;)
125
126 config.mak:
127         ./configure
128
129 depend: .depend
130 ifneq ($(wildcard .depend),)
131 include .depend
132 endif
133
134 SRC2 = $(SRCS) $(SRCCLI)
135 # These should cover most of the important codepaths
136 OPT0 = --crf 30 -b1 -m1 -r1 --me dia --no-cabac --direct temporal --ssim --no-weightb
137 OPT1 = --crf 16 -b2 -m3 -r3 --me hex --no-8x8dct --direct spatial --no-dct-decimate -t0  --slice-max-mbs 50
138 OPT2 = --crf 26 -b4 -m5 -r2 --me hex --cqm jvt --nr 100 --psnr --no-mixed-refs --b-adapt 2 --slice-max-size 1500
139 OPT3 = --crf 18 -b3 -m9 -r5 --me umh -t1 -A all --b-pyramid normal --direct auto --no-fast-pskip --no-mbtree
140 OPT4 = --crf 22 -b3 -m7 -r4 --me esa -t2 -A all --psy-rd 1.0:1.0 --slices 4
141 OPT5 = --frames 50 --crf 24 -b3 -m10 -r3 --me tesa -t2
142 OPT6 = --frames 50 -q0 -m9 -r2 --me hex -Aall
143 OPT7 = --frames 50 -q0 -m2 -r1 --me hex --no-cabac
144
145 ifeq (,$(VIDS))
146 fprofiled:
147         @echo 'usage: make fprofiled VIDS="infile1 infile2 ..."'
148         @echo 'where infiles are anything that x264 understands,'
149         @echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
150 else
151 fprofiled:
152         $(MAKE) clean
153         mv config.mak config.mak2
154         sed -e 's/CFLAGS.*/& -fprofile-generate/; s/LDFLAGS.*/& -fprofile-generate/' config.mak2 > config.mak
155         $(MAKE) x264$(EXE)
156         $(foreach V, $(VIDS), $(foreach I, 0 1 2 3 4 5 6 7, ./x264$(EXE) $(OPT$I) --threads 1 $(V) -o $(DEVNULL) ;))
157         rm -f $(SRC2:%.c=%.o)
158         sed -e 's/CFLAGS.*/& -fprofile-use/; s/LDFLAGS.*/& -fprofile-use/' config.mak2 > config.mak
159         $(MAKE)
160         rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
161         mv config.mak2 config.mak
162 endif
163
164 clean:
165         rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(SONAME) *.a x264 x264.exe .depend TAGS
166         rm -f checkasm checkasm.exe tools/checkasm.o tools/checkasm-a.o
167         rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
168         - sed -e 's/ *-fprofile-\(generate\|use\)//g' config.mak > config.mak2 && mv config.mak2 config.mak
169
170 distclean: clean
171         rm -f config.mak config.h x264.pc
172         rm -rf test/
173
174 install: x264$(EXE) $(SONAME)
175         install -d $(DESTDIR)$(bindir) $(DESTDIR)$(includedir)
176         install -d $(DESTDIR)$(libdir) $(DESTDIR)$(libdir)/pkgconfig
177         install -m 644 x264.h $(DESTDIR)$(includedir)
178         install -m 644 libx264.a $(DESTDIR)$(libdir)
179         install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
180         install x264$(EXE) $(DESTDIR)$(bindir)
181         $(RANLIB) $(DESTDIR)$(libdir)/libx264.a
182 ifeq ($(SYS),MINGW)
183         $(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(bindir))
184 else
185         $(if $(SONAME), ln -sf $(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX))
186         $(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(libdir))
187 endif
188         $(if $(IMPLIBNAME), install -m 644 $(IMPLIBNAME) $(DESTDIR)$(libdir))
189
190 uninstall:
191         rm -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(libdir)/libx264.a
192         rm -f $(DESTDIR)$(bindir)/x264 $(DESTDIR)$(libdir)/pkgconfig/x264.pc
193         $(if $(SONAME), rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX))
194
195 etags: TAGS
196
197 TAGS:
198         etags $(SRCS)
199
200 dox:
201         doxygen Doxyfile
202
203 ifeq (,$(VIDS))
204 test:
205         @echo 'usage: make test VIDS="infile1 infile2 ..."'
206         @echo 'where infiles are anything that x264 understands,'
207         @echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
208 else
209 test:
210         perl tools/regression-test.pl --version=head,current --options='$(OPT0)' --options='$(OPT1)' --options='$(OPT2)' $(VIDS:%=--input=%)
211 endif
212
213 testclean:
214         rm -f test/*.log test/*.264
215         $(foreach DIR, $(wildcard test/x264-r*/), cd $(DIR) ; make clean ; cd ../.. ;)