aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-09-01 20:33:00 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-09-01 20:33:00 +0200
commitd705e71f90bc4874fb13e4496a2ebd6968d38a79 (patch)
treeef7f6cafdce7b2babef39f2c01ab9e66af480c55
parentcc9d637652875020e1a26874f15ff362938aa9e0 (diff)
downloadcli-d705e71f90bc4874fb13e4496a2ebd6968d38a79.zip
cli-d705e71f90bc4874fb13e4496a2ebd6968d38a79.tar.bz2
Switches to Makefiles.
-rw-r--r--CMakeLists.txt27
-rw-r--r--Makefile21
-rw-r--r--README.md2
-rw-r--r--src/CMakeLists.txt10
-rw-r--r--src/Makefile21
-rw-r--r--src/error/CMakeLists.txt6
6 files changed, 43 insertions, 44 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index 7ee5c95..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
-
-project("JabberHive - Command Line Interface")
-
-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")
- #set(CMAKE_C_FLAGS " -g")
-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-cli ${SRC_FILES})
-set_property(TARGET jabberhive-cli PROPERTY C_STANDARD 99)
-set_property(TARGET jabberhive-cli PROPERTY C_STANDARD_REQUIRED ON)
-
-## OPTION HANDLING #############################################################
-# TODO
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..899d412
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,21 @@
+CFLAGS += -O3
+CFLAGS += -D_POSIX_SOURCE
+CFLAGS += -D_POSIX_C_SOURCE=200809L
+################################################################################
+EXECUTABLE = jh-cli
+SRC_DIR = ./src
+################################################################################
+export
+################################################################################
+
+build: $(EXECUTABLE)
+
+$(EXECUTABLE): $(SRC_DIR)/export.a
+ $(CC) -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 0da4380..082987c 100644
--- a/README.md
+++ b/README.md
@@ -20,4 +20,4 @@ send.
## 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 61aeb77..0000000
--- a/src/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-add_subdirectory(error)
-
-set(
- SRC_FILES ${SRC_FILES}
- ${CMAKE_CURRENT_SOURCE_DIR}/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/signal.c
- ${CMAKE_CURRENT_SOURCE_DIR}/socket.c
-)
-
-set(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..1cd5199
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,21 @@
+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)
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)
-