python312Packages.vdf: avoid using pname for src.repo
[NixPkgs.git] / pkgs / os-specific / bsd / setup-hook.sh
blobbc8d372ca8b8672a799a3ea98b34270b459baee9
1 # BSD makefiles should be able to detect this
2 # but without they end up using gcc on Darwin stdenv
3 addMakeFlags() {
4 export setOutputFlags=
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=
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=
29 # Definitions passed to share/mk/*.mk. Should be pretty simple -
30 # eventually maybe move it to a configure script.
31 export USETOOLS=never
32 export NOCLANGERROR=yes
33 export NOGCCERROR=yes
34 export LEX=flex
35 export MKUNPRIVED=yes
36 export EXTERNAL_TOOLCHAIN=yes
38 makeFlags="MACHINE=$MACHINE $makeFlags"
39 makeFlags="MACHINE_ARCH=$MACHINE_ARCH $makeFlags"
40 makeFlags="AR=$AR $makeFlags"
41 makeFlags="CC=$CC $makeFlags"
42 makeFlags="CPP=$CPP $makeFlags"
43 makeFlags="CXX=$CXX $makeFlags"
44 makeFlags="LD=$LD $makeFlags"
45 makeFlags="STRIP=$STRIP $makeFlags"
47 makeFlags="BINDIR=${!outputBin}/bin $makeFlags"
48 makeFlags="LIBDIR=${!outputLib}/lib $makeFlags"
49 makeFlags="SHLIBDIR=${!outputLib}/lib $makeFlags"
50 makeFlags="SHAREDIR=${!outputLib}/share $makeFlags"
51 makeFlags="INFODIR=${!outputInfo}/share/info $makeFlags"
52 makeFlags="DOCDIR=${!outputDoc}/share/doc $makeFlags"
53 makeFlags="LOCALEDIR=${!outputLib}/share/locale $makeFlags"
55 # Parallel building. Needs the space.
56 makeFlags="-j $NIX_BUILD_CORES $makeFlags"
59 setBSDSourceDir() {
60 sourceRoot=$PWD/$sourceRoot
61 export BSDSRCDIR=$sourceRoot
62 export _SRC_TOP_=$BSDSRCDIR
63 cd $sourceRoot
66 cdBSDPath() {
67 if [ -d "$COMPONENT_PATH" ]
68 then sourceRoot=$sourceRoot/$COMPONENT_PATH
69 cd $COMPONENT_PATH
73 includesPhase() {
74 if [ -z "${skipIncludesPhase:-}" ]; then
75 runHook preIncludes
77 local flagsArray=(
78 $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
79 includes
82 echoCmd 'includes flags' "${flagsArray[@]}"
83 make ${makefile:+-f $makefile} "${flagsArray[@]}"
85 moveUsrDir
87 runHook postIncludes
91 moveUsrDir() {
92 if [ -d $prefix ]; then
93 # Remove lingering /usr references
94 if [ -d $prefix/usr ]; then
95 # Didn't try using rsync yet because per
96 # https://unix.stackexchange.com/questions/127712/merging-folders-with-mv,
97 # it's not neessarily better.
98 pushd $prefix/usr
99 find . -type d -exec mkdir -p $out/\{} \;
100 find . \( -type f -o -type l \) -exec mv \{} $out/\{} \;
101 popd
104 find $prefix -type d -empty -delete
108 postUnpackHooks+=(setBSDSourceDir)
109 postPatchHooks+=(cdBSDPath)
110 preConfigureHooks+=(addMakeFlags)
111 preInstallHooks+=(includesPhase)
112 fixupOutputHooks+=(moveUsrDir)