remove colorspace conversion support, because it has no business in any codec
[x262.git] / Makefile
1 # Makefile
2
3 include config.mak
4
5 SRCS = common/mc.c common/predict.c common/pixel.c common/macroblock.c \
6        common/frame.c common/dct.c common/cpu.c common/cabac.c \
7        common/common.c common/mdate.c common/set.c \
8        common/quant.c \
9        encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
10        encoder/set.c encoder/macroblock.c encoder/cabac.c \
11        encoder/cavlc.c encoder/encoder.c encoder/eval.c
12
13 SRCCLI = x264.c matroska.c muxers.c
14
15 # Visualization sources
16 ifeq ($(VIS),yes)
17 SRCS   += common/visualize.c common/display-x11.c
18 endif
19
20 # MMX/SSE optims
21 ifeq ($(ARCH),X86)
22 ifneq ($(AS),)
23 SRCS   += common/i386/mc-c.c common/i386/predict-c.c
24 ASMSRC  = common/i386/dct-a.asm common/i386/cpu-a.asm \
25           common/i386/pixel-a.asm common/i386/mc-a.asm \
26           common/i386/mc-a2.asm common/i386/predict-a.asm \
27           common/i386/pixel-sse2.asm common/i386/quant-a.asm \
28           common/i386/deblock-a.asm
29 OBJASM  = $(ASMSRC:%.asm=%.o)
30 ASFLAGS += -Icommon/i386/
31 endif
32 endif
33
34 # MMX/SSE optims
35 ifeq ($(ARCH),X86_64)
36 ifneq ($(AS),)
37 SRCS   += common/i386/mc-c.c common/i386/predict-c.c
38 ASMSRC  = common/amd64/dct-a.asm common/amd64/cpu-a.asm \
39           common/amd64/pixel-a.asm common/amd64/mc-a.asm \
40           common/amd64/mc-a2.asm common/amd64/predict-a.asm \
41           common/amd64/pixel-sse2.asm common/amd64/quant-a.asm \
42           common/amd64/deblock-a.asm
43 OBJASM  = $(ASMSRC:%.asm=%.o)
44 ASFLAGS += -Icommon/amd64
45 endif
46 endif
47
48 # AltiVec optims
49 ifeq ($(ARCH),PPC)
50 ALTIVECSRC += common/ppc/mc.c common/ppc/pixel.c common/ppc/dct.c \
51               common/ppc/quant.c common/ppc/deblock.c \
52               common/ppc/predict.c
53 SRCS += $(ALTIVECSRC)
54 $(ALTIVECSRC:%.c=%.o): CFLAGS += $(ALTIVECFLAGS)
55 endif
56
57 # VIS optims
58 ifeq ($(ARCH),UltraSparc)
59 ASMSRC += common/sparc/pixel.asm
60 OBJASM  = $(ASMSRC:%.asm=%.o)
61 endif
62
63 ifneq ($(HAVE_GETOPT_LONG),1)
64 SRCS += extras/getopt.c
65 endif
66
67 OBJS = $(SRCS:%.c=%.o)
68 OBJCLI = $(SRCCLI:%.c=%.o)
69 DEP  = depend
70
71 .PHONY: all default fprofiled clean distclean install install-gtk uninstall dox test testclean
72 all: default
73
74 default: $(DEP) x264$(EXE)
75
76 libx264.a: .depend $(OBJS) $(OBJASM)
77         ar rc libx264.a $(OBJS) $(OBJASM)
78         ranlib libx264.a
79
80 $(SONAME): .depend $(OBJS) $(OBJASM)
81         $(CC) -shared -o $@ $(OBJS) $(OBJASM) -Wl,-soname,$(SONAME) $(LDFLAGS)
82
83 x264$(EXE): $(OBJCLI) libx264.a 
84         $(CC) -o $@ $+ $(LDFLAGS)
85
86 libx264gtk.a: muxers.o libx264.a
87         $(MAKE) -C gtk
88
89 checkasm: tools/checkasm.o libx264.a
90         $(CC) -o $@ $+ $(LDFLAGS)
91
92 common/amd64/*.o: common/amd64/amd64inc.asm
93 common/i386/*.o: common/i386/i386inc.asm
94 %.o: %.asm
95         $(AS) $(ASFLAGS) -o $@ $<
96 # delete local/anonymous symbols, so they don't show up in oprofile
97         -@ strip -x $@
98
99 .depend: config.mak
100         rm -f .depend
101 # Hacky - because gcc 2.9x doesn't have -MT
102         $(foreach SRC, $(SRCS) $(SRCCLI), ( $(ECHON) "`dirname $(SRC)`/" && $(CC) $(CFLAGS) $(ALTIVECFLAGS) $(SRC) -MM -g0 ) 1>> .depend;)
103
104 config.mak: $(wildcard .svn/entries */.svn/entries */*/.svn/entries)
105         ./configure $(CONFIGURE_ARGS)
106
107 depend: .depend
108 ifneq ($(wildcard .depend),)
109 include .depend
110 endif
111
112 SRC2 = $(SRCS) $(SRCCLI)
113 # These should cover most of the important codepaths
114 OPT0 = --crf 30 -b1 -m1 -r1 --me dia --no-cabac --pre-scenecut --direct temporal --no-ssim --no-psnr
115 OPT1 = --crf 16 -b2 -m3 -r3 --me hex -8 --direct spatial --no-dct-decimate
116 OPT2 = --crf 26 -b2 -m5 -r2 --me hex -8 -w --cqm jvt --nr 100
117 OPT3 = --crf 18 -b3 -m7 -r5 --me umh -8 -t1 -A all --mixed-refs --b-rdo -w --b-pyramid --direct auto --bime --no-fast-pskip
118 OPT4 = --crf 22 -b3 -m6 -r3 --me esa -8 -t2 -A all --mixed-refs --b-rdo --bime
119
120 ifeq (,$(VIDS))
121 fprofiled:
122         @echo 'usage: make fprofiled VIDS="infile1 infile2 ..."'
123         @echo 'where infiles are anything that x264 understands,'
124         @echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
125 else
126 fprofiled:
127         $(MAKE) clean
128         mv config.mak config.mak2
129         sed -e 's/CFLAGS.*/& -fprofile-generate/; s/LDFLAGS.*/& -fprofile-generate/' config.mak2 > config.mak
130         $(MAKE) x264$(EXE)
131         $(foreach V, $(VIDS), $(foreach I, 0 1 2 3 4, ./x264$(EXE) $(OPT$I) $(V) --progress -o $(DEVNULL) ;))
132         rm -f $(SRC2:%.c=%.o)
133         sed -e 's/CFLAGS.*/& -fprofile-use/; s/LDFLAGS.*/& -fprofile-use/' config.mak2 > config.mak
134         $(MAKE)
135         rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
136         mv config.mak2 config.mak
137 endif
138
139 clean:
140         rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(SONAME) *.a x264 x264.exe .depend TAGS
141         rm -f checkasm checkasm.exe tools/checkasm.o
142         rm -f tools/avc2avi tools/avc2avi.exe tools/avc2avi.o
143         rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
144         - sed -e 's/ *-fprofile-\(generate\|use\)//g' config.mak > config.mak2 && mv config.mak2 config.mak
145         $(MAKE) -C gtk clean
146
147 distclean: clean
148         rm -f config.mak config.h x264.pc
149         rm -rf test/
150         $(MAKE) -C gtk distclean
151
152 install: x264 $(SONAME)
153         install -d $(DESTDIR)$(bindir) $(DESTDIR)$(includedir)
154         install -d $(DESTDIR)$(libdir) $(DESTDIR)$(libdir)/pkgconfig
155         install -m 644 x264.h $(DESTDIR)$(includedir)
156         install -m 644 libx264.a $(DESTDIR)$(libdir)
157         install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
158         install x264 $(DESTDIR)$(bindir)
159         ranlib $(DESTDIR)$(libdir)/libx264.a
160         $(if $(SONAME), ln -sf $(SONAME) $(DESTDIR)$(libdir)/libx264.so)
161         $(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(libdir))
162
163 install-gtk: libx264gtk.a
164         $(MAKE) -C gtk install
165
166 uninstall:
167         rm -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(libdir)/libx264.a
168         rm -f $(DESTDIR)$(bindir)/x264 $(DESTDIR)$(libdir)/pkgconfig/x264.pc
169         $(if $(SONAME), rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.so)
170         $(MAKE) -C gtk uninstall
171
172 etags: TAGS
173
174 TAGS:
175         etags $(SRCS)
176
177 dox:
178         doxygen Doxyfile
179
180 ifeq (,$(VIDS))
181 test:
182         @echo 'usage: make test VIDS="infile1 infile2 ..."'
183         @echo 'where infiles are anything that x264 understands,'
184         @echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
185 else
186 test:
187         perl tools/regression-test.pl --version=head,current --options='$(OPT0)' --options='$(OPT1)' --options='$(OPT2)' $(VIDS:%=--input=%)
188 endif
189
190 testclean:
191         rm -f test/*.log test/*.264
192         $(foreach DIR, $(wildcard test/x264-r*/), cd $(DIR) ; make clean ; cd ../.. ;)