projects/sencrypt

changeset 12:14e58decdf87

Detect the OS and configure build flags and libraries automatically
author Guido Berhoerster <guido+sencrypt@berhoerster.name>
date Tue Sep 13 18:37:25 2016 +0200 (2016-09-13)
parents 27bc2d4947da
children 5a992d873084
files Makefile compat.h sencrypt.c
line diff
     1.1 --- a/Makefile	Tue Sep 13 18:24:21 2016 +0200
     1.2 +++ b/Makefile	Tue Sep 13 18:37:25 2016 +0200
     1.3 @@ -26,6 +26,8 @@
     1.4  DISTNAME :=	$(PACKAGE)-$(VERSION)
     1.5  DECRYPT_ALIAS =	sdecrypt
     1.6  
     1.7 +# gcc, clang, icc, Sun/Solaris Studio
     1.8 +CC :=		$(CC) -std=c99
     1.9  COMPILE.c =	$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(TARGET_ARCH) -c
    1.10  # gcc, clang, icc
    1.11  MAKEDEPEND.c =	$(CC) -MM $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS)
    1.12 @@ -65,26 +67,35 @@
    1.13  datadir ?=	$(prefix)/share
    1.14  mandir ?=	$(datadir)/man
    1.15  
    1.16 -HAVE_ERR_H ?=	1
    1.17 +OS_NAME :=	$(shell uname -s)
    1.18 +OS_RELEASE :=	$(shell uname -r)
    1.19 +
    1.20 +ifneq ($(findstring $(OS_NAME),Linux FreeBSD DragonFly NetBSD OpenBSD),)
    1.21 +  HAVE_ERR_H ?=	1
    1.22 +else ifeq ($(OS_NAME),SunOS)
    1.23 +  ifeq ($(OS_RELEASE),5.10)
    1.24 +    HAVE_ERR_H ?= 0
    1.25 +  else
    1.26 +    HAVE_ERR_H ?= 1
    1.27 +  endif
    1.28 +endif
    1.29  
    1.30  OBJS =		sencrypt.o
    1.31  MANPAGES =	$(PACKAGE).1 $(DECRYPT_ALIAS).1
    1.32  DOCBOOK5_MANPAGES_FLAGS =	--stringparam man.authors.section.enabled 0 \
    1.33  				--stringparam man.copyright.section.enabled 0
    1.34  
    1.35 -ifeq ($(HAVE_ERR_H),0)
    1.36 -  OBJS +=	err.o
    1.37 -endif
    1.38 -
    1.39  .DEFAULT_TARGET = all
    1.40  
    1.41  .PHONY: all clean clobber dist install
    1.42  
    1.43 -all: $(PACKAGE) $(MANPAGES)
    1.44 +all: $(PACKAGE) $(OBJS) $(MANPAGES)
    1.45  
    1.46 -$(PACKAGE): XCPPFLAGS :=	-DOPENSSL_LOAD_CONF
    1.47 +$(PACKAGE): XCPPFLAGS =		-D_XOPEN_SOURCE=600 -DOPENSSL_LOAD_CONF
    1.48  ifeq ($(HAVE_ERR_H),1)
    1.49 -    $(PACKAGE): XCPPFLAGS +=	-DHAVE_ERR_H
    1.50 +  $(PACKAGE): XCPPFLAGS +=	-DHAVE_ERR_H
    1.51 +else
    1.52 +  OBJS +=			err.o
    1.53  endif
    1.54  $(PACKAGE): XCFLAGS :=	$(shell getconf LFS_CFLAGS)
    1.55  $(PACKAGE): LDLIBS :=	-lcrypto
     2.1 --- a/compat.h	Tue Sep 13 18:24:21 2016 +0200
     2.2 +++ b/compat.h	Tue Sep 13 18:37:25 2016 +0200
     2.3 @@ -32,4 +32,8 @@
     2.4  #define	snprintf	_xsnprintf
     2.5  #endif /* defined(__SCO_VERSION__) && !defined(__OPENSERVER__) */
     2.6  
     2.7 +#ifndef	HAVE_ERR_H
     2.8 +#include "err.h"
     2.9 +#endif /* !HAVE_ERR_H */
    2.10 +
    2.11  #endif /* COMPAT_H */
     3.1 --- a/sencrypt.c	Tue Sep 13 18:24:21 2016 +0200
     3.2 +++ b/sencrypt.c	Tue Sep 13 18:37:25 2016 +0200
     3.3 @@ -21,8 +21,6 @@
     3.4   * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     3.5   */
     3.6  
     3.7 -#define	_XOPEN_SOURCE	600
     3.8 -
     3.9  #include <stdio.h>
    3.10  #include <string.h>
    3.11  #include <stdint.h>
    3.12 @@ -39,8 +37,6 @@
    3.13  
    3.14  #ifdef HAVE_ERR_H
    3.15  #include <err.h>
    3.16 -#else
    3.17 -#include "err.h"
    3.18  #endif /* HAVE_ERR_H */
    3.19  #include "compat.h"
    3.20