aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-09-01 22:47:31 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-09-01 22:47:31 +0200
commitb05361b3baa804a2c67e74dbd66828cb8517ed91 (patch)
tree7ee82f12c0a1eecab4ab9daf644a58dd0a701c8e
parentba71528805f777871f52fc278858f56677307064 (diff)
downloadirc-b05361b3baa804a2c67e74dbd66828cb8517ed91.zip
irc-b05361b3baa804a2c67e74dbd66828cb8517ed91.tar.bz2
Switched to Makefiles.
-rw-r--r--CMakeLists.txt31
-rw-r--r--Makefile28
-rw-r--r--Makefile_libircclient42
-rw-r--r--README.md2
-rw-r--r--cmake_modules/FindLibIRCClient.cmake56
-rw-r--r--cmake_modules/LibFindMacros.cmake127
-rw-r--r--src/CMakeLists.txt11
-rw-r--r--src/Makefile30
-rw-r--r--src/error/CMakeLists.txt6
-rw-r--r--src/irc/CMakeLists.txt11
l---------src/irc/Makefile1
-rw-r--r--src/meta_net/CMakeLists.txt9
l---------src/meta_net/Makefile1
-rw-r--r--src/parameters/CMakeLists.txt7
l---------src/parameters/Makefile1
15 files changed, 104 insertions, 259 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index 6f58fe9..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
-
-project("JabberHive - IRC Gateway")
-
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/")
-
-include(FindPkgConfig)
-include(FindPkgConfig)
-
-add_subdirectory(src)
-add_definitions(-D_POSIX_SOURCE)
-add_definitions(-D_POSIX_C_SOURCE=200809L)
-find_package(LibIRCClient REQUIRED)
-
-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 "-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-irc ${SRC_FILES})
-set_property(TARGET jabberhive-irc PROPERTY C_STANDARD 99)
-set_property(TARGET jabberhive-irc PROPERTY C_STANDARD_REQUIRED ON)
-target_link_libraries(jabberhive-irc ${LibIRCClient_LIBRARIES})
-
-## OPTION HANDLING #############################################################
-# TODO
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ef34ce9
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,28 @@
+################################################################################
+PTHREADS_LIB_FLAGS = -pthread
+LIBIRCCLIENT_LIB_FLAGS =
+include Makefile_libircclient
+################################################################################
+CFLAGS += -O3
+CFLAGS += -D_POSIX_SOURCE
+CFLAGS += -D_POSIX_C_SOURCE=200809L
+CFLAGS += $(PTHREADS_LIB_FLAGS)
+CFLAGS += $(LIBIRCCLIENT_LIB_FLAGS)
+################################################################################
+EXECUTABLE = jh-irc
+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/Makefile_libircclient b/Makefile_libircclient
new file mode 100644
index 0000000..a9bd80f
--- /dev/null
+++ b/Makefile_libircclient
@@ -0,0 +1,42 @@
+ifneq ("$(wildcard $(LIBIRCCLIENT_LIB_FLAGS))","")
+else
+## FIND INCLUDE DIR ############################################################
+POSSIBLE_DIR = \
+ /usr/include \
+ /sw/include \
+ /usr/local/include \
+ /usr/include/libircclient \
+ /sw/include/libircclient \
+ /usr/local/include/libircclient
+TARGET_CANDIDATES = $(addsuffix /libircclient.h,$(POSSIBLE_DIR))
+TARGET_FINDINGS = \
+ $(foreach candidate,$(TARGET_CANDIDATES),$(wildcard $(candidate)))
+
+
+ifeq ("$(strip $(TARGET_FINDINGS))","")
+crash:
+ $(info Looked for libircclient.h in: [$(POSSIBLE_DIR)])
+ $(error Could not find libircclient, please set LIBIRCCLIENT_LIB_FLAGS manually)
+endif
+LIBIRCCLIENT_LIB_FLAGS = $(addprefix -I,$(dir $(TARGET_FINDINGS)))
+
+## FIND LIBRARY DIR ############################################################
+POSSIBLE_DIR = \
+ /usr/lib \
+ /lib \
+ /sw/lib \
+ /usr/local/lib
+TARGET_CANDIDATES = $(addsuffix /libircclient.so,$(POSSIBLE_DIR))
+TARGET_FINDINGS = \
+ $(foreach candidate,$(TARGET_CANDIDATES),$(wildcard $(candidate)))
+
+
+ifeq ("$(strip $(TARGET_FINDINGS))","")
+crash:
+ $(info Looked for ircclient lib dir in: [$(POSSIBLE_DIR)])
+ $(error Could not find libircclient, please set LIBIRCCLIENT_LIB_FLAGS manually)
+endif
+
+LIBIRCCLIENT_LIB_FLAGS += $(addprefix -L,$(dir $(TARGET_FINDINGS)))
+LIBIRCCLIENT_LIB_FLAGS += -lircclient
+endif
diff --git a/README.md b/README.md
index 701b909..22b126b 100644
--- a/README.md
+++ b/README.md
@@ -17,5 +17,5 @@ protocol for more information.
## Dependencies
- POSIX compliant OS.
- C compiler (with C99 support).
-- CMake.
+- (GNU) make.
- libircclient
diff --git a/cmake_modules/FindLibIRCClient.cmake b/cmake_modules/FindLibIRCClient.cmake
deleted file mode 100644
index 6884b17..0000000
--- a/cmake_modules/FindLibIRCClient.cmake
+++ /dev/null
@@ -1,56 +0,0 @@
-# Taken from https://github.com/sgielen/libdazeus-irc
-
-
-#Copyright (c) Sjors Gielen, 2010-2012
-#All rights reserved.
-#
-#Redistribution and use in source and binary forms, with or without
-#modification, are permitted provided that the following conditions are met:
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# * Neither the name of the DaVinci or DaZeus team nor the
-# names of its contributors may be used to endorse or promote products
-# derived from this software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-#ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-#DISCLAIMED. IN NO EVENT SHALL SJORS GIELEN OR CONTRIBUTORS BE LIABLE FOR ANY
-#DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-#(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-#ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-# Once done, this will define
-#
-# LibIRCClient_FOUND - system has LibIRCClient
-# LibIRCClient_INCLUDE_DIRS - the LibIRCClient include directories
-# LibIRCClient_LIBRARIES - link these to use LibIRCClient
-
-include(LibFindMacros)
-
-# Include dir
-find_path(LibIRCClient_INCLUDE_DIR
- NAMES libircclient.h
- PATHS ${LibIRCClient_PKGCONF_INCLUDE_DIRS}
- /usr/include /sw/include /usr/local/include
- /usr/include/libircclient /sw/include/libircclient
- /usr/local/include/libircclient
-)
-
-# Finally the library itself
-find_library(LibIRCClient_LIBRARY
- NAMES ircclient
- PATHS ${LibIRCClient_PKGCONF_LIBRARY_DIRS}
- /usr/lib /lib /sw/lib /usr/local/lib
-)
-
-set(LibIRCClient_PROCESS_INCLUDES LibIRCClient_INCLUDE_DIR)
-set(LibIRCClient_PROCESS_LIBS LibIRCClient_LIBRARY)
-libfind_process(LibIRCClient)
diff --git a/cmake_modules/LibFindMacros.cmake b/cmake_modules/LibFindMacros.cmake
deleted file mode 100644
index ea3568b..0000000
--- a/cmake_modules/LibFindMacros.cmake
+++ /dev/null
@@ -1,127 +0,0 @@
-# Taken from https://github.com/sgielen/libdazeus-irc
-
-
-#Copyright (c) Sjors Gielen, 2010-2012
-#All rights reserved.
-#
-#Redistribution and use in source and binary forms, with or without
-#modification, are permitted provided that the following conditions are met:
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# * Neither the name of the DaVinci or DaZeus team nor the
-# names of its contributors may be used to endorse or promote products
-# derived from this software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-#ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-#DISCLAIMED. IN NO EVENT SHALL SJORS GIELEN OR CONTRIBUTORS BE LIABLE FOR ANY
-#DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-#(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-#ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
-# used for the current package. For this to work, the first parameter must be the
-# prefix of the current package, then the prefix of the new package etc, which are
-# passed to find_package.
-macro (libfind_package PREFIX)
- set (LIBFIND_PACKAGE_ARGS ${ARGN})
- if (${PREFIX}_FIND_QUIETLY)
- set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
- endif (${PREFIX}_FIND_QUIETLY)
- if (${PREFIX}_FIND_REQUIRED)
- set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
- endif (${PREFIX}_FIND_REQUIRED)
- find_package(${LIBFIND_PACKAGE_ARGS})
-endmacro (libfind_package)
-
-# CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
-# where they added pkg_check_modules. Consequently I need to support both in my scripts
-# to avoid those deprecated warnings. Here's a helper that does just that.
-# Works identically to pkg_check_modules, except that no checks are needed prior to use.
-macro (libfind_pkg_check_modules PREFIX PKGNAME)
- if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
- include(UsePkgConfig)
- pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
- else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
- find_package(PkgConfig)
- if (PKG_CONFIG_FOUND)
- pkg_check_modules(${PREFIX} ${PKGNAME})
- endif (PKG_CONFIG_FOUND)
- endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
-endmacro (libfind_pkg_check_modules)
-
-# Do the final processing once the paths have been detected.
-# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
-# all the variables, each of which contain one include directory.
-# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
-# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
-# Also handles errors in case library detection was required, etc.
-macro (libfind_process PREFIX)
- # Skip processing if already processed during this run
- if (NOT ${PREFIX}_FOUND)
- # Start with the assumption that the library was found
- set (${PREFIX}_FOUND TRUE)
-
- # Process all includes and set _FOUND to false if any are missing
- foreach (i ${${PREFIX}_PROCESS_INCLUDES})
- if (${i})
- set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
- mark_as_advanced(${i})
- else (${i})
- set (${PREFIX}_FOUND FALSE)
- endif (${i})
- endforeach (i)
-
- # Process all libraries and set _FOUND to false if any are missing
- foreach (i ${${PREFIX}_PROCESS_LIBS})
- if (${i})
- set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
- mark_as_advanced(${i})
- else (${i})
- set (${PREFIX}_FOUND FALSE)
- endif (${i})
- endforeach (i)
-
- # Print message and/or exit on fatal error
- if (${PREFIX}_FOUND)
- if (NOT ${PREFIX}_FIND_QUIETLY)
- message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
- endif (NOT ${PREFIX}_FIND_QUIETLY)
- else (${PREFIX}_FOUND)
- if (${PREFIX}_FIND_REQUIRED)
- foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
- message("${i}=${${i}}")
- endforeach (i)
- message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
- endif (${PREFIX}_FIND_REQUIRED)
- endif (${PREFIX}_FOUND)
- endif (NOT ${PREFIX}_FOUND)
-endmacro (libfind_process)
-
-macro(libfind_library PREFIX basename)
- set(TMP "")
- if(MSVC80)
- set(TMP -vc80)
- endif(MSVC80)
- if(MSVC90)
- set(TMP -vc90)
- endif(MSVC90)
- set(${PREFIX}_LIBNAMES ${basename}${TMP})
- if(${ARGC} GREATER 2)
- set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
- string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
- set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
- endif(${ARGC} GREATER 2)
- find_library(${PREFIX}_LIBRARY
- NAMES ${${PREFIX}_LIBNAMES}
- PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
- )
-endmacro(libfind_library)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
deleted file mode 100644
index 5d1adf6..0000000
--- a/src/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-add_subdirectory(error)
-add_subdirectory(parameters)
-add_subdirectory(meta_net)
-add_subdirectory(irc)
-
-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/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/irc/CMakeLists.txt b/src/irc/CMakeLists.txt
deleted file mode 100644
index b037d15..0000000
--- a/src/irc/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-set(
- SRC_FILES ${SRC_FILES}
- ${CMAKE_CURRENT_SOURCE_DIR}/irc.c
- ${CMAKE_CURRENT_SOURCE_DIR}/irc_handle_connected.c
- ${CMAKE_CURRENT_SOURCE_DIR}/irc_handle_dcc_events.c
- ${CMAKE_CURRENT_SOURCE_DIR}/irc_receive.c
- ${CMAKE_CURRENT_SOURCE_DIR}/irc_select.c
- ${CMAKE_CURRENT_SOURCE_DIR}/irc_send.c
-)
-
-set(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
diff --git a/src/irc/Makefile b/src/irc/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/src/irc/Makefile
@@ -0,0 +1 @@
+../Makefile \ No newline at end of file
diff --git a/src/meta_net/CMakeLists.txt b/src/meta_net/CMakeLists.txt
deleted file mode 100644
index ca047c3..0000000
--- a/src/meta_net/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-set(
- SRC_FILES ${SRC_FILES}
- ${CMAKE_CURRENT_SOURCE_DIR}/meta_net.c
- ${CMAKE_CURRENT_SOURCE_DIR}/meta_net_handle_reply.c
- ${CMAKE_CURRENT_SOURCE_DIR}/meta_net_select.c
- ${CMAKE_CURRENT_SOURCE_DIR}/meta_net_try_request.c
-)
-
-set(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
diff --git a/src/meta_net/Makefile b/src/meta_net/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/src/meta_net/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