aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-09-01 21:15:52 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-09-01 21:15:52 +0200
commit2b1c103df8a566f1fee62a040da079a052cee83f (patch)
tree71a80b80298b3529df10830e3ae1b9b76babbb01
parent8a37d71ce6ca77f87f773299461cbdbf2058565b (diff)
downloadmarkov-k-ram-2b1c103df8a566f1fee62a040da079a052cee83f.zip
markov-k-ram-2b1c103df8a566f1fee62a040da079a052cee83f.tar.bz2
Switches to Makefiles.
-rw-r--r--CMakeLists.txt30
-rw-r--r--Makefile25
-rw-r--r--README.md2
-rw-r--r--src/CMakeLists.txt13
-rw-r--r--src/Makefile30
-rw-r--r--src/core/CMakeLists.txt8
l---------src/core/Makefile1
-rw-r--r--src/error/CMakeLists.txt6
-rw-r--r--src/knowledge/CMakeLists.txt16
l---------src/knowledge/Makefile1
-rw-r--r--src/parameters/CMakeLists.txt6
l---------src/parameters/Makefile1
-rw-r--r--src/sequence/CMakeLists.txt11
l---------src/sequence/Makefile1
-rw-r--r--src/server/CMakeLists.txt18
l---------src/server/Makefile1
16 files changed, 61 insertions, 109 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index 4ac9795..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
-
-project("JabberHive - K-order Markov Server")
-
-include(FindPkgConfig)
-
-add_subdirectory(src)
-add_definitions(-D_POSIX_SOURCE)
-add_definitions(-D_POSIX_C_SOURCE=200809L)
-
-set(CMAKE_C_FLAGS $ENV{CFLAGS})
-if(CMAKE_COMPILER_IS_GNUCC)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wpedantic -Wconversion")
- message(STATUS "GNUCC detected. Adding '-O3' parameter.")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
-endif()
-message(STATUS "CFLAGS=${CMAKE_C_FLAGS}")
-
-
-# ${SRC_FILES} is recursively defined in the subdirectories.
-# Each subdirectory only adds the source files that are present at its level.
-add_executable(jabberhive-markov-k-ram ${SRC_FILES})
-set_property(TARGET jabberhive-markov-k-ram PROPERTY C_STANDARD 99)
-set_property(TARGET jabberhive-markov-k-ram PROPERTY C_STANDARD_REQUIRED ON)
-
-find_package(Threads)
-target_link_libraries(jabberhive-markov-k-ram ${CMAKE_THREAD_LIBS_INIT})
-
-## OPTION HANDLING #############################################################
-# TODO
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d9dc166
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,25 @@
+################################################################################
+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
+################################################################################
+export
+################################################################################
+
+build: $(EXECUTABLE)
+
+$(EXECUTABLE): $(SRC_DIR)/export.a
+ $(CC) $(CFLAGS) -o $@ $<
+
+$(SRC_DIR)/export.a:
+ $(MAKE) -C $(SRC_DIR) export.a
+
+clean:
+ $(MAKE) -C $(SRC_DIR) clean
+ rm -f $(EXECUTABLE)
diff --git a/README.md b/README.md
index d8263fb..81411cd 100644
--- a/README.md
+++ b/README.md
@@ -18,4 +18,4 @@ protocol for more information.
## Dependencies
- POSIX compliant OS.
- C compiler (with C99 support).
-- CMake.
+- (GNU) make.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
deleted file mode 100644
index 97affee..0000000
--- a/src/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-add_subdirectory(core)
-add_subdirectory(error)
-add_subdirectory(knowledge)
-add_subdirectory(parameters)
-add_subdirectory(sequence)
-add_subdirectory(server)
-
-set(
- SRC_FILES ${SRC_FILES}
- ${CMAKE_CURRENT_SOURCE_DIR}/main.c
-)
-
-set(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..8ffa1ab
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,30 @@
+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):
+ $(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 $@.$$$$
+
+include $(DEP_FILES)
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
deleted file mode 100644
index b864aff..0000000
--- a/src/core/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-set(
- SRC_FILES ${SRC_FILES}
- ${CMAKE_CURRENT_SOURCE_DIR}/char.c
- ${CMAKE_CURRENT_SOURCE_DIR}/index.c
-)
-
-set(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
-
diff --git a/src/core/Makefile b/src/core/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/src/core/Makefile
@@ -0,0 +1 @@
+../Makefile \ No newline at end of file
diff --git a/src/error/CMakeLists.txt b/src/error/CMakeLists.txt
deleted file mode 100644
index fa07534..0000000
--- a/src/error/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-set(
- SRC_FILES ${SRC_FILES}
-)
-
-set(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
-
diff --git a/src/knowledge/CMakeLists.txt b/src/knowledge/CMakeLists.txt
deleted file mode 100644
index ab96392..0000000
--- a/src/knowledge/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-set(
- SRC_FILES ${SRC_FILES}
- ${CMAKE_CURRENT_SOURCE_DIR}/knowledge.c
- ${CMAKE_CURRENT_SOURCE_DIR}/knowledge_finalize.c
- ${CMAKE_CURRENT_SOURCE_DIR}/knowledge_get_random_sequence.c
- ${CMAKE_CURRENT_SOURCE_DIR}/knowledge_get_random_target.c
- ${CMAKE_CURRENT_SOURCE_DIR}/knowledge_learn_markov_sequence.c
- ${CMAKE_CURRENT_SOURCE_DIR}/knowledge_learn_sequence.c
- ${CMAKE_CURRENT_SOURCE_DIR}/knowledge_learn_word.c
- ${CMAKE_CURRENT_SOURCE_DIR}/knowledge_locks.c
- ${CMAKE_CURRENT_SOURCE_DIR}/knowledge_search.c
- ${CMAKE_CURRENT_SOURCE_DIR}/knowledge_swt_tws_modifications.c
-)
-
-set(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
-
diff --git a/src/knowledge/Makefile b/src/knowledge/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/src/knowledge/Makefile
@@ -0,0 +1 @@
+../Makefile \ No newline at end of file
diff --git a/src/parameters/CMakeLists.txt b/src/parameters/CMakeLists.txt
deleted file mode 100644
index 94e6337..0000000
--- a/src/parameters/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-set(
- SRC_FILES ${SRC_FILES}
- ${CMAKE_CURRENT_SOURCE_DIR}/parameters.c
-)
-set(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
-
diff --git a/src/parameters/Makefile b/src/parameters/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/src/parameters/Makefile
@@ -0,0 +1 @@
+../Makefile \ No newline at end of file
diff --git a/src/sequence/CMakeLists.txt b/src/sequence/CMakeLists.txt
deleted file mode 100644
index 1186557..0000000
--- a/src/sequence/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-set(
- SRC_FILES ${SRC_FILES}
- ${CMAKE_CURRENT_SOURCE_DIR}/sequence.c
- ${CMAKE_CURRENT_SOURCE_DIR}/sequence_append.c
- ${CMAKE_CURRENT_SOURCE_DIR}/sequence_creation.c
- ${CMAKE_CURRENT_SOURCE_DIR}/sequence_from_string.c
- ${CMAKE_CURRENT_SOURCE_DIR}/sequence_to_string.c
-)
-
-set(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
-
diff --git a/src/sequence/Makefile b/src/sequence/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/src/sequence/Makefile
@@ -0,0 +1 @@
+../Makefile \ No newline at end of file
diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt
deleted file mode 100644
index 3b64500..0000000
--- a/src/server/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-set(
- SRC_FILES ${SRC_FILES}
- ${CMAKE_CURRENT_SOURCE_DIR}/server.c
- ${CMAKE_CURRENT_SOURCE_DIR}/server_create_socket.c
- ${CMAKE_CURRENT_SOURCE_DIR}/server_finalize.c
- ${CMAKE_CURRENT_SOURCE_DIR}/server_initialize.c
- ${CMAKE_CURRENT_SOURCE_DIR}/server_joining_threads.c
- ${CMAKE_CURRENT_SOURCE_DIR}/server_new_connection.c
- ${CMAKE_CURRENT_SOURCE_DIR}/server_signal.c
- ${CMAKE_CURRENT_SOURCE_DIR}/server_wait_for_event.c
- ${CMAKE_CURRENT_SOURCE_DIR}/server_worker.c
- ${CMAKE_CURRENT_SOURCE_DIR}/server_worker_handle_request.c
- ${CMAKE_CURRENT_SOURCE_DIR}/server_worker_receive.c
- ${CMAKE_CURRENT_SOURCE_DIR}/server_worker_send.c
-)
-
-set(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
-
diff --git a/src/server/Makefile b/src/server/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/src/server/Makefile
@@ -0,0 +1 @@
+../Makefile \ No newline at end of file