forked from ground/ground
Tram is now an optional dependency
This commit is contained in:
16
Makefile
16
Makefile
@@ -1,6 +1,6 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -Wextra -Isrc/include -Iinclude -ggdb
|
CFLAGS += -Wall -Wextra -Isrc/include -Iinclude -ggdb
|
||||||
LDFLAGS = -ldl -rdynamic -ltram
|
LDFLAGS += -ldl -rdynamic
|
||||||
|
|
||||||
# Install paths
|
# Install paths
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
@@ -27,9 +27,13 @@ EXE_SOURCES = $(wildcard $(SRC_DIR)/*.c)
|
|||||||
LIB_OBJECTS = $(LIB_SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/lib_%.o)
|
LIB_OBJECTS = $(LIB_SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/lib_%.o)
|
||||||
EXE_OBJECTS = $(EXE_SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/exe_%.o)
|
EXE_OBJECTS = $(EXE_SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/exe_%.o)
|
||||||
|
|
||||||
# Default target: build standalone executable
|
# Default target: build library
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: executable
|
all: both
|
||||||
|
|
||||||
|
DEFINE_TRAM:
|
||||||
|
$(eval CFLAGS += -DGROUND_COMPILE_WITH_TRAM)
|
||||||
|
$(eval LDFLAGS += -ltram)
|
||||||
|
|
||||||
# Build standalone executable
|
# Build standalone executable
|
||||||
.PHONY: executable
|
.PHONY: executable
|
||||||
@@ -43,6 +47,10 @@ library: $(SHARED_LIB) $(HEADERS)
|
|||||||
.PHONY: both
|
.PHONY: both
|
||||||
both: executable library
|
both: executable library
|
||||||
|
|
||||||
|
# both, with tram
|
||||||
|
.PHONY: tram_both
|
||||||
|
tram_both: DEFINE_TRAM both
|
||||||
|
|
||||||
# Link executable
|
# Link executable
|
||||||
$(EXECUTABLE): $(EXE_OBJECTS) | $(BIN_DIR)
|
$(EXECUTABLE): $(EXE_OBJECTS) | $(BIN_DIR)
|
||||||
$(CC) $(EXE_OBJECTS) -o $@ $(LDFLAGS)
|
$(CC) $(EXE_OBJECTS) -o $@ $(LDFLAGS)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#ifdef GROUND_COMPILE_WITH_TRAM
|
||||||
|
|
||||||
#include "compiler.h"
|
#include "compiler.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "include/uthash.h"
|
#include "include/uthash.h"
|
||||||
@@ -554,3 +556,5 @@ void compileGroundInstruction(GroundInstruction* instruction, Tram_Program* prog
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -174,7 +174,11 @@ void groundAddFunctionToStruct(GroundStruct* gstruct, char* name, NativeGroundFu
|
|||||||
}
|
}
|
||||||
|
|
||||||
void groundCompileProgram(GroundProgram* program) {
|
void groundCompileProgram(GroundProgram* program) {
|
||||||
|
#ifdef GROUND_COMPILE_WITH_TRAM
|
||||||
compileGroundProgram(program, "program.gexe");
|
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, ...) {
|
GroundValue groundRunFunction(GroundFunction* function, size_t argc, ...) {
|
||||||
|
|||||||
@@ -111,7 +111,11 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (compile) {
|
if (compile) {
|
||||||
|
#ifdef GROUND_COMPILE_WITH_TRAM
|
||||||
compileGroundProgram(&program, "program.gexe");
|
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) {
|
} else if (writeBytecode) {
|
||||||
serializeProgramToFile(outFileName, &program);
|
serializeProgramToFile(outFileName, &program);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user