diff options
author | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 02:29:14 +0100 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 02:29:14 +0100 |
commit | 879fe74e2a18b7b89d35cf1fc0fb8829a1b70b3d (patch) | |
tree | f80e34fed55cc2b7c8f5fc5f59d6cc4a8245a617 /Makefile | |
parent | 8af4b246d86df7bc906841689912534ea450cce5 (diff) |
Simultaneous Debug and Release builds.
[#29] Makefile now generates both release and debug builds on every
run. Salis.py can load the debug version on demand via a command line
argument (--debug). Release version is loaded by default.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 47 |
1 files changed, 32 insertions, 15 deletions
@@ -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)
|