diff Makefile @ 19:1421ea50aa5c default tip

Improve build system Do not clobber CPPFLAGS, use XCPPFLAGS instead. Request POSIX:2004 headers and libraries. Specify shared libraries in the correct order.
author Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
date Tue, 13 Sep 2016 20:57:12 +0200
parents 7379cd513e6d
children
line wrap: on
line diff
--- a/Makefile	Tue Sep 13 19:57:08 2016 +0200
+++ b/Makefile	Tue Sep 13 20:57:12 2016 +0200
@@ -26,12 +26,17 @@
 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)
 # X makedepend
 #MAKEDEPEND.c =	makedepend -f- -Y -- $(CFLAGS) $(CPPFLAGS) --
+LINK.c =	$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(LDFLAGS) $(XLDFLAGS) $(TARGET_ARCH)
+LINK.o =	$(CC) $(LDFLAGS) $(XLDFLAGS) $(TARGET_ARCH)
 INSTALL :=	install
 INSTALL.exec :=	$(INSTALL) -D -m 0755
 INSTALL.data :=	$(INSTALL) -D -m 0644
@@ -39,8 +44,8 @@
 GZIP :=		gzip
 SED :=		sed
 MSGFMT :=	msgfmt
-INTLTOOL_UPDATE :=	intltool-update
-INTLTOOL_MERGE :=	intltool-merge
+INTLTOOL_UPDATE := intltool-update
+INTLTOOL_MERGE := intltool-merge
 XSLTPROC :=	xsltproc
 DOCBOOK5_MANPAGES_STYLESHEET =	http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl
 
@@ -66,31 +71,37 @@
 mandir ?=	$(datadir)/man
 localedir ?=	$(datadir)/locale
 sysconfdir ?=	/etc
-xdgautostartdir ?=	$(sysconfdir)/xdg/autostart
+xdgautostartdir ?= $(sysconfdir)/xdg/autostart
+
+OS_NAME :=	$(shell uname -s)
+OS_RELEASE :=	$(shell uname -r)
 
 HAVE_LIBXTST ?=	1
 
+$(PACKAGE): XCPPFLAGS := $(shell pkg-config --cflags glib-2.0 gtk+-2.0 unique-1.0) \
+			-D_XOPEN_SOURCE=600 \
+			-DPACKAGE="\"$(PACKAGE)\"" \
+			-DAPP_NAME=\"$(APP_NAME)\" \
+			-DVERSION=\"$(VERSION)\" \
+			-DLOCALEDIR="\"$(localedir)\"" \
+			-DG_LOG_DOMAIN=\"$(PACKAGE)\"
+$(PACKAGE): LDLIBS :=	$(shell pkg-config --libs glib-2.0 gtk+-2.0 unique-1.0)
+ifeq ($(OS_NAME),SunOS)
+  $(PACKAGE): XCPPFLAGS += -I/usr/xpg4/include
+  $(PACKAGE): XLDFLAGS += -L/usr/xpg4/lib -R/usr/xpg4/lib
+endif
 ifeq ($(HAVE_LIBXTST),1)
-    CPPFLAGS_LIBXTST :=	-DHAVE_LIBXTST
-    LDLIBS_LIBXTST :=	-lX11 -lXext -lXtst
+  $(PACKAGE): XCPPFLAGS += -DHAVE_LIBXTST
+  $(PACKAGE): LDLIBS +=	-lXtst -lXext -lX11
 endif
 
 OBJS =		main.o xia-icon.o xia-inhibitor.o xia-debug.o
 MANPAGES =	data/$(PACKAGE).1
-AUTOSTART_FILE =	data/$(PACKAGE).desktop
+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_LIBXTST) \
-		$(shell pkg-config --cflags glib-2.0 gtk+-2.0 unique-1.0) \
-		-DPACKAGE="\"$(PACKAGE)\"" \
-		-DAPP_NAME=\"$(APP_NAME)\" \
-		-DVERSION=\"$(VERSION)\" \
-		-DLOCALEDIR="\"$(localedir)\"" \
-		-DG_LOG_DOMAIN=\"$(PACKAGE)\"
-LDLIBS :=	$(LDLIBS_LIBXTST) \
-		$(shell pkg-config --libs glib-2.0 gtk+-2.0 unique-1.0)
 DOCBOOK5_MANPAGES_FLAGS =	--stringparam man.authors.section.enabled 0 \
 				--stringparam man.copyright.section.enabled 0
 
@@ -142,7 +153,8 @@
 	        "$(DESTDIR)$(mandir)/man1/$(PACKAGE).1"
 
 clean:
-	rm -f $(PACKAGE) $(OBJS) $(POTFILE) $(MOFILES) $(MANPAGES) $(AUTOSTART_FILE)
+	rm -f $(PACKAGE) $(OBJS) $(POTFILE) $(MOFILES) $(MANPAGES) \
+	    $(AUTOSTART_FILE)
 
 clobber: clean
 	rm -f $(patsubst %.o,%.d,$(OBJS))