aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2022-02-17 17:31:18 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2022-02-17 17:31:18 +0100
commit08af514ba3fd9c1d4083c936b677ef74be0ad86b (patch)
treeb25b48158bf452a00d51f2a187ea193d02df69a0
parent2046bffda9c9ebc451155b7d64f1c855b048ca4f (diff)
downloadmarkov-k-ram-08af514ba3fd9c1d4083c936b677ef74be0ad86b.zip
markov-k-ram-08af514ba3fd9c1d4083c936b677ef74be0ad86b.tar.bz2
Greatly improves the compilation process.
-rw-r--r--.gitignore2
-rw-r--r--Makefile32
-rwxr-xr-xrun.sh2
-rw-r--r--src/Makefile32
l---------src/core/Makefile1
l---------src/knowledge/Makefile1
l---------src/parameters/Makefile1
l---------src/sequence/Makefile1
l---------src/server/Makefile1
9 files changed, 23 insertions, 50 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..acf2f34
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+compilation_data/
+jh-markov-k-ram
diff --git a/Makefile b/Makefile
index 31e0d22..40f30dd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,27 +1,35 @@
################################################################################
-PTHREADS_LIB_FLAGS = -pthread
+PTHREADS_LIB_FLAGS ?= -pthread
################################################################################
CFLAGS += -O3
CFLAGS += -D_POSIX_SOURCE
CFLAGS += -D_POSIX_C_SOURCE=200809L
CFLAGS += $(PTHREADS_LIB_FLAGS)
################################################################################
-EXECUTABLE = jh-markov-k-ram
-SRC_DIR = ./src
+EXECUTABLE ?= jh-markov-k-ram
+BASE_DIR ?= $(CURDIR)
+SRC_DIR ?= $(BASE_DIR)/src
+COMPILE_DIR ?= $(BASE_DIR)/compilation_data
################################################################################
-export
+SRC_FILES ?= $(shell find $(SRC_DIR) -type f -name *.c)
+OBJ_FILES ?= $(patsubst $(SRC_DIR)/%.c,$(COMPILE_DIR)/%.o,$(SRC_FILES))
+DEP_FILES ?= $(patsubst %.o,%.d,$(OBJ_FILES))
################################################################################
build: $(EXECUTABLE)
-$(EXECUTABLE): $(SRC_DIR)/export.a
- $(CC) $(CFLAGS) -o $@ $<
+$(OBJ_FILES): $(COMPILE_DIR)/%.o : $(SRC_DIR)/%.c $(COMPILE_DIR)/%.d
+ $(CC) $(CFLAGS) -c -o $@ $<
-$(SRC_DIR)/export.a: .JUST_CHECK
- $(MAKE) -C $(SRC_DIR) export.a
+$(DEP_FILES): $(COMPILE_DIR)/%.d: $(SRC_DIR)/%.c
+ mkdir -p $(dir $@)
+ @set -e; rm -f $@; \
+ $(CC) -M $(CFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
-clean:
- $(MAKE) -C $(SRC_DIR) clean
- rm -f $(EXECUTABLE)
+$(EXECUTABLE): $(OBJ_FILES)
+ $(CC) $(CFLAGS) -o $@ $^
-.JUST_CHECK:
+clean:
+ rm -fr $(EXECUTABLE) $(COMPILE_DIR)
diff --git a/run.sh b/run.sh
index 79a34eb..8fcc169 100755
--- a/run.sh
+++ b/run.sh
@@ -12,5 +12,5 @@ while true
do
rm -f $1
# Run with listenin socket on $1 and Markov rank 3.
- $CURRENT_DIRECTORY/bin/jabberhive-markov-k-ram $1 3
+ $CURRENT_DIRECTORY/jabberhive-markov-k-ram $1 3
done
diff --git a/src/Makefile b/src/Makefile
deleted file mode 100644
index 719b8ea..0000000
--- a/src/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-SUBCOMPONENTS = $(dir $(filter-out "./Makefile",$(wildcard ./*/Makefile)))
-SUBCOMPONENTS_EXPORT = $(addsuffix /export.a,$(SUBCOMPONENTS))
-################################################################################
-SRC_FILES = $(wildcard ./*.c)
-OBJ_FILES = $(SRC_FILES:.c=.o)
-DEP_FILES = $(SRC_FILES:.c=.d)
-################################################################################
-build: export.a
-
-export.a: $(OBJ_FILES) $(SUBCOMPONENTS_EXPORT)
- ar -crT $@ $^
-
-$(SUBCOMPONENTS_EXPORT): .JUST_CHECK
- $(MAKE) -C $(dir $@) export.a
-
-clean:
- rm -f $(OBJ_FILES)
- rm -f $(DEP_FILES)
- rm -f export.a
- for subcmp in $(SUBCOMPONENTS) ; do \
- $(MAKE) -C $$subcmp clean ; \
- done
-################################################################################
-%.d: %.c
- @set -e; rm -f $@; \
- $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
- sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
- rm -f $@.$$$$
-
-.JUST_CHECK:
-
-include $(DEP_FILES)
diff --git a/src/core/Makefile b/src/core/Makefile
deleted file mode 120000
index d0b0e8e..0000000
--- a/src/core/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../Makefile \ No newline at end of file
diff --git a/src/knowledge/Makefile b/src/knowledge/Makefile
deleted file mode 120000
index d0b0e8e..0000000
--- a/src/knowledge/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../Makefile \ No newline at end of file
diff --git a/src/parameters/Makefile b/src/parameters/Makefile
deleted file mode 120000
index d0b0e8e..0000000
--- a/src/parameters/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../Makefile \ No newline at end of file
diff --git a/src/sequence/Makefile b/src/sequence/Makefile
deleted file mode 120000
index d0b0e8e..0000000
--- a/src/sequence/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../Makefile \ No newline at end of file
diff --git a/src/server/Makefile b/src/server/Makefile
deleted file mode 120000
index d0b0e8e..0000000
--- a/src/server/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../Makefile \ No newline at end of file