Makefile 5.8 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
       encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
       encoder/set.c encoder/macroblock.c encoder/cabac.c \
13
       encoder/cavlc.c encoder/encoder.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 \
Fiona Glaser's avatar
Fiona Glaser committed
26
          cpu-a.asm dct-32.asm
27 28 29
X86SRC = $(X86SRC0:%=common/x86/%)

ifeq ($(ARCH),X86)
Loren Merritt's avatar
Loren Merritt committed
30 31
ARCH_X86 = yes
ASMSRC   = $(X86SRC) common/x86/pixel-32.asm
32
endif
33

Loren Merritt's avatar
Loren Merritt committed
34
ifeq ($(ARCH),X86_64)
Loren Merritt's avatar
Loren Merritt committed
35 36 37 38 39 40 41
ARCH_X86 = yes
ASMSRC   = $(X86SRC:-32.asm=-64.asm)
ASFLAGS += -DARCH_X86_64
endif

ifdef ARCH_X86
ASFLAGS += -Icommon/x86/
42
SRCS   += common/x86/mc-c.c common/x86/predict-c.c
Loren Merritt's avatar
Loren Merritt committed
43
OBJASM  = $(ASMSRC:%.asm=%.o)
Loren Merritt's avatar
Loren Merritt committed
44
$(OBJASM): common/x86/x86inc.asm common/x86/x86util.asm
45
checkasm: tools/checkasm-a.o
Loren Merritt's avatar
Loren Merritt committed
46
endif
47
endif
Loren Merritt's avatar
Loren Merritt committed
48

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

58 59 60
# NEON optims
ifeq ($(ARCH),ARM)
ifneq ($(AS),)
61 62
ASMSRC += common/arm/cpu-a.S common/arm/pixel-a.S common/arm/mc-a.S
SRCS   += common/arm/mc-c.c
63 64 65 66
OBJASM  = $(ASMSRC:%.S=%.o)
endif
endif

67 68 69 70 71 72
# VIS optims
ifeq ($(ARCH),UltraSparc)
ASMSRC += common/sparc/pixel.asm
OBJASM  = $(ASMSRC:%.asm=%.o)
endif

73 74 75 76
ifneq ($(HAVE_GETOPT_LONG),1)
SRCS += extras/getopt.c
endif

Laurent Aimar's avatar
Laurent Aimar committed
77
OBJS = $(SRCS:%.c=%.o)
Loren Merritt's avatar
Loren Merritt committed
78
OBJCLI = $(SRCCLI:%.c=%.o)
Laurent Aimar's avatar
Laurent Aimar committed
79 80
DEP  = depend

Loren Merritt's avatar
Loren Merritt committed
81
.PHONY: all default fprofiled clean distclean install uninstall dox test testclean
82

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

Loren Merritt's avatar
Loren Merritt committed
85
libx264.a: .depend $(OBJS) $(OBJASM)
Anton Mitrofanov's avatar
Anton Mitrofanov committed
86 87
	$(AR) rc libx264.a $(OBJS) $(OBJASM)
	$(RANLIB) libx264.a
Laurent Aimar's avatar
Laurent Aimar committed
88

89
$(SONAME): .depend $(OBJS) $(OBJASM)
Zuxy Meng's avatar
Zuxy Meng committed
90
	$(CC) -shared -o $@ $(OBJS) $(OBJASM) $(SOFLAGS) $(LDFLAGS)
91

Loren Merritt's avatar
Loren Merritt committed
92
x264$(EXE): $(OBJCLI) libx264.a 
Loren Merritt's avatar
Loren Merritt committed
93
	$(CC) -o $@ $+ $(LDFLAGS)
Loren Merritt's avatar
Loren Merritt committed
94

Loren Merritt's avatar
Loren Merritt committed
95
checkasm: tools/checkasm.o libx264.a
Loren Merritt's avatar
Loren Merritt committed
96
	$(CC) -o $@ $+ $(LDFLAGS)
Laurent Aimar's avatar
Laurent Aimar committed
97 98 99

%.o: %.asm
	$(AS) $(ASFLAGS) -o $@ $<
100 101 102 103

%.o: %.S
	$(AS) $(ASFLAGS) -o $@ $<

104
# delete local/anonymous symbols, so they don't show up in oprofile
Anton Mitrofanov's avatar
Anton Mitrofanov committed
105
	-@ $(STRIP) -x $@
Laurent Aimar's avatar
Laurent Aimar committed
106

107
.depend: config.mak
108
	rm -f .depend
109
	$(foreach SRC, $(SRCS) $(SRCCLI), $(CC) $(CFLAGS) $(ALTIVECFLAGS) $(SRC) -MT $(SRC:%.c=%.o) -MM -g0 1>> .depend;)
Laurent Aimar's avatar
Laurent Aimar committed
110

111 112
config.mak:
	./configure
113

Laurent Aimar's avatar
Laurent Aimar committed
114 115 116 117 118
depend: .depend
ifneq ($(wildcard .depend),)
include .depend
endif

