summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2022-02-17 19:13:37 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2022-02-17 19:13:37 +0100
commitbd1c23c938501d4d4ab1c8bbe9270bfbf37a1d57 (patch)
tree634d98ad546d27547f82f7fdbda2fbdc5846d005
parent19b28fafe0ee8c0f3123e8698f1fe30ada653b36 (diff)
Greatly improves compilation process.HEADmaster
-rw-r--r--.gitignore2
-rw-r--r--Makefile33
-rwxr-xr-xlearn.sh11
-rwxr-xr-xrun.sh5
-rw-r--r--src/Makefile23
5 files changed, 40 insertions, 34 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e23a117
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+compilation_data/
+jh-cli
diff --git a/Makefile b/Makefile
index 078aa54..e028ca0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,23 +1,34 @@
+################################################################################
+################################################################################
CFLAGS += -O3
+CFLAGS += -Wall -Wextra -pedantic -Werror
CFLAGS += -D_POSIX_SOURCE
CFLAGS += -D_POSIX_C_SOURCE=200809L
################################################################################
-EXECUTABLE = jh-cli
-SRC_DIR = ./src
+EXECUTABLE ?= jh-cli
+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/learn.sh b/learn.sh
new file mode 100755
index 0000000..1dba13d
--- /dev/null
+++ b/learn.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+CURRENT_DIRECTORY=$(cd `dirname $0` && pwd)
+
+if [[ "$#" != "1" ]];
+then
+ echo "Expected single argument: data file."
+ exit
+fi
+
+cat $1 | $CURRENT_DIRECTORY/jabberhive-cli /tmp/jh0
diff --git a/run.sh b/run.sh
new file mode 100755
index 0000000..304fc07
--- /dev/null
+++ b/run.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+CURRENT_DIRECTORY=$(cd `dirname $0` && pwd)
+
+find /my/jabberhive/dataset -name "*.txt" | parallel -j4 $CURRENT_DIRECTORY/learn.sh {}
diff --git a/src/Makefile b/src/Makefile
deleted file mode 100644
index 8ae0d15..0000000
--- a/src/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-################################################################################
-SRC_FILES = $(wildcard ./*.c)
-OBJ_FILES = $(SRC_FILES:.c=.o)
-DEP_FILES = $(SRC_FILES:.c=.d)
-################################################################################
-
-build: export.a
-
-export.a: $(OBJ_FILES)
- ar cr $@ $^
-
-clean:
- rm -f $(OBJ_FILES)
- rm -f $(DEP_FILES)
- rm -f export.a
-
-%.d: %.c
- @set -e; rm -f $@; \
- $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
- sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
- rm -f $@.$$$$
-
-include $(DEP_FILES)