Dented/Makefile
2024-11-22 14:11:26 -07:00

52 lines
1.3 KiB
Makefile

TARGET := dented
SRC := ${wildcard *.c}
OBJ := $(SRC:.c=.o)
INCS := -I/usr/local/include/
LIBS := -L/usr/local/lib/ -lraylib
# -pedantic means using gnu extentions will throw an error
# this allows for better code portability between compilers
CFLAGS_ERRORS = -Werror -Wall -Wextra -Wconversion -Wdouble-promotion -Wunreachable-code -Wshadow -Wpedantic -pedantic-errors -pedantic
CFLAGS = -std=c17 $(CFLAGS_ERRORS) $(INCS)
LDFLAGS = $(LIBS)
ifeq ($(shell echo "Windows"), "Windows")
TARGET := $(TARGET).exe
DEL = del
Q =
else
DEL = rm -f
Q = "
endif
# debug is enabled by default
# debug can be disabled with `make DEBUG=0`
DEBUG := 1
ifeq ($(DEBUG),1)
# -Og compiles with debug specific optimizations
# -g3 compiles with max debug information
CFLAGS += -Og -g3
else
# -O3 compiles with extreme optimizations for performance
# -flto compiles with link time optimizations (LTO), supposed to improve performance by ~5%
CFLAGS += -O3 -flto
# -s when run on the linker will strip out debug symbols for a smaller file size
LDFLAGS += -s -flto
endif
# I believe using cc is better since not every installation has gcc
# this can always be overridden with `make CC=gcc` if needed
CC := cc
all: $(TARGET)
$(TARGET): $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
.c.o:
$(CC) -o $@ -c $< $(CFLAGS)
clean:
$(DEL) $(TARGET) $(OBJ)