Makefile 7.93 KB
Newer Older
1
# Makefile
2

3 4
include config.mak

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

11
all: default
Henrik Gramner's avatar
Henrik Gramner committed
12
default:
13

14 15
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 \
16
       common/common.c common/osdep.c common/rectangle.c \
17
       common/set.c common/quant.c common/deblock.c common/vlc.c \
18
       common/mvpred.c common/bitstream.c \
19 20
       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
21
       encoder/cavlc.c encoder/encoder.c encoder/lookahead.c
Laurent Aimar's avatar
Laurent Aimar committed
22

23 24 25 26 27
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 \
28
         filters/video/select_every.c filters/video/crop.c filters/video/depth.c
29

30
SRCSO =
Henrik Gramner's avatar
Henrik Gramner committed
31 32 33
OBJS =
OBJSO =
OBJCLI =
34

Anton Mitrofanov's avatar
Anton Mitrofanov committed
35 36
OBJCHK = tools/checkasm.o

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

39
# GPL-only files
40
ifneq ($(findstring HAVE_GPL 1, $(CONFIG)),)
41 42 43
SRCCLI +=
endif

44
# Optional module sources
45
ifneq ($(findstring HAVE_AVS 1, $(CONFIG)),)
46
SRCCLI += input/avs.c
47 48
endif

49
ifneq ($(findstring HAVE_THREAD 1, $(CONFIG)),)
50
SRCCLI += input/thread.c
51
SRCS   += common/threadpool.c
52 53
endif

54 55 56 57
ifneq ($(findstring HAVE_WIN32THREAD 1, $(CONFIG)),)
SRCS += common/win32thread.c
endif

58
ifneq ($(findstring HAVE_LAVF 1, $(CONFIG)),)
59 60 61
SRCCLI += input/lavf.c
endif

62
ifneq ($(findstring HAVE_FFMS 1, $(CONFIG)),)
63 64 65
SRCCLI += input/ffms.c
endif

66
ifneq ($(findstring HAVE_GPAC 1, $(CONFIG)),)
67 68
SRCCLI += output/mp4.c
endif
Loren Merritt's avatar
Loren Merritt committed
69

Loren Merritt's avatar
Loren Merritt committed
70
# Visualization sources
71
ifneq ($(findstring HAVE_VISUALIZE 1, $(CONFIG)),)
Loren Merritt's avatar
Loren Merritt committed
72 73 74
SRCS   += common/visualize.c common/display-x11.c
endif

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

ifeq ($(ARCH),X86)
Loren Merritt's avatar
Loren Merritt committed
88 89
ARCH_X86 = yes
ASMSRC   = $(X86SRC) common/x86/pixel-32.asm
90
ASFLAGS += -DARCH_X86_64=0
91
endif
92

Loren Merritt's avatar
Loren Merritt committed
93
ifeq ($(ARCH),X86_64)
Loren Merritt's avatar
Loren Merritt committed
94
ARCH_X86 = yes
95
ASMSRC   = $(X86SRC:-32.asm=-64.asm) common/x86/trellis-64.asm
96
ASFLAGS += -DARCH_X86_64=1
Loren Merritt's avatar
Loren Merritt committed
97 98 99
endif

ifdef ARCH_X86
Oka Motofumi's avatar
Oka Motofumi committed
100
ASFLAGS += -I$(SRCPATH)/common/x86/
101
SRCS   += common/x86/mc-c.c common/x86/predict-c.c
Loren Merritt's avatar
Loren Merritt committed
102
OBJASM  = $(ASMSRC:%.asm=%.o)
Loren Merritt's avatar
Loren Merritt committed
103
$(OBJASM): common/x86/x86inc.asm common/x86/x86util.asm
Anton Mitrofanov's avatar
Anton Mitrofanov committed
104
OBJCHK += tools/checkasm-a.o
Loren Merritt's avatar
Loren Merritt committed
105
endif
106
endif
Loren Merritt's avatar
Loren Merritt committed
107

108 109
# AltiVec optims
ifeq ($(ARCH),PPC)
110
ifneq ($(AS),)
David Conrad's avatar
David Conrad committed
111 112 113
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
114
endif
115
endif
116

117 118 119
# NEON optims
ifeq ($(ARCH),ARM)
ifneq ($(AS),)
120
ASMSRC += common/arm/cpu-a.S common/arm/pixel-a.S common/arm/mc-a.S \
121 122 123
          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
124 125 126 127
OBJASM  = $(ASMSRC:%.S=%.o)
endif
endif

128
# VIS optims
Sean McGovern's avatar
Sean McGovern committed
129
ifeq ($(ARCH),UltraSPARC)
130
ifeq ($(findstring HIGH_BIT_DEPTH, $(CONFIG)),)
131 132 133
ASMSRC += common/sparc/pixel.asm
OBJASM  = $(ASMSRC:%.asm=%.o)
endif
134
endif
135

136
ifneq ($(HAVE_GETOPT_LONG),1)
137
SRCCLI += extras/getopt.c
138 139
endif

Steven Walters's avatar
Steven Walters committed
140
ifeq ($(SYS),WINDOWS)
Henrik Gramner's avatar
Henrik Gramner committed
141 142 143 144
OBJCLI += $(if $(RC), x264res.o)
ifneq ($(SONAME),)
SRCSO  += x264dll.c
OBJSO  += $(if $(RC), x264res.dll.o)
145 146 147
endif
endif

Henrik Gramner's avatar
Henrik Gramner committed
148 149 150
OBJS   += $(SRCS:%.c=%.o)
OBJCLI += $(SRCCLI:%.c=%.o)
OBJSO  += $(SRCSO:%.c=%.o)
Laurent Aimar's avatar
Laurent Aimar committed
151

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

