From 41191cdd54ff7f6bbb5e65bb0cd56fe0a50b5d14 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 17 Apr 2012 05:46:30 +0200 Subject: [PATCH] configure: Windows cross-compilation fixes CARES_BUILDING_LIBRARY and CARES_STATICLIB no longer defined in ares_config.h, configure will generate appropriate conditionals so that mentioned symbols get defined and used in Makefile derived from Makefile.am at compilation time. --- Makefile.am | 17 +++++++++++++++++ configure.ac | 8 ++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8969403a..08d6a586 100644 --- a/Makefile.am +++ b/Makefile.am @@ -103,6 +103,20 @@ libcares_la_LDFLAGS = $(UNDEF) $(VER) # Add -Werror if defined CFLAGS += @CARES_CFLAG_EXTRAS@ +# For Windows build targets, when building or using static c-ares +if USE_CPPFLAG_CARES_STATICLIB +AM_CPPFLAGS = -DCARES_STATICLIB +else +AM_CPPFLAGS = +endif + +# For Windows build targets, when building c-ares library +if USE_CPPFLAG_CARES_BUILDING_LIBRARY +libcares_la_CPPFLAGS = $(AM_CPPFLAGS) -DCARES_BUILDING_LIBRARY +else +libcares_la_CPPFLAGS = $(AM_CPPFLAGS) +endif + # Makefile.inc provides the CSOURCES and HHEADERS defines include Makefile.inc @@ -117,14 +131,17 @@ libcares_la_HEADERS = ares.h ares_version.h ares_dns.h \ ahost_SOURCES = ahost.c $(SAMPLESOURCES) $(SAMPLEHEADERS) ahost_LDADD = $(top_builddir)/libcares.la ahost_CFLAGS = $(AM_CFLAGS) +ahost_CPPFLAGS = $(AM_CPPFLAGS) adig_SOURCES = adig.c $(SAMPLESOURCES) $(SAMPLEHEADERS) adig_LDADD = $(top_builddir)/libcares.la adig_CFLAGS = $(AM_CFLAGS) +adig_CPPFLAGS = $(AM_CPPFLAGS) acountry_SOURCES = acountry.c $(SAMPLESOURCES) $(SAMPLEHEADERS) acountry_LDADD = $(top_builddir)/libcares.la acountry_CFLAGS = $(AM_CFLAGS) +acountry_CPPFLAGS = $(AM_CPPFLAGS) SOURCEDMANDIR = man3 SOURCEDMANPAGES = ares_init.3 diff --git a/configure.ac b/configure.ac index 69dc2e63..2794ccad 100644 --- a/configure.ac +++ b/configure.ac @@ -128,15 +128,17 @@ dnl libtool setup AC_PROG_LIBTOOL AC_MSG_CHECKING([if we need CARES_BUILDING_LIBRARY]) +use_cppflag_cares_building_library="no" +use_cppflag_cares_staticlib="no" case $host in *-*-mingw*) - AC_DEFINE(CARES_BUILDING_LIBRARY, 1, [when building c-ares library]) AC_MSG_RESULT(yes) + use_cppflag_cares_building_library="yes" AC_MSG_CHECKING([if we need CARES_STATICLIB]) if test "X$enable_shared" = "Xno" then - AC_DEFINE(CARES_STATICLIB, 1, [when not building a shared library]) AC_MSG_RESULT(yes) + use_cppflag_cares_staticlib="yes" else AC_MSG_RESULT(no) fi @@ -145,6 +147,8 @@ case $host in AC_MSG_RESULT(no) ;; esac +AM_CONDITIONAL(USE_CPPFLAG_CARES_BUILDING_LIBRARY, test x$use_cppflag_cares_building_library = xyes) +AM_CONDITIONAL(USE_CPPFLAG_CARES_STATICLIB, test x$use_cppflag_cares_staticlib = xyes) dnl ********************************************************************** dnl platform/compiler/architecture specific checks/flags