From a7d0f4047f70c6975f821deb913eb57c607d9a1d Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 9 Apr 2017 17:12:13 +0000
Subject: Fix haiku build


diff --git a/Makefile.am b/Makefile.am
index 6f32061..447e7cc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -66,7 +66,7 @@ avrdude_CFLAGS   = @ENABLE_WARNINGS@
 libavrdude_a_CFLAGS   = @ENABLE_WARNINGS@
 libavrdude_la_CFLAGS  = $(libavrdude_a_CFLAGS)
 
-avrdude_LDADD  = $(top_builddir)/$(noinst_LIBRARIES) @LIBUSB_1_0@ @LIBUSB@ @LIBFTDI1@ @LIBFTDI@ @LIBHID@ @LIBELF@ @LIBPTHREAD@ -lm
+avrdude_LDADD  = $(top_builddir)/$(noinst_LIBRARIES) @LIBUSB_1_0@ @LIBUSB@ @LIBFTDI1@ @LIBFTDI@ @LIBHID@ @LIBELF@
 
 bin_PROGRAMS = avrdude
 
diff --git a/configure.ac b/configure.ac
index a98776e..b498a84 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,7 @@ AC_SUBST(LIBELF, $LIBELF)
 
 AC_SEARCH_LIBS([gethostent], [nsl])
 AC_SEARCH_LIBS([setsockopt], [socket])
+AC_SEARCH_LIBS(socket, socket network)
 AH_TEMPLATE([HAVE_LIBUSB],
             [Define if USB support is enabled via libusb])
 AC_CHECK_LIB([usb], [usb_get_string_simple], [have_libusb=yes])
@@ -175,11 +176,7 @@ else
 fi
 AC_CHECK_HEADERS([pthread.h])
 # as there exits header file only pthread implementations for Windows, check if we have a library
-AC_CHECK_LIB([pthread], [pthread_create], [have_pthread=yes])
-if test x$have_pthread = xyes; then
-   LIBPTHREAD="-lpthread"
-fi
-AC_SUBST(LIBPTHREAD, $LIBPTHREAD)
+AC_SEARCH_LIBS([pthread_create], [pthread], [have_pthread=yes])
 # Checks for header files.
 AC_CHECK_HEADERS([limits.h stdlib.h string.h])
 AC_CHECK_HEADERS([fcntl.h sys/ioctl.h sys/time.h termios.h unistd.h])
-- 
2.7.0

