aboutsummaryrefslogtreecommitdiff
path: root/multimedia/ffmpeg/Makefile
blob: 8830d0ba625821a38d9cbe9b9e0c55bf52075382 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# New ports collection makefile for:	ffmpeg cvs
# Date created:		Sun May  1 20:46:59 UTC 2005
# Whom:			Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>
#
# $FreeBSD$
#      $Id: Makefile 77 2008-07-27 21:50:37Z buhnux $

PORTNAME=	ffmpeg
DISTVERSION=	2008-07-27
PORTREVISION=	6
CATEGORIES=	multimedia audio ipv6 net
MASTER_SITES=	${MASTER_SITE_LOCAL}
MASTER_SITE_SUBDIR=	ahze

MAINTAINER=	multimedia@FreeBSD.org
COMMENT=	Hyper fast realtime audio/video encoder/converter, streaming server

HAS_CONFIGURE=	yes
CONFIGURE_LOG=	config.err
USE_BZIP2=	yes
USE_GMAKE=	yes
WANT_SDL=	yes

OPTIONS=	AMR_NB	"AMR narrowband encoder" off \
		AMR_WB	"AMR wideband encoder" off \
		FAAC	"FAAC mp4/aac audio encoder" off \
		FAAD	"FAAD mp4/aac audio decoder" on \
		GSM	"gsm audio codec" off \
		IPV6	"IPV6 network support" on \
		LAME	"lame MP3 codec" off \
		LIBA52	"liba52 support"	on \
		OPTIMIZED_CFLAGS "Additional optimizations" off \
		SDL	"SDL support (build ffplay)" off \
		THEORA	"libtheora support (implies OGG)" on \
		VORBIS	"libvorbisenc support (implies OGG)" on \
		X264	"X.264 codec" on \
		XVID	"XVID codec" off

COMPAT_HEADERS=	libavcodec/avcodec.h \
	libavcodec/opt.h \
	libavdevice/avdevice.h \
	libavformat/avformat.h \
	libavformat/avio.h \
	libavformat/rtsp.h \
	libavformat/rtspcodes.h \
	libavutil/adler32.h  \
	libavutil/avstring.h \
	libavutil/avutil.h \
	libavutil/base64.h \
	libavutil/common.h \
	libavutil/crc.h \
	libavutil/fifo.h \
	libavutil/intfloat_readwrite.h \
	libavutil/log.h \
	libavutil/lzo.h \
	libavutil/mathematics.h \
	libavutil/md5.h \
	libavutil/mem.h \
	libavutil/random.h \
	libavutil/rational.h \
	libavutil/sha1.h \
	libpostproc/postprocess.h \
	libswscale/rgb2rgb.h \
	libswscale/swscale.h

.include <bsd.port.pre.mk>

CONFIGURE_ARGS+=--cc="${CC}" --prefix="${PREFIX}" \
		--disable-debug \
		--enable-memalign-hack \
		--enable-shared \
		--enable-postproc \
		--extra-cflags="${FFMPEG_CFLAGS} -I${LOCALBASE}/include" \
		--extra-ldflags="-L${LOCALBASE}/lib ${FFMPEG_LDFLAGS}" \
		--extra-libs="${PTHREAD_LIBS}" \
		--enable-gpl \
		--enable-pthreads \
		--enable-swscale \
		--mandir=${PREFIX}/man
CONFIGURE_ENV+=	LANG=C
MAKE_ENV+=	INSTALL="${INSTALL}"
SHLIB_VER=	1
PLIST_SUB=	SHLIB_VER=${SHLIB_VER}
USE_LDCONFIG=	yes

##
DOC_FILES=	Changelog README
# under subdir doc
DOC_DOCFILES=	TODO faq.html ffmpeg-doc.html \
		ffplay-doc.html ffserver-doc.html \
		hooks.html optimization.txt
PORTDOCS=	*

## sse hardware vector support
.if (defined(MACHINE_CPU) && ${MACHINE_CPU:Msse} == "sse")
WITH_BUILTIN_VECTOR=	yes
.endif

##
## support activation
##
## PORTDOCS
.ifndef(NOPORTDOCS)
BUILD_DEPENDS+=	texi2html:${PORTSDIR}/textproc/texi2html
MAN1+=	ffmpeg.1 ffserver.1
.endif

.ifdef(WITH_OPTIMIZED_CFLAGS)
CFLAGS:=		${CFLAGS:N-O*} -O3 -ffast-math -fomit-frame-pointer
.else
CFLAGS:=		${CFLAGS:N-O0} -O2
DEBUG_FLAGS+=		 -O2
.endif

