Makefile 6.09 KB
Newer Older
1
# Makefile
2

3 4
include config.mak

5 6
all: default

7 8
SRCS = common/mc.c common/predict.c common/pixel.c common/macroblock.c \
       common/frame.c common/dct.c common/cpu.c common/cabac.c \
9
       common/common.c common/mdate.c common/set.c \
Loren Merritt's avatar
Loren Merritt committed
10
       common/quant.c common/vlc.c \
11 12 13
       encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
       encoder/set.c encoder/macroblock.c encoder/cabac.c \
       encoder/cavlc.c encoder/encoder.c encoder/eval.c
Laurent Aimar's avatar
Laurent Aimar committed
14

Loren Merritt's avatar
Loren Merritt committed
15 16
SRCCLI = x264.c matroska.c muxers.c

Loren Merritt's avatar
Loren Merritt committed
17 18 19 20 21
# Visualization sources
ifeq ($(VIS),yes)
SRCS   += common/visualize.c common/display-x11.c
endif

22
# MMX/SSE optims
23
ifneq ($(AS),)
Loren Merritt's avatar
Loren Merritt committed
24
X86SRC0 = cabac-a.asm dct-a.asm deblock-a.asm mc-a.asm mc-a2.asm \
25
          pixel-a.asm predict-a.asm quant-a.asm sad-a.asm \
26
          cpu-32.asm dct-32.asm x86util.asm
27 28 29 30 31
X86SRC = $(X86SRC0:%=common/x86/%)

ifeq ($(ARCH),X86)
SRCS   += common/x86/mc-c.c common/x86/predict-c.c
ASMSRC  = $(X86SRC) common/x86/pixel-32.asm
32
OBJASM  = $(ASMSRC:%.asm=%.o)
33 34
ASFLAGS += -Icommon/x86/
$(OBJASM): common/x86/x86inc.asm common/x86/x86inc-32.asm
35
checkasm: tools/checkasm-a.o
36
endif
37

Loren Merritt's avatar
Loren Merritt committed
38
ifeq ($(ARCH),X86_64)
39 40
SRCS   += common/x86/mc-c.c common/x86/predict-c.c
ASMSRC  = $(X86SRC:-32.asm=-64.asm)
Loren Merritt's avatar
Loren Merritt committed
41
OBJASM  = $(ASMSRC:%.asm=%.o)
42 43
ASFLAGS += -Icommon/x86/ -DARCH_X86_64
$(OBJASM): common/x86/x86inc.asm common/x86/x86inc-64.asm
44
checkasm: tools/checkasm-a.o
Loren Merritt's avatar
Loren Merritt committed
45
endif
46
endif
Loren Merritt's avatar
Loren Merritt committed
47

48 49
# AltiVec optims
ifeq ($(ARCH),PPC)
50
ALTIVECSRC += common/ppc/mc.c common/ppc/pixel.c common/ppc/dct.c \
51 52
              common/ppc/quant.c common/ppc/deblock.c \
              common/ppc/predict.c
53 54
SRCS += $(ALTIVECSRC)
$(ALTIVECSRC:%.c=%.o): CFLAGS += $(ALTIVECFLAGS)
55 56
endif

57 58 59 60 61 62
# VIS optims
ifeq ($(ARCH),UltraSparc)
ASMSRC += common/sparc/pixel.asm
OBJASM  = $(ASMSRC:%.asm=%.o)
endif

63 64 65 66
ifneq ($(HAVE_GETOPT_LONG),1)
SRCS += extras/getopt.c
endif

Laurent Aimar's avatar
Laurent Aimar committed
67
OBJS = $(SRCS:%.c=%.o)
Loren Merritt's avatar
Loren Merritt committed
68
OBJCLI = $(SRCCLI:%.c=%.o)
Laurent Aimar's avatar
Laurent Aimar committed
69 70
DEP  = depend

71
.PHONY: all default fprofiled clean distclean install install-gtk uninstall dox test testclean
72

