From 8122098e3854bf68ca63cc25e082ba51a27b8615 Mon Sep 17 00:00:00 2001 From: iamcheeseman Date: Mon, 25 May 2026 15:47:08 -0400 Subject: I realized that Makefiles are dumb --- Makefile | 43 ------------------------------------------- Makefile.dep | 28 ---------------------------- build.env | 4 ++++ build.sh | 33 +++++++++++++++++++++++++++++++++ config.def.mk | 18 ------------------ 5 files changed, 37 insertions(+), 89 deletions(-) delete mode 100644 Makefile delete mode 100644 Makefile.dep create mode 100644 build.env create mode 100755 build.sh delete mode 100644 config.def.mk diff --git a/Makefile b/Makefile deleted file mode 100644 index eadb7b0..0000000 --- a/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -include config.mk - -Q?=@ - -SRC=$(wildcard **/*.c) -SRC+=$(wildcard platform/${PLATFORM}/**/*.c) -SRC+=$(wildcard platform/${PLATFORM}/*.c) -OBJ=$(SRC:%.c=.obj/%.o) - -.PHONY: all echo run clean full-clean - -all: Makefile.dep ${OUT} - -echo: - $(Q)echo CFLAGS=${CFLAGS} - $(Q)echo LDFLAGS=${LDFLAGS} - $(Q)echo SRC=${SRC} - $(Q)echo OBJ=${OBJ} - -${OUT}: ${OBJ} - $(Q)echo linking $@ - $(Q)${CC} -o $@ ${LDFLAGS} ${OBJ} - -.obj/%.o: %.c - $(Q)mkdir -p ${@D} - $(Q)echo ${CC} $< - $(Q)${CC} -c -o $@ ${CFLAGS} $< - -Makefile.dep: ${SRC} - $(Q)echo update $@ - $(Q)${CC} ${CFLAGS} ${SRC} -MM > $@ - -run: all - ${RUN_CMD} ./${OUT} - -clean: - rm -f ${OBJ} ${OUT} - -# Don't use this unless you are fine with your custom config getting deleted -full-clean: clean - rm -rf .obj config.mk - -include Makefile.dep diff --git a/Makefile.dep b/Makefile.dep deleted file mode 100644 index 28add12..0000000 --- a/Makefile.dep +++ /dev/null @@ -1,28 +0,0 @@ -dc.o: dc/dc.c teensy/teensy.h teensy/teensy_common.h teensy/teensy_log.h \ - teensy/teensy_mem.h teensy/teensy_list.h teensy/teensy_ui.h \ - teensy/teensy.h dc/third/qoi.h -teensy_common.o: teensy/teensy_common.c teensy/teensy_common.h \ - teensy/teensy_log.h teensy/teensy_mem.h -teensy_context.o: teensy/teensy_context.c teensy/teensy_context.h \ - teensy/teensy_common.h teensy/teensy_log.h teensy/teensy_mem.h \ - teensy/teensy_renderer.h teensy/teensy.h teensy/teensy_list.h \ - teensy/teensy_platform.h -teensy_log.o: teensy/teensy_log.c teensy/teensy_log.h \ - teensy/teensy_common.h teensy/teensy_mem.h -teensy_math.o: teensy/teensy_math.c teensy/teensy.h \ - teensy/teensy_common.h teensy/teensy_log.h teensy/teensy_mem.h \ - teensy/teensy_list.h -teensy_mem.o: teensy/teensy_mem.c teensy/teensy_mem.h \ - teensy/teensy_common.h teensy/teensy_log.h teensy/teensy_list.h -teensy_renderer.o: teensy/teensy_renderer.c teensy/teensy_renderer.h \ - teensy/teensy_common.h teensy/teensy_log.h teensy/teensy_mem.h \ - teensy/teensy.h teensy/teensy_list.h teensy/teensy_context.h -teensy_ui.o: teensy/teensy_ui.c teensy/teensy_ui.h teensy/teensy_common.h \ - teensy/teensy_log.h teensy/teensy_mem.h teensy/teensy.h \ - teensy/teensy_list.h teensy/teensy_platform.h teensy/teensy_context.h \ - teensy/teensy_renderer.h -gl.o: teensy/platform/gl/gl.c teensy/platform/gl/GLFW/glfw3.h \ - teensy/teensy.h teensy/teensy_common.h teensy/teensy_log.h \ - teensy/teensy_mem.h teensy/teensy_list.h teensy/teensy_common.h \ - teensy/teensy_platform.h teensy/teensy.h teensy/teensy_context.h \ - teensy/teensy_renderer.h diff --git a/build.env b/build.env new file mode 100644 index 0000000..e57d71f --- /dev/null +++ b/build.env @@ -0,0 +1,4 @@ +CC=cc +PLATFORM=gl +OUT=demonchime +DBFLAGS='-g -DTEENSY_DEBUG' diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..51dbc6e --- /dev/null +++ b/build.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +source build.env + +INC="-Iteensy -Iteensy/platform/$PLATFORM -Idc" +CFLAGS="$INC -Wall -Wextra -pedantic -std=c99 -D_XOPEN_SOURCE=700 -O2" +LDFLAGS=-lm + +DO_RUN=0 + +for flag in $@; do + case $flag in + 'debug') + CFLAGS="$DBFLAGS $CFLAGS" + ;; + 'run') + DO_RUN=1 + ;; + esac +done + +if [ "$PLATFORM" == 'gl' ]; then + CFLAGS="$CFLAGS $(pkg-config --cflags glfw3 gl)" + LDFLAGS="$LDFLAGS $(pkg-config --libs glfw3 gl)" +fi + +SRC=$(find dc teensy platform/$PLATFORM -name '*.c' | tr '\n' ' ') + +CMD="$CC -o $OUT $CFLAGS $LDFLAGS $SRC" +echo $CMD +time eval $CC -o $OUT $CFLAGS $LDFLAGS $SRC + +[ "$DO_RUN" -eq 1 ] && $RUN_CMD ./$OUT diff --git a/config.def.mk b/config.def.mk deleted file mode 100644 index 47e829b..0000000 --- a/config.def.mk +++ /dev/null @@ -1,18 +0,0 @@ -CC=cc -PLATFORM=gl - -OUT=demonchime - -DBFLAGS=-g -DTEENSY_DEBUG - -INCS=-Iteensy -Iteensy/platform/${PLATFORM} -CFLAGS=${INCS} -Wall -Wextra -std=c99 -D_XOPEN_SOURCE=700 -O2 -LDFLAGS=-lm - -ifeq (${CONFIG},debug) - CFLAGS+=${DBFLAGS} -endif - -ifeq (${PLATFORM},gl) - LDFLAGS+=-lglfw -lGL -endif -- cgit v1.3-2-g0d8e