gnu: gimp: Ship a copy of the gegl patch.
[jackhill/guix/guix.git] / gnu / packages / patches / bc-fix-cross-compilation.patch
CommitLineData
06b2bc55
MO
1Patch taken from nix.
2
3commit fdda59736ddc048cf38a2c7103f4f5d9eeaf995e
4Author: Ben Gamari <ben@smart-cactus.org>
5Date: Tue Oct 17 10:51:34 2017 -0400
6
7 Try implementing cross-compilation
8
9diff --git a/bc/Makefile.am b/bc/Makefile.am
10index d9d412e..fdef633 100644
11--- a/bc/Makefile.am
12+++ b/bc/Makefile.am
13@@ -17,6 +17,7 @@ MAINTAINERCLEANFILES = Makefile.in bc.c bc.h scan.c \
14
15 AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/../h
16 LIBBC = ../lib/libbc.a
17+LIBBC_HOST = ../lib/libbc_host.a
18 LIBL = @LEXLIB@
19 LDADD = $(LIBBC) $(LIBL) @READLINELIB@
20
21@@ -29,12 +30,20 @@ $(PROGRAMS): libmath.h $(LIBBC)
22 scan.o: bc.h
23 global.o: libmath.h
24+
25+main_host.c : main.c
26+ cp $< $@
27
28-fbcOBJ = main.o bc.o scan.o execute.o load.o storage.o util.o warranty.o
29+fbcOBJ = $(addsuffix _host,main.o bc.o scan.o execute.o load.o storage.o util.o warranty.o)
30+
31+%.o_host : CC:=$(CC_FOR_BUILD)
32+
33+%.o_host : %.c
34+ $(COMPILE) -c $(CFLAGS) $(INCLUDES) -o $@ $<
35
36-libmath.h: libmath.b $(fbcOBJ) $(LIBBC)
37+libmath.h: libmath.b $(fbcOBJ) $(LIBBC_HOST)
38 echo '{0}' > libmath.h
39- $(MAKE) global.o
40- $(LINK) -o fbc $(fbcOBJ) global.o $(LIBBC) $(LIBL) $(READLINELIB) $(LIBS)
41+ $(MAKE) global.o_host
42+ $(CC_FOR_BUILD) -o fbc $(fbcOBJ) global.o_host $(LIBBC_HOST) $(LIBL) ${READLINELIB} $(LIBS)
43 ./fbc -c $(srcdir)/libmath.b </dev/null >libmath.h
44 $(srcdir)/fix-libmath_h
45 rm -f ./fbc ./global.o
46diff --git a/configure.ac b/configure.ac
47index fc74573..5cabb73 100644
48--- a/configure.ac
49+++ b/configure.ac
50@@ -20,6 +20,7 @@ m4_define([dc_version], 1.4.1)
51
52 AC_INIT([bc],[bc_version])
53 AC_CONFIG_SRCDIR(doc/bc.1)
54+AC_CONFIG_MACRO_DIR([m4])
55 AM_INIT_AUTOMAKE([dist-bzip2])
56 AC_CONFIG_HEADERS(config.h)
57
58@@ -35,6 +36,7 @@ AC_DEFINE([DC_COPYRIGHT],
59 [Define the dc copyright line.])
60
61 AC_PROG_CC
62+AX_CC_FOR_BUILD
63 AC_USE_SYSTEM_EXTENSIONS
64
65 AM_PROG_LEX
66diff --git a/lib/Makefile.am b/lib/Makefile.am
67index ec4bf59..c670f5b 100644
68--- a/lib/Makefile.am
69+++ b/lib/Makefile.am
70@@ -1,5 +1,5 @@
71 ## Process this file with automake to produce Makefile.in
72-noinst_LIBRARIES = libbc.a
73+noinst_LIBRARIES = libbc.a libbc_host.a
74
75 AM_CPPFLAGS = -I. -I.. -I$(srcdir)/../h
76
77@@ -24,3 +24,11 @@ testmul: testmul.o number.o
78
79 specialnumber: newnumber.o
80 cp newnumber.o number.o
81+
82+%.o_host : CC:=$(CC_FOR_BUILD)
83+%.o_host : %.c
84+ $(COMPILE) -c $(CFLAGS) $(INCLUDES) -o $@ $<
85+
86+libbc_host.a : $(addsuffix _host,$(libbc_a_OBJECTS))
87+ ar cru $@ $+
88+ ranlib $@
89diff --git a/m4/cc_for_build.m4 b/m4/cc_for_build.m4
90new file mode 100644
91index 0000000..c62ffad
92--- /dev/null
93+++ b/m4/cc_for_build.m4
94@@ -0,0 +1,77 @@
95+# ===========================================================================
96+# https://www.gnu.org/software/autoconf-archive/ax_cc_for_build.html
97+# ===========================================================================
98+#
99+# SYNOPSIS
100+#
101+# AX_CC_FOR_BUILD
102+#
103+# DESCRIPTION
104+#
105+# Find a build-time compiler. Sets CC_FOR_BUILD and EXEEXT_FOR_BUILD.
106+#
107+# LICENSE
108+#
109+# Copyright (c) 2010 Reuben Thomas <rrt@sc3d.org>
110+# Copyright (c) 1999 Richard Henderson <rth@redhat.com>
111+#
112+# This program is free software: you can redistribute it and/or modify it
113+# under the terms of the GNU General Public License as published by the
114+# Free Software Foundation, either version 3 of the License, or (at your
115+# option) any later version.
116+#
117+# This program is distributed in the hope that it will be useful, but
118+# WITHOUT ANY WARRANTY; without even the implied warranty of
119+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
120+# Public License for more details.
121+#
122+# You should have received a copy of the GNU General Public License along
123+# with this program. If not, see <https://www.gnu.org/licenses/>.
124+#
125+# As a special exception, the respective Autoconf Macro's copyright owner
126+# gives unlimited permission to copy, distribute and modify the configure
127+# scripts that are the output of Autoconf when processing the Macro. You
128+# need not follow the terms of the GNU General Public License when using
129+# or distributing such scripts, even though portions of the text of the
130+# Macro appear in them. The GNU General Public License (GPL) does govern
131+# all other use of the material that constitutes the Autoconf Macro.
132+#
133+# This special exception to the GPL applies to versions of the Autoconf
134+# Macro released by the Autoconf Archive. When you make and distribute a
135+# modified version of the Autoconf Macro, you may extend this special
136+# exception to the GPL to apply to your modified version as well.
137+
138+#serial 3
139+
140+dnl Get a default for CC_FOR_BUILD to put into Makefile.
141+AC_DEFUN([AX_CC_FOR_BUILD],
142+[# Put a plausible default for CC_FOR_BUILD in Makefile.
143+if test -z "$CC_FOR_BUILD"; then
144+ if test "x$cross_compiling" = "xno"; then
145+ CC_FOR_BUILD='$(CC)'
146+ else
147+ CC_FOR_BUILD=gcc
148+ fi
149+fi
150+AC_SUBST(CC_FOR_BUILD)
151+# Also set EXEEXT_FOR_BUILD.
152+if test "x$cross_compiling" = "xno"; then
153+ EXEEXT_FOR_BUILD='$(EXEEXT)'
154+else
155+ AC_CACHE_CHECK([for build system executable suffix], bfd_cv_build_exeext,
156+ [rm -f conftest*
157+ echo 'int main () { return 0; }' > conftest.c
158+ bfd_cv_build_exeext=
159+ ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5
160+ for file in conftest.*; do
161+ case $file in
162+ *.c | *.o | *.obj | *.ilk | *.pdb) ;;
163+ *) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
164+ esac
165+ done
166+ rm -f conftest*
167+ test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no])
168+ EXEEXT_FOR_BUILD=""
169+ test x"${bfd_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
170+fi
171+AC_SUBST(EXEEXT_FOR_BUILD)])dnl