-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (74 loc) · 2.01 KB
/
Makefile
File metadata and controls
104 lines (74 loc) · 2.01 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
BUILD_DIR := .build
SRC := $(wildcard src/*.c)
OBJS := $(SRC:%.c=$(BUILD_DIR)/%.o)
CFLAGS := -std=c11 -pedantic -fPIC
CFLAGS += -iquote src
CFLAGS += $(shell cat $/warning_flags.txt)
.PHONY: all
all: libilo.so
libilo.so: $(OBJS)
$(LINK.c) -shared -o $@ $(OBJS)
@ $(LOG_TIME) "$(C_GREEN) SO $(C_PURPLE) $(notdir $@) $(C_RESET)"
$(BUILD_DIR)/%.o: %.c
@ mkdir -p $(dir $@)
$(COMPILE.c) $< -o $@
@ $(LOG_TIME) "$(C_GREEN) CC $(C_PURPLE) $(notdir $@) $(C_RESET)"
clean:
@ $(RM) $(OBJS)
@ $(LOG_TIME) "$(C_YELLOW) RM $(C_PURPLE)$(OBJS)$(C_RESET)"
fclean:
@ $(RM) -r libilo.so $(BUILD_DIR)
@ $(LOG_TIME) "$(C_YELLOW) RM $(C_PURPLE)libilo.so$(C_RESET)"
.NOTPARALLEL: re
re: fclean all
.PHONY: all clean fclean re
PREFIX ?=
BINDIR ?= $(PREFIX)/bin
.PHONY: install uninstall
install: $(NAME_release)
install -Dm755 -t $(BINDIR) $(NAME_release)
uninstall:
$(RM) $(BINDIR)/$(NAME_release)
trame-exporter: src/trame.c
$(LINK.c) -o $@ generators/generate-trame-json.c
@ $(LOG_TIME) "$(C_GREEN) CC $(C_PURPLE) $(notdir $@) $(C_RESET)"
artefacts/trames.json: trame-exporter
@ ./$< > $@
@ $(LOG_TIME) "$(C_GREEN) GEN $(C_PURPLE) $(notdir $@) $(C_RESET)"
.PHONY: primitives
primitives: artefacts/trames.json
@ python generators/generate_primitives.py
.PHONY: doc
doc:
$(MAKE) -C docs html
V ?= 0
ifneq ($(V),0)
Q :=
else
Q := @
endif
ifneq ($(shell command -v tput),)
ifneq ($(shell tput colors),0)
mk-color = \e[$(strip $1)m
C_BEGIN := \033[A
C_RESET := $(call mk-color, 00)
C_RED := $(call mk-color, 31)
C_GREEN := $(call mk-color, 32)
C_YELLOW := $(call mk-color, 33)
C_BLUE := $(call mk-color, 34)
C_PURPLE := $(call mk-color, 35)
C_CYAN := $(call mk-color, 36)
endif
endif
NOW = $(shell date +%s%3N)
STIME := $(shell date +%s%3N)
export STIME
define TIME_MS
$$( expr \( $$(date +%s%3N) - $(STIME) \))
endef
BOXIFY = "[$(C_BLUE)$(1)$(C_RESET)] $(2)"
ifneq ($(shell command -v printf),)
LOG_TIME = printf $(call BOXIFY, %6s , %b\n) "$(call TIME_MS)"
else
LOG_TIME = echo -e $(call BOXIFY, $(call TIME_MS) ,)
endif