aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--Makefile47
-rwxr-xr-xbin/salis.py12
-rw-r--r--build/debug/.keep (renamed from build/.keep)0
-rw-r--r--build/release/.keep0
5 files changed, 46 insertions, 19 deletions
diff --git a/.gitignore b/.gitignore
index 69cc08f..b5cad49 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,8 @@
bin/__pycache__/*
bin/common/pipe
bin/error.log
-bin/lib/libsalis.so
+bin/lib/libsalis-*.so
bin/sims/*.sim
bin/sims/auto/*.auto.gz
-build/*.d
-build/*.o
+build/**/*.d
+build/**/*.o
diff --git a/Makefile b/Makefile
index 156a068..9d88bf6 100644
--- a/Makefile
+++ b/Makefile
@@ -1,29 +1,46 @@
CC := gcc
-LIB := bin/lib/libsalis.so
+LIB_DEB := bin/lib/libsalis-deb.so
+LIB_REL := bin/lib/libsalis-rel.so
SOURCES := $(wildcard src/*.c)
-OBJECTS := $(patsubst src/%.c,build/%.o,$(SOURCES))
-DEPS := $(patsubst %.o,%.d,$(OBJECTS))
+OBJECTS_DEB := $(patsubst src/%.c,build/debug/%.o,$(SOURCES))
+OBJECTS_REL := $(patsubst src/%.c,build/release/%.o,$(SOURCES))
+DEPS_DEB := $(patsubst %.o,%.d,$(OBJECTS_DEB))
+DEPS_REL := $(patsubst %.o,%.d,$(OBJECTS_REL))
LFLAGS := -shared
-# uncomment for debug
-# OFLAGS := -ggdb
+# Compiler flags for debug build.
+DEB_FLAGS := -ggdb
-# uncomment for release
-OFLAGS := -O3 -DNDEBUG -Wno-unused-function -Wno-unused-result \
+# Compiler flags for release build.
+REL_FLAGS := -O3 -DNDEBUG -Wno-unused-function -Wno-unused-result \
-Wno-unused-variable
-CFLAGS := -Iinclude -c $(OFLAGS) -MMD -Wall -Wextra -std=c89 -fPIC -fopenmp \
+# General compiler flags.
+CFLAGS := -Iinclude -c -MMD -Wall -Wextra -std=c89 -fPIC -fopenmp \
-DSALIS_API="" -DSALIS_INST="" -DSALIS_PROC_ELEMENT="" -pedantic-errors \
-Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition
-all: $(OBJECTS)
- $(CC) $(LFLAGS) -fopenmp -o $(LIB) $(OBJECTS)
+# By default, keep a debug and release build available.
+all: debug release
--include $(DEPS)
+debug: $(OBJECTS_DEB)
+ $(CC) $(LFLAGS) -fopenmp -o $(LIB_DEB) $(OBJECTS_DEB)
-$(OBJECTS): $(patsubst build/%.o,src/%.c,$@)
- $(CC) $(CFLAGS) $(patsubst build/%.o,src/%.c,$@) -o $@
+release: $(OBJECTS_REL)
+ $(CC) $(LFLAGS) -fopenmp -o $(LIB_REL) $(OBJECTS_REL)
+
+-include $(DEPS_DEB)
+
+$(OBJECTS_DEB): $(patsubst build/debug/%.o,src/%.c,$@)
+ $(CC) $(DEB_FLAGS) $(CFLAGS) $(patsubst build/debug/%.o,src/%.c,$@) -o $@
+
+-include $(DEPS_REL)
+
+$(OBJECTS_REL): $(patsubst build/release/%.o,src/%.c,$@)
+ $(CC) $(REL_FLAGS) $(CFLAGS) $(patsubst build/release/%.o,src/%.c,$@) -o $@
clean:
- -rm build/*
- -rm $(LIB)
+ -rm build/debug/*
+ -rm build/release/*
+ -rm $(LIB_DEB)
+ -rm $(LIB_REL)
diff --git a/bin/salis.py b/bin/salis.py
index eef4263..dc86d1d 100755
--- a/bin/salis.py
+++ b/bin/salis.py
@@ -191,6 +191,10 @@ class Salis:
"-v", "--version", action="version",
version="Salis: A-Life Simulator (" + __version__ + ")"
)
+ parser.add_argument(
+ "-d", "--debug", action="store_true",
+ help="Run debug build of Salis library"
+ )
# Initialize the 'new/load' action subparsers.
subparsers = parser.add_subparsers(
@@ -266,7 +270,13 @@ class Salis:
Note to developers: the 'SALIS_API' keyword should *NOT* be used
anywhere else in the header files (not even in comments)!
"""
- lib = CDLL(os.path.join(self.path, "lib/libsalis.so"))
+ # Load debug or release versions of Salis into a CDLL object.
+ if self.args.debug:
+ suff = "-deb"
+ else:
+ suff = "-rel"
+
+ lib = CDLL(os.path.join(self.path, "lib/libsalis{}.so".format(suff)))
include_dir = os.path.join(self.path, "../include")
c_includes = [
os.path.join(include_dir, f)
diff --git a/build/.keep b/build/debug/.keep
index e69de29..e69de29 100644
--- a/build/.keep
+++ b/build/debug/.keep
diff --git a/build/release/.keep b/build/release/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/build/release/.keep