-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
84 lines (67 loc) · 2.12 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
## Options
# Name of executable
EXE?=tl
# Compiler statically? (default is dynamic libs)
STATIC?=no
# Installation prefix
PREFIX?=/usr
# Compiler Options
CC?=gcc
STRIP?=strip
CFLAGS=-c -O2 -Wall -std=c99 -pedantic
DEFINES=-D_DEFAULT_SOURCE
MAN=$(EXE).1
SOURCES=$(shell find src/ -type f -name '*.c')
OBJECTS=$(SOURCES:.c=.o)
ifeq ($(STATIC),yes)
DEFINES+=-D_TL_STATIC_BUILD="\"yes\""
# Using a custom build of ffmpeg with:
#
# > git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
# > git checkout release/2.7
# > ./configure --prefix=/home/vagrant/builds/usr --enable-libx264 --enable-gpl
# --disable-libopus --disable-vaapi --enable-static --disable-shared
# > make && make install
#
CFLAGS+=-I/home/vagrant/builds/usr/include
LDFLAGS=-L/home/vagrant/builds/usr/lib\
-static -lX11 -lxcb -lXau -lXdmcp\
/home/vagrant/builds/usr/lib/libavformat.a\
/home/vagrant/builds/usr/lib/libavcodec.a\
/home/vagrant/builds/usr/lib/libavfilter.a\
/home/vagrant/builds/usr/lib/libavutil.a\
/home/vagrant/builds/usr/lib/libswresample.a\
/home/vagrant/builds/usr/lib/libswscale.a\
-lx264 -lm -lz -ldl -lpthread -llzma\
-static-libgcc
# If only system libraries worked...
#LDFLAGS=-static -lX11 -lxcb -lXau -lXdmcp\
-lx264 -lm -lz -ldl -lpthread -llzma\
-lavformat -lavcodec -lavfilter -lavutil -lswresample -lswscale\
-static-libgcc
else
DEFINES+=-D_TL_STATIC_BUILD="\"no\""
LDFLAGS=-lX11 -lavformat -lavcodec -lavutil -lswscale -lm
endif
DEFINES+=\
-D_TL_COMPILE_DATE="\"$(shell date '+%b %d, %Y - %T %Z')\""\
-D_TL_COMMIT_SHA="\"$(shell git rev-parse --verify HEAD)\""\
-D_TL_CFLAGS="\"$(CFLAGS)\""\
-D_TL_LDFLAGS="\"$(LDFLAGS)\""
all: $(SOURCES) $(EXE)
$(EXE): $(OBJECTS)
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
$(STRIP) $(EXE)
.c.o:
@echo $(CC) $(CFLAGS) $< -o $@
@$(CC) $(CFLAGS) $(DEFINES) $< -o $@
install: all
install -Dm 775 $(EXE) $(PREFIX)/bin/$(EXE)
install -Dm 644 src/tl.1 $(PREFIX)/share/man/man1/$(MAN)
uninstall:
@rm -vf $(PREFIX)/bin/$(EXE)
@rm -vf $(PREFIX)/share/man/man1/$(MAN)
clean:
@rm -vf $(EXE)
@find src/ -type f -name '*.o' -exec rm -vf {} \;
.PHONY: clean