amd64 mmx for some intra pred functions
[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/csp.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 # Visualization sources
14 ifeq ($(VIS),yes)
15 SRCS   += common/visualize.c common/display-x11.c
16 endif
17
18 # MMX/SSE optims
19 ifeq ($(ARCH),X86)
20 SRCS   += common/i386/mc-c.c common/i386/dct-c.c common/i386/predict.c
21 ASMSRC  = common/i386/dct-a.asm common/i386/cpu-a.asm \
22           common/i386/pixel-a.asm common/i386/mc-a.asm \
23           common/i386/mc-a2.asm common/i386/predict-a.asm \
24           common/i386/pixel-sse2.asm common/i386/quant-a.asm \
25           common/i386/deblock-a.asm
26 OBJASM  = $(ASMSRC:%.asm=%.o)
27 ASFLAGS += -Icommon/i386/
28 endif
29
30 # MMX/SSE optims
31 ifeq ($(ARCH),X86_64)
32 SRCS   += common/i386/mc-c.c common/i386/dct-c.c common/i386/predict.c
33 ASMSRC  = common/amd64/dct-a.asm common/amd64/cpu-a.asm \
34           common/amd64/pixel-a.asm common/amd64/mc-a.asm \
35           common/amd64/mc-a2.asm common/amd64/predict-a.asm \
36           common/amd64/pixel-sse2.asm common/amd64/quant-a.asm \
37           common/amd64/deblock-a.asm
38 OBJASM  = $(ASMSRC:%.asm=%.o)
39 ASFLAGS += -Icommon/amd64
40 endif
41
42 # AltiVec optims
43 ifeq ($(ARCH),PPC)
44 SRCS += common/ppc/mc.c common/ppc/pixel.c common/ppc/dct.c
45 endif
46
47 # VIS optims
48 ifeq ($(ARCH),UltraSparc)
49 ASMSRC += common/sparc/pixel.asm
50 OBJASM  = $(ASMSRC:%.asm=%.o)
51 endif
52
53 ifneq ($(HAVE_GETOPT_LONG),1)
54 SRCS += extras/getopt.c
55 endif
56
57 OBJS = $(SRCS:%.c=%.o)
58 DEP  = depend
59
60 .PHONY: default fprofiled clean distclean install uninstall
61 default: $(DEP) x264$(EXE)
62
63 libx264.a: .depend $(OBJS) $(OBJASM)
64         ar rc libx264.a $(OBJS) $(OBJASM)
65         ranlib libx264.a
66
67 x264$(EXE): libx264.a x264.o matroska.o
68         $(CC) -o $@ x264.o matroska.o libx264.a $(LDFLAGS)
69
70 x264vfw.dll: libx264.a $(wildcard vfw/*.c vfw/*.h)
71         make -C vfw/build/cygwin
72
73 checkasm: tools/checkasm.o libx264.a
74         $(CC) -o $@ $< libx264.a $(LDFLAGS)
75
76 common/amd64/*.o: common/amd64/amd64inc.asm
77 common/i386/*.o: common/i386/i386inc.asm
78 %.o: %.asm
79         $(AS) $(ASFLAGS) -o $@ $<
80
81 .depend: config.mak
82         rm -f .depend
83 # Hacky - because gcc 2.9x doesn't have -MT
84         $(foreach SRC, $(SRCS) x264.c matroska.c, ( echo -n "`dirname $(SRC)`/" && $(CC) $(CFLAGS) $(SRC) -MM -g0 ) 1>> .depend;)
85
86 config.mak: $(wildcard .svn/entries */.svn/entries */*/.svn/entries)
87         ./configure $(CONFIGURE_ARGS)
88
89 depend: .depend
90 ifneq ($(wildcard .depend),)
91 include .depend
92 endif
93
94 SRC2 = $(SRCS) x264.c matroska.c
95 # These should cover most of the important codepaths
96 OPT0 = --crf 30 -b1 -m1 -r1 --me dia --no-cabac
97 OPT1 = --crf 18 -b2 -m3 -r3 --me hex -8 --cqm jvt --direct spatial
98 OPT2 = --crf 24 -b3 -m6 -r6 --me umh -8 -w -t1 -A all --b-pyramid --b-rdo --mixed-refs
99
100 ifeq (,$(VIDS))
101 fprofiled:
102         @echo 'usage: make fprofiled VIDS="infile1 infile2 ..."'
103         @echo 'where infiles are anything that x264 understands,'
104         @echo 'i.e. YUV with resolution in the filename, or avisynth.'
105 else
106 fprofiled:
107         make clean
108         mv config.mak config.mak2
109         sed -e 's/CFLAGS.*/& -fprofile-generate/; s/LDFLAGS.*/& -fprofile-generate/' config.mak2 > config.mak
110         make x264$(EXE)
111         $(foreach V, $(VIDS), $(foreach I, 0 1 2, ./x264$(EXE) $(OPT$I) $(V) --progress -o $(DEVNULL) ;))
112         rm -f $(SRC2:%.c=%.o)
113         sed -e 's/CFLAGS.*/& -fprofile-use/; s/LDFLAGS.*/& -fprofile-use/' config.mak2 > config.mak
114         make
115         rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
116         mv config.mak2 config.mak
117 endif
118
119 clean:
120         rm -f $(OBJS) $(OBJASM) *.a x264.o matroska.o x264 x264.exe .depend TAGS
121         rm -f checkasm checkasm.exe tools/checkasm.o
122         rm -f tools/avc2avi tools/avc2avi.exe tools/avc2avi.o
123         rm -rf vfw/build/cygwin/bin
124         rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
125         - sed -e 's/ *-fprofile-\(generate\|use\)//g' config.mak > config.mak2 && mv config.mak2 config.mak
126
127 distclean: clean
128         rm -f config.mak config.h vfw/build/cygwin/config.mak x264.pc
129
130 install: x264
131         install -d $(DESTDIR)$(bindir) $(DESTDIR)$(includedir)
132         install -d $(DESTDIR)$(libdir) $(DESTDIR)$(libdir)/pkgconfig
133         install -m 644 x264.h $(DESTDIR)$(includedir)
134         install -m 644 libx264.a $(DESTDIR)$(libdir)
135         install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
136         install x264 $(DESTDIR)$(bindir)
137         ranlib $(DESTDIR)$(libdir)/libx264.a
138
139 uninstall:
140         rm -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(libdir)/libx264.a
141         rm -f $(DESTDIR)$(bindir)/x264 $(DESTDIR)$(libdir)/pkgconfig/x264.pc
142
143 etags: TAGS
144
145 TAGS:
146         etags $(SRCS)