# HG changeset patch # User Mike Becker # Date 1697061635 -7200 # Node ID 24dc84788dee769ed9dd07976d7d8c92302a3038 # Parent aaad6674a1a30ff1015a8cb8cd3bfb76826573f1 replace most of the build system with uwproj diff -r aaad6674a1a3 -r 24dc84788dee .hgignore --- a/.hgignore Sun Sep 03 09:10:16 2023 +0200 +++ b/.hgignore Thu Oct 12 00:00:35 2023 +0200 @@ -1,10 +1,5 @@ -syntax:regexp -^nbproject/ -^build/ -/core$ -DS_Store$ -^stamp-h -/test-suite.log$ -^ucx-.*\.tar.gz$ -^.idea/ -^cmake-build- +nbproject/ +.idea/ +build/ +dist/ +config.mk diff -r aaad6674a1a3 -r 24dc84788dee CMakeLists.txt --- a/CMakeLists.txt Sun Sep 03 09:10:16 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(ucx VERSION 3.0 DESCRIPTION "UAP Common Extensions" LANGUAGES C) - -# Configuration -cmake_policy(SET CMP0077 NEW) -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED 11) - -option(GCC_MORE_WARNINGS "Enable -Wall -Wextra -pedantic when using gcc." OFF) -if (GCC_MORE_WARNINGS AND CMAKE_COMPILER_IS_GNUCC) - add_compile_options(-Wall -Wextra -pedantic) -endif() - -# Library -add_subdirectory(src) - -# Tests -include(CheckLanguage) -check_language(CXX) -if (CMAKE_CXX_COMPILER) - enable_language(CXX) - enable_testing() - add_subdirectory(tests) -else () - message(STATUS "No C++ compiler found - tests are not compiled.") -endif () - -# Web Documentation -add_subdirectory(docs/src) - -# API Documentation -message(CHECK_START "Seaching for Doxygen") -find_package(Doxygen) -if(DOXYGEN_FOUND) - message(CHECK_PASS "found.") -else() - message(CHECK_FAIL "not found - documentation will not be generated.") -endif() -option(BUILD_API_DOC "Create API documentation." ON) - -if(BUILD_API_DOC AND DOXYGEN_FOUND) - set(DOXY_INPUT ${CMAKE_SOURCE_DIR}/src/cx) - set(DOXY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/docs) - set(DOXY_PROJECT_LOGO ${CMAKE_SOURCE_DIR}/uaplogo.png) - - configure_file(${CMAKE_SOURCE_DIR}/cmake_infile.doxygen ${CMAKE_BINARY_DIR}/Doxyfile) - - add_custom_target(docs-api-21 - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/docs/api-2.1 ${CMAKE_BINARY_DIR}/docs/web/api-2.1 - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Copying UCX 2.1 API documentation.") - - add_custom_target(docs-api - COMMAND ${DOXYGEN_EXECUTABLE} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen.") - - add_custom_target(docs-all DEPENDS docs-html docs-api docs-api-21) -else() - add_custom_target(docs-all DEPENDS docs-html) -endif() - diff -r aaad6674a1a3 -r 24dc84788dee Doxyfile --- a/Doxyfile Sun Sep 03 09:10:16 2023 +0200 +++ b/Doxyfile Thu Oct 12 00:00:35 2023 +0200 @@ -68,7 +68,7 @@ # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = docs +OUTPUT_DIRECTORY = build/docs # If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 # sub-directories (in 2 levels) under the output directory of each output format diff -r aaad6674a1a3 -r 24dc84788dee Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,72 @@ +# Copyright 2023 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +include config.mk + +all: compile + +install: + @cd src && $(MAKE) -s install + +dist: FORCE + $(MKDIR) $(DIST_DIR)/libucx + $(COPYALL) CHANGELOG configure COPYING Doxyfile Makefile README \ + uaplogo.png docs make src tests $(DIST_DIR)/libucx/ + @cd $(DIST_DIR) && tar -czf libucx-src-$(VERSION).tar.gz -Hustar libucx + @echo "[ Dist created: $(DIST_DIR)/libucx-src-$(VERSION).tar.gz ]" + +clean: + $(RMDIR) $(BUILD_DIR) + +dist-clean: + $(RMDIR) $(DIST_DIR) + $(RMDIR) $(BUILD_DIR) + +compile: $(BUILD_DIR) static shared + +$(BUILD_DIR): + $(MKDIR) $@ + +shared: FORCE + @cd src && $(MAKE) OBJ_EXT=.shared.o \ + CFLAGS="$(CFLAGS) $(SHLIB_CFLAGS)" \ + LDFLAGS="$(LDFLAGS) $(SHLIB_LDFLAGS)" \ + shared + +static: FORCE + @cd src && $(MAKE) static + +check: test-compile FORCE + $(BUILD_DIR)/tests/ucxtest + +test-compile: + @(test "$(WITH_TESTS)" = "yes" && cd tests && $(MAKE)) \ + || echo "[ Tests disabled - skipped ]" + +docs: FORCE + @(test "$(WITH_DOCS_API)" = "yes" && cd docs && $(MAKE) all-api) \ + || echo "[ Generation of API Docs disabled - skipped ]" + @(test "$(WITH_DOCS_HTML)" = "yes" && cd docs && $(MAKE) all-html) \ + || echo "[ Generation of HTML Docs disabled - skipped ]" + +FORCE: diff -r aaad6674a1a3 -r 24dc84788dee configure --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/configure Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,756 @@ +#!/bin/sh + +# create temporary directory +TEMP_DIR=".tmp-`uname -n`" +rm -Rf "$TEMP_DIR" +if mkdir -p "$TEMP_DIR"; then + : +else + echo "Cannot create tmp dir $TEMP_DIR" + echo "Abort" + exit 1 +fi +touch "$TEMP_DIR/options" +touch "$TEMP_DIR/features" + +# define standard variables +# also define standard prefix (this is where we will search for config.site) +prefix=/usr +exec_prefix= +bindir= +sbindir= +libdir= +libexecdir= +datarootdir= +datadir= +sysconfdir= +sharedstatedir= +localstatedir= +runstatedir= +includedir= +infodir= +localedir= +mandir= + +# custom variables +src_dir=`pwd` +DOXYGEN=`command -v doxygen` +PANDOC=`command -v pandoc` +CMAKE=`command -v cmake` + +# features + +# clean abort +abort_configure() +{ + rm -Rf "$TEMP_DIR" + exit 1 +} + +# help text +printhelp() +{ + echo "Usage: $0 [OPTIONS]..." + cat << __EOF__ +Installation directories: + --prefix=PREFIX path prefix for architecture-independent files + [/usr] + --exec-prefix=EPREFIX path prefix for architecture-dependent files + [PREFIX] + + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR system configuration files [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --mandir=DIR man documentation [DATAROOTDIR/man] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + +Options: + --debug add extra compile flags for debug builds + --release add extra compile flags for release builds + --with-tests=(yes|no) + --with-docs=(all|html|api|none) + +__EOF__ +} + +# +# parse arguments +# +BUILD_TYPE="default" +for ARG in "$@" +do + case "$ARG" in + "--prefix="*) prefix=${ARG#--prefix=} ;; + "--exec-prefix="*) exec_prefix=${ARG#--exec-prefix=} ;; + "--bindir="*) bindir=${ARG#----bindir=} ;; + "--sbindir="*) sbindir=${ARG#--sbindir=} ;; + "--libdir="*) libdir=${ARG#--libdir=} ;; + "--libexecdir="*) libexecdir=${ARG#--libexecdir=} ;; + "--datarootdir="*) datarootdir=${ARG#--datarootdir=} ;; + "--datadir="*) datadir=${ARG#--datadir=} ;; + "--sysconfdir="*) sysconfdir=${ARG#--sysconfdir=} ;; + "--sharedstatedir="*) sharedstatedir=${ARG#--sharedstatedir=} ;; + "--localstatedir="*) localstatedir=${ARG#--localstatedir=} ;; + "--includedir="*) includedir=${ARG#--includedir=} ;; + "--infodir="*) infodir=${ARG#--infodir=} ;; + "--mandir"*) mandir=${ARG#--mandir} ;; + "--localedir"*) localedir=${ARG#--localedir} ;; + "--help"*) printhelp; abort_configure ;; + "--debug") BUILD_TYPE="debug" ;; + "--release") BUILD_TYPE="release" ;; + "--with-tests="*) OPT_WITH_TESTS=${ARG#--with-tests=} ;; + "--with-docs="*) OPT_WITH_DOCS=${ARG#--with-docs=} ;; + "-"*) echo "unknown option: $ARG"; abort_configure ;; + esac +done + + + +# set defaults for dir variables +: ${exec_prefix:="$prefix"} +: ${bindir:='${exec_prefix}/bin'} +: ${sbindir:='${exec_prefix}/sbin'} +: ${libdir:='${exec_prefix}/lib'} +: ${libexecdir:='${exec_prefix}/libexec'} +: ${datarootdir:='${prefix}/share'} +: ${datadir:='${datarootdir}'} +: ${sysconfdir:='${prefix}/etc'} +: ${sharedstatedir:='${prefix}/com'} +: ${localstatedir:='${prefix}/var'} +: ${runstatedir:='${localstatedir}/run'} +: ${includedir:='${prefix}/include'} +: ${infodir:='${datarootdir}/info'} +: ${mandir:='${datarootdir}/man'} +: ${localedir:='${datarootdir}/locale'} + +# check if a config.site exists and load it +if [ -n "$CONFIG_SITE" ]; then + # CONFIG_SITE may contain space separated file names + for cs in $CONFIG_SITE; do + printf "loading defaults from $cs... " + . "$cs" + echo ok + done +elif [ -f "$prefix/share/config.site" ]; then + printf "loading site defaults... " + . "$prefix/share/config.site" + echo ok +elif [ -f "$prefix/etc/config.site" ]; then + printf "loading site defaults... " + . "$prefix/etc/config.site" + echo ok +fi + +# Test for availability of pkg-config +PKG_CONFIG=`command -v pkg-config` +: ${PKG_CONFIG:="false"} + +# Simple uname based platform detection +# $PLATFORM is used for platform dependent dependency selection +OS=`uname -s` +OS_VERSION=`uname -r` +printf "detect platform... " +if [ "$OS" = "SunOS" ]; then + PLATFORM="solaris sunos unix svr4" +fi +if [ "$OS" = "Linux" ]; then + PLATFORM="linux unix" +fi +if [ "$OS" = "FreeBSD" ]; then + PLATFORM="freebsd bsd unix" +fi +if [ "$OS" = "Darwin" ]; then + PLATFORM="macos osx bsd unix" +fi +if echo "$OS" | grep -i "MINGW" > /dev/null; then + PLATFORM="windows mingw" +fi +: ${PLATFORM:="unix"} + +PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` +echo "$PLATFORM_NAME" + +isplatform() +{ + for p in $PLATFORM + do + if [ "$p" = "$1" ]; then + return 0 + fi + done + return 1 +} +notisplatform() +{ + for p in $PLATFORM + do + if [ "$p" = "$1" ]; then + return 1 + fi + done + return 0 +} + + +# generate vars.mk +cat > "$TEMP_DIR/vars.mk" << __EOF__ +prefix="$prefix" +exec_prefix="$exec_prefix" +bindir="$bindir" +sbindir="$sbindir" +libdir="$libdir" +libexecdir="$libexecdir" +datarootdir="$datarootdir" +datadir="$datadir" +sysconfdir="$sysconfdir" +sharedstatedir="$sharedstatedir" +localstatedir="$localstatedir" +runstatedir="$runstatedir" +includedir="$includedir" +infodir="$infodir" +mandir="$mandir" +localedir="$localedir" +src_dir="$src_dir" +DOXYGEN="$DOXYGEN" +PANDOC="$PANDOC" +CMAKE="$CMAKE" +__EOF__ + +# toolchain detection utilities +. make/toolchain.sh + +# +# DEPENDENCIES +# + +# check languages +lang_c= +lang_cpp= +if detect_cpp_compiler ; then + lang_cpp=1 +fi +if detect_c_compiler ; then + lang_c=1 +fi + +# create buffer for make variables required by dependencies +echo > "$TEMP_DIR/make.mk" + +test_pkg_config() +{ + if "$PKG_CONFIG" --exists "$1" ; then : + else return 1 ; fi + if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then : + else return 1 ; fi + if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then : + else return 1 ; fi + if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : + else return 1 ; fi + return 0 +} + +dependency_error_pandoc() +{ + printf "checking for pandoc... " + # dependency pandoc + while true + do + if test -n "$PANDOC" > /dev/null ; then + : + else + break + fi + echo yes + return 1 + done + + echo no + return 0 +} +dependency_error_cpp() +{ + printf "checking for cpp... " + # dependency cpp + while true + do + if [ -z "$lang_cpp" ] ; then + break + fi + echo yes + return 1 + done + + echo no + return 0 +} +dependency_error_c() +{ + printf "checking for c... " + # dependency c platform="mingw" + while true + do + if notisplatform "mingw"; then + break + fi + if [ -z "$lang_c" ] ; then + break + fi + cat >> $TEMP_DIR/make.mk << __EOF__ +# Dependency: c +AR=ar +ARFLAGS=r +STLIB_EXT=.lib +SHLIB_EXT=.dll + +__EOF__ + echo yes + return 1 + done + + # dependency c platform="macos" + while true + do + if notisplatform "macos"; then + break + fi + if [ -z "$lang_c" ] ; then + break + fi + cat >> $TEMP_DIR/make.mk << __EOF__ +# Dependency: c +AR=ar +ARFLAGS=r +STLIB_EXT=.a +SHLIB_EXT=.dylib + +__EOF__ + echo yes + return 1 + done + + # dependency c platform="unix" + while true + do + if notisplatform "unix"; then + break + fi + if [ -z "$lang_c" ] ; then + break + fi + cat >> $TEMP_DIR/make.mk << __EOF__ +# Dependency: c +AR=ar +ARFLAGS=r +STLIB_EXT=.a +SHLIB_EXT=.so + +__EOF__ + echo yes + return 1 + done + + echo no + return 0 +} +dependency_error_file_tools() +{ + printf "checking for file-tools... " + # dependency file-tools + while true + do + cat >> $TEMP_DIR/make.mk << __EOF__ +# Dependency: file-tools +MKDIR=mkdir -p +RMDIR=rm -f -R +COPYFILE=cp +COPYALL=cp -R + +__EOF__ + echo yes + return 1 + done + + echo no + return 0 +} +dependency_error_cmake() +{ + printf "checking for cmake... " + # dependency cmake + while true + do + if test -n "$CMAKE" > /dev/null ; then + : + else + break + fi + echo yes + return 1 + done + + echo no + return 0 +} +dependency_error_doxygen() +{ + printf "checking for doxygen... " + # dependency doxygen + while true + do + if test -n "$DOXYGEN" > /dev/null ; then + : + else + break + fi + echo yes + return 1 + done + + echo no + return 0 +} + + + + +# start collecting dependency information +echo > "$TEMP_DIR/flags.mk" + +DEPENDENCIES_FAILED= +ERROR=0 +# unnamed dependencies +TEMP_CFLAGS= +TEMP_CXXFLAGS= +TEMP_LDFLAGS= +while true +do + while true + do + + cat >> "$TEMP_DIR/make.mk" << __EOF__ +# library version +VERSION="3.0.0" + +# build directory structure !! do not change or override !! +BUILD_DIR=${src_dir}/build +DOCS_DIR=${src_dir}/build/docs +DIST_DIR=${src_dir}/dist + +__EOF__ + break + done + break +done + +# add general dependency flags to flags.mk +echo "# general flags" >> "$TEMP_DIR/flags.mk" +if [ -n "${TEMP_CFLAGS}" -a -n "$lang_c" ]; then + echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" +fi +if [ -n "${TEMP_CXXFLAGS}" -a -n "$lang_cpp" ]; then + echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" +fi +if [ -n "${TEMP_LDFLAGS}" ]; then + echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" +fi + +# +# OPTION VALUES +# +checkopt_with_tests_yes() +{ + VERR=0 + if dependency_error_cpp ; then + VERR=1 + fi + if dependency_error_cmake ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ +WITH_TESTS=yes + +__EOF__ + return 0 +} +checkopt_with_tests_no() +{ + VERR=0 + if [ $VERR -ne 0 ]; then + return 1 + fi + return 0 +} +checkopt_with_docs_all() +{ + VERR=0 + if dependency_error_pandoc ; then + VERR=1 + fi + if dependency_error_doxygen ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ +# Documentation +WITH_DOCS_API=yes +WITH_DOCS_HTML=yes + +__EOF__ + return 0 +} +checkopt_with_docs_html() +{ + VERR=0 + if dependency_error_pandoc ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ +# Documentation +WITH_DOCS_HTML=yes + +__EOF__ + return 0 +} +checkopt_with_docs_api() +{ + VERR=0 + if dependency_error_doxygen ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ +# Documentation +WITH_DOCS_API=yes + +__EOF__ + return 0 +} +checkopt_with_docs_none() +{ + VERR=0 + if [ $VERR -ne 0 ]; then + return 1 + fi + return 0 +} + +# +# TARGETS +# + +echo >> "$TEMP_DIR/flags.mk" +echo "configuring global target" +echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk" +TEMP_CFLAGS= +TEMP_CXXFLAGS= +TEMP_LDFLAGS= + +if dependency_error_c; then + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED c " + ERROR=1 +fi +if dependency_error_file_tools; then + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED file_tools " + ERROR=1 +fi + +# Features + +# Option: --with-tests +if [ -z "$OPT_WITH_TESTS" ]; then + echo "auto-detecting option 'with-tests'" + SAVED_ERROR="$ERROR" + SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED" + ERROR=1 + while true + do + if checkopt_with_tests_yes ; then + echo " with-tests: yes" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + if checkopt_with_tests_no ; then + echo " with-tests: no" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + break + done + if [ $ERROR -ne 0 ]; then + SAVED_ERROR=1 + SAVED_DEPENDENCIES_FAILED="option 'with-tests' $SAVED_DEPENDENCIES_FAILED" + fi + ERROR="$SAVED_ERROR" + DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED" +else + echo "checking option with-tests = $OPT_WITH_TESTS" + if false; then + false + elif [ "$OPT_WITH_TESTS" = "yes" ]; then + echo " with-tests: $OPT_WITH_TESTS" >> $TEMP_DIR/options + if checkopt_with_tests_yes ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'with-tests' $DEPENDENCIES_FAILED" + fi + elif [ "$OPT_WITH_TESTS" = "no" ]; then + echo " with-tests: $OPT_WITH_TESTS" >> $TEMP_DIR/options + if checkopt_with_tests_no ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'with-tests' $DEPENDENCIES_FAILED" + fi + fi +fi +# Option: --with-docs +if [ -z "$OPT_WITH_DOCS" ]; then + echo "auto-detecting option 'with-docs'" + SAVED_ERROR="$ERROR" + SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED" + ERROR=1 + while true + do + if checkopt_with_docs_all ; then + echo " with-docs: all" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + if checkopt_with_docs_html ; then + echo " with-docs: html" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + if checkopt_with_docs_api ; then + echo " with-docs: api" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + if checkopt_with_docs_none ; then + echo " with-docs: none" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + break + done + if [ $ERROR -ne 0 ]; then + SAVED_ERROR=1 + SAVED_DEPENDENCIES_FAILED="option 'with-docs' $SAVED_DEPENDENCIES_FAILED" + fi + ERROR="$SAVED_ERROR" + DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED" +else + echo "checking option with-docs = $OPT_WITH_DOCS" + if false; then + false + elif [ "$OPT_WITH_DOCS" = "all" ]; then + echo " with-docs: $OPT_WITH_DOCS" >> $TEMP_DIR/options + if checkopt_with_docs_all ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'with-docs' $DEPENDENCIES_FAILED" + fi + elif [ "$OPT_WITH_DOCS" = "html" ]; then + echo " with-docs: $OPT_WITH_DOCS" >> $TEMP_DIR/options + if checkopt_with_docs_html ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'with-docs' $DEPENDENCIES_FAILED" + fi + elif [ "$OPT_WITH_DOCS" = "api" ]; then + echo " with-docs: $OPT_WITH_DOCS" >> $TEMP_DIR/options + if checkopt_with_docs_api ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'with-docs' $DEPENDENCIES_FAILED" + fi + elif [ "$OPT_WITH_DOCS" = "none" ]; then + echo " with-docs: $OPT_WITH_DOCS" >> $TEMP_DIR/options + if checkopt_with_docs_none ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'with-docs' $DEPENDENCIES_FAILED" + fi + fi +fi + +if [ -n "${TEMP_CFLAGS}" -a -n "$lang_c" ]; then + echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" +fi +if [ -n "${TEMP_CXXFLAGS}" -a -n "$lang_cpp" ]; then + echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" +fi +if [ "$BUILD_TYPE" = "debug" ]; then + if [ -n "$lang_c" ]; then + echo 'CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi + if [ -n "$lang_cpp" ]; then + echo 'CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi +fi +if [ "$BUILD_TYPE" = "release" ]; then + if [ -n "$lang_c" ]; then + echo 'CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi + if [ -n "$lang_cpp" ]; then + echo 'CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi +fi +if [ -n "${TEMP_LDFLAGS}" ]; then + echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" +fi + + +# final result +if [ $ERROR -ne 0 ]; then + echo + echo "Error: Unresolved dependencies" + echo "$DEPENDENCIES_FAILED" + abort_configure +fi + +echo "configure finished" +echo +echo "Build Config:" +echo " PREFIX: $prefix" +echo " TOOLCHAIN: $TOOLCHAIN_NAME" +echo "Options:" +cat "$TEMP_DIR/options" +echo + +# generate the config.mk file +cat > "$TEMP_DIR/config.mk" << __EOF__ +# +# config.mk generated by configure +# + +__EOF__ +write_toolchain_defaults "$TEMP_DIR/toolchain.mk" +cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk +rm -Rf "$TEMP_DIR" + + diff -r aaad6674a1a3 -r 24dc84788dee docs/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/Makefile Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,58 @@ +# Copyright 2023 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +include ../config.mk + +PAGES = index features install license modules-ucx2 +DOCS_HTML = $(PAGES:%=$(DOCS_DIR)/web/%.html) +DOCS_CSS = $(DOCS_DIR)/web/ucx.css + +all: all-html all-api + +all-html: $(DOCS_DIR)/web $(DOCS_HTML) $(DOCS_CSS) FORCE + @echo "[ HTML Docs Generated ]" + +all-api: $(DOCS_DIR)/web $(DOCS_DIR)/web/api-2.1 $(DOCS_DIR)/web/api FORCE + @echo "[ API Docs Generated ]" + +$(DOCS_DIR)/web/api-2.1: api-2.1 FORCE + $(COPYALL) $< $@ + +$(DOCS_DIR)/web/api: FORCE + cd $(src_dir); $(DOXYGEN) + +$(DOCS_DIR)/web: + $(MKDIR) $@ + +$(DOCS_CSS): src/ucx.css + $(COPYFILE) $< $@ + +$(DOCS_DIR)/web/modules-ucx2.html: src/modules-ucx2.md + $(PANDOC) -c ucx.css -B src/header-ucx2.html -A src/footer.html \ + -T 'UAP Common Extensions' -o $@ $< + +$(DOCS_DIR)/web/%.html: src/%.md + $(PANDOC) -c ucx.css -B src/header.html -A src/footer.html \ + -T 'UAP Common Extensions' -o $@ $< + +FORCE: diff -r aaad6674a1a3 -r 24dc84788dee docs/src/CMakeLists.txt --- a/docs/src/CMakeLists.txt Sun Sep 03 09:10:16 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. -# -# Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -set(PANDOC_DESTDIR ${CMAKE_BINARY_DIR}/docs/web) -set(PANDOC_ARGS -c ucx.css -B header.html -A footer.html -T 'UAP Common Extensions') -set(PANDOC_SRC index.md license.md install.md features.md) -set(LOGO_PATH ../../uaplogo.png) - -if (NOT EXISTS ${PANDOC_EXECUTABLE}) - find_program(PANDOC_EXECUTABLE pandoc) - if(NOT EXISTS ${PANDOC_EXECUTABLE}) - message(STATUS "Pandoc not found, docs-html target will not be generated.") - return() - endif() -endif() - -message(STATUS "HTML Documentation will be generated at: ${PANDOC_DESTDIR}.") -file(MAKE_DIRECTORY ${PANDOC_DESTDIR}) - -# UCX 3.0 documentation -foreach(source_file ${PANDOC_SRC}) - string(REPLACE .md .html dest_file ${source_file}) - string(PREPEND dest_file "${PANDOC_DESTDIR}/") - list(APPEND PANDOC_DEST ${dest_file}) - add_custom_command( - OUTPUT ${dest_file} - COMMAND ${PANDOC_EXECUTABLE} ${PANDOC_ARGS} -o ${dest_file} ${source_file} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - MAIN_DEPENDENCY ${source_file} - DEPENDS header.html footer.html - ) -endforeach() - -# UCX 2.1 documentation -add_custom_target(docs-html-21 - COMMAND ${PANDOC_EXECUTABLE} -c ucx.css -B header-ucx2.html -A footer.html - -T 'UAP Common Extensions' -o ${PANDOC_DESTDIR}/modules-ucx2.html modules-ucx2.md - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS modules-ucx2.md header-ucx2.html footer.html - COMMENT "Adding UCX 2.1 HTML documentation." -) - -# Collect all HTML documentation -add_custom_target(docs-html - COMMAND ${CMAKE_COMMAND} -E copy ucx.css ${PANDOC_DESTDIR}/ucx.css - COMMAND ${CMAKE_COMMAND} -E copy ${LOGO_PATH} ${PANDOC_DESTDIR}/uaplogo.png - DEPENDS ${PANDOC_DEST} docs-html-21 - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Generating HTML documentation with pandoc." -) diff -r aaad6674a1a3 -r 24dc84788dee make/cc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/cc.mk Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,14 @@ +# +# cc toolchain config +# + +CFLAGS = +CXXFLAGS = +DEBUG_CC_FLAGS = -g +DEBUG_CXX_FLAGS = -g +RELEASE_CC_FLAGS = -O3 -DNDEBUG +RELEASE_CXX_FLAGS = -O3 -DNDEBUG +LDFLAGS = + +SHLIB_CFLAGS = -fPIC +SHLIB_LDFLAGS = -shared \ No newline at end of file diff -r aaad6674a1a3 -r 24dc84788dee make/clang.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/clang.mk Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,14 @@ +# +# gcc toolchain config +# + +CFLAGS = +CXXFLAGS = +DEBUG_CC_FLAGS = -g -Wall -Wextra -pedantic +DEBUG_CXX_FLAGS = -g -Wall -Wextra -pedantic +RELEASE_CC_FLAGS = -O3 -DNDEBUG +RELEASE_CXX_FLAGS = -O3 -DNDEBUG +LDFLAGS = + +SHLIB_CFLAGS = -fPIC +SHLIB_LDFLAGS = -shared \ No newline at end of file diff -r aaad6674a1a3 -r 24dc84788dee make/configure.vm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/configure.vm Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,640 @@ +#!/bin/sh + +# create temporary directory +TEMP_DIR=".tmp-`uname -n`" +rm -Rf "$TEMP_DIR" +if mkdir -p "$TEMP_DIR"; then + : +else + echo "Cannot create tmp dir $TEMP_DIR" + echo "Abort" + exit 1 +fi +touch "$TEMP_DIR/options" +touch "$TEMP_DIR/features" + +# define standard variables +# also define standard prefix (this is where we will search for config.site) +prefix=/usr +exec_prefix= +bindir= +sbindir= +libdir= +libexecdir= +datarootdir= +datadir= +sysconfdir= +sharedstatedir= +localstatedir= +runstatedir= +includedir= +infodir= +localedir= +mandir= + +# custom variables +#foreach( $var in $vars ) +#if( $var.exec ) +${var.varName}=`${var.value}` +#else +${var.varName}="${var.value}" +#end +#end + +# features +#foreach( $feature in $features ) +#if( ${feature.auto} ) +${feature.varName}=auto +#end +#end + +# clean abort +abort_configure() +{ + rm -Rf "$TEMP_DIR" + exit 1 +} + +# help text +printhelp() +{ + echo "Usage: $0 [OPTIONS]..." + cat << __EOF__ +Installation directories: + --prefix=PREFIX path prefix for architecture-independent files + [/usr] + --exec-prefix=EPREFIX path prefix for architecture-dependent files + [PREFIX] + + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR system configuration files [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --mandir=DIR man documentation [DATAROOTDIR/man] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + +#if( $options.size() > 0 ) +Options: + --debug add extra compile flags for debug builds + --release add extra compile flags for release builds +#foreach( $opt in $options ) + --${opt.argument}=${opt.valuesString} +#end + +#end +#if( $features.size() > 0 ) +Optional Features: +#foreach( $feature in $features ) +#if( $feature.auto ) + --disable-${feature.arg} +#else + --enable-${feature.arg} +#end +#end + +#end +__EOF__ +} + +# +# parse arguments +# +BUILD_TYPE="default" +#set( $D = '$' ) +for ARG in "$@" +do + case "$ARG" in + "--prefix="*) prefix=${D}{ARG#--prefix=} ;; + "--exec-prefix="*) exec_prefix=${D}{ARG#--exec-prefix=} ;; + "--bindir="*) bindir=${D}{ARG#----bindir=} ;; + "--sbindir="*) sbindir=${D}{ARG#--sbindir=} ;; + "--libdir="*) libdir=${D}{ARG#--libdir=} ;; + "--libexecdir="*) libexecdir=${D}{ARG#--libexecdir=} ;; + "--datarootdir="*) datarootdir=${D}{ARG#--datarootdir=} ;; + "--datadir="*) datadir=${D}{ARG#--datadir=} ;; + "--sysconfdir="*) sysconfdir=${D}{ARG#--sysconfdir=} ;; + "--sharedstatedir="*) sharedstatedir=${D}{ARG#--sharedstatedir=} ;; + "--localstatedir="*) localstatedir=${D}{ARG#--localstatedir=} ;; + "--includedir="*) includedir=${D}{ARG#--includedir=} ;; + "--infodir="*) infodir=${D}{ARG#--infodir=} ;; + "--mandir"*) mandir=${D}{ARG#--mandir} ;; + "--localedir"*) localedir=${D}{ARG#--localedir} ;; + "--help"*) printhelp; abort_configure ;; + "--debug") BUILD_TYPE="debug" ;; + "--release") BUILD_TYPE="release" ;; + #foreach( $opt in $options ) + "--${opt.argument}="*) ${opt.varName}=${D}{ARG#--${opt.argument}=} ;; + #end + #foreach( $feature in $features ) + "--enable-${feature.arg}") ${feature.varName}=on ;; + "--disable-${feature.arg}") unset ${feature.varName} ;; + #end + "-"*) echo "unknown option: $ARG"; abort_configure ;; + esac +done + +## Begin unparsed content. ** +#[[ + +# set defaults for dir variables +: ${exec_prefix:="$prefix"} +: ${bindir:='${exec_prefix}/bin'} +: ${sbindir:='${exec_prefix}/sbin'} +: ${libdir:='${exec_prefix}/lib'} +: ${libexecdir:='${exec_prefix}/libexec'} +: ${datarootdir:='${prefix}/share'} +: ${datadir:='${datarootdir}'} +: ${sysconfdir:='${prefix}/etc'} +: ${sharedstatedir:='${prefix}/com'} +: ${localstatedir:='${prefix}/var'} +: ${runstatedir:='${localstatedir}/run'} +: ${includedir:='${prefix}/include'} +: ${infodir:='${datarootdir}/info'} +: ${mandir:='${datarootdir}/man'} +: ${localedir:='${datarootdir}/locale'} + +# check if a config.site exists and load it +if [ -n "$CONFIG_SITE" ]; then + # CONFIG_SITE may contain space separated file names + for cs in $CONFIG_SITE; do + printf "loading defaults from $cs... " + . "$cs" + echo ok + done +elif [ -f "$prefix/share/config.site" ]; then + printf "loading site defaults... " + . "$prefix/share/config.site" + echo ok +elif [ -f "$prefix/etc/config.site" ]; then + printf "loading site defaults... " + . "$prefix/etc/config.site" + echo ok +fi + +# Test for availability of pkg-config +PKG_CONFIG=`command -v pkg-config` +: ${PKG_CONFIG:="false"} + +# Simple uname based platform detection +# $PLATFORM is used for platform dependent dependency selection +OS=`uname -s` +OS_VERSION=`uname -r` +printf "detect platform... " +if [ "$OS" = "SunOS" ]; then + PLATFORM="solaris sunos unix svr4" +fi +if [ "$OS" = "Linux" ]; then + PLATFORM="linux unix" +fi +if [ "$OS" = "FreeBSD" ]; then + PLATFORM="freebsd bsd unix" +fi +if [ "$OS" = "Darwin" ]; then + PLATFORM="macos osx bsd unix" +fi +if echo "$OS" | grep -i "MINGW" > /dev/null; then + PLATFORM="windows mingw" +fi +: ${PLATFORM:="unix"} + +PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` +echo "$PLATFORM_NAME" + +isplatform() +{ + for p in $PLATFORM + do + if [ "$p" = "$1" ]; then + return 0 + fi + done + return 1 +} +notisplatform() +{ + for p in $PLATFORM + do + if [ "$p" = "$1" ]; then + return 1 + fi + done + return 0 +} +]]# +## End of unparsed content ** + +# generate vars.mk +cat > "$TEMP_DIR/vars.mk" << __EOF__ +prefix="$prefix" +exec_prefix="$exec_prefix" +bindir="$bindir" +sbindir="$sbindir" +libdir="$libdir" +libexecdir="$libexecdir" +datarootdir="$datarootdir" +datadir="$datadir" +sysconfdir="$sysconfdir" +sharedstatedir="$sharedstatedir" +localstatedir="$localstatedir" +runstatedir="$runstatedir" +includedir="$includedir" +infodir="$infodir" +mandir="$mandir" +localedir="$localedir" +#foreach( $var in $vars ) +${var.varName}="${D}${var.varName}" +#end +__EOF__ + +# toolchain detection utilities +. make/toolchain.sh + +# +# DEPENDENCIES +# + +# check languages +lang_c= +lang_cpp= +#foreach( $lang in $languages ) +if detect_${lang}_compiler ; then + lang_${lang}=1 +fi +#end + +# create buffer for make variables required by dependencies +echo > "$TEMP_DIR/make.mk" + +test_pkg_config() +{ + if "$PKG_CONFIG" --exists "$1" ; then : + else return 1 ; fi + if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then : + else return 1 ; fi + if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then : + else return 1 ; fi + if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : + else return 1 ; fi + return 0 +} + +#foreach( $dependency in $namedDependencies ) +dependency_error_${dependency.id}() +{ + printf "checking for ${dependency.name}... " + #foreach( $sub in $dependency.subdependencies ) + # dependency $sub.fullName + while true + do + #if( $sub.platform ) + if notisplatform "${sub.platform}"; then + break + fi + #end + #foreach( $np in $sub.notList ) + if isplatform "${np}"; then + break + fi + #end + #foreach( $lang in $sub.lang ) + if [ -z "$lang_${lang}" ] ; then + break + fi + #end + #if( $sub.pkgconfig.size() > 0 ) + if [ -z "$PKG_CONFIG" ]; then + break + fi + #end + #foreach( $test in $sub.tests ) + if $test > /dev/null ; then + : + else + break + fi + #end + #foreach( $pkg in $sub.pkgconfig ) + if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`" + else + break + fi + #end + #foreach( $flags in $sub.flags ) + #if( $flags.exec ) + if tmp_flags=`$flags.value` ; then + TEMP_$flags.varName="$TEMP_$flags.varName $tmp_flags" + else + break + fi + #else + TEMP_$flags.varName="$TEMP_$flags.varName $flags.value" + #end + #end + #if ( $sub.make.length() > 0 ) + cat >> $TEMP_DIR/make.mk << __EOF__ +# Dependency: $dependency.name +$sub.make +__EOF__ + #end + echo yes + return 1 + done + + #end + echo no + return 0 +} +#end + + + + +# start collecting dependency information +echo > "$TEMP_DIR/flags.mk" + +DEPENDENCIES_FAILED= +ERROR=0 +#if( $dependencies.size() > 0 ) +# unnamed dependencies +TEMP_CFLAGS= +TEMP_CXXFLAGS= +TEMP_LDFLAGS= +#foreach( $dependency in $dependencies ) +while true +do + #if( $dependency.platform ) + if notisplatform "${dependency.platform}"; then + break + fi + #end + #foreach( $np in $dependency.notList ) + if isplatform "${np}"; then + break + fi + #end + while true + do + #foreach( $lang in $dependency.lang ) + if [ -z "$lang_${lang}" ] ; then + ERROR=1 + break + fi + #end + #if( $dependency.pkgconfig.size() > 0 ) + if [ -z "$PKG_CONFIG" ]; then + ERROR=1 + break + fi + #end + #foreach( $pkg in $dependency.pkgconfig ) + printf "checking for pkg-config package $pkg.name... " + if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then + echo yes + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`" + else + echo no + ERROR=1 + break + fi + #end + + #foreach( $flags in $dependency.flags ) + #if( $flags.exec ) + $flags.value > /dev/null + if tmp_flags=`$flags.value` ; then + TEMP_$flags.varName="$TEMP_$flags.varName $tmp_flags" + else + ERROR=1 + break + fi + #else + TEMP_$flags.varName="$TEMP_$flags.varName $flags.value" + #end + #end + #if ( $dependency.make.length() > 0 ) + cat >> "$TEMP_DIR/make.mk" << __EOF__ +$dependency.make +__EOF__ + #end + break + done + break +done +#end + +# add general dependency flags to flags.mk +echo "# general flags" >> "$TEMP_DIR/flags.mk" +if [ -n "${TEMP_CFLAGS}" -a -n "$lang_c" ]; then + echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" +fi +if [ -n "${TEMP_CXXFLAGS}" -a -n "$lang_cpp" ]; then + echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" +fi +if [ -n "${TEMP_LDFLAGS}" ]; then + echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" +fi +#end + +# +# OPTION VALUES +# +#foreach( $opt in $options ) +#foreach( $val in $opt.values ) +${val.func}() +{ + VERR=0 + #foreach( $dep in $val.dependencies ) + if dependency_error_$dep ; then + VERR=1 + fi + #end + if [ $VERR -ne 0 ]; then + return 1 + fi + #foreach( $def in $val.defines ) + TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" + TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" + #end + #if( $val.hasMake() ) + cat >> "$TEMP_DIR/make.mk" << __EOF__ +$val.make +__EOF__ + #end + return 0 +} +#end +#end + +# +# TARGETS +# + +#foreach( $target in $targets ) +echo >> "$TEMP_DIR/flags.mk" +#if ( $target.name ) +echo "configuring target: $target.name" +echo "# flags for target $target.name" >> "$TEMP_DIR/flags.mk" +#else +echo "configuring global target" +echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk" +#end +TEMP_CFLAGS= +TEMP_CXXFLAGS= +TEMP_LDFLAGS= + +#foreach( $dependency in $target.dependencies ) +if dependency_error_$dependency; then + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " + ERROR=1 +fi +#end + +# Features +#foreach( $feature in $target.features ) +if [ -n "${D}${feature.varName}" ]; then +#foreach( $dependency in $feature.dependencies ) + # check dependency + if dependency_error_$dependency ; then + # "auto" features can fail and are just disabled in this case + if [ "${D}${feature.varName}" = "auto" ]; then + DISABLE_${feature.varName}=1 + else + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " + ERROR=1 + fi + fi +#end + if [ -n "$DISABLE_${feature.varName}" ]; then + unset ${feature.varName} + fi +fi +#end + +#foreach( $opt in $target.options ) +# Option: --${opt.argument} +if [ -z "${D}${opt.varName}" ]; then + echo "auto-detecting option '${opt.argument}'" + SAVED_ERROR="$ERROR" + SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED" + ERROR=1 + while true + do + #foreach( $optdef in $opt.defaults ) + #if( $optdef.platform ) + if isplatform "$optdef.platform"; then + #end + if $optdef.func ; then + echo " ${opt.argument}: ${optdef.valueName}" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + #if( $optdef.platform ) + fi + #end + #end + break + done + if [ $ERROR -ne 0 ]; then + SAVED_ERROR=1 + SAVED_DEPENDENCIES_FAILED="option '${opt.argument}' $SAVED_DEPENDENCIES_FAILED" + fi + ERROR="$SAVED_ERROR" + DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED" +else + echo "checking option ${opt.argument} = ${D}${opt.varName}" + if false; then + false + #foreach( $optval in $opt.values ) + elif [ "${D}${opt.varName}" = "${optval.value}" ]; then + echo " ${opt.argument}: ${D}${opt.varName}" >> $TEMP_DIR/options + if $optval.func ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option '${opt.argument}' $DEPENDENCIES_FAILED" + fi + #end + fi +fi +#end + +if [ -n "${TEMP_CFLAGS}" -a -n "$lang_c" ]; then + echo "${target.cFlags} += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" +fi +if [ -n "${TEMP_CXXFLAGS}" -a -n "$lang_cpp" ]; then + echo "${target.cxxFlags} += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" +fi +if [ "$BUILD_TYPE" = "debug" ]; then + if [ -n "$lang_c" ]; then + echo '${target.cFlags} += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi + if [ -n "$lang_cpp" ]; then + echo '${target.cxxFlags} += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi +fi +if [ "$BUILD_TYPE" = "release" ]; then + if [ -n "$lang_c" ]; then + echo '${target.cFlags} += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi + if [ -n "$lang_cpp" ]; then + echo '${target.cxxFlags} += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi +fi +if [ -n "${TEMP_LDFLAGS}" ]; then + echo "${target.ldFlags} += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" +fi + +#end + +# final result +if [ $ERROR -ne 0 ]; then + echo + echo "Error: Unresolved dependencies" + echo "$DEPENDENCIES_FAILED" + abort_configure +fi + +echo "configure finished" +echo +echo "Build Config:" +echo " PREFIX: $prefix" +echo " TOOLCHAIN: $TOOLCHAIN_NAME" +#if ( $options.size() > 0 ) +echo "Options:" +cat "$TEMP_DIR/options" +#end +#if ( $features.size() > 0 ) +echo "Features:" +#foreach( $feature in $features ) +if [ -n "${D}${feature.varName}" ]; then +echo " $feature.name: on" +else +echo " $feature.name: off" +fi +#end +#end +echo + +# generate the config.mk file +cat > "$TEMP_DIR/config.mk" << __EOF__ +# +# config.mk generated by configure +# + +__EOF__ +write_toolchain_defaults "$TEMP_DIR/toolchain.mk" +cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk +rm -Rf "$TEMP_DIR" + + diff -r aaad6674a1a3 -r 24dc84788dee make/gcc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/gcc.mk Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,14 @@ +# +# gcc toolchain config +# + +CFLAGS = +CXXFLAGS = +DEBUG_CC_FLAGS = -g -Wall -Wextra -pedantic +DEBUG_CXX_FLAGS = -g -Wall -Wextra -pedantic +RELEASE_CC_FLAGS = -O3 -DNDEBUG +RELEASE_CXX_FLAGS = -O3 -DNDEBUG +LDFLAGS = + +SHLIB_CFLAGS = -fPIC +SHLIB_LDFLAGS = -shared \ No newline at end of file diff -r aaad6674a1a3 -r 24dc84788dee make/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/project.xml Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,119 @@ + + + + pwd + command -v doxygen + command -v pandoc + command -v cmake + + + + +# library version +VERSION="3.0.0" + +# build directory structure !! do not change or override !! +BUILD_DIR=${src_dir}/build +DOCS_DIR=${src_dir}/build/docs +DIST_DIR=${src_dir}/dist + + + + + +MKDIR=mkdir -p +RMDIR=rm -f -R +COPYFILE=cp +COPYALL=cp -R + + + + + c + +AR=ar +ARFLAGS=r +STLIB_EXT=.lib +SHLIB_EXT=.dll + + + + + c + +AR=ar +ARFLAGS=r +STLIB_EXT=.a +SHLIB_EXT=.dylib + + + + + c + +AR=ar +ARFLAGS=r +STLIB_EXT=.a +SHLIB_EXT=.so + + + + + cpp + + + + test -n "$CMAKE" + + + + test -n "$DOXYGEN" + + + + test -n "$PANDOC" + + + + + + c,file-tools + + + diff -r aaad6674a1a3 -r 24dc84788dee make/suncc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/suncc.mk Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,15 @@ +# +# suncc toolchain +# + +CFLAGS = +CXXFLAGS = +DEBUG_CC_FLAGS = -g +DEBUG_CXX_FLAGS = -g +RELEASE_CC_FLAGS = -O3 -DNDEBUG +RELEASE_CXX_FLAGS = -O3 -DNDEBUG +LDFLAGS = + +SHLIB_CFLAGS = -Kpic +SHLIB_LDFLAGS = -G + diff -r aaad6674a1a3 -r 24dc84788dee make/toolchain.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/toolchain.sh Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,186 @@ +#!/bin/sh +# +# toolchain detection +# + +C_COMPILERS="gcc clang suncc cc" +CPP_COMPILERS="g++ clang++ sunCC CC" +unset TOOLCHAIN_NAME +unset TOOLCHAIN_CC +unset TOOLCHAIN_CXX + +check_c_compiler() +{ + cat > "$TEMP_DIR/test.c" << __EOF__ +/* test file */ +#include +int main(int argc, char **argv) { +#if defined(__clang__) + printf("clang\n"); +#elif defined(__GNUC__) + printf("gcc\n"); +#elif defined(__sun) + printf("suncc\n"); +#else + printf("unknown\n"); +#endif + return 0; +} +__EOF__ + rm -f "$TEMP_DIR/checkcc" + $1 -o "$TEMP_DIR/checkcc" $CFLAGS $LDFLAGS "$TEMP_DIR/test.c" 2> /dev/null +} + +check_cpp_compiler() +{ + cat > "$TEMP_DIR/test.cpp" << __EOF__ +/* test file */ +#include +int main(int argc, char **argv) { +#if defined(__clang__) + std::cout << "clang" << std::endl; +#elif defined(__GNUC__) + std::cout << "gcc" << std::endl; +#elif defined(__sun) + std::cout << "suncc" << std::endl; +#else + std::cout << "cc" << std::endl; +#endif + return 0; +} +__EOF__ + rm -f "$TEMP_DIR/checkcc" + $1 -o "$TEMP_DIR/checkcc" $CXXFLAGS $LDFLAGS "$TEMP_DIR/test.cpp" 2> /dev/null +} + +create_libtest_source() +{ + # $1: filename + # $2: optional include + cat > "$TEMP_DIR/$1" << __EOF__ +/* libtest file */ +int main(int argc, char **argv) { + return 0; +} +__EOF__ + if [ -n "$2" ]; then + echo "#include <$2>" >> "$TEMP_DIR/$1" + fi +} + +check_c_lib() +{ + # $1: libname + # $2: optional include + if [ -z "$TOOLCHAIN_CC" ]; then + return 1 + fi + create_libtest_source "test.c" "$2" + rm -f "$TEMP_DIR/checklib" + $TOOLCHAIN_CC -o "$TEMP_DIR/checklib" $CFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.c" 2> /dev/null +} + +check_cpp_lib() +{ + # $1: libname + # $2: optional include + if [ -z "$TOOLCHAIN_CXX" ]; then + return 1 + fi + create_libtest_source "test.cpp" "$2" + rm -f "$TEMP_DIR/checklib" + $TOOLCHAIN_CXX -o "$TEMP_DIR/checklib" $CXXFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.cpp" 2> /dev/null +} + +check_lib() +{ + # $1: libname + # $2: optional include + if [ -n "$TOOLCHAIN_CC" ]; then + check_c_lib "$1" "$2" + elif [ -n "$TOOLCHAIN_CXX" ]; then + check_cpp_lib "$1" "$2" + fi +} + +detect_c_compiler() +{ + if [ -n "$TOOLCHAIN_CC" ]; then + return 0 + fi + printf "detect C compiler... " + if [ -n "$CC" ]; then + if check_c_compiler "$CC"; then + TOOLCHAIN_CC=$CC + TOOLCHAIN_NAME=`"$TEMP_DIR/checkcc"` + echo "$CC" + return 0 + else + echo "$CC is not a working C compiler" + return 1 + fi + else + for COMP in $C_COMPILERS + do + if check_c_compiler "$COMP"; then + TOOLCHAIN_CC=$COMP + TOOLCHAIN_NAME=`"$TEMP_DIR/checkcc"` + echo "$COMP" + return 0 + fi + done + echo "not found" + return 1 + fi +} + +detect_cpp_compiler() +{ + if [ -n "$TOOLCHAIN_CXX" ]; then + return 0 + fi + printf "detect C++ compiler... " + + if [ -n "$CXX" ]; then + if check_cpp_compiler "$CXX"; then + TOOLCHAIN_CXX=$CXX + TOOLCHAIN_NAME=`"$TEMP_DIR/checkcc"` + echo "$CXX" + return 0 + else + echo "$CXX is not a working C++ compiler" + return 1 + fi + else + for COMP in $CPP_COMPILERS + do + if check_cpp_compiler "$COMP"; then + TOOLCHAIN_CXX=$COMP + TOOLCHAIN_NAME=`"$TEMP_DIR/checkcc"` + echo "$COMP" + return 0 + fi + done + echo "${TOOLCHAIN_CXX:-"not found"}" + return 1 + fi +} + +write_toolchain_defaults() +{ + echo "# toolchain" >> "$1" + if [ -n "$TOOLCHAIN_CC" ]; then + echo "CC = ${TOOLCHAIN_CC}" >> "$1" + fi + if [ -n "$TOOLCHAIN_CXX" ]; then + echo "CXX = ${TOOLCHAIN_CXX}" >> "$1" + fi + echo >> "$1" + if [ -f "make/${TOOLCHAIN_NAME}.mk" ]; then + cat "make/${TOOLCHAIN_NAME}.mk" >> "$1" + elif [ -f "make/cc.mk" ]; then + cat "make/cc.mk" >> "$1" + else + echo "!!! WARNING !!! Default toolchain flags not found. Configuration might be incomplete." + fi +} diff -r aaad6674a1a3 -r 24dc84788dee make/uwproj.xsd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/uwproj.xsd Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,281 @@ + + + + + + + + The root element of an uwproj project. + Consists of an optional config element + and an arbitrary number of dependency + and target elements. + + + + + + + + + + + + + The configuration section. + Consists of an arbitrary number of var elements. + + + + + + + + + + + The definition of a configuration variable. +

