Skip to content

Commit

Permalink
test configure
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilong-Li committed Dec 14, 2024
1 parent fd8b91c commit 40a3453
Showing 1 changed file with 93 additions and 2 deletions.
95 changes: 93 additions & 2 deletions configure
Original file line number Diff line number Diff line change
@@ -1,5 +1,96 @@
#!/bin/sh
#!/bin/bash
# Configure script for R package with htslib integration

# Exit on any error
set -e

HTSLIB_DIR="src/htslib-1.21"
echo "Configuring HTSlib in $HTSLIB_DIR"
cd $HTSLIB_DIR && ./configure --without-libdeflate && make libhts.a
# cd $HTSLIB_DIR && ./configure --without-libdeflate && make libhts.a

# Determine the package source directory
PKG_SOURCE_DIR=$(pwd)

# Create a directory for htslib build
HTSLIB_BUILD_DIR="${PKG_SOURCE_DIR}/src/htslib_build"
mkdir -p "${HTSLIB_BUILD_DIR}"

# Function to check for compilation tools
check_tools() {
# Check for essential build tools
command -v gcc >/dev/null 2>&1 || {
echo "Error: GCC compiler not found" >&2
exit 1
}
command -v make >/dev/null 2>&1 || {
echo "Error: Make not found" >&2
exit 1
}
}

# Function to configure and build htslib
build_htslib() {
echo "Configuring htslib..."

# Go to the htslib source directory
cd "${PKG_SOURCE_DIR}/${HTSLIB_DIR}"

# Clean any previous builds
make clean || true

# Configure htslib
# Customize these options as needed
./configure \
--disable-shared \
--enable-static \
--prefix="${HTSLIB_BUILD_DIR}" \
CFLAGS="-O2 -fPIC"

# Build htslib
make
make install
}

# Function to create Makevars files
create_makevars() {
echo "Creating Makevars files..."

# Unix Makevars
cat > "${PKG_SOURCE_DIR}/src/Makevars" << EOL
# Paths and flags for htslib
PKG_CPPFLAGS = -I${HTSLIB_BUILD_DIR}/include -I${PKG_SOURCE_DIR}/inst/include
PKG_LIBS = -L${HTSLIB_BUILD_DIR}/lib -lhts -lz
# Ensure static linking
STATICALLY_LINKED_LIBS = ${HTSLIB_BUILD_DIR}/lib/libhts.a
EOL

# Windows Makevars
cat > "${PKG_SOURCE_DIR}/src/Makevars.win" << EOL
# Windows-specific paths and flags for htslib
PKG_CPPFLAGS = -I${HTSLIB_BUILD_DIR}/include -I${PKG_SOURCE_DIR}/inst/include
PKG_LIBS = -L${HTSLIB_BUILD_DIR}/lib -lhts -lz
# Ensure static linking
STATICALLY_LINKED_LIBS = ${HTSLIB_BUILD_DIR}/lib/libhts.a
EOL
}

# Main script execution
main() {
# Check for necessary build tools
check_tools

# Build htslib
build_htslib

# Create Makevars files
# create_makevars

echo "htslib configuration complete."
exit 0
}

# Run the main function
main

0 comments on commit 40a3453

Please sign in to comment.