## a52
.if !defined(WITHOUT_LIBA52) && !defined(WITHOUT_A52)
LIB_DEPENDS+=	a52.0:${PORTSDIR}/audio/liba52

CONFIGURE_ARGS+=	--enable-liba52 \
			--enable-liba52bin
FFMPEG_LDFLAGS+=	-la52
.else
CONFIGURE_ARGS+=	--disable-liba52
.endif

.ifdef(WITH_FAAC)
LIB_DEPENDS+=		faac.0:${PORTSDIR}/audio/faac
CONFIGURE_ARGS+=	--enable-libfaac
.else
CONFIGURE_ARGS+=	--disable-libfaac
.endif

## faad
.ifndef(WITHOUT_FAAD)
LIB_DEPENDS+=		faad.0:${PORTSDIR}/audio/faad
CONFIGURE_ARGS+=	--enable-libfaad \
			--enable-libfaadbin
.else
CONFIGURE_ARGS+=	--disable-libfaad
.endif

## amr
.ifdef(WITH_AMR_NB)
LIB_DEPENDS+=		amrnb.3:${PORTSDIR}/audio/libamrnb
CONFIGURE_ARGS+=	--enable-libamr-nb
.else
CONFIGURE_ARGS+=	--disable-libamr-nb
.endif

.ifdef(WITH_AMR_WB)
LIB_DEPENDS+=		amrwb.3:${PORTSDIR}/audio/libamrwb
CONFIGURE_ARGS+=	--enable-libamr-wb
.else
CONFIGURE_ARGS+=	--disable-libamr-wb
.endif

USE_RC_SUBR=		ffserver

.if ${MACHINE_CPU:Mmmx}==""
CONFIGURE_ARGS+=	--disable-mmx

WITHOUT_BUILTIN_VECTOR=	yes
.endif
## gsm
.ifdef(WITH_GSM)
LIB_DEPENDS+=		gsm.1:${PORTSDIR}/audio/gsm

CONFIGURE_ARGS+=	--enable-libgsm
.else
CONFIGURE_ARGS+=	--disable-libgsm
.endif
## mp3
.ifdef(WITH_LAME)
LIB_DEPENDS+=		mp3lame.0:${PORTSDIR}/audio/lame
CONFIGURE_ARGS+=	--enable-libmp3lame
.else
CONFIGURE_ARGS+=	--disable-libmp3lame
.endif

## SDL
.ifdef(WITH_SDL)
USE_SDL+=	sdl
PLIST_FILES+=	bin/ffplay
.if !defined(NOPORTDOCS)
MAN1+=	ffplay.1
.endif
.else
CONFIGURE_ARGS+=	--disable-ffplay
.endif

## theora
.if !defined(WITHOUT_THEORA)
LIB_DEPENDS+=		theora.0:${PORTSDIR}/multimedia/libtheora

CONFIGURE_ARGS+=	--enable-libtheora
.else
CONFIGURE_ARGS+=	--disable-libtheora
.endif

## vorbis
.if !defined(WITHOUT_VORBIS)
LIB_DEPENDS+=		vorbisenc.2:${PORTSDIR}/audio/libvorbis

CONFIGURE_ARGS+=	--enable-libvorbis
FFMPEG_CFLAGS+=		-I${LOCALBASE}/include/vorbis
.else
CONFIGURE_ARGS+=	--disable-libvorbis
.endif

# x264
.ifndef(WITHOUT_X264)
LIB_DEPENDS+=		x264.50:${PORTSDIR}/multimedia/x264

CONFIGURE_ARGS+=	--enable-libx264
.else
CONFIGURE_ARGS+=	--disable-libx264
.endif
## builtin vector, requires mmx
.if !defined(WITHOUT_BUILTIN_VECTOR) && defined(WITH_BUILTIN_VECTOR)
FFMPEG_CFLAGS+=		-msse
.endif

## xvid
.ifdef(WITH_XVID)
LIB_DEPENDS+=		xvidcore.4:${PORTSDIR}/multimedia/xvid
CONFIGURE_ARGS+=	--enable-libxvid
.else
CONFIGURE_ARGS+=	--disable-libxvid
.endif

pre-configure:
.if defined(WITHOUT_OGG) && (!defined(WITHOUT_VORBIS) || !defined(WITHOUT_THEORA))
	@${ECHO_MSG}	WITH_VORBIS or WITH_THEORA defined, libogg will be built
.endif
.if defined(WITHOUT_VHOOK) && (defined(WITH_VHOOK_FREETYPE2) || defined(WITH_VHOOK_IMLIB2))
	@${ECHO_MSG}	WITH_VHOOK_FREETYPE2 or WITH_VHOOK_IMLIB2 defined, video hooks will be built
