Skip to content

Commit

Permalink
posix
Browse files Browse the repository at this point in the history
  • Loading branch information
junjiemars committed Oct 21, 2023
1 parent 9c9c048 commit 86d56f4
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 101 deletions.
6 changes: 3 additions & 3 deletions auto/cc/name
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# author: Junjie Mars
#------------------------------------------------

echo $echo_n "checking for C compiler ... $echo_c"
printf "checking for C compiler ... "

nm_feature="C compiler"
nm_feature_name=
Expand All @@ -16,10 +16,10 @@ nm_feature_test=
. ${NORE_ROOT}/auto/feature

if [ ".no" = ".$nm_found" ]; then
echo "$nm_found"
printf "${nm_found}\n"
exit 1
else
echo "$nm_found"
printf "${nm_found}\n"
fi


Expand Down
6 changes: 3 additions & 3 deletions auto/check
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@
# # #----------------------------------------
# echo "checking Libraries ..."
# has_pkg_config=no
# echo $echo_n " + checking for pkg-config ... $echo_c"
# printf " + checking for pkg-config ... "
# if [ 0 -eq $(pkg-config --version 2>&1 1>/dev/null;echo $?) ]; then
# echo "yes"
# printf "yes\n"
# has_pkg_config=yes
# flag=has_pkg_config op=":=" value="$has_pkg_config" \
# . ${NORE_ROOT}/auto/make_define
# else
# echo "no"
# printf "no\n"
# fi


Expand Down
4 changes: 2 additions & 2 deletions auto/feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
if [ "dumb" != "$nm_feature_run" ]; then
case $nm_feature_indent in
yes|'')
echo $echo_n " + checking for $nm_feature ... $echo_c"
printf " + checking for $nm_feature ... "
;;
no|*)
echo $echo_n "checking for $nm_feature ... $echo_c"
printf "checking for $nm_feature ... "
;;
esac
fi
Expand Down
14 changes: 0 additions & 14 deletions auto/init
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,4 @@ test -d $NM_OUT || mkdir -p $NM_OUT

echo > $NM_AUTO_ERR


# check the echo's "-n" option and "\c" capability
if echo "test\c" | grep -q c; then
echo_c=
if echo -n test | tr '\n' _ | grep -q _; then
echo_n=
else
echo_n=-n
fi
else
echo_n=
echo_c='\c'
fi

