forked from pali/libopenaptx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (71 loc) · 2.55 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
.POSIX:
.SUFFIXES:
.PHONY: default all clean install uninstall
RM = rm -f
CP = cp -a
LNS = ln -sf
MKDIR = mkdir -p
PRINTF = printf
CFLAGS = -W -Wall -O3
LDFLAGS = -s
ARFLAGS = -rcs
PREFIX = /usr/local
BINDIR = bin
LIBDIR = lib
INCDIR = include
PKGDIR = $(LIBDIR)/pkgconfig
NAME = openaptx
MAJOR = 0
MINOR = 2
PATCH = 0
LIBNAME = lib$(NAME).so
SONAME = $(LIBNAME).$(MAJOR)
SOFILENAME = $(SONAME).$(MINOR).$(PATCH)
ANAME = lib$(NAME).a
PCNAME = lib$(NAME).pc
UTILITIES = $(NAME)enc $(NAME)dec
STATIC_UTILITIES = $(NAME)enc.static $(NAME)dec.static
HEADERS = $(NAME).h
SOURCES = $(NAME).c
AOBJECTS = $(NAME).o
IOBJECTS = $(NAME)enc.o $(NAME)dec.o
BUILD = $(SOFILENAME) $(SONAME) $(LIBNAME) $(ANAME) $(AOBJECTS) $(IOBJECTS) $(UTILITIES) $(STATIC_UTILITIES)
default: $(SOFILENAME) $(SONAME) $(LIBNAME) $(ANAME) $(UTILITIES) $(HEADERS)
all: $(BUILD)
clean:
$(RM) $(BUILD)
install: default
$(MKDIR) $(DESTDIR)$(PREFIX)/$(LIBDIR)
$(CP) $(SOFILENAME) $(SONAME) $(LIBNAME) $(ANAME) $(DESTDIR)$(PREFIX)/$(LIBDIR)
$(MKDIR) $(DESTDIR)$(PREFIX)/$(BINDIR)
$(CP) $(UTILITIES) $(DESTDIR)$(PREFIX)/$(BINDIR)
$(MKDIR) $(DESTDIR)$(PREFIX)/$(INCDIR)
$(CP) $(HEADERS) $(DESTDIR)$(PREFIX)/$(INCDIR)
$(MKDIR) $(DESTDIR)$(PREFIX)/$(PKGDIR)
$(PRINTF) 'prefix=%s\nexec_prefix=$${prefix}\nlibdir=$${exec_prefix}/%s\nincludedir=$${prefix}/%s\n\n' $(PREFIX) $(LIBDIR) $(INCDIR) > $(DESTDIR)$(PREFIX)/$(PKGDIR)/$(PCNAME)
$(PRINTF) 'Name: lib%s\nDescription: Open Source aptX codec library\nVersion: %u.%u.%u\n' $(NAME) $(MAJOR) $(MINOR) $(PATCH) >> $(DESTDIR)$(PREFIX)/$(PKGDIR)/$(PCNAME)
$(PRINTF) 'Libs: -Wl,-rpath=$${libdir} -L$${libdir} -l%s\nCflags: -I$${includedir}\n' $(NAME) >> $(DESTDIR)$(PREFIX)/$(PKGDIR)/$(PCNAME)
uninstall:
for f in $(SOFILENAME) $(SONAME) $(LIBNAME) $(ANAME); do $(RM) $(DESTDIR)$(PREFIX)/$(LIBDIR)/$$f; done
for f in $(UTILITIES); do $(RM) $(DESTDIR)$(PREFIX)/$(BINDIR)/$$f; done
for f in $(HEADERS); do $(RM) $(DESTDIR)$(PREFIX)/$(INCDIR)/$$f; done
$(RM) $(DESTDIR)$(PREFIX)/$(PKGDIR)/$(PCNAME)
$(UTILITIES): $(LIBNAME)
$(STATIC_UTILITIES): $(ANAME)
$(AOBJECTS) $(IOBJECTS): $(HEADERS)
$(LIBNAME): $(SONAME)
$(LNS) $(SONAME) $@
$(SONAME): $(SOFILENAME)
$(LNS) $(SOFILENAME) $@
$(SOFILENAME): $(SOURCES) $(HEADERS)
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -I. -shared -fPIC -Wl,-soname,$(SONAME) -o $@ $(SOURCES)
$(ANAME): $(AOBJECTS)
$(RM) $@
$(AR) $(ARFLAGS) $@ $(AOBJECTS)
.SUFFIXES: .o .c .static
.o:
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBNAME)
.o.static:
$(CC) $(CFLAGS) $(LDFLAGS) -static -o $@ $< $(ANAME)
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) -I. -c -o $@ $<