comparison Makefile @ 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
comparison
equal deleted inserted replaced
17:48caa69c609d 18:4a5330979433
1 # 1 #
2 # Copyright (C) 2011 Guido Berhoerster <guido+xwrited@berhoerster.name> 2 # Copyright (C) 2016 Guido Berhoerster <guido+xwrited@berhoerster.name>
3 # 3 #
4 # Permission is hereby granted, free of charge, to any person obtaining 4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the 5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including 6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish, 7 # without limitation the rights to use, copy, modify, merge, publish,
24 PACKAGE = xwrited 24 PACKAGE = xwrited
25 APP_NAME = org.guido-berhoerster.code.xwrited 25 APP_NAME = org.guido-berhoerster.code.xwrited
26 VERSION = 2 26 VERSION = 2
27 DISTNAME := $(PACKAGE)-$(VERSION) 27 DISTNAME := $(PACKAGE)-$(VERSION)
28 28
29 # gcc, clang, icc, Sun/Solaris Studio
30 CC := $(CC) -std=c99
31 COMPILE.c = $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(TARGET_ARCH) -c
29 # gcc, clang, icc 32 # gcc, clang, icc
30 MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(CPPFLAGS) 33 MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS)
31 # Sun/Solaris Studio 34 # Sun/Solaris Studio
32 #MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(CPPFLAGS) 35 #MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS)
33 # X makedepend 36 # X makedepend
34 #MAKEDEPEND.c = makedepend -f- -Y -- $(CFLAGS) $(CPPFLAGS) -- 37 #MAKEDEPEND.c = makedepend -f- -Y -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) --
35 INSTALL := install 38 INSTALL := install
36 INSTALL.exec := $(INSTALL) -D -m 0755 39 INSTALL.exec := $(INSTALL) -D -m 0755
37 INSTALL.data := $(INSTALL) -D -m 0644 40 INSTALL.data := $(INSTALL) -D -m 0644
38 PAX := pax 41 PAX := pax
39 GZIP := gzip 42 GZIP := gzip
70 xdgautostartdir ?= $(sysconfdir)/xdg/autostart 73 xdgautostartdir ?= $(sysconfdir)/xdg/autostart
71 74
72 OS_NAME := $(shell uname -s) 75 OS_NAME := $(shell uname -s)
73 OS_RELEASE := $(shell uname -r) 76 OS_RELEASE := $(shell uname -r)
74 77
75 is_in = $(if $(filter $2, $1),true,false) 78 ifeq ($(shell pkg-config --exists 'glib-2.0 >= 2.25.5' && printf "true"),true)
76 79 HAVE_GLIB_GDBUS = 1
77 PKGCONFIG_LIBS := dbus-1 glib-2.0 libnotify
78 EXTRA_LIBS :=
79
80 ifeq ($(OS_NAME),Linux)
81 OBJS_UTMP := xwrited-utmp-utempter.o
82 EXTRA_LIBS += -lutempter
83 else ifeq ($(OS_NAME),FreeBSD)
84 OBJS_UTMP := xwrited-utmp-utempter.o
85 FREEBSD_RELEASE_MAJOR := $(firstword $(subst ., ,$(OS_RELEASE)))
86 # FreeBSD < 9.0 needs libutempter
87 ifeq ($(call is_in, $(OS_RELEASE_MAJOR), 7 8), true)
88 EXTRA_LIBS += -lutempter
89 else
90 EXTRA_LIBS += -lulog
91 endif
92 else 80 else
93 OBJS_UTMP := xwrited-utmp-utmpx.o 81 HAVE_GLIB_GDBUS = 0
94 endif 82 endif
95 83
96 ifeq ($(shell pkg-config --exists 'glib-2.0 >= 2.25.5' && printf "true"), true) 84 PKGCONFIG_LIBS := dbus-1 glib-2.0 libnotify
97 CPPFLAGS_EXTRA := -DHAVE_GLIB_GDBUS 85 ifeq ($(HAVE_GLIB_GDBUS),1)
86 PKGCONFIG_LIBS += dbus-glib-1
87 endif
88 OBJS = main.o xwrited-debug.o xwrited-unique.o
89 ifneq ($(findstring $(OS_NAME),Linux FreeBSD),)
90 OBJS += xwrited-utmp-utempter.o
98 else 91 else
99 PKGCONFIG_LIBS += dbus-glib-1 92 OBJS += xwrited-utmp-utmpx.o
100 endif 93 endif
101
102 OBJS = main.o xwrited-debug.o xwrited-unique.o $(OBJS_UTMP)
103 MANPAGES = data/$(PACKAGE).1 94 MANPAGES = data/$(PACKAGE).1
104 AUTOSTART_FILE = data/$(PACKAGE).desktop 95 AUTOSTART_FILE = data/$(PACKAGE).desktop
105 MOFILES := $(patsubst %.po,%.mo,$(wildcard po/*.po)) 96 MOFILES := $(patsubst %.po,%.mo,$(wildcard po/*.po))
106 POTFILE = po/$(PACKAGE).pot 97 POTFILE = po/$(PACKAGE).pot
107 POSRCS := $(shell $(SED) -e 's/\#.*//' -e '/^[ \t]*$$/d' \ 98 POSRCS := $(shell $(SED) -e 's/\#.*//' -e '/^[ \t]*$$/d' \
108 -e 's/^\[[^]]*\]//' po/POTFILES.in | $(PASTE) -s -d ' ') 99 -e 's/^\[[^]]*\]//' po/POTFILES.in | $(PASTE) -s -d ' ')
109 CPPFLAGS := $(CPPFLAGS_EXTRA) \
110 $(CPPFLAGS_LIBUTEMPTER) \
111 $(shell pkg-config --cflags $(PKGCONFIG_LIBS)) \
112 -DPACKAGE="\"$(PACKAGE)\"" \
113 -DAPP_NAME=\"$(APP_NAME)\" \
114 -DVERSION=\"$(VERSION)\" \
115 -DLOCALEDIR="\"$(localedir)\"" \
116 -DG_LOG_DOMAIN=\"$(PACKAGE)\"
117 LDLIBS := $(EXTRA_LIBS) \
118 $(shell pkg-config --libs $(PKGCONFIG_LIBS))
119 DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \ 100 DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \
120 --stringparam man.copyright.section.enabled 0 101 --stringparam man.copyright.section.enabled 0
121 102
122 .DEFAULT_TARGET = all 103 .DEFAULT_TARGET = all
123 104
124 .PHONY: all clean clobber dist install 105 .PHONY: all clean clobber dist install
125 106
126 all: $(PACKAGE) $(MANPAGES) $(MOFILES) $(AUTOSTART_FILE) 107 all: $(PACKAGE) $(MANPAGES) $(MOFILES) $(AUTOSTART_FILE)
127 108
109 $(PACKAGE): CPPFLAGS := $(shell pkg-config --cflags $(PKGCONFIG_LIBS)) \
110 -D_XOPEN_SOURCE=600 \
111 -DPACKAGE="\"$(PACKAGE)\"" \
112 -DAPP_NAME=\"$(APP_NAME)\" \
113 -DVERSION=\"$(VERSION)\" \
114 -DLOCALEDIR="\"$(localedir)\"" \
115 -DG_LOG_DOMAIN=\"$(PACKAGE)\"
116 $(PACKAGE): LDLIBS := $(shell pkg-config --libs $(PKGCONFIG_LIBS))
117 ifeq ($(HAVE_GLIB_GDBUS),1)
118 $(PACKAGE): XCPPFLAGS += -DHAVE_GLIB_GDBUS
119 endif
120 ifeq ($(OS_NAME),Linux)
121 $(PACKAGE): LDLIBS += -lutempter
122 else ifeq ($(OS_NAME),FreeBSD)
123 $(PACKAGE): LDLIBS += -lulog
124 else ifeq ($(OS_NAME),SunOS)
125 $(PACKAGE): XCPPFLAGS += -I/usr/xpg4/include
126 $(PACKAGE): XLDFLAGS += -L/usr/xpg4/lib -R/usr/xpg4/lib
127 endif
128 $(PACKAGE): $(OBJS) 128 $(PACKAGE): $(OBJS)
129 $(LINK.o) $^ $(LDLIBS) -o $@ 129 $(LINK.o) $^ $(LDLIBS) -o $@
130 130
131 $(POTFILE): po/POTFILES.in $(POSRCS) 131 $(POTFILE): po/POTFILES.in $(POSRCS)
132 cd po/ && $(INTLTOOL_UPDATE) --pot --gettext-package="$(PACKAGE)" 132 cd po/ && $(INTLTOOL_UPDATE) --pot --gettext-package="$(PACKAGE)"