Skip to content

Commit dc5afa3

Browse files
authored
Merge pull request #1336 from bynect/print-comp-info
Print compile-time options in `dunst --version`
2 parents 3cdd11b + 0dfeaca commit dc5afa3

File tree

7 files changed

+50
-26
lines changed

7 files changed

+50
-26
lines changed

Makefile

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,20 @@ endif
2929

3030
SYSCONF_FORCE_NEW ?= $(shell [ -f ${DESTDIR}${SYSCONFFILE} ] || echo 1)
3131

32-
CFLAGS := ${DEFAULT_CPPFLAGS} ${CPPFLAGS} ${DEFAULT_CFLAGS} ${CFLAGS} ${INCS} -MMD -MP
33-
LDFLAGS := ${DEFAULT_LDFLAGS} ${LDFLAGS} ${LIBS}
32+
ifneq (0,${DUNSTIFY})
33+
DUNSTIFY_CFLAGS := ${DEFAULT_CFLAGS} ${CFLAGS} ${CPPFLAGS} $(shell $(PKG_CONFIG) --cflags libnotify)
34+
DUNSTIFY_LDFLAGS := ${DEFAULT_LDFLAGS} ${LDFLAGS} $(shell $(PKG_CONFIG) --libs libnotify)
35+
endif
36+
37+
CPPFLAGS := ${DEFAULT_CPPFLAGS} ${CPPFLAGS}
38+
CFLAGS := ${DEFAULT_CFLAGS} ${CFLAGS} ${INCS} -MMD -MP
39+
LDFLAGS := ${DEFAULT_LDFLAGS} ${LDFLAGS} ${LIBS}
3440

3541
SRC := $(sort $(shell ${FIND} src/ ! \( -path src/wayland -prune -o -path src/x11 -prune \) -name '*.c'))
3642

3743
ifneq (0,${WAYLAND})
3844
# with Wayland support
39-
CFLAGS += -DHAVE_WL_CURSOR_SHAPE -DHAVE_WL_EXT_IDLE_NOTIFY
45+
CPPFLAGS += -DHAVE_WL_CURSOR_SHAPE -DHAVE_WL_EXT_IDLE_NOTIFY
4046
SRC += $(sort $(shell ${FIND} src/wayland -name '*.c'))
4147
endif
4248

@@ -59,25 +65,29 @@ DEPS := ${SRC:.c=.d} ${TEST_SRC:.c=.d}
5965
.PHONY: all debug
6066
all: doc dunst service
6167

62-
debug: CFLAGS += ${CPPFLAGS_DEBUG} ${CFLAGS_DEBUG}
63-
debug: LDFLAGS += ${LDFLAGS_DEBUG}
6468
debug: CPPFLAGS += ${CPPFLAGS_DEBUG}
69+
debug: CFLAGS += ${CFLAGS_DEBUG}
70+
debug: LDFLAGS += ${LDFLAGS_DEBUG}
6571
debug: all
6672

6773
-include $(DEPS)
6874

6975
${OBJ} ${TEST_OBJ}: Makefile config.mk
7076

77+
src/dunst.o: src/dunst.c
78+
${CC} -o $@ -c $< ${CPPFLAGS} ${CFLAGS} \
79+
-D_CCDATE="$(shell date '+%Y-%m-%d')" -D_CFLAGS="$(filter-out $(filter -I%,${INCS}),${CFLAGS})" -D_LDFLAGS="${LDFLAGS}"
80+
7181
%.o: %.c
72-
${CC} -o $@ -c $< ${CFLAGS}
82+
${CC} -o $@ -c $< ${CPPFLAGS} ${CFLAGS}
7383

7484
dunst: ${OBJ} main.o
7585
${CC} -o ${@} ${OBJ} main.o ${CFLAGS} ${LDFLAGS}
7686

7787
ifneq (0,${DUNSTIFY})
7888
all: dunstify
7989
dunstify: dunstify.o
80-
${CC} -o ${@} dunstify.o ${CFLAGS} ${LDFLAGS}
90+
${CC} -o ${@} dunstify.o ${DUNSTIFY_CFLAGS} ${DUNSTIFY_LDFLAGS}
8191
endif
8292

8393
.PHONY: test test-valgrind test-coverage
@@ -109,7 +119,7 @@ test-coverage-report: test-coverage
109119
-o docs/internal/coverage/index.html
110120

111121
test/%.o: test/%.c src/%.c
112-
${CC} -o $@ -c $< ${CFLAGS}
122+
${CC} -o $@ -c $< ${CFLAGS} ${CPPFLAGS}
113123

114124
test/test: ${OBJ} ${TEST_OBJ}
115125
${CC} -o ${@} ${TEST_OBJ} $(filter-out ${TEST_OBJ:test/%=src/%},${OBJ}) ${CFLAGS} ${LDFLAGS}

config.mk

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ ENABLE_X11= -DENABLE_X11
5151
endif
5252