+ Configuration variables are supposed to be used in the configure script and are also + written to the resulting config file (in contrast to make variables, which are only + written to the config file). + The name attribute is mandatory, the value is defined by the text body of the element. + The optional Boolean exec attribute (false by default) controls, whether the entire + definition is automatically executed under command substitution. +

+
+
+ + + + + + +
+ + + + + Instructs configure to invoke pkg-config, if present on the system, to determine + compiler and linker flags. The text body of this element defines the package name to search. + To constrain the allowed versions, use the attributes atleast, exact, max. + + + + + + + + + + + + + + + Requests a compiler for the specified language. Allowed values are + c, cpp. + + + + + + + + + + + + Declares a dependency. +

+ If the optional name attribute is omitted, the dependency is global + and must be satisfied, otherwise configuration shall fail. + A named dependency can be referenced by a target (or is implicitly referenced + by the default target, if no targets are specified). + Multiple declarations for the same named dependency may exist, in which case each declaration + is checked one after another, until one block is satisfied. The result of the first satisfied + dependency declaration is supposed to be applied to the config file. +

+

+ The optional platform attribute may specify a single platform identifier and + the optional not attribute may specify a comma-separated list of platform identifiers. + The configure script shall skip this dependency declaration if the detected platform is not + matching the filter specification of these attributes. +