.endif

post-patch:
# Faad compat
	@${REINPLACE_CMD} -e 's|faacD|NeAACD|' ${WRKSRC}/libavcodec/libfaad.c
# {C,LD}FLAGS safeness
# fix x264 math, use correct log base 2 from math(3)
.if ${OSVERSION} <= 601000
	@${REINPLACE_CMD} -E \
		-e 's| log2| log|' \
		${WRKSRC}/libavcodec/libx264.c
.endif
	@${REINPLACE_CMD} -e 's|$$(libdir)/pkgconfig|${PREFIX}/libdata/pkgconfig|' \
		${WRKSRC}/common.mak
	@${REINPLACE_CMD} -e 's|/etc/ffserver.conf|${PREFIX}/etc/ffserver.conf|' \
		${WRKSRC}/ffserver.c
	@${REINPLACE_CMD} -E \
		-e "s|(EXTRALIBS[[:space:]]*=)|\1-L${LOCALBASE}/lib |g; \
		s|%%LOCALBASE%%|${LOCALBASE}|g; s|%%SHLIB_VER%%|${SHLIB_VER}|g; \
		s|-pthread|${PTHREAD_LIBS}|g" \
		${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT}
# force detection of texi2html
.ifndef(NOPORTDOCS)
	@${REINPLACE_CMD} -E \
		-e 's|^(texi2html=)no|\1yes|' \
		${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT}
.endif
	@${REINPLACE_CMD} -e 's|-ldl||' \
		${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT}
.if defined(WITH_IMLIB2) && !defined(WITHOUT_IMLIB2)
	@${REINPLACE_CMD} -E \
		-e 's|^(imlib2).*$$|\1=yes|' \
		${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT}
.endif
.if !defined(WITHOUT_IPV6)
	@${REINPLACE_CMD} -E \
		-e 's|^(ipv6).*$$|\1=yes|' \
		${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT}
.endif
.ifdef(WITH_SDL)
	@${REINPLACE_CMD} -E \
		-e 's|sdl-config|${SDL_CONFIG}|g' \
		${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT}
	@${FIND} ${WRKSRC} -type f | \
		${XARGS} -n 10 ${REINPLACE_CMD} -E \
		-e 's|#include <SDL|#include <SDL/SDL|'
.endif
.if !defined(WITHOUT_BUILTIN_VECTOR) && defined(WITH_BUILTIN_VECTOR)
	@${REINPLACE_CMD} -E \
		-e 's|^([[:space:]]+builtin_vector).*$$|\1=yes|' \
		${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT}
.else
	@${REINPLACE_CMD} -E \
		-e 's|^([[:space:]]+builtin_vector).*$$|\1=no|' \
		${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT}
.endif
	@${REINPLACE_CMD} -e 's|$$(LIBDIR)/pkgconfig|${PREFIX}/libdata/pkgconfig|' \
		${WRKSRC}/common.mak

post-configure:
.ifdef(WITHOUT_THEORA)
	@${REINPLACE_CMD} -E \
		-e 's|^(CONFIG_LIBTHEORA).*$$|\1=no|' \
		${WRKSRC}/config.mak
.endif

post-install:
	${INSTALL_DATA} ${WRKSRC}/doc/ffserver.conf ${PREFIX}/etc/ffserver.conf-dist
	if [ ! -f ${PREFIX}/etc/ffserver.conf ]; then \
		${INSTALL_DATA} ${WRKSRC}/doc/ffserver.conf ${PREFIX}/etc; \
	fi
.ifndef(NOPORTDOCS)
	${MKDIR} ${DOCSDIR}
.for FILE in ${DOC_FILES}
	${INSTALL_DATA} ${WRKSRC}/${FILE} ${DOCSDIR}
.endfor
.for FILE in ${DOC_DOCFILES}
	${INSTALL_DATA} ${WRKSRC}/doc/${FILE} ${DOCSDIR}
.endfor
.endif
	${MKDIR} ${PREFIX}/include/ffmpeg
.for FILE in ${COMPAT_HEADERS}
	${CP} -f ${PREFIX}/include/${FILE} ${PREFIX}/include/ffmpeg/${FILE:C,^[^/]+/([^/]+).*,\1,}
.endfor
	${MKDIR} ${PREFIX}/include/postproc
	${CP} -f ${PREFIX}/include/libpostproc/postprocess.h \
		 ${PREFIX}/include/postproc/

.include <bsd.port.post.mk>