# eof
16 changes: 8 additions & 8 deletions auto/make
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ make_stick_norm () {

echo_yes_or_no () {
if [ 0 -eq $1 ]; then
echo "yes"
printf "yes\n"
else
echo "no"
printf "no\n"
fi
}

Expand Down Expand Up @@ -239,7 +239,7 @@ for stick in ${NM_HAS_STICKS}; do

if [ ! -d "$nm_stick_src" ]; then
if [ YES = $NM_NEW ]; then
echo $echo_n " + generating $nm_stick_src directory ... $echo_c"
printf " + generating $nm_stick_src directory ... "
mkdir -p "$nm_stick_src"
echo_yes_or_no $?
else
Expand All @@ -261,7 +261,7 @@ END
fi

if [ YES = $NM_NEW -a ! -f "$nm_stick_norm_c" ]; then
echo $echo_n " + generating `echo_pretty_path $nm_stick_src/$nm_stick_norm_c` file ... $echo_c"
printf " + generating `echo_pretty_path $nm_stick_src/$nm_stick_norm_c` file ... "

cat <<END > "$nm_stick_src/$nm_stick_norm_c"
/*
Expand Down Expand Up @@ -301,7 +301,7 @@ END
value=`cat "$nm_stick_src/version"` . ${NORE_ROOT}/auto/define

elif [ YES = $NM_NEW ]; then
echo $echo_n " + generating `echo_pretty_path $nm_stick_src/version` file ... $echo_c"
printf " + generating `echo_pretty_path $nm_stick_src/version` file ... "
cat << END > "$nm_stick_src/version"
0x030614
Expand All @@ -314,7 +314,7 @@ END
. "$nm_stick_src/auto" 2>> $NM_AUTO_ERR

elif [ YES = $NM_NEW ]; then
echo $echo_n " + generating `echo_pretty_path $nm_stick_src/auto` file ... $echo_c"
printf " + generating `echo_pretty_path $nm_stick_src/auto` file ... "
cat ${NORE_ROOT}/auto/check > "$nm_stick_src/auto"
echo_yes_or_no $?
else
Expand All @@ -330,7 +330,7 @@ END
if [ $nm_stick_src = . ]; then
stick_makefile="$nm_stick_src/Makefile.NEW"
else
echo $echo_n " + generating `echo_pretty_path $nm_stick_src/Makefile` ... $echo_c"
printf " + generating `echo_pretty_path $nm_stick_src/Makefile` ... "
fi
cat << END > "$stick_makefile"
#---------------------------------------
Expand Down Expand Up @@ -401,7 +401,7 @@ fi

# create root Makefile
if [ ! -f Makefile ]; then
echo $echo_n " + generating Makefile file ... $echo_c"
printf " + generating Makefile file ... "
cat << END > Makefile
# Makefile
#
Expand Down
109 changes: 38 additions & 71 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ grep=$(PATH=$PH command -v grep)
iconv=$(PATH=$PH command -v iconv)
ls=$(PATH=$PH command -v ls)
mkdir=$(PATH=$PH command -v mkdir)
printf=$(PATH=$PH command -v printf)
ps=$(PATH=$PH command -v ps)
rm=$(PATH=$PH command -v rm)
sed=$(PATH=$PH command -v sed)
Expand All @@ -32,20 +33,6 @@ tr=$(PATH=$PH command -v tr)
uname=$(PATH=$PH command -v uname)
set +e

# check command options
check_echo_opt () {
# check the echo's "-n" option and "\c" capability
echo_c='\c'
if echo "test\c" | grep -q c; then
echo_c=
fi
echo_n=-n
if echo -n test | tr '\n' _ | grep -q _; then
echo_n=
fi
}
check_echo_opt

bootstrap_path () {
local p="`dirname $0`"
local n="${PWD}/.nore"
Expand Down Expand Up @@ -168,22 +155,6 @@ cat_configure () {
# generated by Nore (${GITHUB_H}/nore)
#------------------------------------------------
check_echo_opt () {
# check the echo's "-n" option and "\c" capability
if echo "test\c" | grep -q c; then
echo_c=
if echo -n test | tr '\n' _ | grep -q _; then
echo_n=
else
echo_n=-n
fi
else
echo_n=
echo_c='\c'
fi
}
check_echo_opt
NORE_ROOT="${ROOT%/}"
NORE_BRANCH="${b}"
NORE_L_BOOT="\${NORE_ROOT}/bootstrap.sh"
Expand All @@ -193,7 +164,6 @@ NORE_L_CONF_OPTS=
NORE_L_CONF_TRACE="no"
NORE_L_CONF_COMMAND=
for option
do
case "\$option" in
Expand Down Expand Up @@ -240,39 +210,38 @@ case "\`echo \${NORE_L_CONF_COMMAND} | tr '[:upper:]' '[:lower:]'\`" in
echo "NORE_BRANCH=\${NORE_BRANCH}"
echo "configure=@\$0"
echo "make=@\$(command -v make)"
`if on_darwin; then
echo " echo \\"shell=@\\\$(ps -p\\\$\\\$ -ocommand | tr ' ' '\\\\\n' | sed -n 2p)\\""
$(if on_darwin; then
echo " echo \"shell=@\$($ps -p\$\$ -ocommand|$sed -n '2p'|$cut -d ' ' -f1)\""
elif $(command -v readlink \&>/dev/null); then
echo " echo \\"shell=@\\\$(readlink /proc/\\\$\\\$/exe)\\""
echo " echo \"shell=@\$(readlink /proc/\$\$/exe)\""
else
echo " echo \\"shell=@\\\$(ls -l /proc/\\\$\\\$/exe | sed 's#.*->[ ]*\(.*\)#\\\1#g')\\""
fi`
echo \$echo_n "cc-env.sh=@\$echo_c"
echo " echo \"shell=@\$(ls -l /proc/\$\$/exe | sed 's#.*->[ ]*\(.*\)#\1#g')\""
fi)
$printf "cc-env.sh=@"
if [ -f "\${HOME}/.nore/cc-env.sh" ]; then
echo "\${HOME}/.nore/cc-env.sh"
$printf "\${HOME}/.nore/cc-env.sh\n"
else
echo ""
$printf "\n"
fi
`if on_windows_nt; then
echo "echo \\\$echo_n \\"cc-env.bat=@\\\$echo_c\\""
echo " if [ -f \"\\\${HOME}/.nore/cc-env.bat\\" ]; then"
echo " echo \"\\\${HOME}/.nore/cc-env.bat\\""
$(if on_windows_nt; then
echo " $printf \"cc-env.bat=@\""
echo " if [ -f \"\${HOME}/.nore/cc-env.bat\" ]; then"
echo " $printf \"\${HOME}/.nore/cc-env.bat\n\""
echo " else"
echo " echo \\"\\""
echo " $printf \"\\n\""
echo " fi"
fi`
echo \$echo_n "cc-inc.lst=@\$echo_c"
fi)
$printf "cc-inc.lst=@"
if [ -f "\${HOME}/.nore/cc-inc.lst" ]; then
echo "\${HOME}/.nore/cc-inc.lst"
$printf "\${HOME}/.nore/cc-inc.lst\n"
else
echo ""
$printf "\n"
fi
echo \$echo_n "cc-inc.vimrc=@\$echo_c"
$printf "cc-inc.vimrc=@"
if [ -f "\${HOME}/.nore/cc-inc.vimrc" ]; then
echo "\${HOME}/.nore/cc-inc.vimrc"
$printf "\${HOME}/.nore/cc-inc.vimrc\n"
else
echo ""
$printf "\n"
fi
exit \$?
;;
Expand All @@ -288,11 +257,10 @@ cd "\$(CDPATH= cd -- \$(dirname -- \$0) && echo \$PWD)"
if [ -f \${NORE_L_CONF} ]; then
case "\${NORE_L_CONF_TRACE}" in
no)
\$NORE_L_CONF "\$@"
PATH="$PH" \$NORE_L_CONF "\$@"
;;
yes)
sh -x \$NORE_L_CONF \${NORE_L_CONF_OPTS}
PATH="$PH" sh -x \$NORE_L_CONF \${NORE_L_CONF_OPTS}
;;
esac
else
Expand Down Expand Up @@ -472,18 +440,17 @@ END
echo_yes_or_no () {
local c="$1"
if [ 0 -eq $c ]; then
echo "yes"
$printf "yes\n"
else
echo "no"
$printf "no\n"
fi
return $c
}
echo_elapsed_seconds () {
local begin=$1
local end="`date +%s`"
echo
echo "... elpased $(( ${end}-${begin} )) seconds."
local end="$(date +%s)"
$printf "\n... elpased %d seconds.\n" $(( ${end}-${begin} ))
}
exit_checking () {
Expand Down Expand Up @@ -525,37 +492,37 @@ echo
echo "configure Nore on $PLATFORM ..."
echo
echo $echo_n " + checking make ... $echo_c"
if `make -v 1>/dev/null 2>&1`; then
$printf " + checking make ... "
if make -v 2>&1 1>/dev/null; then
echo_yes_or_no $?
else
echo_yes_or_no $?
if `on_windows_nt`; then
echo $echo_n " + downloading make ... $echo_c"
$printf " + downloading make ... "
echo_yes_or_no `download_gmake "${HOME}/.nore"; echo $?`
fi
fi
echo $echo_n " + checking nore ... $echo_c"
$printf " + checking nore ... "
if check_nore; then
echo_yes_or_no $?
if [ "yes" = "$NORE_UPGRADE" ]; then
echo $echo_n " + upgrading nore ... $echo_c"
echo_yes_or_no `upgrade_nore ; echo $?`
$printf " + upgrading nore ... "
echo_yes_or_no $(upgrade_nore ; echo $?)
exit_checking $? $BEGIN
fi
else
echo_yes_or_no $?
echo $echo_n " + cloning nore ... $echo_c"
echo_yes_or_no `clone_nore ; echo $?`
$printf " + cloning nore ... "
echo_yes_or_no $(clone_nore ; echo $?)
exit_checking $? $BEGIN
fi
echo $echo_n " + generating configure ... $echo_c"
echo_yes_or_no `cat_configure ; echo $?`
$printf " + generating configure ... "
echo_yes_or_no $(cat_configure ; echo $?)
exit_checking $? $BEGIN
echo $echo_n " + generating ~/.nore/cc-env.sh ... $echo_c"
$printf " + generating ~/.nore/cc-env.sh ... "
echo_yes_or_no $(cat_cc_env "${HOME}/.nore/cc-env.sh"; echo $?)
exit_checking $? $BEGIN
Expand Down

0 comments on commit 86d56f4

Please sign in to comment.