-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
58 lines (42 loc) · 885 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
TARGET = bin/mu
BIN = bin
BUILD = build
CC = gcc
SIZE = size
DIR += . mu repl
SRC += $(foreach dir,$(DIR),$(wildcard $(dir)/*.c))
OBJ += $(SRC:%.c=$(BUILD)/%.o)
DEP += $(SRC:%.c=$(BUILD)/%.d)
ASM += $(SRC:%.c=$(BUILD)/%.s)
ifdef DEBUG
CFLAGS += -O0 -g3 -DMU_DEBUG
CFLAGS += -fkeep-inline-functions
else ifdef FAST
CFLAGS += -O3 -DMU_FAST
else # default to SMALL
CFLAGS += -Os -DMU_SMALL
endif
CFLAGS += -I.
CFLAGS += -std=c99 -pedantic
CFLAGS += -Wall -Winline
LFLAGS += -lm
ifdef MU_NO_DIS
CFLAGS += -DMU_NO_DIS
else
DIR += dis
endif
all: $(TARGET)
asm: $(ASM)
size: $(OBJ)
$(SIZE) -t $^
-include $(DEP)
$(TARGET): $(OBJ)
$(CC) $(CFLAGS) $^ $(LFLAGS) -o $@
$(BUILD):
mkdir -p $(BIN) $(addprefix $(BUILD)/,$(DIR))
$(BUILD)/%.o: %.c | $(BUILD)
$(CC) -c -MMD $(CFLAGS) $< -o $@
$(BUILD)/%.s: %.c | $(BUILD)
$(CC) -S $(CFLAGS) $< -o $@
clean:
rm -rf $(BIN) $(BUILD)