From 0a5f51ff8f50efa8dbfd9bb3b6be91f8ccfe33e1 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 31 Jul 2022 16:48:41 +0300 Subject: [PATCH] add musl check --- build_release.sh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/build_release.sh b/build_release.sh index 72335af..9c785ea 100755 --- a/build_release.sh +++ b/build_release.sh @@ -1,2 +1,23 @@ -rm dist/* -crystal build ./src/pmng.cr --release --progress -o ./dist/pmng-0.2.5-linux-x86_64 +#!/bin/sh + +# Preparing +if [ -d "./dist/" ]; +then + rm dist/* 2> /dev/null +else + mkdir dist/ +fi + +# Detect Musl C library +# thx @Unmanned Player https://stackoverflow.com/a/60471114 + +libc=$(ldd /bin/ls | grep 'musl' | head -1 | cut -d ' ' -f1) +if [ -z $libc ]; +then + # build libc + crystal build ./src/pmng.cr --release --progress -L/usr/lib/ -o ./dist/pmng-0.2.5-linux-x86_64 +else + # Build musl + crystal build ./src/pmng.cr --release --progress -o ./dist/pmng-0.2.5-linux-musl-x86_64 +fi +