Loren Merritt's avatar
Loren Merritt committed
73
default: $(DEP) x264$(EXE)
Laurent Aimar's avatar
Laurent Aimar committed
74

Loren Merritt's avatar
Loren Merritt committed
75
libx264.a: .depend $(OBJS) $(OBJASM)
Laurent Aimar's avatar
Laurent Aimar committed
76
	ar rc libx264.a $(OBJS) $(OBJASM)
77
	ranlib libx264.a
Laurent Aimar's avatar
Laurent Aimar committed
78

79
$(SONAME): .depend $(OBJS) $(OBJASM)
Zuxy Meng's avatar
Zuxy Meng committed
80
	$(CC) -shared -o $@ $(OBJS) $(OBJASM) $(SOFLAGS) $(LDFLAGS)
81

Loren Merritt's avatar
Loren Merritt committed
82
x264$(EXE): $(OBJCLI) libx264.a 
Loren Merritt's avatar
Loren Merritt committed
83
	$(CC) -o $@ $+ $(LDFLAGS)
Loren Merritt's avatar
Loren Merritt committed
84

85 86 87
libx264gtk.a: muxers.o libx264.a
	$(MAKE) -C gtk

Loren Merritt's avatar
Loren Merritt committed
88
checkasm: tools/checkasm.o libx264.a
Loren Merritt's avatar
Loren Merritt committed
89
	$(CC) -o $@ $+ $(LDFLAGS)
Laurent Aimar's avatar
Laurent Aimar committed
90 91 92

%.o: %.asm
	$(AS) $(ASFLAGS) -o $@ $<
93 94
# delete local/anonymous symbols, so they don't show up in oprofile
	-@ strip -x $@
Laurent Aimar's avatar
Laurent Aimar committed
95

96
.depend: config.mak
97
	rm -f .depend
98
# Hacky - because gcc 2.9x doesn't have -MT
99
	$(foreach SRC, $(SRCS) $(SRCCLI), ( $(ECHON) "`dirname $(SRC)`/" && $(CC) $(CFLAGS) $(ALTIVECFLAGS) $(SRC) -MM -g0 ) 1>> .depend;)
Laurent Aimar's avatar
Laurent Aimar committed
100

