From ebfc13ea80b4797a8dd80e58e181d3fb80874e2a Mon Sep 17 00:00:00 2001
From: begasus <begasus@gmail.com>
Date: Sat, 15 Jun 2019 08:04:54 +0200
Subject: Add manpage install, add Haiku to the platform


diff --git a/Makefile b/Makefile
index 837e7f7..d973681 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,7 @@ RUN = argon2
 BENCH = bench
 GENKAT = genkat
 ARGON2_VERSION ?= ZERO
+MAN = man/argon2.1
 
 # installation parameters for staging area and final installation path
 # Note; if Linux and not Debian/Ubuntu version also add lib override to make command-line
@@ -40,10 +41,12 @@ OBJ = $(SRC:.c=.o)
 CFLAGS += -std=c89 -O3 -Wall -g -Iinclude -Isrc
 
 ifeq ($(NO_THREADS), 1)
+ifeq ($(KERNEL_NAME), Haiku)
 CFLAGS += -DARGON2_NO_THREADS
 else
 CFLAGS += -pthread
 endif
+endif
 
 CI_CFLAGS := $(CFLAGS) -Werror=declaration-after-statement -D_FORTIFY_SOURCE=2 \
 				-Wextra -Wno-type-limits -Werror -coverage -DTEST_LARGE_RAM
@@ -109,6 +112,13 @@ ifeq ($(KERNEL_NAME), SunOS)
 	LIB_CFLAGS := -shared -fPIC
 	PC_EXTRA_LIBS ?=
 endif
+ifeq ($(KERNEL_NAME), Haiku)
+	LIB_EXT := so.$(ABI_VERSION)
+	LIB_CFLAGS := -shared -fPIC -DA2_VISCTL=1
+	SO_LDFLAGS := -Wl,-soname,lib$(LIB_NAME).$(LIB_EXT)
+	LINKED_LIB_EXT := so
+	PC_EXTRA_LIBS ?=
+endif
 
 ifeq ($(KERNEL_NAME), Linux)
 ifeq ($(CC), clang)
@@ -136,6 +146,7 @@ ifeq ($(KERNEL_NAME), $(filter $(KERNEL_NAME),DragonFly FreeBSD))
 BINARY_REL ?= bin
 INCLUDE_REL ?= include
 LIBRARY_REL ?= lib
+MAN_REL ?= man/man1
 PKGCONFIG_REL ?= libdata
 
 else ifeq ($(KERNEL_NAME)-$(MACHINE_NAME), Linux-x86_64)
@@ -144,6 +155,16 @@ else ifeq ($(KERNEL_NAME)-$(MACHINE_NAME), Linux-x86_64)
 BINARY_REL ?= bin
 INCLUDE_REL ?= include
 LIBRARY_REL ?= lib/x86_64-linux-gnu
+MAN_REL ?= man/man1
+PKGCONFIG_REL ?= $(LIBRARY_REL)
+
+else ifeq ($(KERNEL_NAME), Haiku)
+
+# default for Haiku
+BINARY_REL ?= bin
+INCLUDE_REL ?= develop/headers
+LIBRARY_REL ?= lib
+MAN_REL ?= documentation/man/man1
 PKGCONFIG_REL ?= $(LIBRARY_REL)
 
 else
@@ -152,6 +173,7 @@ else
 BINARY_REL ?= bin
 INCLUDE_REL ?= include
 LIBRARY_REL ?= lib
+MAN_REL ?= man/man1
 PKGCONFIG_REL ?= $(LIBRARY_REL)
 
 endif
@@ -160,6 +182,7 @@ endif
 INST_INCLUDE = $(DESTDIR)$(PREFIX)/$(INCLUDE_REL)
 INST_LIBRARY = $(DESTDIR)$(PREFIX)/$(LIBRARY_REL)
 INST_BINARY = $(DESTDIR)$(PREFIX)/$(BINARY_REL)
+INST_MAN = $(DESTDIR)$(PREFIX)/$(MAN_REL)
 INST_PKGCONFIG = $(DESTDIR)$(PREFIX)/$(PKGCONFIG_REL)/pkgconfig
 
 # main target
@@ -242,6 +265,8 @@ ifdef LINKED_LIB_SH
 endif
 	$(INSTALL) -d $(INST_BINARY)
 	$(INSTALL) $(RUN) $(INST_BINARY)
+	$(INSTALL) -d $(INST_MAN)
+	$(INSTALL) -m 0644 $(MAN) $(INST_MAN)
 	$(INSTALL) -d $(INST_PKGCONFIG)
 	$(INSTALL) -m 0644 $(PC_NAME) $(INST_PKGCONFIG)
 
@@ -250,4 +275,5 @@ uninstall:
 	cd $(INST_INCLUDE) && rm -f $(notdir $(HEADERS))
 	cd $(INST_LIBRARY) && rm -f $(notdir $(LIBRARIES) $(LINKED_LIB_SH))
 	cd $(INST_BINARY) && rm -f $(notdir $(RUN))
+	cd $(INST_MAN) && rm -f $(notdir $(MAN))
 	cd $(INST_PKG_CONFIG) && rm -f $(notdir $(PC_NAME))
-- 
2.21.0

