1This patch makes configure use the cross ld and ar rather than the native tools.
2
3It was build up by Yann E. MORIN <yann.morin.1998@anciens.enib.fr> from some
4bits gathered from buildroot, which is LGPL v2.1
5License for dmalloc is:
6 * Permission to use, copy, modify, and distribute this software for
7 * any purpose and without fee is hereby granted, provided that the
8 * above copyright notice and this permission notice appear in all
9 * copies, and that the name of Gray Watson not be used in advertising
10 * or publicity pertaining to distribution of the document or software
11 * without specific, written prior permission.
12 *
13 * Gray Watson makes no representations about the suitability of the
14 * software described herein for any purpose.  It is provided "as is"
15 * without express or implied warranty.
16
17I personnaly believe that the resulting code should therefore be
18LGPL v2.1, but don't believe me, ask your lawyers!
19
20Index: dmalloc-5.5.2/configure.ac
21===================================================================
22--- dmalloc-5.5.2.orig/configure.ac
23+++ dmalloc-5.5.2/configure.ac
24@@ -69,6 +69,15 @@ if test "$ac_cv_prog_cc_stdc" = "no" ; t
25 fi
26 AC_PROG_INSTALL
27 AC_PROG_RANLIB
28+AN_MAKEVAR([AR], [AC_PROG_AR])
29+AN_PROGRAM([ar], [AC_PROG_AR])
30+AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)])
31+AC_PROG_AR
32+AN_MAKEVAR([LD], [AC_PROG_LD])
33+AN_PROGRAM([ld], [AC_PROG_LD])
34+AC_DEFUN([AC_PROG_LD], [AC_CHECK_TOOL(LD, ld, :)])
35+AC_PROG_LD
36+
37 AC_C_CONST
38
39 # we need this for various settings
40@@ -131,14 +140,14 @@ AC_SUBST(shlibdir)
41 AC_MSG_CHECKING([shared library link args])
42 AC_COMPILE_IFELSE([ int foo(int val) { return val + 1; } ],[
43 	# so now we try to create an archive from the compiled .o file
44-	(ar cr conftest.a conftest.o) 2>&5
45+	(${ac_cv_prog_AR} cr conftest.a conftest.o) 2>&5
46 	# see which shared-library ld commands work
47 	#
48 	# Darwin/Mac OS X - Terry Teague
49 	# username terry_teague at domain users.sourceforge.net
50 	ac_cv_shared_lib_link_objs=no
51 	if test `uname` = "Darwin"; then
52-          if (ld -dylib -o conftest.so.t -lc conftest.a) 2>&5; then
53+          if (${ac_cv_prog_LD} -dylib -o conftest.so.t -lc conftest.a) 2>&5; then
54             # By convention on some platforms
55             # libLLL.so, libLLL.X.so are symlinks to libLLL.X.Y.Z.so
56             # where X.Y.Z is version # (major.minor.increment) of the library
57@@ -156,12 +165,12 @@ AC_COMPILE_IFELSE([ int foo(int val) { r
58             ac_cv_shared_link_args='# Could not configure shlib linking'
59             enable_shlib=no
60           fi
61-       elif (ld -shared --whole-archive -soname conftest.so -o conftest.so.t conftest.a) 2>&5; then
62-		ac_cv_shared_link_args='ld -shared --whole-archive -soname $@ -o $@.t'
63-	elif (ld -shared -o conftest.so.t -all -soname conftest.so.t -none -lc -all conftest.a) 2>&5; then
64-		ac_cv_shared_link_args='ld -shared -o $@.t -all -soname $@ -none -lc -all'
65-	elif (ld -G -o conftest.so.t conftest.a) 2>&5; then
66-		ac_cv_shared_link_args='ld -G -o $@.t'
67+        elif (${ac_cv_prog_LD} -shared --whole-archive -soname conftest.so -o conftest.so.t conftest.a) 2>&5; then
68+		ac_cv_shared_link_args='${CC} -Wl,-shared -Wl,--whole-archive -Wl,-soname,$@ -o $@.t -Wl,--no-whole-archive'
69+	elif (${ac_cv_prog_LD} -shared -o conftest.so.t -all -soname conftest.so.t -none -lc -all conftest.a) 2>&5; then
70+		ac_cv_shared_link_args='${CC} -Wl,-shared -o $@.t -Wl,-all -Wl,-soname,$@ -Wl,-none -lc -Wl,-all'
71+	elif (${ac_cv_prog_LD} -G -o conftest.so.t conftest.a) 2>&5; then
72+		ac_cv_shared_link_args='${CC} -Wl,-G -o $@.t'
73 	else
74 		# oh well, toss an error
75 		ac_cv_shared_link_args='# Could not configure shlib linking'
76Index: dmalloc-5.5.2/Makefile.in
77===================================================================
78--- dmalloc-5.5.2.orig/Makefile.in
79+++ dmalloc-5.5.2/Makefile.in
80@@ -263,25 +263,25 @@ $(LIB_SL) : $(OBJS_SL) $(NORMAL_OBJS_SL)
81 	$(CC) $(LDFLAGS) -shared -Wl,-soname,libdmalloc.so.5 -o $@ $(OBJS_SL) $(NORMAL_OBJS_SL)
82
83 $(LIBRARY) : $(OBJS) $(NORMAL_OBJS)
84-	ar cr $@ $?
85+	@AR@ cr $@ $?
86 	@RANLIB@ $@
87
88 $(LIB_TH) : $(OBJS) $(THREAD_OBJS)
89-	ar cr $@ $?
90+	@AR@ cr $@ $?
91 	@RANLIB@ $@
92
93 $(LIB_TH_SL) : $(OBJS_SL) $(THREAD_OBJS_SL)
94 	$(CC) $(LDFLAGS) -shared -Wl,-soname,libdmallocth.so.5 -o $@ $(OBJS_SL) $(THREAD_OBJS_SL)
95
96 $(LIB_CXX) : $(OBJS) $(NORMAL_OBJS) $(CXX_OBJS)
97-	ar cr $@ $?
98+	@AR@ cr $@ $?
99 	@RANLIB@ $@
100
101 $(LIB_CXX_SL) : $(OBJS_SL) $(NORMAL_OBJS_SL) $(CXX_OBJS_SL)
102 	$(CC) $(LDFLAGS) -shared -Wl,-soname,libdmalloccxx.so.5 -o $@ $(OBJS_SL) $(NORMAL_OBJS_SL) $(CXX_OBJS_SL)
103
104 $(LIB_TH_CXX) : $(OBJS) $(THREAD_OBJS) $(CXX_OBJS)
105-	ar cr $@ $?
106+	@AR@ cr $@ $?
107 	@RANLIB@ $@
108
109 $(LIB_TH_CXX_SL) : $(OBJS_SL) $(THREAD_OBJS_SL) $(CXX_OBJS_SL)
110