at 24.05-pre 114 lines 2.9 kB view raw
1# BSD makefiles should be able to detect this 2# but without they end up using gcc on Darwin stdenv 3addMakeFlags() { 4 export setOutputFlags= 5 6 export LIBCRT0= 7 export LIBCRTI= 8 export LIBCRTEND= 9 export LIBCRTBEGIN= 10 export LIBC= 11 export LIBUTIL= 12 export LIBSSL= 13 export LIBCRYPTO= 14 export LIBCRYPT= 15 export LIBCURSES= 16 export LIBTERMINFO= 17 export LIBM= 18 export LIBL= 19 20 export _GCC_CRTBEGIN= 21 export _GCC_CRTBEGINS= 22 export _GCC_CRTEND= 23 export _GCC_CRTENDS= 24 export _GCC_LIBGCCDIR= 25 export _GCC_CRTI= 26 export _GCC_CRTN= 27 export _GCC_CRTDIR= 28 29 # Definitions passed to share/mk/*.mk. Should be pretty simple - 30 # eventually maybe move it to a configure script. 31 export DESTDIR= 32 export USETOOLS=never 33 export NOCLANGERROR=yes 34 export NOGCCERROR=yes 35 export LEX=flex 36 export MKUNPRIVED=yes 37 export EXTERNAL_TOOLCHAIN=yes 38 39 makeFlags="MACHINE=$MACHINE $makeFlags" 40 makeFlags="MACHINE_ARCH=$MACHINE_ARCH $makeFlags" 41 makeFlags="AR=$AR $makeFlags" 42 makeFlags="CC=$CC $makeFlags" 43 makeFlags="CPP=$CPP $makeFlags" 44 makeFlags="CXX=$CXX $makeFlags" 45 makeFlags="LD=$LD $makeFlags" 46 makeFlags="STRIP=$STRIP $makeFlags" 47 48 makeFlags="BINDIR=${!outputBin}/bin $makeFlags" 49 makeFlags="LIBDIR=${!outputLib}/lib $makeFlags" 50 makeFlags="SHLIBDIR=${!outputLib}/lib $makeFlags" 51 makeFlags="SHAREDIR=${!outputLib}/share $makeFlags" 52 makeFlags="MANDIR=${!outputMan}/share/man $makeFlags" 53 makeFlags="INFODIR=${!outputInfo}/share/info $makeFlags" 54 makeFlags="DOCDIR=${!outputDoc}/share/doc $makeFlags" 55 makeFlags="LOCALEDIR=${!outputLib}/share/locale $makeFlags" 56 57 # Parallel building. Needs the space. 58 makeFlags="-j $NIX_BUILD_CORES $makeFlags" 59} 60 61setBSDSourceDir() { 62 sourceRoot=$PWD/$sourceRoot 63 export BSDSRCDIR=$sourceRoot 64 export _SRC_TOP_=$BSDSRCDIR 65 cd $sourceRoot 66} 67 68cdBSDPath() { 69 if [ -d "$COMPONENT_PATH" ] 70 then sourceRoot=$sourceRoot/$COMPONENT_PATH 71 cd $COMPONENT_PATH 72 fi 73} 74 75includesPhase() { 76 if [ -z "${skipIncludesPhase:-}" ]; then 77 runHook preIncludes 78 79 local flagsArray=( 80 $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"} 81 includes 82 ) 83 84 echoCmd 'includes flags' "${flagsArray[@]}" 85 make ${makefile:+-f $makefile} "${flagsArray[@]}" 86 87 moveUsrDir 88 89 runHook postIncludes 90 fi 91} 92 93moveUsrDir() { 94 if [ -d $prefix ]; then 95 # Remove lingering /usr references 96 if [ -d $prefix/usr ]; then 97 # Didn't try using rsync yet because per 98 # https://unix.stackexchange.com/questions/127712/merging-folders-with-mv, 99 # it's not neessarily better. 100 pushd $prefix/usr 101 find . -type d -exec mkdir -p $out/\{} \; 102 find . \( -type f -o -type l \) -exec mv \{} $out/\{} \; 103 popd 104 fi 105 106 find $prefix -type d -empty -delete 107 fi 108} 109 110postUnpackHooks+=(setBSDSourceDir) 111postPatchHooks+=(cdBSDPath) 112preConfigureHooks+=(addMakeFlags) 113preInstallHooks+=(includesPhase) 114fixupOutputHooks+=(moveUsrDir)