SUMMARY="C++ Common Libraries"
DESCRIPTION="Abseil is an open-source collection of C++ code (compliant to \
C++11) designed to augment the C++ standard library."
HOMEPAGE="https://abseil.io"
COPYRIGHT="2017-2021 The Abseil Authors"
LICENSE="Apache v2"
REVISION="1"
SOURCE_URI="http://github.com/abseil/abseil-cpp/archive/$portVersion/abseil-$portVersion.tar.gz"
CHECKSUM_SHA256="dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4"
SOURCE_DIR="abseil-cpp-$portVersion"
PATCHES="abseil_cpp-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

libVersion="2111.0.0"
libVersionCompat="$libVersion compat >= $libVersion"
libs="
bad_optional_access bad_variant_access bad_any_cast_impl base city \
civil_time cord cord_internal cordz_functions cordz_handle cordz_info \
cordz_sample_token debugging_internal demangle_internal examine_stack \
exponential_biased failure_signal_handler flags flags_commandlineflag \
flags_commandlineflag_internal flags_config flags_internal flags_marshalling \
flags_parse flags_private_handle_accessor flags_program_name flags_reflection \
flags_usage flags_usage_internal graphcycles_internal hash hashtablez_sampler \
int128 leak_check leak_check_disable log_severity low_level_hash malloc_internal \
periodic_sampler random_distributions random_internal_distribution_test_util \
random_internal_platform random_internal_pool_urbg random_internal_randen \
random_internal_randen_hwaes random_internal_randen_hwaes_impl \
random_internal_randen_slow random_internal_seed_material \
random_seed_gen_exception random_seed_sequences raw_hash_set \
raw_logging_internal scoped_set_env spinlock_wait stacktrace status statusor \
str_format_internal strerror strings strings_internal symbolize \
synchronization throw_delegate time time_zone"
PROVIDES="
	abseil_cpp$secondaryArchSuffix = $portVersion
	"
for lib in $libs; do
	PROVIDES+="
		lib:libabsl_$lib$secondaryArchSuffix = $libVersionCompat"
done
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	abseil_cpp${secondaryArchSuffix}_devel = $portVersion
	"
for lib in $libs; do
	PROVIDES_devel+="
		devel:libabsl_$lib$secondaryArchSuffix = $libVersionCompat"
done
REQUIRES_devel="
	abseil_cpp$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

debugList=()
for lib in $libs; do
	debugList+=("$libDir"/libabsl_$lib.so.$libVersion)
done
defineDebugInfoPackage abseil_cpp$secondaryArchSuffix "${debugList[@]}"

BUILD()
{
	cmake -B build -S . $cmakeDirArgs \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_CXX_FLAGS="-DNDEBUG" \
		-DCMAKE_CXX_STANDARD=17 \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_POSITION_INDEPENDENT_CODE=ON
	make -C build $jobArgs
}

INSTALL()
{
	make -C build install PREFIX=$prefix

	for lib in $libs; do
		prepareInstalledDevelLib libabsl_$lib
	done

	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir \
		$libDir/cmake
}
