about summary refs log tree commit diff stats
path: root/Makefile
blob: c9ddf663580f584541bd8f15381f2b2dadfeb1bf (plain) (blame)
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
include config.mk

SRC = $(shell find src/ -type f -name '*.c')
OBJ = $(SRC:%=$(BUILD_DIR)/%.o)
H = include/uv_link_t.h

.PHONY: all static shared clean install-static install-shared install

all: static shared

static: $(SNAME)

shared: $(DNAME)

$(OBJ): config.mk

$(SNAME): $(OBJ)
	ar rcs $@ $?

$(DNAME): LDFLAGS += -shared
$(DNAME): $(OBJ)
	$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@

$(BUILD_DIR)/%.c.o: %.c
	mkdir -p '$(@D)'
	$(CC) -c -o $@ $(INCLUDES) $(CFLAGS) $<

clean:
	rm -rf $(SNAME) $(DNAME) $(BUILD_DIR)

install-header: $(H)
	install -d $(DESTDIR)$(INCLUDEDIR)
	install -m 644 $^ $(DESTDIR)$(INCLUDEDIR)

install-static: $(SNAME)
	install -d $(DESTDIR)$(LIBDIR)
	install -m 755 $^ $(DESTDIR)$(LIBDIR)

install-shared: $(DNAME)
	install -d $(DESTDIR)$(LIBDIR)
	install -m 755 $^ $(DESTDIR)$(LIBDIR)

install: install-header install-static install-shared