+
+
+ + + + + + + + + + Specifies a custom command that shall be executed to test whether this dependency is satisfied. + + + + + + + + +
+ + + + + Instructs configure to append the contents of the element's body to the respective flags variable. + If the optional exec flag is set to true, the contents are supposed to be + executed under command substitution at configuration time before they are applied. + + + + + + + + + + + + + Declares a build target that is supposed to be configured. +

+ If no build target is declared explicitly, an implicit default + target is generated, which has the alldependencies + flag set. +

+

+ The optional name attribute is also used to generate a prefix + for the compiler and linker flags variables. + Furthermore, a target may consist of an arbitrary number of feature, + option, and define elements. + Named dependencies can be listed (separated by comma) in the dependencies + element. If this target shall use all available named dependencies, the empty + element alldependencies can be used as a shortcut. +

+
+
+ + + + + + + + + + +
+ + + + + Declares an optional feature, that can be enabled during configuration, if all + dependencies are satisfied. + If a feature is enabled, all define and make definitions are + supposed to be applied to the config file. + In case the optional default attribute is set to true, the feature is enabled by default + and is supposed to be automatically disabled (without error) when the dependencies are not satisfied. + The name that is supposed to be used for the --enable and --disable arguments can be optionally + specified with the arg attribute. Otherwise, the name is used by default. + + + + + + + + + + + + + + Declares a configuration option. + The option argument name is specified with the arg attribute. + Then, the children of this element specify possible values by defining the conditions + (in terms of dependencies) and effects (in terms of defines and make variables) of each value. + Finally, a set of defaults is specified which supposed to automagically select the most + appropriate value for a specific platform under the available dependencies (in case the option is not + explicitly specified by using the command line argument). + + + + + + + + + + + + + Declares a possible value for the option (in the str attribute) and + the conditions (dependencies) and effects, the value has. + + + + + + + + + + + + Specifies a default value for this option. Multiple default values can be specified, in which case + they are checked one after another for availability. With the optional platform attribute, + the default value can be constrained to a single specific platform and is supposed to be + skipped by configure, when this platform is not detected. + + + + + + + + + + + + + + + + + + Specifies C/C++ pre-processor definitions that are supposed to + be appended to the compiler flags, if supported. + (Note: for example, Fortran also supports C/C++ style pre-processor definitions under + certain circumstances) + + + + + + + + + A comma-separated list of named dependencies. + + + + + + + + The text contents in the body of this element are supposed to be appended literally + to the config file without prior processing. + + + + +
\ No newline at end of file diff -r aaad6674a1a3 -r 24dc84788dee src/CMakeLists.txt --- a/src/CMakeLists.txt Sun Sep 03 09:10:16 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -set(sources - utils.c - allocator.c - string.c - list.c - array_list.c - linked_list.c - buffer.c - map.c - hash_key.c - hash_map.c - mempool.c - printf.c - compare.c -) -set(headers - cx/common.h - cx/utils.h - cx/string.h - cx/allocator.h - cx/iterator.h - cx/collection.h - cx/list.h - cx/array_list.h - cx/linked_list.h - cx/buffer.h - cx/map.h - cx/hash_key.h - cx/hash_map.h - cx/mempool.h - cx/printf.h - cx/compare.h - ) - -add_library(ucx SHARED ${sources}) -add_library(ucx_static STATIC ${sources}) - -target_include_directories(ucx PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_include_directories(ucx_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) - -set_target_properties(ucx PROPERTIES SOVERSION 4 VERSION 4.0.0) -set_target_properties(ucx_static PROPERTIES VERSION ${CMAKE_PROJECT_VERSION}) - -# it is sufficient to specify the headers for one of the targets -set_target_properties(ucx PROPERTIES PUBLIC_HEADER "${headers}") - -include(GNUInstallDirs) -install(TARGETS ucx ucx_static - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cx) \ No newline at end of file diff -r aaad6674a1a3 -r 24dc84788dee src/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Makefile Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,107 @@ +# Copyright 2023 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +include ../config.mk + +SRC = allocator.c array_list.c buffer.c compare.c hash_key.c hash_map.c \ + linked_list.c list.c map.c mempool.c printf.c string.c utils.c + +OBJ_EXT=.o +OBJ=$(SRC:%.c=$(BUILD_DIR)/%$(OBJ_EXT)) + +static: $(BUILD_DIR)/libucx$(STLIB_EXT) + +shared: $(BUILD_DIR)/libucx$(SHLIB_EXT) + +$(BUILD_DIR)/libucx$(STLIB_EXT): $(OBJ) + $(AR) $(ARFLAGS) $@ $^ + +$(BUILD_DIR)/libucx$(SHLIB_EXT): $(OBJ) + $(CC) $(LDFLAGS) -o $@ $^ + +install: + @echo "[ not supported yet ]" + + +$(BUILD_DIR)/allocator$(OBJ_EXT): allocator.c cx/allocator.h cx/common.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + +$(BUILD_DIR)/array_list$(OBJ_EXT): array_list.c cx/array_list.h cx/list.h \ + cx/common.h cx/collection.h cx/allocator.h cx/iterator.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + +$(BUILD_DIR)/buffer$(OBJ_EXT): buffer.c cx/buffer.h cx/common.h cx/allocator.h \ + cx/utils.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + +$(BUILD_DIR)/compare$(OBJ_EXT): compare.c cx/compare.h cx/common.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + +$(BUILD_DIR)/hash_key$(OBJ_EXT): hash_key.c cx/hash_key.h cx/common.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + +$(BUILD_DIR)/hash_map$(OBJ_EXT): hash_map.c cx/hash_map.h cx/map.h cx/common.h \ + cx/collection.h cx/allocator.h cx/iterator.h cx/string.h cx/hash_key.h \ + cx/utils.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + +$(BUILD_DIR)/linked_list$(OBJ_EXT): linked_list.c cx/linked_list.h cx/common.h \ + cx/list.h cx/collection.h cx/allocator.h cx/iterator.h cx/utils.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + +$(BUILD_DIR)/list$(OBJ_EXT): list.c cx/list.h cx/common.h cx/collection.h \ + cx/allocator.h cx/iterator.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + +$(BUILD_DIR)/map$(OBJ_EXT): map.c cx/map.h cx/common.h cx/collection.h \ + cx/allocator.h cx/iterator.h cx/string.h cx/hash_key.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + +$(BUILD_DIR)/mempool$(OBJ_EXT): mempool.c cx/mempool.h cx/common.h cx/allocator.h \ + cx/utils.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + +$(BUILD_DIR)/printf$(OBJ_EXT): printf.c cx/printf.h cx/common.h cx/string.h \ + cx/allocator.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + +$(BUILD_DIR)/string$(OBJ_EXT): string.c cx/string.h cx/common.h cx/allocator.h \ + cx/utils.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + +$(BUILD_DIR)/utils$(OBJ_EXT): utils.c cx/utils.h cx/common.h + echo "Compiling $<" + $(CC) -o $@ $(CFLAGS) -c $< + diff -r aaad6674a1a3 -r 24dc84788dee tests/CMakeLists.txt --- a/tests/CMakeLists.txt Sun Sep 03 09:10:16 2023 +0200 +++ b/tests/CMakeLists.txt Thu Oct 12 00:00:35 2023 +0200 @@ -1,5 +1,10 @@ -# Use C++ for Testing +cmake_minimum_required(VERSION 3.14) +project(ucxtest VERSION 3.0 DESCRIPTION "UAP Common Extensions - Tests") + +# Configuration +cmake_policy(SET CMP0077 NEW) set(CMAKE_CXX_STANDARD 17) +enable_testing() # Load Google Test Framework option(INSTALL_GTEST "By default googletest shall not be installed." OFF) @@ -31,5 +36,5 @@ selftest.cpp util_allocator.cpp ) -target_link_libraries(ucxtest PRIVATE ucx_static gtest_main) +target_link_libraries(ucxtest ${CMAKE_BINARY_DIR}/../libucx${STLIB_EXT} gtest_main) gtest_discover_tests(ucxtest) diff -r aaad6674a1a3 -r 24dc84788dee tests/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/Makefile Thu Oct 12 00:00:35 2023 +0200 @@ -0,0 +1,35 @@ +# Copyright 2023 Mike Becker. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +include ../config.mk + +TEST_DIR=$(BUILD_DIR)/tests + +all: $(TEST_DIR) $(BUILD_DIR)/libucx.a + cd $(TEST_DIR) && $(CMAKE) -DSTLIB_EXT="$(STLIB_EXT)" "$(src_dir)/tests" && $(CMAKE) --build . + @echo "[ Tests complete ]" + +# do not define libucx.a target - if it wasn't build, we simply fail! + +$(TEST_DIR): + $(MKDIR) $@ \ No newline at end of file