write-ups-challenges-2024-2025/tic-tac-toes/Makefile
2024-11-25 22:33:42 +01:00

50 lines
1.0 KiB
Makefile

CC=gcc
LD=gcc
# I'm using GCC to link code. This is prefered over using LD directly since
# it will handle all the GLIBC linkage for you.
SRCS = $(wildcard src/*.c)
OBJS = ${SRCS:.c=.o}
DEST = tic-tac-toes
CC_FLAGS = -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function
LD_FLAGS =
LIBS =
ifeq ($(FLAG),)
FLAG := "\"IGCTF{REDACTED}\""
endif
# This is to let make know these are not actually file targets but rather
# command targets.
.PHONY = all clean format debug run
all: $(DEST)
# Link all objects together into one binary
$(DEST): ${OBJS}
$(LD) ${LD_FLAGS} $^ $(LIBS) -o $(DEST)
# For every c file, compile it to an object file
%.o: %.c
$(CC) ${CC_FLAGS} -c $< -o $@ -DFLAG=$(FLAG)
# Run the formatter
format:
clang-format -i src/*.c src/*.h
# Run the created binary
run: $(DEST)
./$(DEST)
# Run the created binary using the debugger
debug: $(DEST)
gdb ./$(DEST) -ex "set disassembly-flavor intel"
# Clean the project of all build files
clean:
$(info [INFO] Cleaning directory)
rm -rf ${OBJS} $(DEST)