Added build scripts for FreeBSD, Solaris and MacOS X platforms.

This commit is contained in:
LoRd_MuldeR 2022-09-23 00:10:07 +02:00
parent e4d9fc9162
commit 3fcaa5f40c
Signed by: mulder
GPG Key ID: 2B5913365F57E03F
7 changed files with 82 additions and 11 deletions

21
etc/utils/freebsd/mk-release.sh Executable file
View File

@ -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."

View File

@ -0,0 +1 @@
sudo hdiutil create archive.dmg -ov -volname "CRC-64" -fs HFS+ -srcfolder out

21
etc/utils/macosx/mk-release.sh Executable file
View File

@ -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."

21
etc/utils/solaris/mk-release.sh Executable file
View File

@ -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."

View 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;

View File

@ -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"