aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-25 15:47:08 -0400
committeriamcheeseman <[email protected]>2026-05-25 15:47:08 -0400
commit8122098e3854bf68ca63cc25e082ba51a27b8615 (patch)
tree471e7191211b0f66f1c7c7c4c81cf2589e6f3c8d
parent1fb9ed0d6f627662f8d001afa761860d63d9f4a2 (diff)
I realized that Makefiles are dumb
-rw-r--r--Makefile43
-rw-r--r--Makefile.dep28
-rw-r--r--build.env4
-rwxr-xr-xbuild.sh33
-rw-r--r--config.def.mk18
5 files changed, 37 insertions, 89 deletions
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