Commit Diff


commit - e6f4ba3109814ba43d3a9e9c9c9dc55c40149dbc
commit + 92a9e85d28a30997176ce0d3c2915e3ea70782c7
blob - 29fcf763e3848c8a1969abb0e63d5de38675cf3c
blob + 77a4b663e28d1206c2b7ed331a3fef25b9a5e44d
--- compat/Makefile.am
+++ compat/Makefile.am
@@ -29,10 +29,13 @@ libopenbsd_compat_a_SOURCES =  \
 	strnlen.c \
 	strsep.c \
 	strtonum.c \
-	uuid.c \
 	imsg.h \
 	queue.h \
 	tree.h
+if HOST_FREEBSD
+else
+libopenbsd_compat_a_SOURCES += uuid.c
+endif
 
 EXTRA_DIST = \
 	$(top_srcdir)/include/got_compat.h \
blob - cdd6e15964896469690ab60d154424b9e4358b73
blob + c3f6d3a3df96207adb3645a88553071f00fe841e
--- configure.ac
+++ configure.ac
@@ -143,6 +143,26 @@ AC_REPLACE_FUNCS([ \
 # implementations.
 AC_LIBOBJ(getopt)
 
+# Check the platform we're compiling on.
+AC_MSG_CHECKING(platform)
+case "$host_os" in
+	*linux*)
+		AC_MSG_RESULT(linux)
+		PLATFORM=linux
+		;;
+	*freebsd*)
+		AC_MSG_RESULT(freebsd)
+		PLATFORM=freebsd
+		;;
+	*)
+		AC_MSG_RESULT(unknown)
+		PLATFORM=unknown
+		;;
+esac
+AC_SUBST(PLATFORM)
+AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
+AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
+
 # Clang sanitizers wrap reallocarray even if it isn't available on the target
 # system. When compiled it always returns NULL and crashes the program. To
 # detect this we need a more complicated test.
@@ -183,10 +203,14 @@ PKG_CHECK_MODULES(
 		found_libcrypto=yes
 	],
 	[
-	 	AC_MSG_ERROR("*** couldn't find libcrypto via pkg-config")
+	 	found_libcrypto=no
 	]
 )
 
+if test "x$found_libcrypto" = "xyes"; then
+	AC_DEFINE(HAVE_LIBCRYPTO)
+fi
+
 AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID))
 AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))
 
@@ -200,11 +224,21 @@ PKG_CHECK_MODULES(
 		found_libuuid=yes
 	],
 	[
-	 	AC_MSG_ERROR("*** couldn't find libuuid via pkg-config")
+	 	found_libuuid=no
 	]
 )
 
+if test "x$found_libuuid" = "xno"; then
+	AC_CHECK_HEADER(
+		uuid.h,
+		found_libuuid=yes,
+		found_libuuid=no)
+fi
 
+if test "x$found_libuuid" = "xno"; then
+	AC_MSG_ERROR("*** couldn't find uuid ***")
+fi
+
 PKG_CHECK_MODULES(
 	ZLIB,
 	zlib,
@@ -215,45 +249,48 @@ PKG_CHECK_MODULES(
 		found_zlib=yes
 	],
 	[
-	 	AC_MSG_ERROR("*** couldn't find zlib via pkg-config")
+	 	found_zlib=no
 	]
 )
 
-PKG_CHECK_MODULES(
-	LIBMD,
-	libmd,
-	[
-	 	AM_CFLAGS="$LIBMD_CFLAGS $AM_CFLAGS"
-		CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
-		LIBS="$LIBMD_LIBS $LIBS"
-	],
-	[
-	 	AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
-	]
-)
-# libmd (uuid)
-# imsg
-# libbsd (some portability gloop)
-# lssl
-# lz
-# ldl *
-# rdynamic *
+if test "x$found_zlib" = "xno"; then
+	AC_CHECK_HEADER(
+		zlib.h,
+		,
+		found_zlib=no)
+fi
 
-# Check if libbsd is installed -- if we can use that version of sys/tree.h or
-# our own if not.
-PKG_CHECK_MODULES(
-	LIBBSD,
-	libbsd-overlay,
-	[
-		AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
-		CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
-		LIBS="$LIBBSD_LIBS $LIBS"
-		found_libbsd=yes
-		AC_DEFINE(HAVE_LIBBSD)
-	],
-	[]
-)
+if test "x$found_zlib" = "xno"; then
+	AC_MSG_ERROR("*** couldn't find zlib ***")
+fi
 
