Makefile 7.71 KB
Newer Older
1
# Makefile
2

3 4
include config.mak

Oka Motofumi's avatar
Oka Motofumi committed
5 6 7 8 9
vpath %.c $(SRCPATH)
vpath %.h $(SRCPATH)
vpath %.S $(SRCPATH)
vpath %.asm $(SRCPATH)

10 11
all: default

12 13
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 \
14
       common/common.c common/osdep.c common/rectangle.c \
15
       common/set.c common/quant.c common/deblock.c common/vlc.c \
16
       common/mvpred.c common/bitstream.c \
17 18
       encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
       encoder/set.c encoder/macroblock.c encoder/cabac.c \
Steven Walters's avatar
Steven Walters committed
19
       encoder/cavlc.c encoder/encoder.c encoder/lookahead.c
Laurent Aimar's avatar
Laurent Aimar committed
20

21 22 23 24 25
SRCCLI = x264.c input/input.c input/timecode.c input/raw.c input/y4m.c \
         output/raw.c output/matroska.c output/matroska_ebml.c \
         output/flv.c output/flv_bytestream.c filters/filters.c \
         filters/video/video.c filters/video/source.c filters/video/internal.c \
         filters/video/resize.c filters/video/cache.c filters/video/fix_vfr_pts.c \
26
         filters/video/select_every.c filters/video/crop.c filters/video/depth.c
27

28 29
SRCSO =

Anton Mitrofanov's avatar
Anton Mitrofanov committed
30 31
OBJCHK = tools/checkasm.o

Diogo Franco's avatar
Diogo Franco committed
32
CONFIG := $(shell cat config.h)
33

34
# GPL-only files
35
ifneq ($(findstring HAVE_GPL 1, $(CONFIG)),)
36 37 38
SRCCLI +=
endif

39
# Optional module sources
40
ifneq ($(findstring HAVE_AVS 1, $(CONFIG)),)
41
SRCCLI += input/avs.c
42 43
endif

44
ifneq ($(findstring HAVE_THREAD 1, $(CONFIG)),)
45
SRCCLI += input/thread.c
46
SRCS   += common/threadpool.c
47 48
endif

49 50 51 52
ifneq ($(findstring HAVE_WIN32THREAD 1, $(CONFIG)),)
SRCS += common/win32thread.c
endif

53
ifneq ($(findstring HAVE_LAVF 1, $(CONFIG)),)
54 55 56
SRCCLI += input/lavf.c
endif

57
ifneq ($(findstring HAVE_FFMS 1, $(CONFIG)),)
58 59 60
SRCCLI += input/ffms.c
endif

61
ifneq ($(findstring HAVE_GPAC 1, $(CONFIG)),)
62 63
SRCCLI += output/mp4.c
endif
Loren Merritt's avatar
Loren Merritt committed
64

Loren Merritt's avatar
Loren Merritt committed
65
# Visualization sources
66
ifneq ($(findstring HAVE_VISUALIZE 1, $(CONFIG)),)
Loren Merritt's avatar
Loren Merritt committed
67 68 69
SRCS   += common/visualize.c common/display-x11.c
endif

70
# MMX/SSE optims
71
ifneq ($(AS),)
72
X86SRC0 = const-a.asm cabac-a.asm dct-a.asm deblock-a.asm mc-a.asm \
73
          mc-a2.asm pixel-a.asm predict-a.asm quant-a.asm \
74
          cpu-a.asm dct-32.asm bitstream-a.asm
75
ifneq ($(findstring HIGH_BIT_DEPTH, $(CONFIG)),)
76 77 78 79
X86SRC0 += sad16-a.asm
else
X86SRC0 += sad-a.asm
endif
80 81 82
X86SRC = $(X86SRC0:%=common/x86/%)

ifeq ($(ARCH),X86)
Loren Merritt's avatar
Loren Merritt committed
83 84
ARCH_X86 = yes
ASMSRC   = $(X86SRC) common/x86/pixel-32.asm
85
endif
86

