void-packages/srcpkgs/yaboot/patches/0003-build-system.patch
q66 90f5f8ffe1 New package: yaboot-1.3.17
This should replace the yaboot-bin package (which should be dropped
assuming this is found to be working well). This, instead of taking
the binary from Debian, compiles yaboot from source.

The tricky part here is e2fsprogs, or rather, libext2fs. Yaboot
requires a fairly old version of it, and being a strictly ppc32
program, needs that library compiled in a minimal form for ppc32.
In order to achieve that, I abuse the cross-compiler, using the
musl ppc32 cross-compiler as that's universally available on all
crosshosts, as well as all ppc64 (and ppc32 doesn't need it).

The main reason to do this over shipping the binary is that this
will actually work properly on some ppc64 machines, which require
the bundled addnote executable, which can now be compiled properly
for the native architecture.
2019-10-25 23:52:27 +02:00

110 lines
4.1 KiB
Diff

This is different from what Debian does. It does several things required only
for us. We disable usage of native CFLAGS for the yaboot binary itself as that
is loaded by OF (and is 32-bit). We keep CFLAGS intact for the userland part.
Additionally, we fix various paths, and make sure a 32-bit crosscompiler is
used for yaboot itself, in order to ensure linkage against correct libgcc and
so on, which is required. We alter the flags for that too (must be synchronized
with the flags used for e2fsprogs, see the template).
Also do not strip the binaries upon install, xbps-src will take care of that.
--- a/Makefile
+++ b/Makefile
@@ -7,8 +7,8 @@ VERSION = 1.3.17
DEBUG = 0
# make install vars
ROOT =
-PREFIX = usr/local
-MANDIR = man
+PREFIX = usr
+MANDIR = share/man
# command used to get root (needed for tarball creation)
GETROOT = fakeroot
@@ -32,14 +32,17 @@ LD := $(CROSS)ld
AS := $(CROSS)as
OBJCOPY := $(CROSS)objcopy
+# The compiler to use for yaboot itself
+YBCC = $(CC)
+
# The flags for the yaboot binary.
#
-YBCFLAGS = -Os -m32 $(CFLAGS) -nostdinc -Wall -isystem `$(CC) -m32 -print-file-name=include` -fsigned-char
+YBCFLAGS = -Os -m32 -nostdinc -Wall -isystem `$(YBCC) -m32 -print-file-name=include` -fsigned-char
YBCFLAGS += -DVERSION="\"${VERSION}${VERSIONEXTRA}\""
YBCFLAGS += -DTEXTADDR=$(TEXTADDR) -DDEBUG=$(DEBUG)
YBCFLAGS += -DMALLOCADDR=$(MALLOCADDR) -DMALLOCSIZE=$(MALLOCSIZE)
YBCFLAGS += -DKERNELADDR=$(KERNELADDR)
-YBCFLAGS += -Werror -fdiagnostics-show-option
+YBCFLAGS += -fgnu89-inline -fno-builtin-malloc -fno-stack-protector -no-pie
YBCFLAGS += -I ./include
YBCFLAGS += -fno-strict-aliasing
@@ -69,12 +72,12 @@ LFLAGS = -Ttext $(TEXTADDR) -Bstatic -melf32ppclinux
# Libraries
#
-LLIBS = -lext2fs
+LLIBS = ./libext2fs.a ./libcom_err.a
# For compiling userland utils
#
UCFLAGS = -Os $(CFLAGS) -Wall -I/usr/include
-UCFLAGS += -Werror -fdiagnostics-show-option
+UCFLAGS += -fdiagnostics-show-option
# For compiling build-tools that run on the host.
#
@@ -103,7 +106,7 @@ OBJS += second/fs_reiserfs.o
endif
# compilation
-lgcc = `$(CC) -m32 -print-libgcc-file-name`
+lgcc = `$(YBCC) -m32 -print-libgcc-file-name`
all: yaboot addnote mkofboot
@@ -125,10 +128,10 @@ mkofboot:
fi
%.o: %.c
- $(CC) $(YBCFLAGS) -c -o $@ $<
+ $(YBCC) $(YBCFLAGS) -c -o $@ $<
%.o: %.S
- $(CC) $(YBCFLAGS) -D__ASSEMBLY__ -c -o $@ $<
+ $(YBCC) $(YBCFLAGS) -D__ASSEMBLY__ -c -o $@ $<
dep:
makedepend -Iinclude *.c lib/*.c util/*.c gui/*.c
@@ -181,9 +184,9 @@ strip: all
strip util/addnote
strip --remove-section=.comment --remove-section=.note util/addnote
-install: all strip
+install: all
install -d -o root -g root -m 0755 ${ROOT}/etc/
- install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/sbin/
+ install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/bin/
install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/lib
install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/lib/yaboot
install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/${MANDIR}/man5/
@@ -191,11 +194,11 @@ install: all strip
install -o root -g root -m 0644 second/yaboot ${ROOT}/$(PREFIX)/lib/yaboot
install -o root -g root -m 0755 util/addnote ${ROOT}/${PREFIX}/lib/yaboot/addnote
install -o root -g root -m 0644 first/ofboot ${ROOT}/${PREFIX}/lib/yaboot/ofboot
- install -o root -g root -m 0755 ybin/ofpath ${ROOT}/${PREFIX}/sbin/ofpath
- install -o root -g root -m 0755 ybin/ybin ${ROOT}/${PREFIX}/sbin/ybin
- install -o root -g root -m 0755 ybin/yabootconfig ${ROOT}/${PREFIX}/sbin/yabootconfig
- rm -f ${ROOT}/${PREFIX}/sbin/mkofboot
- ln -s ybin ${ROOT}/${PREFIX}/sbin/mkofboot
+ install -o root -g root -m 0755 ybin/ofpath ${ROOT}/${PREFIX}/bin/ofpath
+ install -o root -g root -m 0755 ybin/ybin ${ROOT}/${PREFIX}/bin/ybin
+ install -o root -g root -m 0755 ybin/yabootconfig ${ROOT}/${PREFIX}/bin/yabootconfig
+ rm -f ${ROOT}/${PREFIX}/bin/mkofboot
+ ln -s ybin ${ROOT}/${PREFIX}/bin/mkofboot
@gzip -9 man/*.[58]
install -o root -g root -m 0644 man/bootstrap.8.gz ${ROOT}/${PREFIX}/${MANDIR}/man8/bootstrap.8.gz
install -o root -g root -m 0644 man/mkofboot.8.gz ${ROOT}/${PREFIX}/${MANDIR}/man8/mkofboot.8.gz