diff Makefile @ 12:14e58decdf87

Detect the OS and configure build flags and libraries automatically
author Guido Berhoerster <guido+sencrypt@berhoerster.name>
date Tue, 13 Sep 2016 18:37:25 +0200
parents 27bc2d4947da
children 5a992d873084
line wrap: on
line diff
--- a/Makefile	Tue Sep 13 18:24:21 2016 +0200
+++ b/Makefile	Tue Sep 13 18:37:25 2016 +0200
@@ -26,6 +26,8 @@
 DISTNAME :=	$(PACKAGE)-$(VERSION)
 DECRYPT_ALIAS =	sdecrypt
 
+# 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) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS)
@@ -65,26 +67,35 @@
 datadir ?=	$(prefix)/share
 mandir ?=	$(datadir)/man
 
-HAVE_ERR_H ?=	1
+OS_NAME :=	$(shell uname -s)
+OS_RELEASE :=	$(shell uname -r)
+
+ifneq ($(findstring $(OS_NAME),Linux FreeBSD DragonFly NetBSD OpenBSD),)
+  HAVE_ERR_H ?=	1
+else ifeq ($(OS_NAME),SunOS)
+  ifeq ($(OS_RELEASE),5.10)
+    HAVE_ERR_H ?= 0
+  else
+    HAVE_ERR_H ?= 1
+  endif
+endif
 
 OBJS =		sencrypt.o
 MANPAGES =	$(PACKAGE).1 $(DECRYPT_ALIAS).1
 DOCBOOK5_MANPAGES_FLAGS =	--stringparam man.authors.section.enabled 0 \
 				--stringparam man.copyright.section.enabled 0
 
-ifeq ($(HAVE_ERR_H),0)
-  OBJS +=	err.o
-endif
-
 .DEFAULT_TARGET = all
 
 .PHONY: all clean clobber dist install
 
-all: $(PACKAGE) $(MANPAGES)
+all: $(PACKAGE) $(OBJS) $(MANPAGES)
 
-$(PACKAGE): XCPPFLAGS :=	-DOPENSSL_LOAD_CONF
+$(PACKAGE): XCPPFLAGS =		-D_XOPEN_SOURCE=600 -DOPENSSL_LOAD_CONF
 ifeq ($(HAVE_ERR_H),1)
-    $(PACKAGE): XCPPFLAGS +=	-DHAVE_ERR_H
+  $(PACKAGE): XCPPFLAGS +=	-DHAVE_ERR_H
+else
+  OBJS +=			err.o
 endif
 $(PACKAGE): XCFLAGS :=	$(shell getconf LFS_CFLAGS)
 $(PACKAGE): LDLIBS :=	-lcrypto