#!/bin/bash
source $ROOT_PATH/scripts/common.sh

echo "### Creating build directory for libwebsockets on macOS..."
mkdir -p ./libwebsockets/build/mac || handle_error "Failed to create build directory for libwebsockets on macOS"

echo "### Changing directory to libwebsockets build directory on macOS..."
cd ./libwebsockets/build/mac || handle_error "Failed to change directory to libwebsockets build directory on macOS"

echo "### Configuring libwebsockets with CMake on macOS..."
cmake ../../ -DLWS_WITH_SSL=ON -DOPENSSL_ROOT_DIR="$OPENSSL_ROOT_DIR" -DOPENSSL_LIBRARIES="$OPENSSL_LIBRARIES" || handle_error "Failed to configure libwebsockets with CMake on macOS"

echo "### Building libwebsockets on macOS..."
cmake --build . || handle_error "Failed to build libwebsockets on macOS"

echo "### Build process for libwebsockets on macOS completed successfully."
