diff options
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | build_and_test.sh | 105 | ||||
-rw-r--r-- | include/kit.inl.h | 6 |
3 files changed, 76 insertions, 37 deletions
@@ -1,5 +1,7 @@ To-Do +- Build with GCC on Windows + - Cryptography - hmac_sha256 https://github.com/h5p9sl/hmac_sha256 - ecdh https://github.com/kokke/tiny-ECDH-c diff --git a/build_and_test.sh b/build_and_test.sh index 627e062..873bacf 100644 --- a/build_and_test.sh +++ b/build_and_test.sh @@ -11,50 +11,83 @@ FLAG_OBJ="-c -o " FLAG_EXE="-o " LINK_FLAGS= +if [ "$2" = "gcc" ]; then + COMPILE=gcc + COMPILEPP=g++ +elif [ "$2" = "clang" ]; then + COMPILE=clang + COMPILEPP=clang++ +elif [ "$2" = "msvc" ]; then + COMPILE=cl.exe + COMPILEPP=cl.exe + OBJ_POSTFIX=.obj + FLAG_OBJ="-c -Fo" + FLAG_EXE="-Fe" + LINK_FLAGS="Shlwapi.lib" +elif [ "$2" != "" ]; then + echo "Unknown C compiler" + exit 1 +fi + +if [ "$2" != "" ]; then + if command -v $COMPILE >/dev/null 2>&1; then + echo "C compiler found" + else + echo "C compiler not found" + exit 1 + fi +fi + case $(uname | tr '[:upper:]' '[:lower:]') in *darwin*) - if command -v clang >/dev/null 2>&1; then - echo "C compiler found - Clang" - COMPILE=clang - COMPILEPP=clang++ - elif command -v gcc >/dev/null 2>&1; then - echo "C compiler found - GCC" - else - echo "C compiler not found" - exit 1 + if [ "$2" = "" ]; then + if command -v clang >/dev/null 2>&1; then + echo "C compiler found - Clang" + COMPILE=clang + COMPILEPP=clang++ + elif command -v gcc >/dev/null 2>&1; then + echo "C compiler found - GCC" + else + echo "C compiler not found" + exit 1 + fi fi ;; *msys*|*cygwin*|*mingw*|*nt*|*win*) - if command -v cl.exe >/dev/null 2>&1; then - echo "C compiler found - MSVC" - COMPILE=cl.exe - COMPILEPP=cl.exe - OBJ_POSTFIX=.obj - EXE_POSTFIX=.exe - FLAG_OBJ="-c -Fo" - FLAG_EXE="-Fe" - LINK_FLAGS="Shlwapi.lib" - elif command -v gcc >/dev/null 2>&1; then - echo "C compiler found - GCC" - elif command -v clang >/dev/null 2>&1; then - echo "C compiler found - Clang" - COMPILE=clang - COMPILEPP=clang++ - else - echo "C compiler not found" - exit 1 + EXE_POSTFIX=.exe + if [ "$2" = "" ]; then + if command -v cl.exe >/dev/null 2>&1; then + echo "C compiler found - MSVC" + COMPILE=cl.exe + COMPILEPP=cl.exe + OBJ_POSTFIX=.obj + FLAG_OBJ="-c -Fo" + FLAG_EXE="-Fe" + LINK_FLAGS="Shlwapi.lib" + elif command -v gcc >/dev/null 2>&1; then + echo "C compiler found - GCC" + elif command -v clang >/dev/null 2>&1; then + echo "C compiler found - Clang" + COMPILE=clang + COMPILEPP=clang++ + else + echo "C compiler not found" + exit 1 + fi fi ;; *) - if command -v gcc >/dev/null 2>&1; then - echo "C compiler found - GCC" - elif command -v clang >/dev/null 2>&1; then - echo "C compiler found - Clang" - COMPILE=clang - COMPILEPP=clang++ - else - echo "C compiler not found" - exit 1 + if [ "$2" = "" ]; then + if command -v gcc >/dev/null 2>&1; then + echo "C compiler found - GCC" + elif command -v clang >/dev/null 2>&1; then + echo "C compiler found - Clang" + COMPILE=clang + COMPILEPP=clang++ + else + echo "C compiler not found" + exit 1 + fi fi ;; esac diff --git a/include/kit.inl.h b/include/kit.inl.h index 06eaafd..c1c054c 100644 --- a/include/kit.inl.h +++ b/include/kit.inl.h @@ -339,6 +339,9 @@ uint64_t kit_atomic_fetch_add_explicit_64(uint64_t volatile *var, # define _GNU_SOURCE # endif # include <time.h> +# ifndef TIME_UTC +# define TIME_UTC 1 +# endif # if !defined(_WIN32) || defined(__CYGWIN__) # include <pthread.h> # endif @@ -2797,11 +2800,12 @@ void kit_ib_destroy(kit_ib_handle_t buf) { #include <string.h> enum { PATH_BUF_SIZE = 4096 }; #if defined(_WIN32) && !defined(__CYGWIN__) +# include <stdint.h> # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif -# include <stdint.h> # include <Windows.h> +# include <Shlwapi.h> #else # include <dirent.h> # include <sys/stat.h> |