From cb4b2cbdd61f27f9936c86ddbfcaf45f3b671177 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 17 Feb 2016 00:19:13 -0500 Subject: [PATCH] Add separate install path for native tools. We need to distinguish between tools we compile to use as part of the build process, and things we build for the eventual target. Install these into separate install directories; for now, pkg-config is the only one of these. --- .gitignore | 1 + chocpkg/chocpkg | 47 +++++++++++++++++++++++++++++------- pkgdef/chocolate-doom-git.sh | 2 +- pkgdef/pkg-config.sh | 1 + setup.sh | 2 +- 5 files changed, 42 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 1bc3b65..a4dacd4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build install +install.native packages diff --git a/chocpkg/chocpkg b/chocpkg/chocpkg index 7b279ae..0ea907c 100755 --- a/chocpkg/chocpkg +++ b/chocpkg/chocpkg @@ -9,9 +9,10 @@ basic_setup() { exit -1 fi INSTALL_DIR="$CHOCPKG_ROOT/install" + NATIVE_INSTALL_DIR="$CHOCPKG_ROOT/install.native" PACKAGES_DIR="$CHOCPKG_ROOT/packages" BUILD_DIR="$CHOCPKG_ROOT/build" - mkdir -p "$INSTALL_DIR" "$PACKAGES_DIR" "$BUILD_DIR" + mkdir -p "$INSTALL_DIR" "$NATIVE_INSTALL_DIR" "$PACKAGES_DIR" "$BUILD_DIR" } basic_setup @@ -49,14 +50,15 @@ configure_for_package() { fi # Defaults for package unless overridden: PACKAGE_NAME=$package - PACKAGE_TYPE=fetch + PACKAGE_SOURCE_TYPE=fetch + PACKAGE_TYPE=target PACKAGE_CONFIGURE_OPTS="" DEPENDENCIES="" GIT_BRANCH=master . "$pkg_file" # After reading the package file, configure a few more variables: - case "$PACKAGE_TYPE" in + case "$PACKAGE_SOURCE_TYPE" in fetch) PACKAGE_FILENAME="$PACKAGE_NAME-$PACKAGE_VERSION.tar.gz" PACKAGE_BUILD_DIR="$BUILD_DIR/$PACKAGE_NAME-$PACKAGE_VERSION" @@ -64,10 +66,29 @@ configure_for_package() { git) PACKAGE_BUILD_DIR="$BUILD_DIR/$PACKAGE_NAME" ;; + *) + error_exit "Unknown package source type $PACKAGE_SOURCE_TYPE" + ;; + esac + + # We set up build differently depending on the package type: some packages + # are for the target we're building for; others are native tools to run on + # the build machine as part of the build process. + case "$PACKAGE_TYPE" in + target) + PACKAGE_INSTALL_DIR="$INSTALL_DIR" + ;; + native) + PACKAGE_INSTALL_DIR="$NATIVE_INSTALL_DIR" + ;; *) error_exit "Unknown package type $PACKAGE_TYPE" ;; esac + + # We must set PKG_CONFIG_PATH now so we know where to look for packages. + PKG_CONFIG_PATH="$PACKAGE_INSTALL_DIR/lib/pkgconfig:${PKG_CONFIG_PATH:-}" + export PKG_CONFIG_PATH } download_package_file() { @@ -90,7 +111,7 @@ extract_package_file() { } fetch_package() { - case "$PACKAGE_TYPE" in + case "$PACKAGE_SOURCE_TYPE" in fetch) download_package_file extract_package_file @@ -104,12 +125,19 @@ fetch_package() { } setup_build_environment() { - . "$CHOCPKG_ROOT/buildenv.sh" + if [ "$PACKAGE_TYPE" = "target" ]; then + . "$CHOCPKG_ROOT/buildenv.sh" + fi - CPPFLAGS="-I$INSTALL_DIR/include" - LDFLAGS="-L$INSTALL_DIR/lib ${LDFLAGS:-}" + CPPFLAGS="-I$PACKAGE_INSTALL_DIR/include" + LDFLAGS="-L$PACKAGE_INSTALL_DIR/lib ${LDFLAGS:-}" + export CPPFLAGS LDFLAGS + + # ACLOCAL_PATH is a special case: we include the aclocal paths from both + # target and native, so that it is possible to get the pkg-config macros. ACLOCAL_PATH="$INSTALL_DIR/share/aclocal:${ACLOCAL_PATH:-}" - export CPPFLAGS LDFLAGS ACLOCAL_PATH + ACLOCAL_PATH="$NATIVE_INSTALL_DIR/share/aclocal:$ACLOCAL_PATH" + export ACLOCAL_PATH } build_package() { @@ -123,13 +151,14 @@ build_package() { echo ======================================================= echo cd "$PACKAGE_BUILD_DIR" + setup_build_environment if ! prebuild_setup; then error_exit "Failed pre-build setup step for $PACKAGE_NAME." fi - ./configure --prefix="$INSTALL_DIR" $PACKAGE_CONFIGURE_OPTS || ( + ./configure --prefix="$PACKAGE_INSTALL_DIR" $PACKAGE_CONFIGURE_OPTS || ( error_exit "Failed to configure package $PACKAGE_NAME for build." ) diff --git a/pkgdef/chocolate-doom-git.sh b/pkgdef/chocolate-doom-git.sh index 52a644c..db806b6 100644 --- a/pkgdef/chocolate-doom-git.sh +++ b/pkgdef/chocolate-doom-git.sh @@ -1,4 +1,4 @@ -PACKAGE_TYPE=git +PACKAGE_SOURCE_TYPE=git GIT_URL=https://github.com/fragglet/chocolate-doom.git GIT_BRANCH=sdl2-branch DEPENDENCIES="SDL2 SDL2_mixer SDL2_net" diff --git a/pkgdef/pkg-config.sh b/pkgdef/pkg-config.sh index 54f9868..5d87a7a 100644 --- a/pkgdef/pkg-config.sh +++ b/pkgdef/pkg-config.sh @@ -2,4 +2,5 @@ PACKAGE_VERSION=0.28 PACKAGE_URL=https://pkgconfig.freedesktop.org/releases/pkg-config-${PACKAGE_VERSION}.tar.gz PACKAGE_INSTALLED_TOOL=pkg-config PACKAGE_CONFIGURE_OPTS="--with-internal-glib" +PACKAGE_TYPE=native diff --git a/setup.sh b/setup.sh index e3fb2ca..c5518df 100644 --- a/setup.sh +++ b/setup.sh @@ -20,5 +20,5 @@ exit -1 esac # Set up various environment variables: -PATH="$CHOCPKG_ROOT/chocpkg:$CHOCPKG_ROOT/install/bin:$PATH" +PATH="$CHOCPKG_ROOT/chocpkg:$CHOCPKG_ROOT/install.native/bin:$PATH"