From 18ac18bc6d8cd6b556c22dfb22be4b7621953863 Mon Sep 17 00:00:00 2001 From: Maxwell Jeffress Date: Sat, 11 Apr 2026 12:31:37 +1000 Subject: [PATCH] Tram is now an optional dependency --- Makefile | 16 ++++++++++++---- src/compiler.c | 4 ++++ src/interface.c | 4 ++++ src/main.c | 4 ++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 5561874..83a69b0 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC = gcc -CFLAGS = -Wall -Wextra -Isrc/include -Iinclude -ggdb -LDFLAGS = -ldl -rdynamic -ltram +CFLAGS += -Wall -Wextra -Isrc/include -Iinclude -ggdb +LDFLAGS += -ldl -rdynamic # Install paths PREFIX ?= /usr/local @@ -27,9 +27,13 @@ EXE_SOURCES = $(wildcard $(SRC_DIR)/*.c) LIB_OBJECTS = $(LIB_SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/lib_%.o) EXE_OBJECTS = $(EXE_SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/exe_%.o) -# Default target: build standalone executable +# Default target: build library .PHONY: all -all: executable +all: both + +DEFINE_TRAM: + $(eval CFLAGS += -DGROUND_COMPILE_WITH_TRAM) + $(eval LDFLAGS += -ltram) # Build standalone executable .PHONY: executable @@ -43,6 +47,10 @@ library: $(SHARED_LIB) $(HEADERS) .PHONY: both both: executable library +# both, with tram +.PHONY: tram_both +tram_both: DEFINE_TRAM both + # Link executable $(EXECUTABLE): $(EXE_OBJECTS) | $(BIN_DIR) $(CC) $(EXE_OBJECTS) -o $@ $(LDFLAGS) diff --git a/src/compiler.c b/src/compiler.c index 3bc373e..18cea94 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -1,3 +1,5 @@ +#ifdef GROUND_COMPILE_WITH_TRAM + #include "compiler.h" #include "types.h" #include "include/uthash.h" @@ -554,3 +556,5 @@ void compileGroundInstruction(GroundInstruction* instruction, Tram_Program* prog break; } } + +#endif \ No newline at end of file diff --git a/src/interface.c b/src/interface.c index 4cef8d8..2ff4d01 100644 --- a/src/interface.c +++ b/src/interface.c @@ -174,7 +174,11 @@ void groundAddFunctionToStruct(GroundStruct* gstruct, char* name, NativeGroundFu } void groundCompileProgram(GroundProgram* program) { +#ifdef GROUND_COMPILE_WITH_TRAM compileGroundProgram(program, "program.gexe"); +#else + printf("This version of Ground has been compiled without Tram, so compilation is not supported.\n"); +#endif } GroundValue groundRunFunction(GroundFunction* function, size_t argc, ...) { diff --git a/src/main.c b/src/main.c index ad32258..1993d33 100644 --- a/src/main.c +++ b/src/main.c @@ -111,7 +111,11 @@ int main(int argc, char** argv) { } if (compile) { +#ifdef GROUND_COMPILE_WITH_TRAM compileGroundProgram(&program, "program.gexe"); +#else + printf("This version of Ground has been compiled without Tram, so compilation is not supported.\n"); +#endif } else if (writeBytecode) { serializeProgramToFile(outFileName, &program); } else {