diff Makefile @ 12:8768fbd09bc5

Add generatepassword command to generate random passwords Refactor and generalize handling of named arguments.
author Guido Berhoerster <guido+pwm@berhoerster.name>
date Thu, 03 Aug 2017 10:22:07 +0200
parents 25e227eba3da
children a08ef0674d8e
line wrap: on
line diff
--- a/Makefile	Mon Jul 31 09:20:21 2017 +0200
+++ b/Makefile	Thu Aug 03 10:22:07 2017 +0200
@@ -77,49 +77,64 @@
 OS_RELEASE :=	$(shell uname -r)
 
 ifeq ($(OS_NAME),Linux)
+  HAVE_ARC4RANDOM ?=	0
   HAVE_ASPRINTF ?=	1
   HAVE_ERR_H ?=		1
+  HAVE_GETRANDOM ?=	0
   HAVE_READPASSPHRASE_H ?= 0
   HAVE_SETPROGNAME ?=	0
   HAVE_SYS_TREE_H ?=	0
 else ifneq ($(findstring $(OS_NAME),FreeBSD DragonFly),)
+  HAVE_ARC4RANDOM ?=	1
   HAVE_ASPRINTF ?=	1
   HAVE_ERR_H ?=		1
+  HAVE_GETRANDOM ?=	0
   HAVE_READPASSPHRASE_H ?= 1
   HAVE_SETPROGNAME ?=	1
   HAVE_SYS_TREE_H ?=	1
 else ifeq ($(OS_NAME),NetBSD)
+  HAVE_ARC4RANDOM ?=	1
   HAVE_ASPRINTF ?=	1
   HAVE_ERR_H ?=		1
+  HAVE_GETRANDOM ?=	0
   HAVE_READPASSPHRASE_H ?= 0
   HAVE_SYS_TREE_H ?=	1
   HAVE_SETPROGNAME ?=	1
 else ifeq ($(OS_NAME),OpenBSD)
+  HAVE_ARC4RANDOM ?=	1
   HAVE_ASPRINTF ?=	1
   HAVE_ERR_H ?=		1
+  HAVE_GETRANDOM ?=	0
   HAVE_READPASSPHRASE_H ?= 1
   HAVE_SYS_TREE_H ?=	1
   HAVE_SETPROGNAME ?=	1
 else ifeq ($(OS_NAME),SunOS)
   ifeq ($(OS_RELEASE),5.10)
+    HAVE_ARC4RANDOM ?=	0
     HAVE_ASPRINTF ?=	0
     HAVE_ERR_H ?=	0
+    HAVE_GETRANDOM ?=	0
   else
+    HAVE_ARC4RANDOM ?=	1
     HAVE_ASPRINTF ?=	1
     HAVE_ERR_H ?=	1
+    HAVE_GETRANDOM ?=	1
   endif
   HAVE_READPASSPHRASE_H ?= 0
   HAVE_SYS_TREE_H ?=	0
   HAVE_SETPROGNAME ?=	0
 else
+  HAVE_ARC4RANDOM ?=	0
   HAVE_ASPRINTF ?=	0
   HAVE_ERR_H ?=		0
+  HAVE_GETRANDOM ?=	0
   HAVE_READPASSPHRASE_H ?= 0
   HAVE_SETPROGNAME ?=	0
   HAVE_SYS_TREE_H ?=	0
 endif
 
 OBJS =	cmd.o \
+	pw.o \
 	pwfile.o \
 	pwm.o \
 	tok.o \
@@ -141,6 +156,15 @@
 else
   OBJS +=	compat/asprintf.o
 endif
+ifeq ($(HAVE_ARC4RANDOM),1)
+  XCPPFLAGS +=	-DHAVE_ARC4RANDOM
+  OBJS +=	rand-arc4random.o
+else ifeq ($(HAVE_GETRANDOM),1)
+  XCPPFLAGS +=	-DHAVE_GETRANDOM
+  OBJS +=	rand-getrandom.o
+else
+  OBJS +=	rand-dev-random.o
+endif
 ifeq ($(HAVE_ERR_H),1)
   XCPPFLAGS +=	-DHAVE_ERR_H
 else