-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
157 lines (138 loc) · 3.29 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
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
PREFIX=/usr/local
TARGET=$(shell uname|tr '[A-Z]' '[a-z]')$(shell getconf LONG_BIT)
INCLUDE=
LIBDIRS=
LIBS=
APPNAME=mediaextract
BINEXT=
MANPAGE=$(APPNAME).1.gz
PLATFORM=posix
BUILD_TYPE=debug
BUILDDIR=build/$(TARGET)/$(BUILD_TYPE)
OBJ=\
$(BUILDDIR)/mediaextract.o \
$(BUILDDIR)/mediaextract_$(PLATFORM).o \
$(BUILDDIR)/formatstring.o \
$(BUILDDIR)/riff.o \
$(BUILDDIR)/aiff.o \
$(BUILDDIR)/ogg.o \
$(BUILDDIR)/mpg123.o \
$(BUILDDIR)/mp4.o \
$(BUILDDIR)/id3.o \
$(BUILDDIR)/midi.o \
$(BUILDDIR)/xmidi.o \
$(BUILDDIR)/mod.o \
$(BUILDDIR)/s3m.o \
$(BUILDDIR)/xm.o \
$(BUILDDIR)/it.o \
$(BUILDDIR)/asf.o \
$(BUILDDIR)/bink.o \
$(BUILDDIR)/au.o \
$(BUILDDIR)/smk.o \
$(BUILDDIR)/bmp.o \
$(BUILDDIR)/png.o \
$(BUILDDIR)/jpg.o \
$(BUILDDIR)/avif.o \
$(BUILDDIR)/gif.o \
$(BUILDDIR)/mpeg.o \
$(BUILDDIR)/text.o
CC=gcc
LD=$(CC)
CFLAGS+= -Wall -Werror -Wextra -std=gnu99 $(INCLUDE) $(LIBDIRS) -D_FILE_OFFSET_BITS=64
WINDOWS_LIBS=-lws2_32
BIN=$(BUILDDIR)/$(APPNAME)$(BINEXT)
ifeq ($(BUILD_TYPE),release)
CFLAGS+=-O2
else
CFLAGS+=-g
endif
ifeq ($(TARGET),win32)
PLATFORM=windows
CC=i686-w64-mingw32-gcc
CFLAGS+=-DWINVER=0x500 -m32
LDFLAGS+=-m32
LIBS=$(WINDOWS_LIBS)
BINEXT=.exe
else
ifeq ($(TARGET),win64)
PLATFORM=windows
CC=x86_64-w64-mingw32-gcc
CFLAGS+=-DWINVER=0x500 -m64
LDFLAGS+=-m64
LIBS=$(WINDOWS_LIBS)
BINEXT=.exe
else
ifeq ($(TARGET),linux32)
CFLAGS+=-pedantic -m32
LDFLAGS+=-m32
else
ifeq ($(TARGET),linux64)
CFLAGS+=-pedantic -m64
LDFLAGS+=-m64
endif
endif
endif
endif
.PHONY: all clean install uninstall builddir
ifeq ($(PLATFORM),posix)
all: $(BIN) $(BUILDDIR)/$(MANPAGE)
else
all: $(BIN)
endif
builddir: $(BUILDDIR)
$(BUILDDIR):
mkdir -p $(BUILDDIR)
$(BIN): $(OBJ)
$(LD) $(LIBDIRS) $(LDFLAGS) $(OBJ) -o $@ $(LIBS)
$(BUILDDIR)/mediaextract.o: src/mediaextract.c \
src/mediaextract.h \
src/formatstring.h \
src/ogg.h \
src/riff.h \
src/aiff.h \
src/mpg123.h \
src/mp4.h \
src/id3.h \
src/midi.h \
src/xmidi.h \
src/mod.h \
src/s3m.h \
src/xm.h \
src/it.h \
src/asf.h \
src/bink.h \
src/au.h \
src/smk.h \
src/bmp.h \
src/png.h \
src/jpg.h \
src/avif.h \
src/gif.h \
src/mpeg.h \
src/text.h
$(CC) $(CFLAGS) $< -o $@ -c $(LIBS)
$(BUILDDIR)/mediaextract_$(PLATFORM).o: src/mediaextract_$(PLATFORM).c src/mediaextract.h
$(CC) $(CFLAGS) $< -o $@ -c $(LIBS)
$(BUILDDIR)/formatstring.o: src/formatstring.c src/formatstring.h
$(CC) $(CFLAGS) $< -o $@ -c $(LIBS)
$(BUILDDIR)/%.o: src/%.c src/mediaextract.h src/riff.h
$(CC) $(CFLAGS) $< -o $@ -c $(LIBS)
ifeq ($(PLATFORM),posix)
install: $(PREFIX)/bin/$(APPNAME) $(PREFIX)/share/man/man1/$(MANPAGE)
$(BUILDDIR)/$(MANPAGE): src/ManPageIncludeFile $(BIN)
PATH=$(BUILDDIR):$(PATH) help2man $(APPNAME) --no-info -n "extracts media files that are embedded within other files" -S "Mathias Panzenböck" -i src/ManPageIncludeFile >$(BUILDDIR)/$(APPNAME).1
gzip -kf $(BUILDDIR)/$(APPNAME).1
$(PREFIX)/share/man/man1/$(MANPAGE): $(BUILDDIR)/$(APPNAME).1
mkdir -p "$(PREFIX)/share/man/man1/"
install $(BUILDDIR)/$(MANPAGE) "$@"
$(PREFIX)/bin/$(APPNAME): $(BIN)
mkdir -p "$(PREFIX)/bin"
install -s $(BIN) "$@"
uninstall:
rm -f "$(PREFIX)/bin/$(APPNAME)"
endif
recode: $(BUILDDIR)/recode
$(BUILDDIR)/recode: src/text.c src/text.h
$(CC) $(CFLAGS) $< -o $@ -DMEDIAEXTRACT_RECODE_BIN
clean:
rm -f $(BUILDDIR)/*