summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2022-02-17 19:36:01 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2022-02-17 19:36:01 +0100
commitee38065c01d1c679304d7b85a372e0264cd36aa1 (patch)
treead1e397989e099dc9460879a873163eb036587fe
parent197336db213195e015a3f301473eeb29f23a2d49 (diff)
Greatly improves compilation process.HEADmaster
-rw-r--r--.gitignore2
-rw-r--r--Makefile33
-rw-r--r--Makefile_libircclient6
-rwxr-xr-xrun.sh14
-rw-r--r--src/Makefile32
-rw-r--r--src/irc/irc.c21
-rw-r--r--src/irc/irc_handle_connected.c8
-rw-r--r--src/irc/irc_handle_dcc_events.c12
-rw-r--r--src/irc/irc_receive.c8
-rw-r--r--src/main.c2
-rw-r--r--src/meta_net/meta_net.h2
-rw-r--r--src/meta_net/meta_net_handle_reply.c5
-rw-r--r--src/meta_net/meta_net_select.c2
-rw-r--r--src/parameters/parameters.h6
-rw-r--r--src/parameters/parameters_getters.c6
15 files changed, 75 insertions, 84 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ff1cace
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+compilation_data/
+jh-irc
diff --git a/Makefile b/Makefile
index d3fca0f..6259d42 100644
--- a/Makefile
+++ b/Makefile
@@ -1,30 +1,37 @@
################################################################################
-PTHREADS_LIB_FLAGS = -pthread
LIBIRCCLIENT_LIB_FLAGS =
include Makefile_libircclient
################################################################################
CFLAGS += -O3
+CFLAGS += -Wall -Wextra -pedantic -Werror
CFLAGS += -D_POSIX_SOURCE
CFLAGS += -D_POSIX_C_SOURCE=200809L
-CFLAGS += $(PTHREADS_LIB_FLAGS)
CFLAGS += $(LIBIRCCLIENT_LIB_FLAGS)
################################################################################
-EXECUTABLE = jh-irc
-SRC_DIR = ./src
+EXECUTABLE ?= jh-irc
+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/Makefile_libircclient b/Makefile_libircclient
index a9bd80f..bd7ab29 100644
--- a/Makefile_libircclient
+++ b/Makefile_libircclient
@@ -25,7 +25,11 @@ POSSIBLE_DIR = \
/usr/lib \
/lib \
/sw/lib \
- /usr/local/lib
+ /usr/local/lib\
+ /usr/lib64 \
+ /lib64 \
+ /sw/lib64 \
+ /usr/local/lib64
TARGET_CANDIDATES = $(addsuffix /libircclient.so,$(POSSIBLE_DIR))
TARGET_FINDINGS = \
$(foreach candidate,$(TARGET_CANDIDATES),$(wildcard $(candidate)))
diff --git a/run.sh b/run.sh
new file mode 100755
index 0000000..fa15bae
--- /dev/null
+++ b/run.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+CURRENT_DIRECTORY=$(cd `dirname $0` && pwd)
+
+if [[ "$#" != "1" ]];
+then
+ echo "Expected single argument: JabberHive socket to connect to."
+ exit
+fi
+
+while true
+do
+ /my/jabberhive_backup/gateway/irc/bin2/jabberhive-irc $1 "irc.foonetic.net" "nightredbot" "#projectjen" "6667" -u "JabberHive" -r "JabberHive IRC Gateway" -c
+done
diff --git a/src/Makefile b/src/Makefile
deleted file mode 100644
index 719b8ea..0000000
--- a/src/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-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): .JUST_CHECK
- $(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 $@.$$$$
-
-.JUST_CHECK:
-
-include $(DEP_FILES)
diff --git a/src/irc/irc.c b/src/irc/irc.c
index 5d2aba4..7407ed3 100644
--- a/src/irc/irc.c
+++ b/src/irc/irc.c
@@ -115,18 +115,21 @@ int JH_irc_connect (struct JH_irc irc [const restrict static 1])
return 0;
}
-void JH_irc_finalize (struct JH_irc irc [const restrict static 1])
+void JH_irc_finalize
+(
+ __attribute__((unused)) struct JH_irc irc [const restrict static 1]
+)
{
/* TODO */
}
void JH_irc_do_nothing
(
- irc_session_t * session,
- const char * event,
- const char * origin,
- const char ** params,
- unsigned int count
+ __attribute__((unused)) irc_session_t * session,
+ __attribute__((unused)) const char * event,
+ __attribute__((unused)) const char * origin,
+ __attribute__((unused)) const char ** params,
+ __attribute__((unused)) unsigned int count
)
{
}
@@ -135,9 +138,9 @@ void JH_irc_handle_numeric_event
(
irc_session_t * session,
unsigned int event,
- const char * origin,
- const char ** params,
- unsigned int count
+ __attribute__((unused)) const char * origin,
+ __attribute__((unused)) const char ** params,
+ __attribute__((unused)) unsigned int count
)
{
struct JH_irc * irc;
diff --git a/src/irc/irc_handle_connected.c b/src/irc/irc_handle_connected.c
index b797d91..a0b8ccf 100644
--- a/src/irc/irc_handle_connected.c
+++ b/src/irc/irc_handle_connected.c
@@ -10,10 +10,10 @@
void JH_irc_handle_connected_event
(
irc_session_t * session,
- const char * event,
- const char * origin,
- const char ** params,
- unsigned int count
+ __attribute__((unused)) const char * event,
+ __attribute__((unused)) const char * origin,
+ __attribute__((unused)) const char ** params,
+ __attribute__((unused)) unsigned int count
)
{
struct JH_irc * irc;
diff --git a/src/irc/irc_handle_dcc_events.c b/src/irc/irc_handle_dcc_events.c
index 2fe6904..f78b392 100644
--- a/src/irc/irc_handle_dcc_events.c
+++ b/src/irc/irc_handle_dcc_events.c
@@ -5,8 +5,8 @@
void JH_irc_handle_dcc_chat_req_event
(
irc_session_t * session,
- const char * nick,
- const char * addr,
+ __attribute__((unused)) const char * nick,
+ __attribute__((unused)) const char * addr,
irc_dcc_t dccid
)
{
@@ -16,10 +16,10 @@ void JH_irc_handle_dcc_chat_req_event
void JH_irc_handle_dcc_send_req_event
(
irc_session_t * session,
- const char * nick,
- const char * addr,
- const char * filename,
- unsigned long size,
+ __attribute__((unused)) const char * nick,
+ __attribute__((unused)) const char * addr,
+ __attribute__((unused)) const char * filename,
+ __attribute__((unused)) unsigned long size,
irc_dcc_t dccid
)
{
diff --git a/src/irc/irc_receive.c b/src/irc/irc_receive.c
index 64804e3..aad93e2 100644
--- a/src/irc/irc_receive.c
+++ b/src/irc/irc_receive.c
@@ -12,10 +12,10 @@
void JH_irc_handle_channel_message_event
(
irc_session_t * session,
- const char * event,
+ __attribute__((unused)) const char * event,
const char * origin,
const char ** params,
- unsigned int count
+ __attribute__((unused)) unsigned int count
)
{
struct JH_irc * irc;
@@ -43,10 +43,10 @@ void JH_irc_handle_channel_message_event
void JH_irc_handle_ctcp_action_event
(
irc_session_t * session,
- const char * event,
+ __attribute__((unused)) const char * event,
const char * origin,
const char ** params,
- unsigned int count
+ __attribute__((unused)) unsigned int count
)
{
struct JH_irc * irc;
diff --git a/src/main.c b/src/main.c
index dcb8a66..103330f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -133,7 +133,6 @@ static int event_handling_loop
JH_meta_net_pre_select
(
socket,
- params,
&in_set,
&out_set,
&fd_max
@@ -212,7 +211,6 @@ static int event_handling_loop
JH_meta_net_post_select
(
socket,
- params,
&in_set,
&out_set
) < 0
diff --git a/src/meta_net/meta_net.h b/src/meta_net/meta_net.h
index 0673f74..6f51964 100644
--- a/src/meta_net/meta_net.h
+++ b/src/meta_net/meta_net.h
@@ -64,7 +64,6 @@ void JH_meta_net_handle_reply
int JH_meta_net_pre_select
(
struct JH_meta_net socket [const restrict static 1],
- const struct JH_parameters params [const restrict static 1],
fd_set in [const restrict static 1],
fd_set out [const restrict static 1],
int max_fd [const restrict static 1]
@@ -73,7 +72,6 @@ int JH_meta_net_pre_select
int JH_meta_net_post_select
(
struct JH_meta_net socket [const restrict static 1],
- const struct JH_parameters params [const restrict static 1],
fd_set in [const restrict static 1],
fd_set out [const restrict static 1]
);
diff --git a/src/meta_net/meta_net_handle_reply.c b/src/meta_net/meta_net_handle_reply.c
index 83ee654..6e2ff60 100644
--- a/src/meta_net/meta_net_handle_reply.c
+++ b/src/meta_net/meta_net_handle_reply.c
@@ -8,8 +8,7 @@
static void handle_generated_reply
(
struct JH_meta_net socket [const restrict static 1],
- struct JH_irc irc [const restrict static 1],
- const struct JH_parameters params [const restrict static 1]
+ struct JH_irc irc [const restrict static 1]
)
{
if
@@ -169,7 +168,7 @@ void JH_meta_net_handle_reply
)
)
{
- handle_generated_reply(socket, irc, params);
+ handle_generated_reply(socket, irc);
}
else if
(
diff --git a/src/meta_net/meta_net_select.c b/src/meta_net/meta_net_select.c
index f126176..7107d86 100644
--- a/src/meta_net/meta_net_select.c
+++ b/src/meta_net/meta_net_select.c
@@ -6,7 +6,6 @@
int JH_meta_net_pre_select
(
struct JH_meta_net socket [const restrict static 1],
- const struct JH_parameters params [const restrict static 1],
fd_set in [const restrict static 1],
fd_set out [const restrict static 1],
int max_fd [const restrict static 1]
@@ -30,7 +29,6 @@ int JH_meta_net_pre_select
int JH_meta_net_post_select
(
struct JH_meta_net socket [const restrict static 1],
- const struct JH_parameters params [const restrict static 1],
fd_set in [const restrict static 1],
fd_set out [const restrict static 1]
)
diff --git a/src/parameters/parameters.h b/src/parameters/parameters.h
index 14c1dc1..bf78a6b 100644
--- a/src/parameters/parameters.h
+++ b/src/parameters/parameters.h
@@ -10,17 +10,17 @@ int JH_parameters_initialize
const char * argv [const static argc]
);
-const int JH_parameters_get_request_pipelining
+int JH_parameters_get_request_pipelining
(
const struct JH_parameters param [const restrict static 1]
);
-const int JH_parameters_get_print_additional_info
+int JH_parameters_get_print_additional_info
(
const struct JH_parameters param [const restrict static 1]
);
-const int JH_parameters_get_print_chat
+int JH_parameters_get_print_chat
(
const struct JH_parameters param [const restrict static 1]
);
diff --git a/src/parameters/parameters_getters.c b/src/parameters/parameters_getters.c
index 868a059..8a7907b 100644
--- a/src/parameters/parameters_getters.c
+++ b/src/parameters/parameters_getters.c
@@ -1,6 +1,6 @@
#include "parameters.h"
-const int JH_parameters_get_request_pipelining
+int JH_parameters_get_request_pipelining
(
const struct JH_parameters param [const restrict static 1]
)
@@ -8,7 +8,7 @@ const int JH_parameters_get_request_pipelining
return param->request_pipelining;
}
-const int JH_parameters_get_print_additional_info
+int JH_parameters_get_print_additional_info
(
const struct JH_parameters param [const restrict static 1]
)
@@ -16,7 +16,7 @@ const int JH_parameters_get_print_additional_info
return param->print_additional_info;
}
-const int JH_parameters_get_print_chat
+int JH_parameters_get_print_chat
(
const struct JH_parameters param [const restrict static 1]
)