-
Notifications
You must be signed in to change notification settings - Fork 23
/
Makefile
66 lines (50 loc) · 2.22 KB
/
Makefile
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
#target is to generate several bin files automatically
ARCHES := linux_amd64 i686-w64-mingw32 x86_64-w64-mingw32 arm-linux-gnueabihf
FFMPEG_VERSION = 6.0
FFMPEG_PKG = ffmpeg-$(FFMPEG_VERSION)
FFMPEG_EXT = tar.bz2
FFMPEG_SRC = http://ffmpeg.org/releases/$(FFMPEG_PKG).$(FFMPEG_EXT)
GOARCH = $(shell go env GOARCH)
GOOS = $(shell go env GOOS)
PROJECTROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
PREFIX = $(PROJECTROOT)dep
FFMPEGTARGET = $(PREFIX)/ffmpeg_$(FFMPEG_VERSION)_$(GOOS)_$(GOARCH)
VERSIONFLAGS = -X main.GitVersion=`git describe --tags --always --dirty` -X main.BuildTimestamp=`date -u '+%Y-%m-%d_%I:%M:%S_UTC'` -X main.FfmpegVersion=$(FFMPEG_PKG)
ifeq ($(UNAME),Darwin)
GOFLAGS = -ldflags "$(VERSIONFLAGS) -L '$(PREFIX)/ffmpeg_$(FFMPEG_VERSION)_$(GOOS)_$(GOARCH)/lib/' -extldflags '-static -Wl,--allow-multiple-definition'"
else
GOFLAGS = -ldflags "$(VERSIONFLAGS) -L '$(PREFIX)/ffmpeg_$(FFMPEG_VERSION)_$(GOOS)_$(GOARCH)/lib/'"
endif
all: ffmpeg build
build:
PKG_CONFIG_LIBDIR=$(FFMPEGTARGET)/lib/pkgconfig/ LD_LIBRARY_PATH=$(FFMPEGTARGET)/lib/ go build $(GOFLAGS)
buildffmpeg:
ifeq ("$(wildcard $(PREFIX)/$(FFMPEG_PKG).$(FFMPEG_EXT))","")
mkdir -p $(FFMPEGTARGET)
endif
ifeq ("$(wildcard $(PREFIX)/$(FFMPEG_PKG).$(FFMPEG_EXT))","")
wget -P $(PREFIX) $(FFMPEG_SRC)
endif
ifeq ("$(wildcard $(PREFIX)/$(FFMPEG_PKG))","")
tar -xf $(PREFIX)/$(FFMPEG_PKG).$(FFMPEG_EXT) -C $(PREFIX)/
endif
cd $(PREFIX)/$(FFMPEG_PKG) && ./configure --disable-yasm --disable-programs --disable-doc --prefix=$(FFMPEGTARGET)
$(MAKE) -C $(PREFIX)/$(FFMPEG_PKG) --silent -j`nproc`; $(MAKE) -C $(PREFIX)/$(FFMPEG_PKG) --silent -j`nproc`
$(MAKE) -C $(PREFIX)/$(FFMPEG_PKG) install --silent
$(FFMPEGTARGET)/lib/libavcodec.a:
$(MAKE) buildffmpeg
$(FFMPEGTARGET)/lib/libavformat.a:
$(MAKE) buildffmpeg
$(FFMPEGTARGET)/lib/libavutil.a:
$(MAKE) buildffmpeg
$(FFMPEGTARGET)/lib/libswresample.a:
$(MAKE) buildffmpeg
$(FFMPEGTARGET)/lib/libswscale.a:
$(MAKE) buildffmpeg
ffmpeg: $(FFMPEGTARGET)/lib/libavcodec.a $(FFMPEGTARGET)/lib/libavformat.a $(FFMPEGTARGET)/lib/libavutil.a $(FFMPEGTARGET)/lib/libswresample.a $(FFMPEGTARGET)/lib/libswscale.a
clean:
rm -f $(PREFIX)/$(FFMPEG_PKG).$(FFMPEG_EXT)
rm -rf $(PREFIX)/$(FFMPEG_PKG)
rm -f mt
wipe: clean
rm -rf dep