5353
# flags
54-
DEFAULT_CPPFLAGS = -Wno-gnu-zero-variadic-macro-arguments -D_DEFAULT_SOURCE -DVERSION=\"${VERSION}\" -DSYSCONFDIR=\"${SYSCONFDIR}\"
55-
DEFAULT_CFLAGS = -g -std=gnu11 -pedantic -Wall -Wno-overlength-strings -Os ${ENABLE_WAYLAND} ${ENABLE_X11} ${EXTRA_CFLAGS}
54+
DEFAULT_CPPFLAGS = -Wno-gnu-zero-variadic-macro-arguments -D_DEFAULT_SOURCE -DVERSION=\"${VERSION}\" -DSYSCONFDIR=\"${SYSCONFDIR}\" ${ENABLE_WAYLAND} ${ENABLE_X11}
55+
DEFAULT_CFLAGS = -g -std=gnu11 -pedantic -Wall -Wno-overlength-strings -Os ${EXTRA_CFLAGS}
5656
DEFAULT_LDFLAGS = -lm -lrt
5757

5858
CPPFLAGS_DEBUG := -DDEBUG_BUILD
@@ -64,12 +64,6 @@ pkg_config_packs := gio-2.0 \
6464
"glib-2.0 >= 2.44" \
6565
pangocairo \
6666

67-
68-
ifneq (0,${DUNSTIFY})
69-
# dunstify also needs libnotify
70-
pkg_config_packs += libnotify
71-
endif
72-
7367
ifneq (0,${WAYLAND})
7468
pkg_config_packs += wayland-client
7569
pkg_config_packs += wayland-cursor

src/dunst.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,15 @@ void usage(int exit_status)
302302

303303
void print_version(void)
304304
{
305-
printf
306-
("Dunst - A customizable and lightweight notification-daemon %s\n",
307-
VERSION);
305+
printf("Dunst - A customizable and lightweight notification-daemon %s\n", VERSION);
306+
printf("Compiled on %s with the following options:\n", STR_TO(_CCDATE));
307+
308+
printf("X11 support: %s\n", X11_SUPPORT ? "enabled" : "disabled");
309+
printf("Wayland support: %s\n", WAYLAND_SUPPORT ? "enabled" : "disabled");
310+
printf("SYSCONFDIR set to: %s\n", SYSCONFDIR);
311+
312+
printf("Compiler flags: %s\n", STR_TO(_CFLAGS));
313+
printf("Linker flags: %s\n", STR_TO(_LDFLAGS));
308314
exit(EXIT_SUCCESS);
309315
}
310316

src/output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const struct output* get_wl_output(void) {
9292
const struct output* output_create(bool force_xwayland)
9393
{
9494
#ifdef ENABLE_WAYLAND
95-
if ((!force_xwayland || WAYLAND_ONLY) && is_running_wayland()) {
95+
if ((!force_xwayland || !X11_SUPPORT) && is_running_wayland()) {
9696
LOG_I("Using Wayland output");
9797
if (force_xwayland)
9898
LOG_W("Ignoring force_xwayland setting because X11 output was not compiled");

src/output.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,28 @@ struct output {
5151
double (*get_scale)(void);
5252
};
5353

54-
#ifndef ENABLE_X11
55-
#define WAYLAND_ONLY 1
56-
#ifndef ENABLE_WAYLAND
57-
#error "You have to compile at least one output (X11, Wayland)"
54+
#ifdef ENABLE_X11
55+
#define X11_SUPPORT 1
56+
#else
57+
#define X11_SUPPORT 0
5858
#endif
59+
60+
#ifdef ENABLE_WAYLAND
61+
#define WAYLAND_SUPPORT 1
5962
#else
60-
#define WAYLAND_ONLY 0
63+
#define WAYLAND_SUPPORT 0
64+
#endif
65+
66+
#if !WAYLAND_SUPPORT && !X11_SUPPORT
67+
#error "You have to compile at least one output (X11, Wayland)"
6168
#endif
6269

6370
/**
6471
* return an initialized output, selecting the correct output type from either
6572
* wayland or X11 according to the settings and environment.
6673
* When the wayland output fails to initilize, it falls back to X11 output.
74+
*
75+
* Either output is skipped if it was not compiled.
6776
*/
6877
const struct output* output_create(bool force_xwayland);
6978

src/utils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
//! Get a non null string from a possibly null one
2121
#define STR_NN(s) (s == NULL ? "(null)" : s)
2222

23+
//! Stringify the given expression or macro
24+
#define STR_TO(...) _STR_TO(__VA_ARGS__)
25+
#define _STR_TO(...) "" # __VA_ARGS__
26+
27+
2328
//! Assert that expr evaluates to true, if not return with val
2429
#define ASSERT_OR_RET(expr, val) if (!(expr)) return val;
2530

test/draw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const struct screen_info* noop_screen(void) {
1919
}
2020

2121
const struct output dummy_output = {
22-
#if WAYLAND_ONLY
22+
#if !X11_SUPPORT
2323
wl_init,
2424
wl_deinit,
2525

0 commit comments

Comments
 (0)