commit
177fc30484
@ -15,7 +15,7 @@ addons:
|
||||
dist: trusty
|
||||
sudo: false
|
||||
language: c
|
||||
script: make && make test
|
||||
script: CFLAGS=-Werror make all dunstify test
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
80
Makefile
80
Makefile
@ -3,14 +3,36 @@
|
||||
|
||||
include config.mk
|
||||
|
||||
CFLAGS += -I.
|
||||
LDFLAGS += -L.
|
||||
VERSION := "1.2.0-non-git"
|
||||
ifneq ($(wildcard ./.git/.),)
|
||||
VERSION := $(shell git describe --tags)
|
||||
endif
|
||||
|
||||
LIBS := $(shell pkg-config --libs ${pkg_config_packs})
|
||||
INCS := $(shell pkg-config --cflags ${pkg_config_packs})
|
||||
|
||||
ifneq (clean, $(MAKECMDGOALS))
|
||||
ifeq ($(and $(INCS),$(LIBS)),)
|
||||
$(error "pkg-config failed!")
|
||||
endif
|
||||
endif
|
||||
|
||||
CFLAGS += -I. ${INCS}
|
||||
LDFLAGS+= -L. ${LIBS}
|
||||
|
||||
SRC := $(sort $(shell find src/ -name '*.c'))
|
||||
OBJ := ${SRC:.c=.o}
|
||||
TEST_SRC := $(sort $(shell find test/ -name '*.c'))
|
||||
TEST_OBJ := $(TEST_SRC:.c=.o)
|
||||
|
||||
.PHONY: all debug
|
||||
all: doc dunst service
|
||||
|
||||
debug: CFLAGS += ${CFLAGS_DEBUG}
|
||||
debug: LDFLAGS += ${LDFLAGS_DEBUG}
|
||||
debug: CPPFLAGS += ${CPPFLAGS_DEBUG}
|
||||
debug: all
|
||||
|
||||
.c.o:
|
||||
${CC} -o $@ -c $< ${CFLAGS}
|
||||
|
||||
@ -19,6 +41,29 @@ ${OBJ}: config.mk
|
||||
dunst: ${OBJ} main.o
|
||||
${CC} ${CFLAGS} -o $@ ${OBJ} main.o ${LDFLAGS}
|
||||
|
||||
dunstify: dunstify.o
|
||||
${CC} ${CFLAGS} -o $@ dunstify.o ${LDFLAGS}
|
||||
|
||||
.PHONY: test
|
||||
test: test/test
|
||||
cd test && ./test
|
||||
|
||||
test/test: ${OBJ} ${TEST_OBJ}
|
||||
${CC} ${CFLAGS} -o $@ ${TEST_OBJ} ${OBJ} ${LDFLAGS}
|
||||
|
||||
.PHONY: doc
|
||||
doc: docs/dunst.1
|
||||
docs/dunst.1: docs/dunst.pod
|
||||
pod2man --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@
|
||||
|
||||
.PHONY: service
|
||||
service:
|
||||
@sed "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service
|
||||
@sed "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service
|
||||
|
||||
.PHONY: clean clean-dunst clean-dunstify clean-doc clean-tests
|
||||
clean: clean-dunst clean-dunstify clean-doc clean-tests
|
||||
|
||||
clean-dunst:
|
||||
rm -f dunst ${OBJ} main.o
|
||||
rm -f org.knopwob.dunst.service
|
||||
@ -31,15 +76,11 @@ clean-dunstify:
|
||||
clean-doc:
|
||||
rm -f docs/dunst.1
|
||||
|
||||
clean: clean-dunst clean-dunstify clean-doc test-clean
|
||||
clean-tests:
|
||||
rm -f test/test test/*.o
|
||||
|
||||
doc: docs/dunst.1
|
||||
docs/dunst.1: docs/dunst.pod
|
||||
pod2man --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@
|
||||
|
||||
service:
|
||||
@sed "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service
|
||||
@sed "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service
|
||||
.PHONY: install install-dunst install-doc install-service uninstall
|
||||
install: install-dunst install-doc install-service
|
||||
|
||||
install-dunst: dunst doc
|
||||
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||
@ -56,28 +97,9 @@ install-service: service
|
||||
install -m644 org.knopwob.dunst.service ${DESTDIR}${PREFIX}/share/dbus-1/services
|
||||
install -Dm644 dunst.systemd.service ${DESTDIR}${PREFIX}/lib/systemd/user/dunst.service
|
||||
|
||||
install: install-dunst install-doc install-service
|
||||
|
||||
uninstall:
|
||||
rm -f ${DESTDIR}${PREFIX}/bin/dunst
|
||||
rm -f ${DESTDIR}${MANPREFIX}/man1/dunst.1
|
||||
rm -f ${DESTDIR}${PREFIX}/share/dbus-1/services/org.knopwob.dunst.service
|
||||
rm -f ${DESTDIR}${PREFIX}/lib/systemd/user/dunst.service
|
||||
rm -rf ${DESTDIR}${PREFIX}/share/dunst
|
||||
|
||||
test: test/test
|
||||
cd test && ./test
|
||||
|
||||
TEST_SRC := $(shell find test/ -name '*.c')
|
||||
TEST_OBJ := $(TEST_SRC:.c=.o)
|
||||
|
||||
test/test: ${OBJ} ${TEST_OBJ}
|
||||
${CC} ${CFLAGS} -o $@ ${TEST_OBJ} ${OBJ} ${LDFLAGS}
|
||||
|
||||
test-clean:
|
||||
rm -f test/test test/*.o
|
||||
|
||||
dunstify: dunstify.o
|
||||
${CC} ${CFLAGS} -o $@ dunstify.o $(shell pkg-config --libs --cflags glib-2.0 libnotify gdk-3.0)
|
||||
|
||||
.PHONY: all clean dist install uninstall
|
||||
|
43
config.mk
43
config.mk
@ -2,28 +2,28 @@
|
||||
PREFIX ?= /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
||||
VERSION := "1.2.0-non-git"
|
||||
ifneq ($(wildcard ./.git/.),)
|
||||
VERSION := $(shell git describe --tags)
|
||||
endif
|
||||
|
||||
# Warning: This is deprecated behavior
|
||||
# uncomment to disable parsing of dunstrc
|
||||
# or use "CFLAGS=-DSTATIC_CONFIG make" to build
|
||||
#STATIC= -DSTATIC_CONFIG
|
||||
|
||||
PKG_CONFIG:=$(shell which pkg-config)
|
||||
ifeq (${PKG_CONFIG}, ${EMPTY})
|
||||
$(error "Failed to find pkg-config, please make sure it is installed")
|
||||
endif
|
||||
#STATIC= -DSTATIC_CONFIG # Warning: This is deprecated behavior
|
||||
|
||||
# flags
|
||||
CPPFLAGS += -D_DEFAULT_SOURCE -DVERSION=\"${VERSION}\"
|
||||
CFLAGS += -g --std=gnu99 -pedantic -Wall -Wno-overlength-strings -Os ${STATIC} ${CPPFLAGS}
|
||||
LDFLAGS += -lm -L${X11LIB}
|
||||
|
||||
pkg_config_packs := dbus-1 x11 xscrnsaver \
|
||||
"glib-2.0 >= 2.36" gio-2.0 \
|
||||
pangocairo gdk-3.0 xrandr xinerama
|
||||
CPPFLAGS_DEBUG := -DDEBUG_BUILD
|
||||
CFLAGS_DEBUG := -O0
|
||||
LDFLAGS_DEBUG :=
|
||||
|
||||
pkg_config_packs := dbus-1 \
|
||||
gio-2.0 \
|
||||
gdk-3.0 \
|
||||
"glib-2.0 >= 2.36" \
|
||||
pangocairo \
|
||||
x11 \
|
||||
xinerama \
|
||||
xrandr \
|
||||
xscrnsaver
|
||||
|
||||
# check if we need libxdg-basedir
|
||||
ifeq (,$(findstring STATIC_CONFIG,$(CFLAGS)))
|
||||
@ -32,14 +32,7 @@ else
|
||||
$(warning STATIC_CONFIG is deprecated behavior. It will get removed in future releases)
|
||||
endif
|
||||
|
||||
# includes and libs
|
||||
INCS := $(shell ${PKG_CONFIG} --cflags ${pkg_config_packs})
|
||||
CFLAGS += ${INCS}
|
||||
LDFLAGS += -lm -L${X11LIB} -lXss $(shell ${PKG_CONFIG} --libs ${pkg_config_packs})
|
||||
|
||||
# only make this an fatal error when where not cleaning
|
||||
ifneq (clean, $(MAKECMDGOALS))
|
||||
ifeq (${INCS}, ${EMPTY})
|
||||
$(error "pkg-config failed, see errors above")
|
||||
endif
|
||||
# dunstify also needs libnotify
|
||||
ifneq (,$(findstring dunstify,${MAKECMDGOALS}))
|
||||
pkg_config_packs += libnotify
|
||||
endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user