Loren Merritt's avatar
Loren Merritt committed
87
ifeq ($(ARCH),X86_64)
Loren Merritt's avatar
Loren Merritt committed
88 89 90 91 92 93
ARCH_X86 = yes
ASMSRC   = $(X86SRC:-32.asm=-64.asm)
ASFLAGS += -DARCH_X86_64
endif

ifdef ARCH_X86
Oka Motofumi's avatar
Oka Motofumi committed
94
ASFLAGS += -I$(SRCPATH)/common/x86/
95
SRCS   += common/x86/mc-c.c common/x86/predict-c.c
Loren Merritt's avatar
Loren Merritt committed
96
OBJASM  = $(ASMSRC:%.asm=%.o)
Loren Merritt's avatar
Loren Merritt committed
97
$(OBJASM): common/x86/x86inc.asm common/x86/x86util.asm
Anton Mitrofanov's avatar
Anton Mitrofanov committed
98
OBJCHK += tools/checkasm-a.o
Loren Merritt's avatar
Loren Merritt committed
99
endif
100
endif
Loren Merritt's avatar
Loren Merritt committed
101

102 103
# AltiVec optims
ifeq ($(ARCH),PPC)
104
ifneq ($(AS),)
David Conrad's avatar
David Conrad committed
105 106 107
SRCS += common/ppc/mc.c common/ppc/pixel.c common/ppc/dct.c \
        common/ppc/quant.c common/ppc/deblock.c \
        common/ppc/predict.c
108
endif
109
endif
110

111 112 113
# NEON optims
ifeq ($(ARCH),ARM)
ifneq ($(AS),)
114
ASMSRC += common/arm/cpu-a.S common/arm/pixel-a.S common/arm/mc-a.S \
115 116 117
          common/arm/dct-a.S common/arm/quant-a.S common/arm/deblock-a.S \
          common/arm/predict-a.S
SRCS   += common/arm/mc-c.c common/arm/predict-c.c
118 119 120 121
OBJASM  = $(ASMSRC:%.S=%.o)
endif
endif

122
# VIS optims
Sean McGovern's avatar
Sean McGovern committed
123
ifeq ($(ARCH),UltraSPARC)
124
ifeq ($(findstring HIGH_BIT_DEPTH, $(CONFIG)),)
125 126 127
ASMSRC += common/sparc/pixel.asm
OBJASM  = $(ASMSRC:%.asm=%.o)
endif
128
endif
129

130
ifneq ($(HAVE_GETOPT_LONG),1)
131
SRCCLI += extras/getopt.c
132 133
endif

134
ifneq ($(SONAME),)
Steven Walters's avatar
Steven Walters committed
135
ifeq ($(SYS),WINDOWS)
136 137 138 139
SRCSO += x264dll.c
endif
endif

Laurent Aimar's avatar
Laurent Aimar committed
140
OBJS = $(SRCS:%.c=%.o)
Loren Merritt's avatar
Loren Merritt committed
141
OBJCLI = $(SRCCLI:%.c=%.o)
142
OBJSO = $(SRCSO:%.c=%.o)
Laurent Aimar's avatar
Laurent Aimar committed
143 144
DEP  = depend

Anton Mitrofanov's avatar
Anton Mitrofanov committed
145
.PHONY: all default fprofiled clean distclean install uninstall lib-static lib-shared cli install-lib-dev install-lib-static install-lib-shared install-cli
146

Nikoli's avatar
Nikoli committed
147 148 149 150 151
default: $(DEP)

cli: x264$(EXE)
lib-static: $(LIBX264)
lib-shared: $(SONAME)
Laurent Aimar's avatar
Laurent Aimar committed
152

Steven Walters's avatar
Steven Walters committed
153
$(LIBX264): .depend $(OBJS) $(OBJASM)
Anton Mitrofanov's avatar
Anton Mitrofanov committed
154
	rm -f $(LIBX264)
Steven Walters's avatar
Steven Walters committed
155 156
	$(AR)$@ $(OBJS) $(OBJASM)
	$(if $(RANLIB), $(RANLIB) $@)
