From bd1c23c938501d4d4ab1c8bbe9270bfbf37a1d57 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Thu, 17 Feb 2022 19:13:37 +0100 Subject: Greatly improves compilation process. --- .gitignore | 2 ++ Makefile | 33 ++++++++++++++++++++++----------- learn.sh | 11 +++++++++++ run.sh | 5 +++++ src/Makefile | 23 ----------------------- 5 files changed, 40 insertions(+), 34 deletions(-) create mode 100644 .gitignore create mode 100755 learn.sh create mode 100755 run.sh delete mode 100644 src/Makefile 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) -- cgit v1.2.3-70-g09d2