Loren Merritt's avatar
Loren Merritt committed
119
SRC2 = $(SRCS) $(SRCCLI)
120
# These should cover most of the important codepaths
121 122 123
OPT0 = --crf 30 -b1 -m1 -r1 --me dia --no-cabac --direct temporal --ssim --no-weightb
OPT1 = --crf 16 -b2 -m3 -r3 --me hex --no-8x8dct --direct spatial --no-dct-decimate -t0
OPT2 = --crf 26 -b4 -m5 -r2 --me hex --cqm jvt --nr 100 --psnr --no-mixed-refs --b-adapt 2
124
OPT3 = --crf 18 -b3 -m9 -r5 --me umh -t1 -A all --b-pyramid --direct auto --no-fast-pskip --no-mbtree
125
OPT4 = --crf 22 -b3 -m7 -r4 --me esa -t2 -A all --psy-rd 1.0:1.0
Fiona Glaser's avatar
Fiona Glaser committed
126
OPT5 = --frames 50 --crf 24 -b3 -m10 -r3 --me tesa -t2
127
OPT6 = --frames 50 -q0 -m9 -r2 --me hex -Aall
128
OPT7 = --frames 50 -q0 -m2 -r1 --me hex --no-cabac
129 130 131 132 133

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
134
	@echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
135 136
else
fprofiled:
Loren Merritt's avatar
Loren Merritt committed
137
	$(MAKE) clean
138 139
	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
140
	$(MAKE) x264$(EXE)
141
	$(foreach V, $(VIDS), $(foreach I, 0 1 2 3 4 5 6 7, ./x264$(EXE) $(OPT$I) --threads 1 $(V) -o $(DEVNULL) ;))
142
	rm -f $(SRC2:%.c=%.o)
143
	sed -e 's/CFLAGS.*/& -fprofile-use/; s/LDFLAGS.*/& -fprofile-use/' config.mak2 > config.mak
Loren Merritt's avatar
Loren Merritt committed
144
	$(MAKE)
145
	rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
146
	mv config.mak2 config.mak
147 148
endif

Laurent Aimar's avatar
Laurent Aimar committed
149
clean:
150
	rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(SONAME) *.a x264 x264.exe .depend TAGS
Anton Mitrofanov's avatar
Anton Mitrofanov committed
151
	rm -f checkasm checkasm.exe tools/checkasm.o tools/checkasm-a.o
152
	rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
153
	- sed -e 's/ *-fprofile-\(generate\|use\)//g' config.mak > config.mak2 && mv config.mak2 config.mak
Laurent Aimar's avatar
Laurent Aimar committed
154

Måns Rullgård's avatar
Måns Rullgård committed
155
distclean: clean
Loren Merritt's avatar
Loren Merritt committed
156
	rm -f config.mak config.h x264.pc
157
	rm -rf test/
Laurent Aimar's avatar
Laurent Aimar committed
158

Zuxy Meng's avatar
Zuxy Meng committed
159
install: x264$(EXE) $(SONAME)
Loren Merritt's avatar
Loren Merritt committed
160 161
	install -d $(DESTDIR)$(bindir) $(DESTDIR)$(includedir)
	install -d $(DESTDIR)$(libdir) $(DESTDIR)$(libdir)/pkgconfig
162 163
	install -m 644 x264.h $(DESTDIR)$(includedir)
	install -m 644 libx264.a $(DESTDIR)$(libdir)
Loren Merritt's avatar
Loren Merritt committed
164
	install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
Zuxy Meng's avatar
Zuxy Meng committed
165
	install x264$(EXE) $(DESTDIR)$(bindir)
Anton Mitrofanov's avatar
Anton Mitrofanov committed
166
	$(RANLIB) $(DESTDIR)$(libdir)/libx264.a
Zuxy Meng's avatar
Zuxy Meng committed
167 168 169
ifeq ($(SYS),MINGW)
	$(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(bindir))
else
170
	$(if $(SONAME), ln -sf $(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX))
171
	$(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(libdir))
Zuxy Meng's avatar
Zuxy Meng committed
172 173
endif
	$(if $(IMPLIBNAME), install -m 644 $(IMPLIBNAME) $(DESTDIR)$(libdir))
Loren Merritt's avatar
Loren Merritt committed
174

Loren Merritt's avatar
Loren Merritt committed
175 176 177
uninstall:
	rm -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(libdir)/libx264.a
	rm -f $(DESTDIR)$(bindir)/x264 $(DESTDIR)$(libdir)/pkgconfig/x264.pc
178
	$(if $(SONAME), rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX))
Loren Merritt's avatar
Loren Merritt committed
179

Måns Rullgård's avatar
Måns Rullgård committed
180 181 182 183
etags: TAGS

TAGS:
	etags $(SRCS)
184 185 186

dox:
	doxygen Doxyfile
187

Loren Merritt's avatar
Loren Merritt committed
188 189 190 191 192 193
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
194 195
test:
	perl tools/regression-test.pl --version=head,current --options='$(OPT0)' --options='$(OPT1)' --options='$(OPT2)' $(VIDS:%=--input=%)
Loren Merritt's avatar
Loren Merritt committed
196
endif
197 198 199 200

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