-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (29 loc) · 883 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
CC ?= gcc
CFLAGS ?= -std=c11 -Wall -Wextra -O3 -MMD -MP
PREFIX ?= /usr/local
SRC = $(filter-out $(wildcard test_*.c),$(wildcard *.c))
OBJ = $(SRC:.c=.o)
HDR = $(wildcard imm_*.h)
LIB = libimm.a
TEST_SRC = $(wildcard test_*.c)
TEST_OBJ = $(TEST_SRC:.c=.o)
TEST_TARGET = $(basename $(TEST_OBJ))
all: $(LIB)
$(LIB): $(OBJ)
ar rcs $@ $^
-include $(SRC:.c=.d)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
$(TEST_TARGET): %: %.o $(LIB)
$(CC) $(CFLAGS) $< -L. -limm -llio -llite_pack -lm -o $@
check: $(TEST_TARGET)
for test in $(TEST_TARGET); do ./$$test || exit 1; done
install: $(LIB) $(HDR)
@mkdir -p $(PREFIX)/lib $(PREFIX)/include
install -m 0755 $(LIB) $(PREFIX)/lib/
install -m 0644 $(HDR) $(PREFIX)/include/
uninstall:
rm -f $(PREFIX)/lib/$(LIB) $(HDR:%=$(PREFIX)/include/%)
.PHONY: all clean check uninstall
clean:
rm -f $(OBJ) $(LIB) $(TEST_OBJ) $(TEST_TARGET) *.d