-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
38 lines (29 loc) · 746 Bytes
/
Makefile
File metadata and controls
38 lines (29 loc) · 746 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
# Compiler and Flags
CC = gcc
CFLAGS = -Wall -Wextra -Werror -g -Iinclude
LDFLAGS = -lcrypto -lz
# Directories
SRC_DIR = src
INC_DIR = include
BUILD_DIR = build
# Source and Object Files
SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(SRCS:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
# Target Executable
TARGET = minigit
# Default rule
all: $(BUILD_DIR) $(TARGET)
# Create build directory if it doesn't exist
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Link objects to create the executable
$(TARGET): $(OBJS)
$(CC) $(OBJS) -o $(TARGET) $(LDFLAGS)
# Compile C files into Object files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
# Clean rule to remove build artifacts
clean:
rm -rf $(BUILD_DIR) $(TARGET)
# Phony targets
.PHONY: all clean