-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
45 lines (33 loc) · 808 Bytes
/
makefile
File metadata and controls
45 lines (33 loc) · 808 Bytes
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
# Compiler and flags
CC = gcc
CFLAGS = -Wall -Wpedantic -Wextra -std=c11 -Iinclude -MMD -MP
LDFLAGS = -lm
# Directories
SRC_DIR = src
OBJ_DIR = obj
INC_DIR = include
# Target
TARGET = tralala-maker
# Source, object, and dependency files
SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRCS))
DEPS = $(OBJS:.o=.d)
# Default rule
all: $(TARGET)
# Link
$(TARGET): $(OBJS)
$(CC) $(OBJS) -o $(TARGET) $(LDFLAGS)
# Compile source files into object files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CFLAGS) -c $< -o $@
# Create object directory if it doesn't exist
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
# Include auto-generated header dependencies
-include $(DEPS)
# Clean
clean:
rm -rf $(OBJ_DIR) $(TARGET) *.wav
run: all
./$(TARGET)
.PHONY: all clean