diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | compile_flags.txt | 2 | ||||
| -rw-r--r-- | config.h.in | 39 | ||||
| -rw-r--r-- | config.mk | 2 | ||||
| -rw-r--r-- | makefile | 4 | ||||
| -rw-r--r-- | src/main.c | 1 |
6 files changed, 37 insertions, 13 deletions
| @@ -1,3 +1,3 @@ | |||
| 1 | bin/ | 1 | bin/ |
| 2 | obj/ | 2 | obj/ |
| 3 | include/config.h | 3 | 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 @@ | |||
| 5 | -Wdouble-promotion | 5 | -Wdouble-promotion |
| 6 | -pedantic | 6 | -pedantic |
| 7 | -std=c17 | 7 | -std=c17 |
| 8 | -Iinclude | 8 | -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 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | 2 | ||
| 3 | #define CLIENT_ID "my-client-id" | 3 | #ifndef CLIENT_ID |
| 4 | #define HOST "localhost" | 4 | # define CLIENT_ID "my-client-id" |
| 5 | #define PORT 1883 | 5 | #endif |
| 6 | #define USERNAME "user" | 6 | |
| 7 | #define PASSWORD "password" | 7 | #ifndef HOST |
| 8 | #define TOPIC "topic" | 8 | # define HOST "localhost" |
| 9 | #define KEEPALIVE 10 | 9 | #endif |
| 10 | #define WAIT_UNTIL_RECONNECT 10 | 10 | |
| 11 | #ifndef PORT | ||
| 12 | # define PORT 1883 | ||
| 13 | #endif | ||
| 14 | |||
| 15 | #ifndef USERNAME | ||
| 16 | # define USERNAME "user" | ||
| 17 | #endif | ||
| 18 | |||
| 19 | #ifndef PASSWORD | ||
| 20 | # define PASSWORD "password" | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #ifndef TOPIC | ||
| 24 | # define TOPIC "topic" | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #ifndef KEEPALIVE | ||
| 28 | # define KEEPALIVE 10 | ||
| 29 | #endif | ||
| 30 | |||
| 31 | #ifndef WAIT_UNTIL_RECONNECT | ||
| 32 | # define WAIT_UNTIL_RECONNECT 10 | ||
| 33 | #endif | ||
| @@ -1,2 +1,2 @@ | |||
| 1 | CFLAGS=-Wall -Werror -Wextra -Wconversion -Wdouble-promotion -pedantic -std=c17 -Iinclude | 1 | CFLAGS=-Wall -Werror -Wextra -Wconversion -Wdouble-promotion -pedantic -std=c17 -Isrc |
| 2 | LDFLAGS=-lmosquitto | 2 | LDFLAGS=-lmosquitto |
| @@ -14,10 +14,10 @@ debug: CFLAGS+=-g | |||
| 14 | $(BINARY): $(OBJ_FILES) | bin | 14 | $(BINARY): $(OBJ_FILES) | bin |
| 15 | cc $(LDFLAGS) $^ -o $@ | 15 | cc $(LDFLAGS) $^ -o $@ |
| 16 | 16 | ||
| 17 | obj/%.o: src/%.c include/config.h | obj | 17 | obj/%.o: src/%.c src/config.h | obj |
| 18 | cc $(CFLAGS) -c $< -o $@ | 18 | cc $(CFLAGS) -c $< -o $@ |
| 19 | 19 | ||
| 20 | include/config.h: | 20 | src/config.h: |
| 21 | cp config.h.in $@ | 21 | cp config.h.in $@ |
| 22 | 22 | ||
| 23 | bin obj: | 23 | bin obj: |
| @@ -9,6 +9,7 @@ | |||
| 9 | 9 | ||
| 10 | // Project | 10 | // Project |
| 11 | #include <mosquitto.h> | 11 | #include <mosquitto.h> |
| 12 | |||
| 12 | #include "config.h" | 13 | #include "config.h" |
| 13 | 14 | ||
| 14 | #ifndef UNUSED | 15 | #ifndef UNUSED |
