Commit ceceaa4a authored by Ramon Nou's avatar Ramon Nou
Browse files

reduced arch compilationf for capstone

parent 12d80926
Loading
Loading
Loading
Loading
Loading
+39 −1
Original line number Diff line number Diff line
@@ -48,7 +48,45 @@ pkg_install() {
    CURR="${SOURCE_DIR}/${ID}"
    prepare_build_dir "${CURR}"
    cd "${CURR}/build"
    ${CMAKE} -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_SHARED_LIBS=ON ..
    ARCH_FLAGS="-DCAPSTONE_ARCHITECTURE_DEFAULT=OFF"

    # 2. Detect the host device's architecture
    DEVICE_ARCH=$(uname -m)

    case "$DEVICE_ARCH" in
    aarch64*|arm64)
        # For 64-bit ARM, it's usually best to include both 32-bit and 64-bit ARM support
        ARCH_FLAGS="$ARCH_FLAGS -DCAPSTONE_AARCH64_SUPPORT=ON -DCAPSTONE_ARM_SUPPORT=ON"
        ;;
    arm*)
        # 32-bit ARM devices (armv7l, etc.)
        ARCH_FLAGS="$ARCH_FLAGS -DCAPSTONE_ARM_SUPPORT=ON"
        ;;
    x86_64|i*86)
        # Intel / AMD devices
        ARCH_FLAGS="$ARCH_FLAGS -DCAPSTONE_X86_SUPPORT=ON"
        ;;
    riscv*)
        # RISC-V devices
        ARCH_FLAGS="$ARCH_FLAGS -DCAPSTONE_RISCV_SUPPORT=ON"
        ;;
    mips*)
        # MIPS devices
        ARCH_FLAGS="$ARCH_FLAGS -DCAPSTONE_MIPS_SUPPORT=ON"
        ;;
    ppc*)
        # PowerPC devices
        ARCH_FLAGS="$ARCH_FLAGS -DCAPSTONE_PPC_SUPPORT=ON"
        ;;
    *)
        # Fallback if architecture is unknown: just build everything
        echo "Unknown architecture $DEVICE_ARCH, falling back to all architectures."
        ARCH_FLAGS="-DCAPSTONE_ARCHITECTURE_DEFAULT=ON"
        ;;
    esac


    ${CMAKE} -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_SHARED_LIBS=ON $ARCH_FLAGS ..
    make -j"${CORES}" install
}