Nikoli's avatar
Nikoli committed
154 155 156
cli: x264$(EXE)
lib-static: $(LIBX264)
lib-shared: $(SONAME)
Laurent Aimar's avatar
Laurent Aimar committed
157

Steven Walters's avatar
Steven Walters committed
158
$(LIBX264): .depend $(OBJS) $(OBJASM)
Anton Mitrofanov's avatar
Anton Mitrofanov committed
159
	rm -f $(LIBX264)
Steven Walters's avatar
Steven Walters committed
160 161
	$(AR)$@ $(OBJS) $(OBJASM)
	$(if $(RANLIB), $(RANLIB) $@)
Laurent Aimar's avatar
Laurent Aimar committed
162

163
$(SONAME): .depend $(OBJS) $(OBJASM) $(OBJSO)
Steven Walters's avatar
Steven Walters committed
164
	$(LD)$@ $(OBJS) $(OBJASM) $(OBJSO) $(SOFLAGS) $(LDFLAGS)
165

Anton Mitrofanov's avatar
Anton Mitrofanov committed
166 167 168 169 170 171
ifneq ($(EXE),)
.PHONY: x264 checkasm
x264: x264$(EXE)
checkasm: checkasm$(EXE)
endif

Nikoli's avatar
Nikoli committed
172 173
x264$(EXE): .depend $(OBJCLI) $(CLI_LIBX264)
	$(LD)$@ $(OBJCLI) $(CLI_LIBX264) $(LDFLAGSCLI) $(LDFLAGS)
Loren Merritt's avatar
Loren Merritt committed
174

Anton Mitrofanov's avatar
Anton Mitrofanov committed
175 176 177 178
checkasm$(EXE): .depend $(OBJCHK) $(LIBX264)
	$(LD)$@ $(OBJCHK) $(LIBX264) $(LDFLAGS)

$(OBJS) $(OBJASM) $(OBJSO) $(OBJCLI) $(OBJCHK): .depend
Laurent Aimar's avatar
Laurent Aimar committed
179 180 181

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

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

Henrik Gramner's avatar
Henrik Gramner committed
188
%.dll.o: %.rc x264.h
189
	$(RC)$@ -DDLL $<
Henrik Gramner's avatar
Henrik Gramner committed
190 191

%.o: %.rc x264.h
192
	$(RC)$@ $<
Henrik Gramner's avatar
Henrik Gramner committed
193

194
.depend: config.mak
195
	@rm -f .depend
Oka Motofumi's avatar
Oka Motofumi committed
196
	@$(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
197

198 199
config.mak:
	./configure
200

Laurent Aimar's avatar
Laurent Aimar committed
201 202 203 204 205
depend: .depend
ifneq ($(wildcard .depend),)
include .depend
endif

Loren Merritt's avatar
Loren Merritt committed
206
SRC2 = $(SRCS) $(SRCCLI)
207
# These should cover most of the important codepaths
208
OPT0 = --crf 30 -b1 -m1 -r1 --me dia --no-cabac --direct temporal --ssim --no-weightb
Fiona Glaser's avatar
Fiona Glaser committed
209 210
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
211
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
212
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
213
OPT5 = --frames 50 --crf 24 -b3 -m10 -r3 --me tesa -t2
214
OPT6 = --frames 50 -q0 -m9 -r2 --me hex -Aall
215
OPT7 = --frames 50 -q0 -m2 -r1 --me hex --no-cabac
216 217 218 219 220

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
221
	@echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
222 223
else
fprofiled:
Loren Merritt's avatar
Loren Merritt committed
224
	$(MAKE) clean
Steven Walters's avatar
Steven Walters committed
225
	$(MAKE) x264$(EXE) CFLAGS="$(CFLAGS) $(PROF_GEN_CC)" LDFLAGS="$(LDFLAGS) $(PROF_GEN_LD)"
226
	$(foreach V, $(VIDS), $(foreach I, 0 1 2 3 4 5 6 7, ./x264$(EXE) $(OPT$I) --threads 1 $(V) -o $(DEVNULL) ;))
227
	rm -f $(SRC2:%.c=%.o)
Steven Walters's avatar
Steven Walters committed
228 229
	$(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
230 231
endif

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

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

Nikoli's avatar
Nikoli committed
240
install-cli: cli
241
	install -d $(DESTDIR)$(bindir)
Nikoli's avatar
Nikoli committed
242 243 244
	install x264$(EXE) $(DESTDIR)$(bindir)

install-lib-dev:
245 246 247
	install -d $(DESTDIR)$(includedir)
	install -d $(DESTDIR)$(libdir)
	install -d $(DESTDIR)$(libdir)/pkgconfig
Oka Motofumi's avatar
Oka Motofumi committed
248
	install -m 644 $(SRCPATH)/x264.h $(DESTDIR)$(includedir)
249
	install -m 644 x264_config.h $(DESTDIR)$(includedir)
Loren Merritt's avatar
Loren Merritt committed
250
	install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
Nikoli's avatar
Nikoli committed
251 252 253

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

install-lib-shared: lib-shared install-lib-dev
257 258 259 260 261 262 263
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
264
endif
Loren Merritt's avatar
Loren Merritt committed
265

Loren Merritt's avatar
Loren Merritt committed
266
uninstall:
267
	rm -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(includedir)/x264_config.h $(DESTDIR)$(libdir)/libx264.a
268
	rm -f $(DESTDIR)$(bindir)/x264$(EXE) $(DESTDIR)$(libdir)/pkgconfig/x264.pc
269 270 271 272 273
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
274

Måns Rullgård's avatar
Måns Rullgård committed
275 276 277 278
etags: TAGS

TAGS:
	etags $(SRCS)