OSDN Git Service

Added build scripts for FreeBSD, Solaris and MacOS X platforms.
authorLoRd_MuldeR <mulder2@gmx.de>
Thu, 22 Sep 2022 22:10:07 +0000 (00:10 +0200)
committerLoRd_MuldeR <mulder2@gmx.de>
Fri, 23 Sep 2022 21:27:02 +0000 (23:27 +0200)
etc/utils/freebsd/mk-release.sh [new file with mode: 0755]
etc/utils/linux/mk-musl-libc.sh [moved from etc/utils/linux/mk-musl.sh with 100% similarity]
etc/utils/macosx/hdiutil.txt [new file with mode: 0644]
etc/utils/macosx/mk-release.sh [new file with mode: 0755]
etc/utils/solaris/mk-release.sh [new file with mode: 0755]
libslunkcrypt/src/junk.c
mk-release.sh

diff --git a/etc/utils/freebsd/mk-release.sh b/etc/utils/freebsd/mk-release.sh
new file mode 100755 (executable)
index 0000000..acf4f60
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+set -e
+cd -- "$(dirname -- "${0}")/../../.."
+
+if [ -z "${cc_path}" ]; then
+       cc_path="/usr/local/bin/gcc12"
+fi
+
+mk_slunk() {
+       gmake -B CC="${cc_path}" CPU=${1} MARCH=${3} MTUNE=${4} STATIC=1 STRIP=1
+       cp -vf "frontend/bin/slunkcrypt" "out/slunkcrypt-${2}"
+}
+
+rm -rf "out" && mkdir -p "out"
+
+gmake CC="${cc_path}" clean
+
+mk_slunk 32 "i686"   "pentiumpro" "pentium3"
+mk_slunk 64 "x86_64" "x86-64"     "nocona"
+
+echo "Build completed successfully."
diff --git a/etc/utils/macosx/hdiutil.txt b/etc/utils/macosx/hdiutil.txt
new file mode 100644 (file)
index 0000000..70d1d31
--- /dev/null
@@ -0,0 +1 @@
+sudo hdiutil create archive.dmg -ov -volname "CRC-64" -fs HFS+ -srcfolder out
diff --git a/etc/utils/macosx/mk-release.sh b/etc/utils/macosx/mk-release.sh
new file mode 100755 (executable)
index 0000000..c5a9be6
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/zsh
+set -e
+cd -- "$(dirname -- "${(%):-%N}")/../../.."
+
+if [ -z "${cc_path}" ]; then
+       cc_path="/usr/bin/cc"
+fi
+
+mk_slunk() {
+       make -B CC="${cc_path}" TARGET="${1}-apple-macos" FLTO=1
+       strip -o "out/slunkcrypt-${1}" "frontend/bin/slunkcrypt"
+}
+
+rm -rf "out" && mkdir -p "out"
+
+make CC="${cc_path}" clean
+
+mk_slunk "x86_64"
+mk_slunk "arm64"
+
+echo "Build completed successfully."
diff --git a/etc/utils/solaris/mk-release.sh b/etc/utils/solaris/mk-release.sh
new file mode 100755 (executable)
index 0000000..f772460
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+set -e
+cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../../.."
+
+if [ -z "${cc_path}" ]; then
+       cc_path="/usr/gcc/11/bin/gcc"
+fi
+
+mk_slunk() {
+       gmake -B CC="${cc_path}" CPU=${1} MARCH=${3} MTUNE=${4} FLTO=1 STRIP=1
+       cp -f "frontend/bin/slunkcrypt" "out/slunkcrypt-${2}"
+}
+
+rm -rf "out" && mkdir -p "out"
+
+gmake CC="${cc_path}" clean
+
+mk_slunk 32 "i686"   "pentiumpro" "pentium3"
+mk_slunk 64 "x86_64" "x86-64"     "nocona"
+
+echo "Build completed successfully."
index c33bec1..24b4822 100644 (file)
@@ -32,6 +32,11 @@ static INLINE size_t MIN_SIZE(const size_t a, const size_t b) { return (a > b) ?
 #else
 #  include <unistd.h>
 #  include <sched.h>
+#  include <strings.h>
+#endif
+
+#if defined(__APPLE__) && defined(__MACH__)
+#  include <sys/random.h>
 #endif
 
 /* detect compiler destructor support */
@@ -45,7 +50,7 @@ static INLINE size_t MIN_SIZE(const size_t a, const size_t b) { return (a > b) ?
 #undef HAVE_WIN32RTLGENRANDOM
 #if defined(_WIN32)
 #  define HAVE_WIN32RTLGENRANDOM 1
-#elif (defined(__linux__) && !defined(__UCLIBC__)) || (defined(__FreeBSD__) && (__FreeBSD__ >= 12)) || defined(__DragonFly__) || defined(__OpenBSD__) || (defined(__sun) && defined(__SVR4))
+#elif (defined(__linux__) && !defined(__UCLIBC__)) || (defined(__FreeBSD__) && (__FreeBSD__ >= 12)) || defined(__DragonFly__) || defined(__OpenBSD__) || (defined(__sun) && defined(__SVR4)) || (defined(__APPLE__) && defined(__MACH__))
 #  define HAVE_GETENTROPY 1
 #else
 #  pragma message("Function getentropy() is *not* available -> using fallback!")
@@ -63,9 +68,9 @@ static INLINE size_t MIN_SIZE(const size_t a, const size_t b) { return (a > b) ?
 
 /* detect sched_yield() or Sleep() support */
 #ifdef _WIN32
-#  define SCHED_YIELD() Sleep(0)
+#  define THREAD_YIELD() Sleep(0)
 #else
-#  define SCHED_YIELD() sched_yield()
+#  define THREAD_YIELD() sched_yield()
 #endif
 
 // ==========================================================================
@@ -74,27 +79,29 @@ static INLINE size_t MIN_SIZE(const size_t a, const size_t b) { return (a > b) ?
 
 /* atomic memory access */
 #if defined(_MSC_VER) && (!defined(__GNUC__))
+#  define ONCE_FLAG_T LONG
 #  define ATOMIC_COMPARE_EXCHANGE(X,Y,Z) InterlockedCompareExchange((X),(Y),(Z))
 #  define ATOMIC_EXCHANGE(X,Y) InterlockedExchange((X),(Y))
 #else
+#  define ONCE_FLAG_T int
 #  define ATOMIC_COMPARE_EXCHANGE(X,Y,Z) __sync_val_compare_and_swap((X),(Z),(Y))
 #  define ATOMIC_EXCHANGE(X,Y) __sync_lock_test_and_set((X),(Y))
 #endif
 
-/* execute initialization function once */
-static INLINE void initialize_once(volatile long *const once_flag, void (*const init_routine)(void))
+/* execute init routine once */
+static INLINE void initialize_once(volatile ONCE_FLAG_T *const once_control, void (*const init_routine)(void))
 {
-       long state;
-       while ((state = ATOMIC_COMPARE_EXCHANGE(once_flag, -1, 0)) != 0)
+       ONCE_FLAG_T state;
+       while ((state = ATOMIC_COMPARE_EXCHANGE(once_control, -1, 0)) != 0)
        {
                if (state > 0)
                {
                        return; /*already initialized*/
                }
-               SCHED_YIELD();
+               THREAD_YIELD();
        }
        init_routine();
-       ATOMIC_EXCHANGE(once_flag, 1);
+       ATOMIC_EXCHANGE(once_control, 1);
 }
 
 // ==========================================================================
@@ -104,7 +111,7 @@ static INLINE void initialize_once(volatile long *const once_flag, void (*const
 #define MAX_COUNT 1048576U
 
 /* Global state */
-static volatile long s_random_is_initialized = 0L;
+static volatile ONCE_FLAG_T s_random_is_initialized = 0;
 #if defined(_WIN32)
 typedef BOOLEAN(WINAPI *ptr_genrandom_t)(void *buffer, ULONG length);
 static HMODULE s_advapi32 = NULL;
index f77b570..17a3249 100755 (executable)
@@ -19,7 +19,7 @@ rm -rf "out" && mkdir -p "out"
 $BASH -x -c "make clean"
 
 mk_slunk "x86_64" "MARCH=x86-64 MTUNE=nocona"
-mk_slunk "i686" "MARCH=pentiumpro MTUNE=pentium3"
+mk_slunk "i686"   "MARCH=pentiumpro MTUNE=pentium3"
 mk_slunk "armel"
 mk_slunk "armhf"
 mk_slunk "arm64"