# HG changeset patch # User Guido Berhoerster # Date 1473784645 -7200 # Node ID 14e58decdf8777b4043ac9a6ddf3a4ca72055f01 # Parent 27bc2d4947da5f393c75cd6c735f446637c6b54a Detect the OS and configure build flags and libraries automatically diff -r 27bc2d4947da -r 14e58decdf87 Makefile --- 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 diff -r 27bc2d4947da -r 14e58decdf87 compat.h --- a/compat.h Tue Sep 13 18:24:21 2016 +0200 +++ b/compat.h Tue Sep 13 18:37:25 2016 +0200 @@ -32,4 +32,8 @@ #define snprintf _xsnprintf #endif /* defined(__SCO_VERSION__) && !defined(__OPENSERVER__) */ +#ifndef HAVE_ERR_H +#include "err.h" +#endif /* !HAVE_ERR_H */ + #endif /* COMPAT_H */ diff -r 27bc2d4947da -r 14e58decdf87 sencrypt.c --- a/sencrypt.c Tue Sep 13 18:24:21 2016 +0200 +++ b/sencrypt.c Tue Sep 13 18:37:25 2016 +0200 @@ -21,8 +21,6 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define _XOPEN_SOURCE 600 - #include #include #include @@ -39,8 +37,6 @@ #ifdef HAVE_ERR_H #include -#else -#include "err.h" #endif /* HAVE_ERR_H */ #include "compat.h"