libevhtp: build checked out copy

Now that libevhtp is part of the manifest, build it directly and store
the results in out/.

This also deletes references to third_party/{include,lib} as they're
no longer needed.

BUG=b/27820899
TEST+`make` still works, as does the unittests

Change-Id: I6b1dd91cea0f152f8e79527e842add6a9d797a3c
Reviewed-on: https://weave-review.googlesource.com/3001
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/third_party/get_libevhtp.sh b/third_party/get_libevhtp.sh
deleted file mode 100755
index cfcada9..0000000
--- a/third_party/get_libevhtp.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-# Copyright 2016 The Weave Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Make libevhtp.
-# Example uses libevhtp to implement HTTPS server. This step could be
-# replaced with apt-get in future (Debian jessie, Ubuntu vivid).
-cd $(dirname "$0")
-THIRD_PARTY=$(pwd)
-
-LIBEVHTP_VERSION=1.2.11n
-
-mkdir -p include lib
-
-rm -rf $THIRD_PARTY/libevhtp
-curl -L https://github.com/ellzey/libevhtp/archive/$LIBEVHTP_VERSION.tar.gz | tar xz || exit 1
-mv libevhtp-$LIBEVHTP_VERSION $THIRD_PARTY/libevhtp || exit 1
-cd $THIRD_PARTY/libevhtp || exit 1
-
-cmake -D EVHTP_DISABLE_REGEX:BOOL=ON . || exit 1
-make evhtp || exit 1
-
-cp -rf *.h $THIRD_PARTY/include/ || exit 1
-cp -f libevhtp.a $THIRD_PARTY/lib/ || exit 1
-
-rm -rf $THIRD_PARTY/libevhtp
diff --git a/third_party/third_party.mk b/third_party/third_party.mk
index e53529b..18f9b98 100644
--- a/third_party/third_party.mk
+++ b/third_party/third_party.mk
@@ -79,15 +79,18 @@
 		$(third_party_gtest_all) $(third_party_gmock_all)
 
 ###
-# libevhtp (third_party, downloaded on build)
+# libevhtp (third_party)
 
-third_party/lib/libevhtp.a : third_party/include/evhtp.h
-third_party/include/evhtp.h :
-	@echo Downloading and building libevhtp...
-	third_party/get_libevhtp.sh
-	@echo Finished downloading and building libevhtp.
+third_party_libevhtp = out/$(BUILD_MODE)/third_party/libevhtp
+third_party_libevhtp_lib = $(third_party_libevhtp)/libevhtp.a
+third_party_libevhtp_header = $(third_party_libevhtp)/evhtp-config.h
+
+$(third_party_libevhtp_header) :
+	mkdir -p $(dir $@)
+	cd $(dir $@) && cmake -D EVHTP_DISABLE_REGEX:BOOL=ON $(PWD)/third_party/libevhtp
+
+$(third_party_libevhtp_lib) : $(third_party_libevhtp_header)
+	$(MAKE) -C $(third_party_libevhtp)
 
 clean-libevhtp :
-	rm -rf third_party/include/evhtp.h third_party/include/evhtp-config.h third_party/include/evthr.h third_party/include/htparse.h
-	rm -rf third_party/lib/libevhtp.a
-	rm -rf third_party/libevhtp
+	rm -rf $(third_party_libevhtp)