aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-09-01 21:24:16 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-09-01 21:24:16 +0200
commit2096085d658947d5fb7685090d9f26bd23595f4d (patch)
treecb57cac18facf139f21bbb39f49664b06f0abb62
parentd582b266356b79e6879d7ae30b8defe3a565ee03 (diff)
downloadlowercase-2096085d658947d5fb7685090d9f26bd23595f4d.zip
lowercase-2096085d658947d5fb7685090d9f26bd23595f4d.tar.bz2
Switches to Makefiles.
-rw-r--r--CMakeLists.txt29
-rw-r--r--Makefile25
-rw-r--r--README.md2
-rw-r--r--src/CMakeLists.txt12
-rw-r--r--src/Makefile30
-rw-r--r--src/core/CMakeLists.txt6
-rw-r--r--src/error/CMakeLists.txt6
-rw-r--r--src/filter/CMakeLists.txt6
l---------src/filter/Makefile1
-rw-r--r--src/parameters/CMakeLists.txt7
l---------src/parameters/Makefile1
-rw-r--r--src/server/CMakeLists.txt15
l---------src/server/Makefile1
13 files changed, 59 insertions, 82 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index 9aeaef1..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
-
-project("JabberHive - Lowercase")
-
-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-lowercase ${SRC_FILES})
-set_property(TARGET jabberhive-lowercase PROPERTY C_STANDARD 99)
-set_property(TARGET jabberhive-lowercase PROPERTY C_STANDARD_REQUIRED ON)
-
-find_package(Threads)
-target_link_libraries(jabberhive-lowercase ${CMAKE_THREAD_LIBS_INIT})
-
-## OPTION HANDLING #############################################################
-# TODO
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..8a77d80
--- /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-lowercase
+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 9d7049c..84a23b4 100644
--- a/README.md
+++ b/README.md
@@ -21,4 +21,4 @@ lowercase equivalent.
## 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 0b242bc..0000000
--- a/src/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-add_subdirectory(error)
-add_subdirectory(core)
-add_subdirectory(filter)
-add_subdirectory(server)
-add_subdirectory(parameters)
-
-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 fa07534..0000000
--- a/src/core/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-set(
- SRC_FILES ${SRC_FILES}
-)
-
-set(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
-
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/filter/CMakeLists.txt b/src/filter/CMakeLists.txt
deleted file mode 100644
index c8add44..0000000
--- a/src/filter/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-set(
- SRC_FILES ${SRC_FILES}
- ${CMAKE_CURRENT_SOURCE_DIR}/filter.c
-)
-
-set(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
diff --git a/src/filter/Makefile b/src/filter/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/src/filter/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 2aa7ece..0000000
--- a/src/parameters/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-set(
- SRC_FILES ${SRC_FILES}
- ${CMAKE_CURRENT_SOURCE_DIR}/parameters.c
- ${CMAKE_CURRENT_SOURCE_DIR}/parameters_getters.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/server/CMakeLists.txt b/src/server/CMakeLists.txt
deleted file mode 100644
index 9ade789..0000000
--- a/src/server/CMakeLists.txt
+++ /dev/null
@@ -1,15 +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
-)
-
-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