-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
37 lines (27 loc) · 868 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
CC = gcc
CFLAGS = -Wall -Wextra -pedantic -Wshadow -Wformat=2 -Wnull-dereference -Wvla -fstack-protector-strong -std=c99 -Iinclude
LIBS = -lraylib
SRC_DIR = src
INC_DIR = include
BUILD_DIR = build
TARGET = c6502
# Automatically find all .c files in the SRC_DIR
SRC = $(wildcard $(SRC_DIR)/*.c)
HEADERS = $(wildcard $(INC_DIR)/*.h)
# Create corresponding .o files in the BUILD_DIR
OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC))
all: format $(TARGET)
$(TARGET): $(OBJ)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
# Rule to compile .c files into .o files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
$(CC) $(CFLAGS) -c $< -o $@
# Create the build directory if it doesn't exist
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
clean:
rm -rf $(BUILD_DIR) $(TARGET)
run: ${TARGET}
./${TARGET} sample/6502_functional_test.bin
format:
clang-format -i $(SRC) $(HEADERS)