101 102
config.mak: $(wildcard .svn/entries */.svn/entries */*/.svn/entries)
	./configure $(CONFIGURE_ARGS)
103

Laurent Aimar's avatar
Laurent Aimar committed
104 105 106 107 108
depend: .depend
ifneq ($(wildcard .depend),)
include .depend
endif

Loren Merritt's avatar
Loren Merritt committed
109
SRC2 = $(SRCS) $(SRCCLI)
110
# These should cover most of the important codepaths
111 112 113 114
OPT0 = --crf 30 -b1 -m1 -r1 --me dia --no-cabac --pre-scenecut --direct temporal --no-ssim --no-psnr
OPT1 = --crf 16 -b2 -m3 -r3 --me hex -8 --direct spatial --no-dct-decimate
OPT2 = --crf 26 -b2 -m5 -r2 --me hex -8 -w --cqm jvt --nr 100
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
115 116 117 118
OPT4 = --crf 22 -b3 -m6 -r4 --me esa -8 -t2 -A all --mixed-refs --b-rdo --bime
OPT5 = --frames 50 --crf 24 -b3 -m7 -r3 --me tesa -8 -t1 --mixed-refs --b-rdo --bime
OPT6 = --frames 50 -q0 -m6 -r2 --me hex -Aall
OPT7 = --frames 50 -q0 -m2 -r1 --me hex --no-cabac
119 120 121 122 123

ifeq (,$(VIDS))
fprofiled:
	@echo 'usage: make fprofiled VIDS="infile1 infile2 ..."'
	@echo 'where infiles are anything that x264 understands,'
Loren Merritt's avatar
Loren Merritt committed
124
	@echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
125 126
else
fprofiled:
Loren Merritt's avatar
Loren Merritt committed
127
	$(MAKE) clean
128 129
	mv config.mak config.mak2
	sed -e 's/CFLAGS.*/& -fprofile-generate/; s/LDFLAGS.*/& -fprofile-generate/' config.mak2 > config.mak
Loren Merritt's avatar
Loren Merritt committed
130
	$(MAKE) x264$(EXE)
131
	$(foreach V, $(VIDS), $(foreach I, 0 1 2 3 4 5 6 7, ./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
Loren Merritt's avatar
Loren Merritt committed
134
	$(MAKE)
135
	rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
136
	mv config.mak2 config.mak
137 138
endif

Laurent Aimar's avatar
Laurent Aimar committed
139
clean:
140
	rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(SONAME) *.a x264 x264.exe .depend TAGS
Loren Merritt's avatar
Loren Merritt committed
141 142
	rm -f checkasm checkasm.exe tools/checkasm.o
	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
Loren Merritt's avatar
Loren Merritt committed
145
	$(MAKE) -C gtk clean
Laurent Aimar's avatar
Laurent Aimar committed
146

Måns Rullgård's avatar
Måns Rullgård committed
147
distclean: clean
Loren Merritt's avatar
Loren Merritt committed
148
	rm -f config.mak config.h x264.pc
149
	rm -rf test/
150
	$(MAKE) -C gtk distclean
Laurent Aimar's avatar
Laurent Aimar committed
151

Zuxy Meng's avatar
Zuxy Meng committed
152
install: x264$(EXE) $(SONAME)
Loren Merritt's avatar
Loren Merritt committed
153 154
	install -d $(DESTDIR)$(bindir) $(DESTDIR)$(includedir)
	install -d $(DESTDIR)$(libdir) $(DESTDIR)$(libdir)/pkgconfig
155 156
	install -m 644 x264.h $(DESTDIR)$(includedir)
	install -m 644 libx264.a $(DESTDIR)$(libdir)
Loren Merritt's avatar
Loren Merritt committed
157
	install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
Zuxy Meng's avatar
Zuxy Meng committed
158
	install x264$(EXE) $(DESTDIR)$(bindir)
159
	ranlib $(DESTDIR)$(libdir)/libx264.a
Zuxy Meng's avatar
Zuxy Meng committed
160 161 162
ifeq ($(SYS),MINGW)
	$(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(bindir))
else
163
	$(if $(SONAME), ln -sf $(SONAME) $(DESTDIR)$(libdir)/libx264.so)
164
	$(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(libdir))
Zuxy Meng's avatar
Zuxy Meng committed
165 166
endif
	$(if $(IMPLIBNAME), install -m 644 $(IMPLIBNAME) $(DESTDIR)$(libdir))
Loren Merritt's avatar
Loren Merritt committed
167

168 169 170
install-gtk: libx264gtk.a
	$(MAKE) -C gtk install

Loren Merritt's avatar
Loren Merritt committed
171 172 173
uninstall:
	rm -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(libdir)/libx264.a
	rm -f $(DESTDIR)$(bindir)/x264 $(DESTDIR)$(libdir)/pkgconfig/x264.pc
174
	$(if $(SONAME), rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.so)
175
	$(MAKE) -C gtk uninstall
Loren Merritt's avatar
Loren Merritt committed
176

Måns Rullgård's avatar
Måns Rullgård committed
177 178 179 180
etags: TAGS

TAGS:
	etags $(SRCS)
181 182 183

dox:
	doxygen Doxyfile
184

Loren Merritt's avatar
Loren Merritt committed
185 186 187 188 189 190
ifeq (,$(VIDS))
test:
	@echo 'usage: make test VIDS="infile1 infile2 ..."'
	@echo 'where infiles are anything that x264 understands,'
	@echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
else
191 192
test:
	perl tools/regression-test.pl --version=head,current --options='$(OPT0)' --options='$(OPT1)' --options='$(OPT2)' $(VIDS:%=--input=%)
Loren Merritt's avatar
Loren Merritt committed
193
endif
194 195 196 197

testclean:
	rm -f test/*.log test/*.264
	$(foreach DIR, $(wildcard test/x264-r*/), cd $(DIR) ; make clean ; cd ../.. ;)