Mercurial > projects > xwrited
changeset 18:4a5330979433
Modernize and improve build system
Do not clobber CPPFLAGS, use XCPPFLAGS instead.
Request POSIX:2004 headers and libraries.
Remove support for FreeBSD < 9.
Add support for DragonFly BSD.
author | Guido Berhoerster <guido+xwrited@berhoerster.name> |
---|---|
date | Wed, 14 Sep 2016 09:46:59 +0200 |
parents | 48caa69c609d |
children | f0accfc74f7b |
files | Makefile README main.c xwrited-debug.c xwrited-unique.c xwrited-utmp-utempter.c xwrited-utmp-utmpx.c |
diffstat | 7 files changed, 41 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Tue Sep 13 20:59:33 2016 +0200 +++ b/Makefile Wed Sep 14 09:46:59 2016 +0200 @@ -1,5 +1,5 @@ # -# Copyright (C) 2011 Guido Berhoerster <guido+xwrited@berhoerster.name> +# Copyright (C) 2016 Guido Berhoerster <guido+xwrited@berhoerster.name> # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -26,12 +26,15 @@ VERSION = 2 DISTNAME := $(PACKAGE)-$(VERSION) +# gcc, clang, icc, Sun/Solaris Studio +CC := $(CC) -std=c99 +COMPILE.c = $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(TARGET_ARCH) -c # gcc, clang, icc -MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(CPPFLAGS) +MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) # Sun/Solaris Studio -#MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(CPPFLAGS) +#MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) # X makedepend -#MAKEDEPEND.c = makedepend -f- -Y -- $(CFLAGS) $(CPPFLAGS) -- +#MAKEDEPEND.c = makedepend -f- -Y -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) -- INSTALL := install INSTALL.exec := $(INSTALL) -D -m 0755 INSTALL.data := $(INSTALL) -D -m 0644 @@ -72,50 +75,28 @@ OS_NAME := $(shell uname -s) OS_RELEASE := $(shell uname -r) -is_in = $(if $(filter $2, $1),true,false) - -PKGCONFIG_LIBS := dbus-1 glib-2.0 libnotify -EXTRA_LIBS := - -ifeq ($(OS_NAME),Linux) - OBJS_UTMP := xwrited-utmp-utempter.o - EXTRA_LIBS += -lutempter -else ifeq ($(OS_NAME),FreeBSD) - OBJS_UTMP := xwrited-utmp-utempter.o - FREEBSD_RELEASE_MAJOR := $(firstword $(subst ., ,$(OS_RELEASE))) - # FreeBSD < 9.0 needs libutempter - ifeq ($(call is_in, $(OS_RELEASE_MAJOR), 7 8), true) - EXTRA_LIBS += -lutempter - else - EXTRA_LIBS += -lulog - endif +ifeq ($(shell pkg-config --exists 'glib-2.0 >= 2.25.5' && printf "true"),true) + HAVE_GLIB_GDBUS = 1 else - OBJS_UTMP := xwrited-utmp-utmpx.o + HAVE_GLIB_GDBUS = 0 endif -ifeq ($(shell pkg-config --exists 'glib-2.0 >= 2.25.5' && printf "true"), true) - CPPFLAGS_EXTRA := -DHAVE_GLIB_GDBUS +PKGCONFIG_LIBS := dbus-1 glib-2.0 libnotify +ifeq ($(HAVE_GLIB_GDBUS),1) + PKGCONFIG_LIBS += dbus-glib-1 +endif +OBJS = main.o xwrited-debug.o xwrited-unique.o +ifneq ($(findstring $(OS_NAME),Linux FreeBSD),) + OBJS += xwrited-utmp-utempter.o else - PKGCONFIG_LIBS += dbus-glib-1 + OBJS += xwrited-utmp-utmpx.o endif - -OBJS = main.o xwrited-debug.o xwrited-unique.o $(OBJS_UTMP) MANPAGES = data/$(PACKAGE).1 AUTOSTART_FILE = data/$(PACKAGE).desktop MOFILES := $(patsubst %.po,%.mo,$(wildcard po/*.po)) POTFILE = po/$(PACKAGE).pot POSRCS := $(shell $(SED) -e 's/\#.*//' -e '/^[ \t]*$$/d' \ -e 's/^\[[^]]*\]//' po/POTFILES.in | $(PASTE) -s -d ' ') -CPPFLAGS := $(CPPFLAGS_EXTRA) \ - $(CPPFLAGS_LIBUTEMPTER) \ - $(shell pkg-config --cflags $(PKGCONFIG_LIBS)) \ - -DPACKAGE="\"$(PACKAGE)\"" \ - -DAPP_NAME=\"$(APP_NAME)\" \ - -DVERSION=\"$(VERSION)\" \ - -DLOCALEDIR="\"$(localedir)\"" \ - -DG_LOG_DOMAIN=\"$(PACKAGE)\" -LDLIBS := $(EXTRA_LIBS) \ - $(shell pkg-config --libs $(PKGCONFIG_LIBS)) DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \ --stringparam man.copyright.section.enabled 0 @@ -125,6 +106,25 @@ all: $(PACKAGE) $(MANPAGES) $(MOFILES) $(AUTOSTART_FILE) +$(PACKAGE): CPPFLAGS := $(shell pkg-config --cflags $(PKGCONFIG_LIBS)) \ + -D_XOPEN_SOURCE=600 \ + -DPACKAGE="\"$(PACKAGE)\"" \ + -DAPP_NAME=\"$(APP_NAME)\" \ + -DVERSION=\"$(VERSION)\" \ + -DLOCALEDIR="\"$(localedir)\"" \ + -DG_LOG_DOMAIN=\"$(PACKAGE)\" +$(PACKAGE): LDLIBS := $(shell pkg-config --libs $(PKGCONFIG_LIBS)) +ifeq ($(HAVE_GLIB_GDBUS),1) + $(PACKAGE): XCPPFLAGS += -DHAVE_GLIB_GDBUS +endif +ifeq ($(OS_NAME),Linux) + $(PACKAGE): LDLIBS += -lutempter +else ifeq ($(OS_NAME),FreeBSD) + $(PACKAGE): LDLIBS += -lulog +else ifeq ($(OS_NAME),SunOS) + $(PACKAGE): XCPPFLAGS += -I/usr/xpg4/include + $(PACKAGE): XLDFLAGS += -L/usr/xpg4/lib -R/usr/xpg4/lib +endif $(PACKAGE): $(OBJS) $(LINK.o) $^ $(LDLIBS) -o $@
--- a/README Tue Sep 13 20:59:33 2016 +0200 +++ b/README Wed Sep 14 09:46:59 2016 +0200 @@ -10,7 +10,7 @@ ------------------ xwrited requires a POSIX:2004 compatible operating system, it has been tested -to work on Linux distributions, FreeBSD, NetBSD, and Solaris and +to work on Linux distributions, FreeBSD, DragonFly BSD, NetBSD, and Solaris and Illumos-derived distributions. The following tools and shared libraries are required to build xwrited: @@ -18,7 +18,7 @@ - GNU or BSD install - GLib version 2.26 or later - the D-Bus GLib bindings for GLib < 2.25.5 -- libutempter on Linux and FreeBSD < 9.0 +- libutempter on Linux Rebuilding the man pages additionally requires the xsltproc tool from libxml2.
--- a/main.c Tue Sep 13 20:59:33 2016 +0200 +++ b/main.c Wed Sep 14 09:46:59 2016 +0200 @@ -21,8 +21,6 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define _XOPEN_SOURCE 600 - #include <stdio.h> #include <stdlib.h> #include <string.h>
--- a/xwrited-debug.c Tue Sep 13 20:59:33 2016 +0200 +++ b/xwrited-debug.c Wed Sep 14 09:46:59 2016 +0200 @@ -21,8 +21,6 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define _XOPEN_SOURCE 600 - #include <string.h> #include <stdarg.h> #include <glib.h>
--- a/xwrited-unique.c Tue Sep 13 20:59:33 2016 +0200 +++ b/xwrited-unique.c Wed Sep 14 09:46:59 2016 +0200 @@ -21,8 +21,6 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define _XOPEN_SOURCE 600 - #include <glib.h> #ifdef HAVE_GLIB_GDBUS #include <gio/gio.h>
--- a/xwrited-utmp-utempter.c Tue Sep 13 20:59:33 2016 +0200 +++ b/xwrited-utmp-utempter.c Wed Sep 14 09:46:59 2016 +0200 @@ -21,8 +21,6 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define _XOPEN_SOURCE 600 - #include <stdlib.h> #include <utempter.h>
--- a/xwrited-utmp-utmpx.c Tue Sep 13 20:59:33 2016 +0200 +++ b/xwrited-utmp-utmpx.c Wed Sep 14 09:46:59 2016 +0200 @@ -21,8 +21,6 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define _XOPEN_SOURCE 600 - #include <glib.h> #include <stdlib.h> #include <string.h> @@ -32,7 +30,9 @@ #include <errno.h> #include <sys/time.h> +#ifndef DEV_PREFIX #define DEV_PREFIX "/dev/" +#endif /* !DEV_PREFIX */ static void utmp_write_entry(int fd, gboolean add)