Laurent Aimar's avatar
Laurent Aimar committed
157

158
$(SONAME): .depend $(OBJS) $(OBJASM) $(OBJSO)
Steven Walters's avatar
Steven Walters committed
159
	$(LD)$@ $(OBJS) $(OBJASM) $(OBJSO) $(SOFLAGS) $(LDFLAGS)
160

Anton Mitrofanov's avatar
Anton Mitrofanov committed
161 162 163 164 165 166
ifneq ($(EXE),)
.PHONY: x264 checkasm
x264: x264$(EXE)
checkasm: checkasm$(EXE)
endif

Nikoli's avatar
Nikoli committed
167 168
x264$(EXE): .depend $(OBJCLI) $(CLI_LIBX264)
	$(LD)$@ $(OBJCLI) $(CLI_LIBX264) $(LDFLAGSCLI) $(LDFLAGS)
Loren Merritt's avatar
Loren Merritt committed
169

Anton Mitrofanov's avatar
Anton Mitrofanov committed
170 171 172 173
checkasm$(EXE): .depend $(OBJCHK) $(LIBX264)
	$(LD)$@ $(OBJCHK) $(LIBX264) $(LDFLAGS)

$(OBJS) $(OBJASM) $(OBJSO) $(OBJCLI) $(OBJCHK): .depend
Laurent Aimar's avatar
Laurent Aimar committed
174 175 176

%.o: %.asm
	$(AS) $(ASFLAGS) -o $@ $<
Steven Walters's avatar
Steven Walters committed
177
	-@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile
178 179 180

%.o: %.S
	$(AS) $(ASFLAGS) -o $@ $<
Steven Walters's avatar
Steven Walters committed
181
	-@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile
182

183
.depend: config.mak
184
	@rm -f .depend
Oka Motofumi's avatar
Oka Motofumi committed
185
	@$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%.o) $(DEPMM) 1>> .depend;)
Laurent Aimar's avatar
Laurent Aimar committed
186

187 188
config.mak:
	./configure
189

Laurent Aimar's avatar
Laurent Aimar committed
190 191 192 193 194
depend: .depend
ifneq ($(wildcard .depend),)
include .depend
endif

Loren Merritt's avatar
Loren Merritt committed
195
SRC2 = $(SRCS) $(SRCCLI)
196
# These should cover most of the important codepaths
197
OPT0 = --crf 30 -b1 -m1 -r1 --me dia --no-cabac --direct temporal --ssim --no-weightb
Fiona Glaser's avatar
Fiona Glaser committed
198 199
OPT1 = --crf 16 -b2 -m3 -r3 --me hex --no-8x8dct --direct spatial --no-dct-decimate -t0  --slice-max-mbs 50
OPT2 = --crf 26 -b4 -m5 -r2 --me hex --cqm jvt --nr 100 --psnr --no-mixed-refs --b-adapt 2 --slice-max-size 1500
200
OPT3 = --crf 18 -b3 -m9 -r5 --me umh -t1 -A all --b-pyramid normal --direct auto --no-fast-pskip --no-mbtree
Fiona Glaser's avatar
Fiona Glaser committed
201
OPT4 = --crf 22 -b3 -m7 -r4 --me esa -t2 -A all --psy-rd 1.0:1.0 --slices 4
Fiona Glaser's avatar
Fiona Glaser committed
202
OPT5 = --frames 50 --crf 24 -b3 -m10 -r3 --me tesa -t2
203
OPT6 = --frames 50 -q0 -m9 -r2 --me hex -Aall
204
OPT7 = --frames 50 -q0 -m2 -r1 --me hex --no-cabac
205 206 207 208 209

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
210
	@echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
211 212
else
fprofiled:
Loren Merritt's avatar
Loren Merritt committed
213
	$(MAKE) clean
Steven Walters's avatar
Steven Walters committed
214
	$(MAKE) x264$(EXE) CFLAGS="$(CFLAGS) $(PROF_GEN_CC)" LDFLAGS="$(LDFLAGS) $(PROF_GEN_LD)"
