forked from xkahn/camlink
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
40 lines (29 loc) · 844 Bytes
/
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
CC=gcc
CFLAGS= -Wall -Wextra -Wwrite-strings -fPIC
LFLAGS= -Wall -Wextra -Wwrite-strings -shared
BUILD_DIR = build
LIBS = camlink
INSTALL_DIR = /usr/local/lib/camlink
SOURCES = $(wildcard *.c)
all: build
LIB_TARGETS = $(addprefix $(BUILD_DIR)/, $(addsuffix .so, $(LIBS)))
OBJECT_TARGETS = $(addprefix $(BUILD_DIR)/, $(addsuffix .o, $(basename $(SOURCES))))
.PHONY: build
build: $(LIB_TARGETS) $(OBJECT_TARGETS)
$(BUILD_DIR)/%.so: $(BUILD_DIR)/%.o
$(CC) $(LFLAGS) -o $@ $< -ldl
$(BUILD_DIR)/%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
INSTALL_TARGETS = $(addprefix $(INSTALL_DIR)/, camlink.so)
.PHONY: install
install: $(INSTALL_TARGETS)
$(INSTALL_DIR)/%.so: $(BUILD_DIR)/%.so $(INSTALL_DIR)
cp $< $@
$(INSTALL_DIR):
mkdir -p $(INSTALL_DIR)
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)/*
.PHONY: uninstall
uninstall:
rm -rf $(INSTALL_DIR)