-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
84 lines (63 loc) · 2.25 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
.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 = freeaptx
MAJOR = 0
MINOR = 1
PATCH = 1
LIBNAME = lib$(NAME).so
SONAME = $(LIBNAME).$(MAJOR)
SOFILENAME = $(SONAME).$(MINOR).$(PATCH)
PCNAME = lib$(NAME).pc
UTILITIES = $(NAME)enc $(NAME)dec
STATIC_UTILITIES = $(NAME)enc.static $(NAME)dec.static
HEADERS = $(NAME).h
SOURCES = $(NAME).c
IOBJECTS = $(NAME)enc.o $(NAME)dec.o
BUILD = $(SOFILENAME) $(SONAME) $(LIBNAME) $(IOBJECTS) $(UTILITIES)
default: $(SOFILENAME) $(SONAME) $(LIBNAME) $(UTILITIES) $(HEADERS)
all: $(BUILD)
clean:
$(RM) $(BUILD)
install: default
$(MKDIR) $(DESTDIR)$(PREFIX)/$(LIBDIR)
$(CP) $(SOFILENAME) $(SONAME) $(LIBNAME) $(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: -L$${libdir} -l%s\nCflags: -I$${includedir}\n' $(NAME) >> $(DESTDIR)$(PREFIX)/$(PKGDIR)/$(PCNAME)
uninstall:
for f in $(SOFILENAME) $(SONAME) $(LIBNAME); 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)
$(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)
.SUFFIXES: .o .c .static
.o:
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBNAME)
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) -I. -c -o $@ $<