diff --git a/src/bin/cook.rs b/src/bin/cook.rs index 4b394b74c..071b77add 100644 --- a/src/bin/cook.rs +++ b/src/bin/cook.rs @@ -168,6 +168,30 @@ fn run_command_stdin(mut command: process::Command, stdin_data: &[u8]) -> Result Ok(()) } +static SHARED_PRESCRIPT: &str = r#" +function DYNAMIC_INIT { + echo "WARN: Program is being compiled dynamically." + + COOKBOOK_CONFIGURE_FLAGS=( + --host="${GNU_TARGET}" + --prefix="" + --enable-shared + --disable-static + ) + + # TODO: check paths for spaces + export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib" + + COOKBOOK_AUTORECONF="autoreconf" + autotools_recursive_regenerate() { + for f in $(find . -name configure.ac -o -name configure.in -type f | sort); do + echo "* autotools regen in '$(dirname $f)'..." + ( cd "$(dirname "$f")" && "${COOKBOOK_AUTORECONF}" -fvi "$@" -I${COOKBOOK_HOST_SYSROOT}/share/aclocal ) + done + } +} +"#; + fn fetch(recipe_dir: &Path, source: &Option) -> Result { let source_dir = recipe_dir.join("source"); match source { @@ -392,7 +416,7 @@ fi"#, let mut command = Command::new("bash"); command.arg("-ex"); command.current_dir(&source_dir_tmp); - run_command_stdin(command, script.as_bytes())?; + run_command_stdin(command, format!("{SHARED_PRESCRIPT}\n{script}").as_bytes())?; } // Move source.tmp to source atomically @@ -716,7 +740,7 @@ done command }; - let full_script = format!("{}\n{}\n{}", pre_script, script, post_script); + let full_script = format!("{}\n{}\n{}\n{}", pre_script, SHARED_PRESCRIPT, script, post_script); run_command_stdin(command, full_script.as_bytes())?; // Move stage.tmp to stage atomically