-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
38 lines (30 loc) · 910 Bytes
/
Copy pathMakefile
File metadata and controls
38 lines (30 loc) · 910 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
# ===========================
# Basic GCC Makefile (Windows + PowerShell)
# Supports: build, run, debug, clean
# ===========================
# Compiler and flags
CC = gcc
CFLAGS = -Wall -Wextra -Wpedantic -g -O0
TARGET = a.exe
# Source and object files (auto-detects all .c files except working.c)
SRC = $(filter-out working.c, $(wildcard *.c))
OBJ = $(SRC:.c=.o)
# Default target — same as 'make run'
all: run
# Build rule
$(TARGET): $(OBJ)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJ) $(LDFLAGS)
# Compile each .c into .o
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# Run the program in maximized Command Prompt
run: $(TARGET)
cmd /c start "" /max cmd /k "$(CURDIR)\$(TARGET)"
# Launch GDB in TUI mode for debugging
debug: $(TARGET)
cmd /c start "" /max cmd /k "gdb -tui $(TARGET)"
# Clean up build artifacts
clean:
del /q $(OBJ) $(TARGET) 2>nul || exit 0
# Phony targets
.PHONY: all run debug clean