From 350ad938a0a6b9e9f72386bd5bd1f230380485fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Sat, 20 May 2017 15:33:40 +0200
Subject: LMDB: Haiku build fix


diff --git a/libraries/liblmdb/Makefile b/libraries/liblmdb/Makefile
index f254511..0075f9d 100644
--- a/libraries/liblmdb/Makefile
+++ b/libraries/liblmdb/Makefile
@@ -21,7 +21,7 @@
 CC	= gcc
 AR	= ar
 W	= -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized
-THREADS = -pthread
+THREADS = -lpthread
 OPT = -O2 -g
 CFLAGS	= $(THREADS) $(OPT) $(W) $(XCFLAGS)
 LDLIBS	=
@@ -65,8 +65,8 @@ liblmdb.a:	mdb.o midl.o
 	$(AR) rs $@ mdb.o midl.o
 
 liblmdb$(SOEXT):	mdb.lo midl.lo
-#	$(CC) $(LDFLAGS) -pthread -shared -Wl,-Bsymbolic -o $@ mdb.o midl.o $(SOLIBS)
-	$(CC) $(LDFLAGS) -pthread -shared -o $@ mdb.lo midl.lo $(SOLIBS)
+#	$(CC) $(LDFLAGS) -lpthread -shared -Wl,-Bsymbolic -o $@ mdb.o midl.o $(SOLIBS)
+	$(CC) $(LDFLAGS) -lpthread -shared -o $@ mdb.lo midl.lo $(SOLIBS)
 
 mdb_stat: mdb_stat.o liblmdb.a
 mdb_copy: mdb_copy.o liblmdb.a
@@ -102,13 +102,13 @@ COV_OBJS=xmdb.o xmidl.o
 
 coverage: xmtest
 	for i in mtest*.c [0-9]*.c; do j=`basename \$$i .c`; $(MAKE) $$j.o; \
-		gcc -o x$$j $$j.o $(COV_OBJS) -pthread $(COV_FLAGS); \
+		gcc -o x$$j $$j.o $(COV_OBJS) -lpthread $(COV_FLAGS); \
 		rm -rf testdb; mkdir testdb; ./x$$j; done
 	gcov xmdb.c
 	gcov xmidl.c
 
 xmtest:	mtest.o xmdb.o xmidl.o
-	gcc -o xmtest mtest.o xmdb.o xmidl.o -pthread $(COV_FLAGS)
+	gcc -o xmtest mtest.o xmdb.o xmidl.o -lpthread $(COV_FLAGS)
 
 xmdb.o: mdb.c lmdb.h midl.h
 	$(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -O0 $(COV_FLAGS) -c mdb.c -o $@
diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c
index 621cbcf..19e2174 100644
--- a/libraries/liblmdb/mdb.c
+++ b/libraries/liblmdb/mdb.c
@@ -127,7 +127,7 @@ typedef SSIZE_T	ssize_t;
 #if defined(__FreeBSD__) && defined(__FreeBSD_version) && __FreeBSD_version >= 1100110
 # define MDB_USE_POSIX_MUTEX	1
 # define MDB_USE_ROBUST	1
-#elif defined(__APPLE__) || defined (BSD) || defined(__FreeBSD_kernel__)
+#elif defined(__APPLE__) || defined (BSD) || defined(__FreeBSD_kernel__) || defined(__HAIKU__)
 # define MDB_USE_POSIX_SEM	1
 # define MDB_FDATASYNC		fsync
 #elif defined(ANDROID)
-- 
2.30.2

