From 739409d3beb97d68b1caedbf852332379d09333d Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 27 Nov 2025 00:45:51 +0000 Subject: [PATCH] Use a shell script over a makefile Simpler build system, easier to read. --- .dir-locals.el | 2 +- .gitignore | 2 +- Makefile | 50 -------------------------------------------------- build.sh | 10 ++++++++++ 4 files changed, 12 insertions(+), 52 deletions(-) delete mode 100644 Makefile create mode 100644 build.sh diff --git a/.dir-locals.el b/.dir-locals.el index 2d77eb0..c14c3d8 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -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)))) diff --git a/.gitignore b/.gitignore index d3b8be9..0a18301 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -build/ +*.out TAGS diff --git a/Makefile b/Makefile deleted file mode 100644 index 9fc08c9..0000000 --- a/Makefile +++ /dev/null @@ -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) diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..b591865 --- /dev/null +++ b/build.sh @@ -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