Use a shell script over a makefile

Simpler build system, easier to read.
This commit is contained in:
2025-11-27 00:45:51 +00:00
parent 9d8215bd45
commit 739409d3be
4 changed files with 12 additions and 52 deletions

View File

@@ -2,5 +2,5 @@
;;; For more information see (info "(emacs) Directory Variables")
((nil . ((+license/license-choice . "GNU General Public License Version 2")
(compile-command . "make run")))
(compile-command . "sh build.sh")))
(c++-mode . ((mode . clang-format))))

2
.gitignore vendored
View File

@@ -1,2 +1,2 @@
build/
*.out
TAGS

View File

@@ -1,50 +0,0 @@
CC=g++
OUT=cwtree.out
LIBS=-lm -lraylib
ARGS=
RELEASE=0
GFLAGS=-Wall -Wextra -Wswitch-enum -std=c++17
DFLAGS=-ggdb -fsanitize=address -fsanitize=undefined
RFLAGS=-O3
DEPFLAGS=-MT $@ -MMD -MP -MF
ifeq ($(RELEASE), 1)
CFLAGS=$(GFLAGS) $(RFLAGS)
else
CFLAGS=$(GFLAGS) $(DFLAGS)
endif
SRC=src
DIST=build
CODE=$(addprefix $(SRC)/, numerics.cpp) # add source files here
OBJECTS=$(CODE:$(SRC)/%.cpp=$(DIST)/%.o)
DEPDIR:=$(DIST)/dependencies
DEPS:=$(CODE:$(SRC)/%.cpp=$(DEPDIR):%.d) $(DEPDIR)/main.d
.PHONY: all
all: $(OUT)
$(OUT): $(DIST)/$(OUT)
$(DIST)/$(OUT): $(OBJECTS) $(DIST)/main.o | $(DIST)
$(CC) $(CFLAGS) $^ -o $@ $(LIBS)
$(DIST)/%.o: $(SRC)/%.cpp | $(DIST) $(DEPDIR)
$(CC) $(CFLAGS) $(DEPFLAGS) $(DEPDIR)/$*.d -c $< -o $@ $(LIBS)
.PHONY: run
run: $(DIST)/$(OUT)
./$^ $(ARGS)
.PHONY:
clean:
rm -rfv $(DIST)/*
$(DIST):
mkdir -p $(DIST)
$(DEPDIR):
mkdir -p $(DEPDIR)
-include $(DEPS)

10
build.sh Normal file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env sh
set -xe
GFLAGS="-Wall -Wextra -Wswitch-enum -std=c++17"
DFLAGS="-ggdb -fsanitize=address -fsanitize=undefined"
CFLAGS="$GFLAGS $DFLAGS"
LIBS="-lraylib -lm"
c++ $CFLAGS -o cw_tree.out src/numerics.cpp src/main.cpp $LIBS