summaryrefslogtreecommitdiff
path: root/b
diff options
context:
space:
mode:
authorpryazha <pryadeiniv@mail.ru>2025-10-20 19:05:33 +0500
committerpryazha <pryadeiniv@mail.ru>2025-10-20 19:05:33 +0500
commit9e1ccaa8becf1e18a68001b8c11ef095dc2ab7d9 (patch)
tree3b3d4fcb05646f2aa94ef8547f44770e08c0be19 /b
parent223b1056273f5d48d1c0bbfee75be7b82374d4eb (diff)
add command check and freebsd support (not really)
Diffstat (limited to 'b')
-rwxr-xr-xb57
1 files changed, 38 insertions, 19 deletions
diff --git a/b b/b
index 235cc28..e81c6b6 100755
--- a/b
+++ b/b
@@ -8,27 +8,40 @@ echorun()
compile()
{
- echorun "$cc $cflags $include $lflags -o $dir/$1.o $dir/$1.c $libs"
+ echorun "$cc $cflags $include $lflags -o $1.o $1.c $libs"
}
-cur=`pwd`
+check_commands()
+{
+ for cmd in $@ ; do
+ if [ ! `which $cmd` ] ; then
+ echo "command $cmd didn't exist"
+ exit
+ fi
+ done
+}
+
+cc='gcc'
+
+os=`uname`
+if [ "$os" = "FreeBSD" ] ; then
+ cc="clang"
+fi
+
+check_commands pwd realpath dirname $cc
+
+start=`pwd`
dir=`realpath $0`
dir=`dirname $dir`
echorun "cd $dir"
if [ "$1" = 'clean' ] ; then
- echorun "rm -f *.o"
- echorun "cd $cur"
- exit
-fi
-if [ "$1" = 'cleanlib' ] ; then
echorun "rm -f *.o libprb.a"
- echorun "cd $cur"
+ echorun "cd $start"
exit
fi
-cc='gcc'
debug='-g'
release='-O2'
cflags="-c"
@@ -38,15 +51,21 @@ else
cflags="$release $cflags"
fi
-compile prbm
-compile arena
-compile prbs
-compile linux
+srcs='
+prbm
+arena
+prbs
+linux
+'
+
+for src in $srcs ; do
+ compile $src
+done
-echorun "ar rcs $dir/libprb.a \
- $dir/prbm.o \
- $dir/arena.o \
- $dir/prbs.o \
- $dir/linux.o"
+echorun "ar rcs libprb.a \
+ prbm \
+ arena \
+ prbs \
+ linux"
-echorun "cd $cur"
+echorun "cd $start"