From 2458e6aa1658b2cc5b6349b89f1276873554ad6f Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Mon, 28 Oct 2024 18:03:34 +0100 Subject: Verschiebe die Konfiguration nach 'src' --- .gitignore | 2 +- compile_flags.txt | 2 +- config.h.in | 39 +++++++++++++++++++++++++++++++-------- config.mk | 2 +- makefile | 4 ++-- src/main.c | 1 + 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index fa770c6..bc22094 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ bin/ obj/ -include/config.h +src/config.h diff --git a/compile_flags.txt b/compile_flags.txt index 8e3330c..255b429 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -5,4 +5,4 @@ -Wdouble-promotion -pedantic -std=c17 --Iinclude +-Isrc diff --git a/config.h.in b/config.h.in index a622aad..0cf0d70 100644 --- a/config.h.in +++ b/config.h.in @@ -1,10 +1,33 @@ #pragma once -#define CLIENT_ID "my-client-id" -#define HOST "localhost" -#define PORT 1883 -#define USERNAME "user" -#define PASSWORD "password" -#define TOPIC "topic" -#define KEEPALIVE 10 -#define WAIT_UNTIL_RECONNECT 10 +#ifndef CLIENT_ID +# define CLIENT_ID "my-client-id" +#endif + +#ifndef HOST +# define HOST "localhost" +#endif + +#ifndef PORT +# define PORT 1883 +#endif + +#ifndef USERNAME +# define USERNAME "user" +#endif + +#ifndef PASSWORD +# define PASSWORD "password" +#endif + +#ifndef TOPIC +# define TOPIC "topic" +#endif + +#ifndef KEEPALIVE +# define KEEPALIVE 10 +#endif + +#ifndef WAIT_UNTIL_RECONNECT +# define WAIT_UNTIL_RECONNECT 10 +#endif diff --git a/config.mk b/config.mk index 8ca0709..d733c58 100644 --- a/config.mk +++ b/config.mk @@ -1,2 +1,2 @@ -CFLAGS=-Wall -Werror -Wextra -Wconversion -Wdouble-promotion -pedantic -std=c17 -Iinclude +CFLAGS=-Wall -Werror -Wextra -Wconversion -Wdouble-promotion -pedantic -std=c17 -Isrc LDFLAGS=-lmosquitto diff --git a/makefile b/makefile index 536bcd2..2365415 100644 --- a/makefile +++ b/makefile @@ -14,10 +14,10 @@ debug: CFLAGS+=-g $(BINARY): $(OBJ_FILES) | bin cc $(LDFLAGS) $^ -o $@ -obj/%.o: src/%.c include/config.h | obj +obj/%.o: src/%.c src/config.h | obj cc $(CFLAGS) -c $< -o $@ -include/config.h: +src/config.h: cp config.h.in $@ bin obj: diff --git a/src/main.c b/src/main.c index 16deb68..a181171 100644 --- a/src/main.c +++ b/src/main.c @@ -9,6 +9,7 @@ // Project #include + #include "config.h" #ifndef UNUSED -- cgit v1.3