-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (39 loc) · 1.12 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
CC ?= gcc
CFLAGS ?= -std=c11 -Wall -Wextra -O3 -MMD -MP
SRC = $(filter-out $(wildcard test_*.c),$(wildcard *.c))
OBJ = $(SRC:.c=.o)
HDR = liknorm.h
TEST_SRC = $(wildcard test_*.c)
TEST_OBJ = $(TEST_SRC:.c=.o)
TEST_TARGET = $(basename $(TEST_OBJ))
ifeq ($(OS),Windows_NT)
LIB ?= liknorm.lib
PREFIX ?= "${ProgramFiles}/Common Files"
else
LIB ?= libliknorm.a
PREFIX ?= /usr/local
endif
all: $(LIB)
$(LIB): $(OBJ)
ar rcs $@ $^
-include $(SRC:.c=.d)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
$(TEST_TARGET): %: %.o $(LIB)
$(CC) $(CFLAGS) $< -L. $(LIB) -lm -o $@
check_integration: test_integration
./test_integration
check_logprod: test_logprod
./test_logprod
check_specific: test_specific
./test_specific
check: check_integration check_logprod check_specific
install: $(LIB) $(HDR)
@mkdir -p $(PREFIX)/lib $(PREFIX)/include
install -m 0755 $(LIB) $(PREFIX)/lib/
install -m 0655 $(HDR) $(PREFIX)/include/
uninstall:
rm -f $(PREFIX)/lib/$(LIB) $(HDR:%=$(PREFIX)/include/%)
.PHONY: all clean check
clean:
rm -f $(OBJ) $(LIB) $(TEST_OBJ) $(TEST_TARGET) *.d