summaryrefslogtreecommitdiff
path: root/Makefile
blob: 3782237fe8fa66590a71d4474bd9c27f472bdab3 (plain)
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
PREFIX ?= /usr/local
libdir ?= /lib
includedir ?= /include
pkgconfigdir ?= /lib/pkgconfig

MAKEFLAGS += --no-builtin-rules

WARNINGS := -Wall -Wextra -Wpedantic -Wformat=2 -Wstrict-aliasing=3 -Wstrict-overflow=5 -Wstack-usage=12500 \
        -Wfloat-equal -Wcast-align -Wpointer-arith -Wchar-subscripts -Warray-bounds=2

override CFLAGS ?= -g
override CFLAGS += -std=c11 $(WARNINGS)
override CPPFLAGS += -Iinclude
override LDFLAGS += -fPIC

libs = libasound.so.2.0.0
libsymlinks = libasound.so.2 libasound.so
pkgconfigs = alsa.pc
all: $(libs) $(libsymlinks) $(pkgconfigs)

%.pc: %.pc.in
        m4 -DINCLUDEDIR="$(PREFIX)$(includedir)" -DLIBDIR="$(PREFIX)$(libdir)" $^ > $@

libasound.so.2.0.0: private override CPPFLAGS += -D_DEFAULT_SOURCE
libasound.so.2.0.0: private override CPPFLAGS += -DBYTE_ORDER=__BYTE_ORDER -DLITTLE_ENDIAN=__LITTLE_ENDIAN -DBIG_ENDIAN=__BIG_ENDIAN
libasound.so.2.0.0: private override CFLAGS += -Wno-unused-parameter -Wno-deprecated-declarations
libasound.so.2.0.0: private override LDFLAGS += -Wl,--version-script=libasound.map -Wl,-soname,libasound.so.2
libasound.so.2.0.0: private override LDLIBS += -lsndio
libasound.so.2.0.0: src/libasound.c src/pcm.c src/mixer.c src/util/dsp.c src/util/dsp.h src/util/sysex.h src/util/defs.h src/util/util.h src/stubs.h src/symversioning-hell.h libasound.map
        $(LINK.c) -shared $(filter %.c,$^) $(LDLIBS) -o $@

libasound.so.2: libasound.so.2.0.0
        ln -fs $^ $@

libasound.so: libasound.so.2.0.0
        ln -fs $^ $@

install-lib: $(libs)
        install -Dm755 $^ -t "$(DESTDIR)$(PREFIX)$(libdir)"

install-symlinks: $(libsymlinks)
        chmod 755 $^
        mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)"
        cp -P $^ "$(DESTDIR)$(PREFIX)$(libdir)"

install-pkgconfig: $(pkgconfigs)
        install -Dm755 $^ -t "$(DESTDIR)$(PREFIX)$(pkgconfigdir)"

install-include:
        mkdir -p "$(DESTDIR)$(PREFIX)$(includedir)"
        cp -r include/alsa "$(DESTDIR)$(PREFIX)$(includedir)/"

install: install-lib install-symlinks install-pkgconfig install-include

clean:
        $(RM) $(libs) $(libsymlinks) $(pkgconfigs)

.PHONY: all clean install