+if test "$PLATFORM" = "linux"; then
+	PKG_CHECK_MODULES(
+		LIBMD,
+		libmd,
+		[
+			AM_CFLAGS="$LIBMD_CFLAGS $AM_CFLAGS"
+			CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
+			LIBS="$LIBMD_LIBS $LIBS"
+		],
+		[
+			AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
+		]
+	)
+	PKG_CHECK_MODULES(
+		LIBBSD,
+		libbsd-overlay,
+		[
+			AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
+			CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
+			LIBS="$LIBBSD_LIBS $LIBS"
+			found_libbsd=yes
+			AC_DEFINE(HAVE_LIBBSD)
+		],
+		[]
+	)
+fi
+
 # Look for a suitable queue.h.  We hope libbsd is enough, but that is missing
 # SIMPLEQ.
 AC_CHECK_DECL(
@@ -313,13 +350,21 @@ AC_LINK_IFELSE([AC_LANG_SOURCE(
 	AC_MSG_RESULT(no)
 )
 
-PKG_CHECK_MODULES(
-	LIBPANELW,
-	panelw,
-	found_panel=yes,
-	AC_MSG_ERROR("*** couldn't find -lpanel from ncurses")
-)
+if test "$PLATFORM" = "linux"; then
+	PKG_CHECK_MODULES(
+		LIBPANELW,
+		panelw,
+		found_panel=yes,
+		AC_MSG_ERROR("*** couldn't find -lpanel from ncurses")
+	)
+else
+	AC_CHECK_LIB(panelw, update_panels,,
+		AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"])
+	)
 
+	LIBPANELW_LIBS="-lpanelw"
+fi
+
 PKG_CHECK_MODULES(
 	LIBNCURSES,
 	ncursesw,
@@ -345,7 +390,7 @@ else
 			LIBS="$LIBS -lncursesw $LIBPANELW_LIBS",
 			found_ncurses=no
 		)
-		fi
+	fi
 fi
 if test "x$found_ncurses" = xyes; then
 	AC_DEFINE(HAVE_NCURSES_H)
blob - 8bd2ae2ccbea5a02855dc5d1948dc6cd4653ea24
blob + 5ebe78c6f3672b7046aad9c58c524fe8813b9de0
--- got/Makefile.am
+++ got/Makefile.am
@@ -63,3 +63,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - 0cca8d79904b63b432150b621f6d24a9a06c7ee3
blob + 00a672f3581ffa440c383d285a0221d1b337c6f9
--- gotadmin/Makefile.am
+++ gotadmin/Makefile.am
@@ -39,4 +39,7 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
        -I$(top_srcdir)/include \
        -I.
 
-LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+LDADD = -L$(top_builddir)/compat -lopenbsd-compat -lmd
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - 2cd34eb41da9f6c9505bd2ead2e8c3442c744f3c
blob + 647269f28f4fe3ad994980e8ae5ca9a14aa5ef19
--- gotadmin/gotadmin.c
+++ gotadmin/gotadmin.c
@@ -22,7 +22,6 @@
 #include <errno.h>
 #include <locale.h>
 #include <inttypes.h>
-#include <sha1.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
blob - 6270fd4e8165f8236d032b97398fed86ef03d723
blob + 78da94b5a6a66a86e58077352388589e6c6a18f2
--- include/got_compat.h
+++ include/got_compat.h
@@ -4,6 +4,11 @@
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/uio.h>
+#if defined(__FreeBSD__)
+#include <sys/endian.h>
+#else
+#include <endian.h>
+#endif
 
 #include <fnmatch.h>
 #include <limits.h>
@@ -100,6 +105,20 @@ void uuid_to_string(uuid_t *, char **, uint32_t *);
 #include "compat/imsg.h"
 #endif
 
+#ifdef HAVE_LIBCRYPTO
+#include <sha1.h>
+#else
+#include <sha.h>
+
+#define SHA1_DIGEST_LENGTH		SHA_DIGEST_LENGTH
+#define SHA1_DIGEST_STRING_LENGTH	(SHA1_DIGEST_LENGTH * 2 + 1)
+
+#define SHA1_CTX	SHA_CTX
+#define SHA1Init	SHA1_Init
+#define SHA1Update	SHA1_Update
+#define SHA1Final	SHA1_Final
+#endif
+
 #ifndef HAVE_ASPRINTF
 /* asprintf.c */
 int		 asprintf(char **, const char *, ...);
@@ -122,6 +141,10 @@ int		 getdtablecount(void);
 #define closefrom(fd) (closefrom(fd), 0)
 #endif
 
+#if defined (__FreeBSD__)
+#define closefrom(fd) (closefrom(fd), 0)
+#endif
+
 #ifndef HAVE_STRSEP
 /* strsep.c */
 char		*strsep(char **, const char *);
blob - e59a64ac627c2f057a122da8629bdafe70f1b4bd
blob + 1a2198b5cc07faf4571492ff7929354c27d77842
--- lib/blame.c
+++ lib/blame.c
@@ -19,7 +19,6 @@
 #include <sys/stat.h>
 
 #include <errno.h>
-#include <sha1.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
blob - bf42765e12770cf525a5b72369096a45e33cde0f
blob + 2369ddba562872276ef866bc1cae1e2eb9e53a19
--- lib/commit_graph.c
+++ lib/commit_graph.c
@@ -21,7 +21,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <zlib.h>
 #include <ctype.h>
 
blob - d98ac2f3491f673a1fcd85cd32e0d40a242d1e0d
blob + 7b925666bac45b450541651a1bbcae461660613b
--- lib/deflate.c
+++ lib/deflate.c
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <zlib.h>
 #include <time.h>
 
blob - d9cd7b365f0040f867ceec9e6ac810fdf3a7f4ed
blob + a19a21be699a9382d152a7d628d82068ead2d78c
--- lib/delta.c
+++ lib/delta.c
@@ -21,7 +21,6 @@
 #include <string.h>
 #include <limits.h>
 #include <zlib.h>
-#include <sha1.h>
 #include <time.h>
 #include <zlib.h>
 
blob - 1e84c72b2144ed7cfd8c7e6cc1053cee28f0f5b2
blob + e4977e93a1361623ed181cbec59a9512bf69c155
--- lib/delta_cache.c
+++ lib/delta_cache.c
@@ -17,7 +17,6 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <stdio.h>
 #include <zlib.h>
 #include <limits.h>
blob - 9e3f821a1f3aac172264fa8c7455389773c8e3c9
blob + 66068c68c2f0df0c48a3d770770a23b1db8e9c61
--- lib/deltify.c
+++ lib/deltify.c
@@ -18,14 +18,12 @@
 #include <sys/types.h>
 
 #include <assert.h>
-#include <endian.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 
 #include "got_error.h"
 
blob - 869cbaa12c615c85191fd515a65c919ce654d5e1
blob + 92405943c1b236430780ec2eebfbe0a2153f2dd9
--- lib/diff.c
+++ lib/diff.c
@@ -20,7 +20,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
-#include <sha1.h>
 #include <zlib.h>
 
 #include "got_compat.h"
blob - 3173307f2ab8682ed6c74f18e1dcce9c02344d9d
blob + 62a1719e317f17da42a7802c245017926889d142
--- lib/error.c
+++ lib/error.c
@@ -21,7 +21,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <zlib.h>
 #include <uuid.h>
 
blob - ab84f74f3c3156397f41e92c01cebdbda2d6d79f
blob + 71ee12e8b498271db30de124a1e7955985cf8129
--- lib/fetch.c
+++ lib/fetch.c
@@ -22,7 +22,6 @@
 #include <sys/resource.h>
 #include <sys/socket.h>
 
-#include <endian.h>
 #include <errno.h>
 #include <err.h>
 #include <fcntl.h>
@@ -30,7 +29,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 #include <ctype.h>
blob - 71dbb004fec2b3779639139eebb46b7002be5611
blob + 814eb2087943991b565469794ce542b904c409f4
--- lib/fileindex.c
+++ lib/fileindex.c
@@ -22,8 +22,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
-#include <endian.h>
 #include <limits.h>
 #include <unistd.h>
 #include <uuid.h>
blob - 7d5fed69d8e41b0563b8081619c094d338399d9f
blob + 52d754a3a69afa383b42fc9f243286a0fecf6e54
--- lib/gotconfig.c
+++ lib/gotconfig.c
@@ -24,7 +24,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdint.h>
-#include <sha1.h>
 #include <limits.h>
 
 #include "got_compat.h"
blob - e72bf08569b2eb4b9cb8e28ced29141dd9e14bb7
blob + d003180a59ce769ce2902ad25521f09c341f0076
--- lib/inflate.c
+++ lib/inflate.c
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 #include <time.h>
blob - eaea9d8f0365e98800abb62b9edfaaceb89bb84b
blob + edb39eef485f9b575297475dd981f0e81f1f9da3
--- lib/object.c
+++ lib/object.c
@@ -27,7 +27,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 #include <ctype.h>
blob - 117648fc324c5a4b533c596bf8201739199dc811
blob + b6e53c387893d82c8683a9e3087d1c7052af32fd
--- lib/object_cache.c
+++ lib/object_cache.c
@@ -21,7 +21,6 @@
 #include <stdint.h>
 #include <string.h>
 #include <limits.h>
-#include <sha1.h>
 #include <zlib.h>
 
 #include "got_error.h"
blob - fb842d05b1ddc1f853d2c8d63d5b6db4793a3a55
blob + 2d3f2ac0339c7d159f40426028eb11947353a4f1
--- lib/object_create.c
+++ lib/object_create.c
@@ -25,7 +25,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 
blob - c11b7204cadf33408433ee5be41a74768088dfef
blob + 3f1622d7ea2ca6f0d35921c81ea6be1936f0cb48
--- lib/object_idset.c
+++ lib/object_idset.c
@@ -17,7 +17,6 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <stdio.h>
 #include <zlib.h>
 #include <limits.h>
blob - 0bcee86b223c71a52037d7b42aced837c04d98b1
blob + 4bebeb4f4082dbe85a1bc266597d4aaf35b7ba97
--- lib/object_parse.c
+++ lib/object_parse.c
@@ -25,7 +25,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
-#include <sha1.h>
 #include <zlib.h>
 #include <ctype.h>
 #include <limits.h>
blob - 69694e82b0bb6192be25b3c8a2c84c45468e4e80
blob + 0dd65c8a831a778b1fb0333b3c7f20b4b0700e43
--- lib/pack.c
+++ lib/pack.c
@@ -26,8 +26,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
-#include <sha1.h>
-#include <endian.h>
 #include <unistd.h>
 #include <zlib.h>
 
blob - 4fe546b8b066241ff47803d542c21ebd0c212343
blob + c0d6e28feff22e3c6f2c9901d5faf98218b9eab2
--- lib/pack_create.c
+++ lib/pack_create.c
@@ -23,7 +23,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <limits.h>
 #include <zlib.h>
 
blob - 05b4a3a90b306e5c0db905e4e1b4c938181dea9e
blob + ca518be1b33674bad2932799890ca39f6b2520f7
--- lib/privsep.c
+++ lib/privsep.c
@@ -28,7 +28,6 @@
 #include <errno.h>
 #include <stdint.h>
 #include <poll.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 #include <time.h>
blob - 6ccff34b22c6c2a0f614e842066303d8c80da9b1
blob + e173458388a0eed6a09cc84f91b9a2f7a3bd001b
--- lib/reference.c
+++ lib/reference.c
@@ -21,7 +21,6 @@
 #include <ctype.h>
 #include <dirent.h>
 #include <limits.h>
-#include <sha1.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
blob - 08f2da0fa31f815709a79732dbc9ae1114b527b3
blob + 5c7fe289fa9cc9d698112237e6ab55298613e64b
--- lib/repository.c
+++ lib/repository.c
@@ -22,14 +22,12 @@
 #include <sys/resource.h>
 
 #include <ctype.h>
-#include <endian.h>
 #include <fcntl.h>
 #include <fnmatch.h>
 #include <limits.h>
 #include <dirent.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <sha1.h>
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
blob - 8ca2cef563de87d804e5cb6ea193dbfab6476f6d
blob + f73c38388a2637a76122e000a939cc43c4314c89
--- lib/repository_admin.c
+++ lib/repository_admin.c
@@ -21,11 +21,9 @@
 #include <sys/wait.h>
 
 #include <dirent.h>
-#include <endian.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdint.h>
-#include <sha1.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
blob - 6b14f325c677d19b2b5a068c142b1d40c812e58f
blob + d8008aed09683d24fbe274c29012d76cc3039e85
--- lib/send.c
+++ lib/send.c
@@ -23,7 +23,6 @@
 #include <sys/resource.h>
 #include <sys/socket.h>
 
-#include <endian.h>
 #include <errno.h>
 #include <err.h>
 #include <fcntl.h>
@@ -31,7 +30,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 #include <ctype.h>
blob - 1f25f1bb9dff77000b14a85bc42e8bd04577d1a3
blob + 67cb8d0ec4656cfe59e70cdd326f7c9cbbdafa68
--- lib/sha1.c
+++ lib/sha1.c
@@ -15,12 +15,13 @@
  */
 
 #include <sys/types.h>
-#include <sha1.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
 
+#include "got_compat.h"
+
 #include "got_lib_sha1.h"
 
 int
blob - 11f8c658d9a14769d0a5e48c2ef17c3d3ba107dc
blob + edd1cb8a01ae94e9786f52b9546fd6ab207b9882
--- lib/worktree.c
+++ lib/worktree.c
@@ -26,10 +26,10 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <unistd.h>
-#include <sha1.h>
 #include <zlib.h>
 #include <fnmatch.h>
 #include <libgen.h>
+#include <uuid.h>
 
 #include "got_compat.h"
 
blob - 649877a6a123c30120cf6751d081f92f9c4046f4
blob + 25485b0cbb26cde38501d4f61c0b23715d78ea9d
--- libexec/got-fetch-pack/Makefile.am
+++ libexec/got-fetch-pack/Makefile.am
@@ -22,3 +22,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - 2b84c4fa3f8e08974358a499d31231a7047989d7
blob + 0b62c26c8990e23ab00c91090588f0e298ef258e
--- libexec/got-fetch-pack/got-fetch-pack.c
+++ libexec/got-fetch-pack/got-fetch-pack.c
@@ -27,7 +27,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#include <sha1.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <zlib.h>
blob - ea1b1c5e08e4dc34527b675fa2c1d16f29651305
blob + 6b20deb93e0e6937c17444e2f1ec563946e69d8e
--- libexec/got-index-pack/Makefile.am
+++ libexec/got-index-pack/Makefile.am
@@ -23,3 +23,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - 886a63ddb89f836df04c04f1dff94e3a6c4ea980
blob + 01ca110a1eb4d1461ce37f77a21391e3d8322e9a
--- libexec/got-index-pack/got-index-pack.c
+++ libexec/got-index-pack/got-index-pack.c
@@ -29,8 +29,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#include <sha1.h>
-#include <endian.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <zlib.h>
blob - 993333968f226d50dbc80ce5e46bd0330019bb3d
blob + 849842417d2a67c5e3618fbd1d71c0d04c20faa3
--- libexec/got-read-blob/Makefile.am
+++ libexec/got-read-blob/Makefile.am
@@ -19,3 +19,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - 35d6fe9a97a0086757eab53417ef6e5414bcb01a
blob + 24a9911b4e2319200c86e0be0d525a3980763d80
--- libexec/got-read-blob/got-read-blob.c
+++ libexec/got-read-blob/got-read-blob.c
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 
blob - f1f5756264aa3dbd78ba6664313c682f8587b7fa
blob + 99d20ab33888f19cfec22d0602b3ab39a37dbb57
--- libexec/got-read-commit/Makefile.am
+++ libexec/got-read-commit/Makefile.am
@@ -19,3 +19,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - 63723fc13f12844d56c1be7e4cef38be62a52937
blob + f324bf809bdb1dbc68030ee2676b88f4ec11dc4e
--- libexec/got-read-commit/got-read-commit.c
+++ libexec/got-read-commit/got-read-commit.c
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 
blob - 64b7b621af5015185af2dfde801bca0ae8ca0de2
blob + 54fa239e44980145bf0350fc9ebad50ce68c5c42
--- libexec/got-read-gitconfig/Makefile.am
+++ libexec/got-read-gitconfig/Makefile.am
@@ -20,3 +20,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - e295f14e62e3c0b1638ec35b5e3c065cf4464b14
blob + 465fc301b0dceaeef13bda6ff6eb82c76ed7eac6
--- libexec/got-read-gitconfig/got-read-gitconfig.c
+++ libexec/got-read-gitconfig/got-read-gitconfig.c
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 
blob - 025806c14300b828814f70050faacfbe961dadfb
blob + 429a7857ecb688b5163f9e16cbfdd4bacab32e6f
--- libexec/got-read-gotconfig/Makefile.am
+++ libexec/got-read-gotconfig/Makefile.am
@@ -22,3 +22,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - 39e02e68a0ab56940b556b9aaef010a796ac9449
blob + 69f6999b8df42a9f230c521287de6e5aadebd128
--- libexec/got-read-gotconfig/got-read-gotconfig.c
+++ libexec/got-read-gotconfig/got-read-gotconfig.c
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 
blob - 5c47a9f77d6d2e22fd8e735296ef9ae6697536fc
blob + 3ce3eec95827db17f651b41c24dec627e19a1cfd
--- libexec/got-read-object/Makefile.am
+++ libexec/got-read-object/Makefile.am
@@ -19,3 +19,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - a59095676603202ad73ba5ae27415c88582791a7
blob + 3d9bc64ad66ca532a2c58b8d50e3d4ab51abb4db
--- libexec/got-read-object/got-read-object.c
+++ libexec/got-read-object/got-read-object.c
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 
blob - 8205ace1b1d62316fe2aa75718f074864a7a073e
blob + 2a0a70e217dfdb8232c7823b197c9dfd15a96d3b
--- libexec/got-read-pack/Makefile.am
+++ libexec/got-read-pack/Makefile.am
@@ -25,3 +25,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - ead69bd509f8bf3acbbeae7e92de9002b0370ac7
blob + a5318c83459bae63af9da826aa7e3c4ebb0e683c
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
@@ -25,7 +25,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 
blob - 2e99e3934e5b4eac7ad1c9f03461e156dba13740
blob + 606ce8304c922730b4de471b4784a19cc3b69da2
--- libexec/got-read-tag/Makefile.am
+++ libexec/got-read-tag/Makefile.am
@@ -19,3 +19,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - f2c0102bd3d4652d1971eb3fbf4cfb4cf094d224
blob + 870e8ca6c8d4439248bc960e5d6797861de4de07
--- libexec/got-read-tag/got-read-tag.c
+++ libexec/got-read-tag/got-read-tag.c
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 
blob - 86f5f879fcd5554c70e232f687a57f28cf9ec45f
blob + ed03e85174527f0b6dc6ad2bba5e7921c7cf0dc6
--- libexec/got-read-tree/Makefile.am
+++ libexec/got-read-tree/Makefile.am
@@ -19,3 +19,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - fad33d19b6531464a1a748fc33e8fa13babd68f4
blob + 35323190d763a2a21c96e0b0f6c3d19f6687f007
--- libexec/got-read-tree/got-read-tree.c
+++ libexec/got-read-tree/got-read-tree.c
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sha1.h>
 #include <unistd.h>
 #include <zlib.h>
 
blob - 6140278235d28f1fe0fbf7e82ab390b3c57a7277
blob + d6178b1ec93457ae8bf70fe9c85b90186d9471c2
--- libexec/got-send-pack/Makefile.am
+++ libexec/got-send-pack/Makefile.am
@@ -22,3 +22,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat
+if HOST_FREEBSD
+LDADD += -lmd
+endif
blob - 8096c808058c2f8f54fa4bb9c8c5b039a8e5a7eb
blob + 91674461564887f691b79dc590d4f9199284f2df
--- libexec/got-send-pack/got-send-pack.c
+++ libexec/got-send-pack/got-send-pack.c
@@ -28,7 +28,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#include <sha1.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <zlib.h>
blob - f82eee92550a4d0bab5f70c6fadbbb7d4540bb38
blob + da1c40a1cf3887d098de63cce0f5417b159042d6
--- tog/Makefile.am
+++ tog/Makefile.am
@@ -57,3 +57,6 @@ AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \
 	-I.
 
 LDADD = -L$(top_builddir)/compat -lopenbsd-compat -lpthread
+if HOST_FREEBSD
+LDADD += -lmd
+endif