cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH 6/8] src/Makefile.am: build static lib for unit tests if enabled

From: Kamil Dudka <kdudka_at_redhat.com>
Date: Fri, 3 May 2013 23:32:52 +0200

---
 src/Makefile.am        |    8 ++++++++
 src/tool_main.c        |    2 ++
 tests/unit/Makefile.am |   11 +++++++++--
 3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 814af6e..9cf1545 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,6 +66,14 @@ curl_LDFLAGS = @LIBMETALINK_LDFLAGS@
 curl_CPPFLAGS = $(AM_CPPFLAGS) $(LIBMETALINK_CPPFLAGS)
 curl_DEPENDENCIES = $(top_builddir)/lib/libcurl.la
 
+# if unit tests are enabled, build a static library to link them with
+if BUILD_UNITTESTS
+noinst_LTLIBRARIES = libcurltool.la
+libcurltool_la_CFLAGS = -DUNITTESTS
+libcurltool_la_LDFLAGS = -static $(LINKFLAGS)
+libcurltool_la_SOURCES = $(curl_SOURCES)
+endif
+
 BUILT_SOURCES = tool_hugehelp.c
 CLEANFILES = tool_hugehelp.c
 # Use the C locale to ensure that only ASCII characters appear in the
diff --git a/src/tool_main.c b/src/tool_main.c
index 5e1010a..f66f19a 100644
--- a/src/tool_main.c
+++ b/src/tool_main.c
@@ -79,6 +79,7 @@ static void main_checkfds(void)
 #endif
 }
 
+#ifndef UNITTESTS
 /*
 ** curl tool main function.
 */
@@ -118,3 +119,4 @@ int main(int argc, char *argv[])
 #endif
 }
 
+#endif /* ndef UNITTESTS */
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
index 666fc00..4b47f72 100644
--- a/tests/unit/Makefile.am
+++ b/tests/unit/Makefile.am
@@ -40,6 +40,7 @@ AM_CPPFLAGS = -I$(top_builddir)/include/curl \
               -I$(top_srcdir)/include        \
               -I$(top_builddir)/lib          \
               -I$(top_srcdir)/lib            \
+              -I$(top_srcdir)/src            \
               -I$(top_srcdir)/tests/libtest  \
               -I$(top_builddir)/ares         \
               -I$(top_srcdir)/ares
@@ -49,6 +50,7 @@ AM_CPPFLAGS = -I$(top_builddir)/include/curl \
               -I$(top_srcdir)/include        \
               -I$(top_builddir)/lib          \
               -I$(top_srcdir)/lib            \
+              -I$(top_srcdir)/src            \
               -I$(top_srcdir)/tests/libtest
 endif
 
@@ -57,8 +59,13 @@ EXTRA_DIST = Makefile.inc
 # Prevent LIBS from being used for all link targets
 LIBS = $(BLANK_AT_MAKETIME)
 
-LDADD = $(top_builddir)/lib/libcurlu.la @LDFLAGS@ @LIBCURL_LIBS@
-DEPENDENCIES = $(top_builddir)/lib/libcurlu.la
+LDADD = $(top_builddir)/src/libcurltool.la   \
+        $(top_builddir)/lib/libcurlu.la      \
+        @LDFLAGS@ @LIBCURL_LIBS@
+
+DEPENDENCIES = $(top_builddir)/src/libcurltool.la \
+               $(top_builddir)/lib/libcurlu.la
+
 AM_CPPFLAGS += -DCURL_STATICLIB -DUNITTESTS
 
 # Makefile.inc provides neat definitions
-- 
1.7.1
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2013-05-03