Mercurial > projects > sencrypt
changeset 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 |
files | Makefile compat.h sencrypt.c |
diffstat | 3 files changed, 23 insertions(+), 12 deletions(-) [+] |
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
--- 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 */
--- 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 <stdio.h> #include <string.h> #include <stdint.h> @@ -39,8 +37,6 @@ #ifdef HAVE_ERR_H #include <err.h> -#else -#include "err.h" #endif /* HAVE_ERR_H */ #include "compat.h"