mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 11:40:45 +00:00
jam: fix OS determination on linux (#349044)
This commit is contained in:
commit
0ff4d56425
|
@ -49,21 +49,26 @@ stdenv.mkDerivation (finalAttrs: {
|
|||
export AR="$AR rc"
|
||||
'';
|
||||
|
||||
# When cross-compiling, we need to set the preprocessor macros
|
||||
# OSMAJOR/OSMINOR/OSPLAT to the values from the target platform, not the host
|
||||
# platform. This looks a little ridiculous because the vast majority of build
|
||||
# tools don't embed target-specific information into their binary, but in this
|
||||
# case we behave more like a compiler than a make(1)-alike.
|
||||
postPatch = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) ''
|
||||
cat >>jam.h <<EOF
|
||||
#undef OSMAJOR
|
||||
#undef OSMINOR
|
||||
#undef OSPLAT
|
||||
$(
|
||||
${pkgsBuildTarget.targetPackages.stdenv.cc}/bin/${pkgsBuildTarget.targetPackages.stdenv.cc.targetPrefix}cc -E -dM jam.h | grep -E '^#define (OSMAJOR|OSMINOR|OSPLAT) '
|
||||
)
|
||||
EOF
|
||||
'';
|
||||
postPatch =
|
||||
''
|
||||
substituteInPlace jam.h --replace-fail 'ifdef linux' 'ifdef __linux__'
|
||||
''
|
||||
+
|
||||
# When cross-compiling, we need to set the preprocessor macros
|
||||
# OSMAJOR/OSMINOR/OSPLAT to the values from the target platform, not the host
|
||||
# platform. This looks a little ridiculous because the vast majority of build
|
||||
# tools don't embed target-specific information into their binary, but in this
|
||||
# case we behave more like a compiler than a make(1)-alike.
|
||||
lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) ''
|
||||
cat >>jam.h <<EOF
|
||||
#undef OSMAJOR
|
||||
#undef OSMINOR
|
||||
#undef OSPLAT
|
||||
$(
|
||||
${pkgsBuildTarget.targetPackages.stdenv.cc}/bin/${pkgsBuildTarget.targetPackages.stdenv.cc.targetPrefix}cc -E -dM jam.h | grep -E '^#define (OSMAJOR|OSMINOR|OSPLAT) '
|
||||
)
|
||||
EOF
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
@ -87,6 +92,15 @@ stdenv.mkDerivation (finalAttrs: {
|
|||
package = finalAttrs.finalPackage;
|
||||
command = "jam -v";
|
||||
};
|
||||
tests.os = testers.runCommand {
|
||||
name = "${finalAttrs.finalPackage.name}-os";
|
||||
nativeBuildInputs = [ finalAttrs.finalPackage ];
|
||||
script = ''
|
||||
echo 'echo $(OS) ;' > Jamfile
|
||||
os=$(jam -d0)
|
||||
[[ $os != UNKNOWN* ]] && touch $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
|
Loading…
Reference in a new issue