From f8c1dba3d3e375bb97f64a4d29d07035bdb0f2a9 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Thu, 12 Jan 2023 16:29:19 -0500 Subject: [PATCH] gnu: bc: Fix cross-compilation. The existing cross-compilation patch no longer worked. It's been reworked and submitted to upstream. * gnu/packages/algebra.scm (bc) [native-inputs]: Add readline. * gnu/packages/patches/bc-fix-cross-compilation.patch: Refresh patch. Series-postfix: core-updates Series-to: 60760@debbugs.gnu.org --- gnu/packages/algebra.scm | 2 +- .../patches/bc-fix-cross-compilation.patch | 74 ++++++++++++------- 2 files changed, 47 insertions(+), 29 deletions(-) diff --git a/gnu/packages/algebra.scm b/gnu/packages/algebra.scm index e093056e0d..620bd5c355 100644 --- a/gnu/packages/algebra.scm +++ b/gnu/packages/algebra.scm @@ -685,7 +685,7 @@ (define-public bc (patches (search-patches "bc-fix-cross-compilation.patch")))) (build-system gnu-build-system) (native-inputs - (list automake autoconf ed flex texinfo)) + (list automake autoconf ed flex readline texinfo)) (inputs (list readline)) (arguments diff --git a/gnu/packages/patches/bc-fix-cross-compilation.patch b/gnu/packages/patches/bc-fix-cross-compilation.patch index 14dfecdbde..04f2c92abf 100644 --- a/gnu/packages/patches/bc-fix-cross-compilation.patch +++ b/gnu/packages/patches/bc-fix-cross-compilation.patch @@ -1,15 +1,19 @@ -Patch taken from nix. - -commit fdda59736ddc048cf38a2c7103f4f5d9eeaf995e -Author: Ben Gamari -Date: Tue Oct 17 10:51:34 2017 -0400 - - Try implementing cross-compilation +Patch adapted from Nix. +Upstream-status: Submitted to bug-bc@gnu.org. diff --git a/bc/Makefile.am b/bc/Makefile.am -index d9d412e..fdef633 100644 +index d9d412e..13f2b1e 100644 --- a/bc/Makefile.am +++ b/bc/Makefile.am +@@ -8,7 +8,7 @@ EXTRA_DIST = bc.h bcdefs.h const.h fix-libmath_h global.h libmath.b proto.h \ + sbc.y + noinst_HEADERS = libmath.h + +-DISTCLEANFILES = sbc sbc.c sbc.h libmath.h ++DISTCLEANFILES = fbc sbc sbc.c sbc.h libmath.h + + MAINTAINERCLEANFILES = Makefile.in bc.c bc.h scan.c \ + bc.y bcdefs.h const.h execute.c fix-libmath_h \ @@ -17,6 +17,7 @@ MAINTAINERCLEANFILES = Makefile.in bc.c bc.h scan.c \ AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/../h @@ -18,31 +22,36 @@ index d9d412e..fdef633 100644 LIBL = @LEXLIB@ LDADD = $(LIBBC) $(LIBL) @READLINELIB@ -@@ -29,12 +30,20 @@ $(PROGRAMS): libmath.h $(LIBBC) +@@ -29,15 +30,22 @@ $(PROGRAMS): libmath.h $(LIBBC) scan.o: bc.h global.o: libmath.h -+ -+main_host.c : main.c -+ cp $< $@ -fbcOBJ = main.o bc.o scan.o execute.o load.o storage.o util.o warranty.o -+fbcOBJ = $(addsuffix _host,main.o bc.o scan.o execute.o load.o storage.o util.o warranty.o) -+ -+%.o_host : CC:=$(CC_FOR_BUILD) -+ -+%.o_host : %.c -+ $(COMPILE) -c $(CFLAGS) $(INCLUDES) -o $@ $< ++%.o_host: CC := $(CC_FOR_BUILD) ++%.o_host: %.c ++ $(COMPILE) -c -o $@ $< -libmath.h: libmath.b $(fbcOBJ) $(LIBBC) -+libmath.h: libmath.b $(fbcOBJ) $(LIBBC_HOST) - echo '{0}' > libmath.h +- echo '{0}' > libmath.h - $(MAKE) global.o - $(LINK) -o fbc $(fbcOBJ) global.o $(LIBBC) $(LIBL) $(READLINELIB) $(LIBS) -+ $(MAKE) global.o_host -+ $(CC_FOR_BUILD) -o fbc $(fbcOBJ) global.o_host $(LIBBC_HOST) $(LIBL) ${READLINELIB} $(LIBS) - ./fbc -c $(srcdir)/libmath.b libmath.h +- ./fbc -c $(srcdir)/libmath.b libmath.h ++fbcOBJ = $(addsuffix _host,\ ++ main.o bc.o scan.o execute.o load.o storage.o util.o warranty.o) ++ ++global_host.c: global.c ++ sed 's/#include "libmath.h"/{0}/' $< > $@ ++ ++fbc: $(fbcOBJ) global_host.o_host $(LIBBC_HOST) $(LIBS) ++ $(CC_FOR_BUILD) $(LIBL) $(READLINELIB) -o $@ $^ ++ ++libmath.h: libmath.b fbc $(LIBBC_HOST) ++ ./fbc -c $(srcdir)/libmath.b < /dev/null > libmath.h $(srcdir)/fix-libmath_h - rm -f ./fbc ./global.o +- rm -f ./fbc ./global.o + + sbcOBJ = main.o sbc.o scan.o execute.o global.o load.o storage.o util.o \ + warranty.o diff --git a/configure.ac b/configure.ac index fc74573..5cabb73 100644 --- a/configure.ac @@ -64,7 +73,7 @@ index fc74573..5cabb73 100644 AM_PROG_LEX diff --git a/lib/Makefile.am b/lib/Makefile.am -index ec4bf59..c670f5b 100644 +index ec4bf59..24c9f42 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,5 +1,5 @@ @@ -74,14 +83,23 @@ index ec4bf59..c670f5b 100644 AM_CPPFLAGS = -I. -I.. -I$(srcdir)/../h -@@ -24,3 +24,11 @@ testmul: testmul.o number.o +@@ -7,8 +7,6 @@ libbc_a_SOURCES = getopt.c getopt1.c vfprintf.c number.c + + DEFS = @DEFS@ $(DEFSADD) + +-AM_CFLAGS = @CFLAGS@ +- + MAINTAINERCLEANFILES = Makefile.in number.c + CLEANFILES = testmul specialnumber muldigits.h + +@@ -24,3 +22,11 @@ testmul: testmul.o number.o specialnumber: newnumber.o cp newnumber.o number.o + -+%.o_host : CC:=$(CC_FOR_BUILD) ++%.o_host: CC := $(CC_FOR_BUILD) +%.o_host : %.c -+ $(COMPILE) -c $(CFLAGS) $(INCLUDES) -o $@ $< ++ $(COMPILE) -c -o $@ $< + +libbc_host.a : $(addsuffix _host,$(libbc_a_OBJECTS)) + ar cru $@ $+