aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: f4be161e217eb1ef0758de2b0d96d02d46acad0f (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
export TOPDIR = $(shell pwd)
export SRCDIR = $(TOPDIR)
export INCDIR = $(TOPDIR)/include

export DESTDIR ?=
export PREFIX ?= /usr/local
export CROSS_COMPILE =

CC = $(CROSS_COMPILE)gcc
CFLAGS = -Wall -Wextra -Werror -Wfatal-errors -I $(INCDIR)

LD = $(CROSS_COMPILE)ld
LDFLAGS =

OBJECTS = mixer.o pcm.o
LIB = libtinyalsa.a
SHLIB = libtinyalsa.so

.PHONY: all
all: $(LIB) $(SHLIB)
	$(MAKE) -C utils

$(SHLIB): $(OBJECTS)
	$(CC) $(LDFLAGS) -shared $(OBJECTS) -o $(SHLIB)

$(LIB): $(OBJECTS)
	$(CROSS_COMPILE)$(AR) rcs $@ $^

%.o: %.c
	$(CROSS_COMPILE)$(CC) $(CFLAGS) -fPIC -c $^ -o $@

.PHONY: clean
clean:
	-rm $(LIB) $(SHLIB) $(OBJECTS)
	$(MAKE) -C utils clean

.PHONY: install
install: $(LIB) $(SHLIB)
	cp -u $(SHLIB) $(PREFIX)/lib/
	cp -u $(LIB) $(PREFIX)/lib/
	mkdir -p $(PREFIX)/include/tinyalsa
	cp -Ru $(INCDIR)/tinyalsa $(PREFIX)/include/
	$(MAKE) -C utils install