-
Notifications
You must be signed in to change notification settings - Fork 0
/
MacMakefile
62 lines (47 loc) · 1.42 KB
/
MacMakefile
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
.POSIX:
CC=clang
SRC_DIR=src
OBJ_DIR=obj
BIN_DIR=bin
DEVICES_DIR=$(BIN_DIR)/devices
PLUGINS=$(SRC_DIR)/plugins
EXE=$(BIN_DIR)/simulator
SRC=$(wildcard $(SRC_DIR)/*.c)
PLUGIN_SRC=$(wildcard $(PLUGINS)/*.c)
DEVICES=$(patsubst $(PLUGINS)/%.c, $(OBJ_DIR)/%.dylib, $(PLUGIN_SRC))
OBJ=$(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC))
CPPFLAGS=-MMD -MP
debug : CFLAGS=-Wall -g -fsanitize=undefined -fsanitize=address
release : CFLAGS = -Wall -O2
LDFLAGS=-ldl -g
DYLIBFLAGS=-dynamiclib -I ./src
.PHONY: debug clean release install uninstall
debug: $(EXE) $(DEVICES)
release: $(EXE) $(DEVICES)
$(EXE): $(OBJ) | $(BIN_DIR)
$(CC) $(OBJ) -o $@ $(CFLAGS) $(LDFLAGS)
$(OBJ_DIR)/%.dylib: $(PLUGINS)/%.c | $(OBJ_DIR)
$(CC) $(CPPFLAGS) $(CFLAGS) $(DYLIBFLAGS) $< -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(BIN_DIR):
mkdir -p $@
$(OBJ_DIR):
mkdir -p $@
install:
mkdir -p /usr/local/lc3-simulator
mkdir -p /usr/local/lc3-simulator/plugins
mkdir -p ~/lc3-simulator
mkdir -p ~/lc3-simulator/plugins
cp ./bin/simulator /usr/local/bin/lc3-simulator
cp ./obj/keyboard.dylib /usr/local/lc3-simulator/plugins
cp ./obj/display.dylib /usr/local/lc3-simulator/plugins
uninstall:
rm -f /usr/local/bin/lc3-simulator
rm -f -r /usr/local/lc3-simulator
rm -f -r ~/lc3-simulator
rm -f -r ~/lc3-simulator/plugins
clean:
@$(RM) -rv $(BIN_DIR) $(OBJ_DIR)
-include $(OBJ:.o=.d)
-include $(DEVICES:.dylib=.d)