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