2020-03-09 06:10:06 +00:00
|
|
|
# BSD makefiles should be able to detect this
|
2018-07-28 17:29:02 +01:00
|
|
|
# but without they end up using gcc on Darwin stdenv
|
|
|
|
addMakeFlags() {
|
|
|
|
export setOutputFlags=
|
|
|
|
|
|
|
|
export LIBCRT0=
|
|
|
|
export LIBCRTI=
|
|
|
|
export LIBCRTEND=
|
|
|
|
export LIBCRTBEGIN=
|
|
|
|
export LIBC=
|
|
|
|
export LIBUTIL=
|
|
|
|
export LIBSSL=
|
|
|
|
export LIBCRYPTO=
|
|
|
|
export LIBCRYPT=
|
|
|
|
export LIBCURSES=
|
|
|
|
export LIBTERMINFO=
|
|
|
|
export LIBM=
|
|
|
|
export LIBL=
|
|
|
|
|
|
|
|
export _GCC_CRTBEGIN=
|
|
|
|
export _GCC_CRTBEGINS=
|
|
|
|
export _GCC_CRTEND=
|
|
|
|
export _GCC_CRTENDS=
|
|
|
|
export _GCC_LIBGCCDIR=
|
|
|
|
export _GCC_CRTI=
|
|
|
|
export _GCC_CRTN=
|
|
|
|
export _GCC_CRTDIR=
|
|
|
|
|
|
|
|
# Definitions passed to share/mk/*.mk. Should be pretty simple -
|
|
|
|
# eventually maybe move it to a configure script.
|
|
|
|
export USETOOLS=never
|
|
|
|
export NOCLANGERROR=yes
|
|
|
|
export NOGCCERROR=yes
|
|
|
|
export LEX=flex
|
|
|
|
export MKUNPRIVED=yes
|
|
|
|
export EXTERNAL_TOOLCHAIN=yes
|
|
|
|
|
|
|
|
makeFlags="MACHINE=$MACHINE $makeFlags"
|
|
|
|
makeFlags="MACHINE_ARCH=$MACHINE_ARCH $makeFlags"
|
|
|
|
makeFlags="AR=$AR $makeFlags"
|
|
|
|
makeFlags="CC=$CC $makeFlags"
|
|
|
|
makeFlags="CPP=$CPP $makeFlags"
|
|
|
|
makeFlags="CXX=$CXX $makeFlags"
|
|
|
|
makeFlags="LD=$LD $makeFlags"
|
|
|
|
makeFlags="STRIP=$STRIP $makeFlags"
|
|
|
|
|
|
|
|
makeFlags="BINDIR=${!outputBin}/bin $makeFlags"
|
|
|
|
makeFlags="LIBDIR=${!outputLib}/lib $makeFlags"
|
|
|
|
makeFlags="SHLIBDIR=${!outputLib}/lib $makeFlags"
|
2022-10-06 05:51:05 +01:00
|
|
|
makeFlags="SHAREDIR=${!outputLib}/share $makeFlags"
|
2018-07-28 17:29:02 +01:00
|
|
|
makeFlags="INFODIR=${!outputInfo}/share/info $makeFlags"
|
|
|
|
makeFlags="DOCDIR=${!outputDoc}/share/doc $makeFlags"
|
|
|
|
makeFlags="LOCALEDIR=${!outputLib}/share/locale $makeFlags"
|
|
|
|
|
|
|
|
# Parallel building. Needs the space.
|
|
|
|
makeFlags="-j $NIX_BUILD_CORES $makeFlags"
|
|
|
|
}
|
|
|
|
|
2020-03-09 06:10:06 +00:00
|
|
|
setBSDSourceDir() {
|
2018-07-28 17:29:02 +01:00
|
|
|
sourceRoot=$PWD/$sourceRoot
|
2020-03-09 06:10:06 +00:00
|
|
|
export BSDSRCDIR=$sourceRoot
|
|
|
|
export _SRC_TOP_=$BSDSRCDIR
|
2018-07-28 17:29:02 +01:00
|
|
|
cd $sourceRoot
|
2022-10-06 05:51:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cdBSDPath() {
|
2022-10-06 19:44:14 +01:00
|
|
|
if [ -d "$COMPONENT_PATH" ]
|
|
|
|
then sourceRoot=$sourceRoot/$COMPONENT_PATH
|
|
|
|
cd $COMPONENT_PATH
|
2018-07-28 17:29:02 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
includesPhase() {
|
|
|
|
if [ -z "${skipIncludesPhase:-}" ]; then
|
2020-03-09 06:10:06 +00:00
|
|
|
runHook preIncludes
|
2018-07-28 17:29:02 +01:00
|
|
|
|
|
|
|
local flagsArray=(
|
|
|
|
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
netbsd.compat: Fix cross compilation
Not to netbsd, where it isn't needed, but elsewhere.
A few things going on here:
- Make compat use the "regular" not "host" makefile infra. This,
however, makes more assumptions that the toolchain is BSD-like, and
so we need to compensate for them with the likes of:
- `LORDER=...` and `TSORT=...`
- Move `export INSTALL_*` to install's setup hook so they don't interfere
with coreutils install
- Don't use `DESTDIR` for installing include files, instead set `INCSDIR`.
This is more proper, but doesn't work when `INCSDIR` is set multiple
times, unfortunately, as CLI defs override all other assignments. So
instead set `INCSDIR0` on the CLI, and do some `INCSDIR =
${INCSDIR0}/...` in the relevant packages.
- `INCSDIR` is set just in the NetBSD setup hook because FreeBSD uses
`INCLUDEDIR`.
2021-09-01 22:44:25 +01:00
|
|
|
includes
|
2018-07-28 17:29:02 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
echoCmd 'includes flags' "${flagsArray[@]}"
|
|
|
|
make ${makefile:+-f $makefile} "${flagsArray[@]}"
|
|
|
|
|
|
|
|
moveUsrDir
|
|
|
|
|
2020-03-09 06:10:06 +00:00
|
|
|
runHook postIncludes
|
2018-07-28 17:29:02 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
moveUsrDir() {
|
|
|
|
if [ -d $prefix ]; then
|
|
|
|
# Remove lingering /usr references
|
|
|
|
if [ -d $prefix/usr ]; then
|
2021-04-19 23:23:30 +01:00
|
|
|
# Didn't try using rsync yet because per
|
|
|
|
# https://unix.stackexchange.com/questions/127712/merging-folders-with-mv,
|
|
|
|
# it's not neessarily better.
|
2021-04-18 11:50:14 +01:00
|
|
|
pushd $prefix/usr
|
2018-07-28 17:29:02 +01:00
|
|
|
find . -type d -exec mkdir -p $out/\{} \;
|
|
|
|
find . \( -type f -o -type l \) -exec mv \{} $out/\{} \;
|
2021-04-18 11:50:14 +01:00
|
|
|
popd
|
2018-07-28 17:29:02 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
find $prefix -type d -empty -delete
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-03-09 06:10:06 +00:00
|
|
|
postUnpackHooks+=(setBSDSourceDir)
|
2022-10-06 05:51:05 +01:00
|
|
|
postPatchHooks+=(cdBSDPath)
|
2018-07-28 17:29:02 +01:00
|
|
|
preConfigureHooks+=(addMakeFlags)
|
|
|
|
preInstallHooks+=(includesPhase)
|
|
|
|
fixupOutputHooks+=(moveUsrDir)
|