215
	$(foreach V, $(VIDS), $(foreach I, 0 1 2 3 4 5 6 7, ./x264$(EXE) $(OPT$I) --threads 1 $(V) -o $(DEVNULL) ;))
216
	rm -f $(SRC2:%.c=%.o)
Steven Walters's avatar
Steven Walters committed
217 218
	$(MAKE) CFLAGS="$(CFLAGS) $(PROF_USE_CC)" LDFLAGS="$(LDFLAGS) $(PROF_USE_LD)"
	rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock
219 220
endif

Laurent Aimar's avatar
Laurent Aimar committed
221
clean:
Steven Walters's avatar
Steven Walters committed
222
	rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(OBJSO) $(SONAME) *.a *.lib *.exp *.pdb x264 x264.exe .depend TAGS
Anton Mitrofanov's avatar
Anton Mitrofanov committed
223
	rm -f checkasm checkasm.exe $(OBJCHK)
Steven Walters's avatar
Steven Walters committed
224
	rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock
Laurent Aimar's avatar
Laurent Aimar committed
225

Måns Rullgård's avatar
Måns Rullgård committed
226
distclean: clean
Steven Walters's avatar
Steven Walters committed
227
	rm -f config.mak x264_config.h config.h config.log x264.pc x264.def
Laurent Aimar's avatar
Laurent Aimar committed
228

Nikoli's avatar
Nikoli committed
229
install-cli: cli
230
	install -d $(DESTDIR)$(bindir)
Nikoli's avatar
Nikoli committed
231 232 233
	install x264$(EXE) $(DESTDIR)$(bindir)

install-lib-dev:
234 235 236
	install -d $(DESTDIR)$(includedir)
	install -d $(DESTDIR)$(libdir)
	install -d $(DESTDIR)$(libdir)/pkgconfig
Oka Motofumi's avatar
Oka Motofumi committed
237
	install -m 644 $(SRCPATH)/x264.h $(DESTDIR)$(includedir)
238
	install -m 644 x264_config.h $(DESTDIR)$(includedir)
Loren Merritt's avatar
Loren Merritt committed
239
	install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
Nikoli's avatar
Nikoli committed
240 241 242

install-lib-static: lib-static install-lib-dev
	install -m 644 $(LIBX264) $(DESTDIR)$(libdir)
Steven Walters's avatar
Steven Walters committed
243
	$(if $(RANLIB), $(RANLIB) $(DESTDIR)$(libdir)/$(LIBX264))
Nikoli's avatar
Nikoli committed
244 245

install-lib-shared: lib-shared install-lib-dev
246 247 248 249 250 251 252
ifneq ($(IMPLIBNAME),)
	install -d $(DESTDIR)$(bindir)
	install -m 755 $(SONAME) $(DESTDIR)$(bindir)
	install -m 644 $(IMPLIBNAME) $(DESTDIR)$(libdir)
else ifneq ($(SONAME),)
	ln -f -s $(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
	install -m 755 $(SONAME) $(DESTDIR)$(libdir)
Zuxy Meng's avatar
Zuxy Meng committed
253
endif
Loren Merritt's avatar
Loren Merritt committed
254

Loren Merritt's avatar
Loren Merritt committed
255
uninstall:
256
	rm -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(includedir)/x264_config.h $(DESTDIR)$(libdir)/libx264.a
257
	rm -f $(DESTDIR)$(bindir)/x264$(EXE) $(DESTDIR)$(libdir)/pkgconfig/x264.pc
258 259 260 261 262
ifneq ($(IMPLIBNAME),)
	rm -f $(DESTDIR)$(bindir)/$(SONAME) $(DESTDIR)$(libdir)/$(IMPLIBNAME)
else ifneq ($(SONAME),)
	rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
endif
Loren Merritt's avatar
Loren Merritt committed
263

Måns Rullgård's avatar
Måns Rullgård committed
264 265 266 267
etags: TAGS

TAGS:
	etags $(SRCS)