-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
53 lines (42 loc) · 826 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
CFLAGS=-Wall -g -O2
TARGET := tiny6502
ifeq ($(OS), Windows_NT)
CC=gcc-mingw-w64
TARGET += .exe
else
ifeq ($(shell uname), Darwin)
CC=clang
else
CC=gcc
endif
endif
SRC_DIR := src
BUILD_DIR := build
OBJ_DIR := obj
SRCS := $(wildcard $(SRC_DIR)/*.c)
OBJS := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRCS))
all: $(TARGET)
$(TARGET): $(BUILD_DIR)/$(TARGET)
$(BUILD_DIR)/$(TARGET): $(OBJS) | $(BUILD_DIR)
$(CC) $(CFLAGS) $(OBJS) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR):
mkdir -p $@
$(OBJ_DIR):
mkdir -p $@
.PHONY: clean
cleanall:
ifeq ($(OS), Windows_NT)
del $(BUILD_DIR)\$(TARGET)
del $(OBJ_DIR)\*.o
else
rm -r $(BUILD_DIR)/$(TARGET)
rm -r $(OBJ_DIR)/*.obj
endif
clean:
ifeq ($(OS), Windows_NT)
del $(OBJ_DIR)\*.o
else
rm -r $(OBJ_DIR)/*.o
endif