diff --git a/bin/package b/bin/package index 588bc7fd6b5c..b6c844a7f4d6 100755 --- a/bin/package +++ b/bin/package @@ -5411,6 +5411,25 @@ license)# all work in $PACKAGESRC/LICENSES ;; make|view) + # Add flags for build type + case `git branch 2>/dev/null` in + '' | *\*\ [0-9]*.[0-9]*) + # If we're not on a git branch (tarball) or on a branch that starts + # with a number (release branch), then compile as a release version + CCFLAGS="-D_AST_ksh_release${CCFLAGS:+ $CCFLAGS}" # prefix it to allow override with -U + export CCFLAGS + ;; + *) # Otherwise, add 8-character git commit hash if available, and if the working dir is clean + git_commit=`git status >/dev/null 2>&1 && git diff-index --quiet HEAD && git rev-parse --short=8 HEAD` + case $git_commit in + ????????) + CCFLAGS="-D_AST_git_commit=\\\"$git_commit\\\"${CCFLAGS:+ $CCFLAGS}" + export CCFLAGS + ;; + esac + unset git_commit + ;; + esac # Hack to build on some systems that need an explicit link with libm due to a bug in the build system case `uname` in NetBSD | SunOS) diff --git a/src/cmd/INIT/package.sh b/src/cmd/INIT/package.sh index 626cc3cb90d5..40ba9fcd8dbd 100644 --- a/src/cmd/INIT/package.sh +++ b/src/cmd/INIT/package.sh @@ -5410,6 +5410,25 @@ license)# all work in $PACKAGESRC/LICENSES ;; make|view) + # Add flags for build type + case `git branch 2>/dev/null` in + '' | *\*\ [0-9]*.[0-9]*) + # If we're not on a git branch (tarball) or on a branch that starts + # with a number (release branch), then compile as a release version + CCFLAGS="-D_AST_ksh_release${CCFLAGS:+ $CCFLAGS}" # prefix it to allow override with -U + export CCFLAGS + ;; + *) # Otherwise, add 8-character git commit hash if available, and if the working dir is clean + git_commit=`git status >/dev/null 2>&1 && git diff-index --quiet HEAD && git rev-parse --short=8 HEAD` + case $git_commit in + ????????) + CCFLAGS="-D_AST_git_commit=\\\"$git_commit\\\"${CCFLAGS:+ $CCFLAGS}" + export CCFLAGS + ;; + esac + unset git_commit + ;; + esac # Hack to build on some systems that need an explicit link with libm due to a bug in the build system case `uname` in NetBSD | SunOS) diff --git a/src/cmd/ksh93/data/builtins.c b/src/cmd/ksh93/data/builtins.c index 54b0f3181098..87f939cfde88 100644 --- a/src/cmd/ksh93/data/builtins.c +++ b/src/cmd/ksh93/data/builtins.c @@ -1486,6 +1486,7 @@ USAGE_LICENSE const char sh_optksh[] = "+[-1?\n@(#)$Id: sh (AT&T Research) "SH_RELEASE" $\n]" USAGE_LICENSE +"[-copyright?(c) 2020-2021 Contributors to ksh " SH_RELEASE_FORK "]" "[+NAME?\b\f?\f\b - Shell, the standard command language interpreter]" "[+DESCRIPTION?\b\f?\f\b is a command language interpreter that " "executes commands read from a command line string, the " diff --git a/src/cmd/ksh93/include/version.h b/src/cmd/ksh93/include/version.h index 4e8840c20b50..c6db0fbef91a 100644 --- a/src/cmd/ksh93/include/version.h +++ b/src/cmd/ksh93/include/version.h @@ -17,4 +17,19 @@ * David Korn * * * ***********************************************************************/ -#define SH_RELEASE "93u+m 2021-01-03" + +#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */ +#define SH_RELEASE_SVER "1.0.0-alpha" /* semantic version number: https://semver.org */ +#define SH_RELEASE_DATE "2021-01-03" /* must be in this format for $((.sh.version)) */ + +/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */ +/* Arithmetic $((.sh.version)) uses the last 10 chars, so the date must be at the end. */ +#if _AST_ksh_release +# define SH_RELEASE SH_RELEASE_FORK "/" SH_RELEASE_SVER " " SH_RELEASE_DATE +#else +# ifdef _AST_git_commit +# define SH_RELEASE SH_RELEASE_FORK "/" SH_RELEASE_SVER "+" _AST_git_commit " " SH_RELEASE_DATE +# else +# define SH_RELEASE SH_RELEASE_FORK "/" SH_RELEASE_SVER "+dev " SH_RELEASE_DATE +# endif +#endif diff --git a/src/cmd/ksh93/sh/init.c b/src/cmd/ksh93/sh/init.c index c37425127748..51fc5cdebeaa 100644 --- a/src/cmd/ksh93/sh/init.c +++ b/src/cmd/ksh93/sh/init.c @@ -107,6 +107,10 @@ char e_version[] = "\n@(#)$Id: Version " #define ATTRS 1 "R" #endif +#if !_std_malloc && !_AST_std_malloc +#define ATTRS 1 + "v" /* uses vmalloc */ +#endif #if ATTRS " " #endif diff --git a/src/lib/libast/features/vmalloc b/src/lib/libast/features/vmalloc index 787ccb8b61a6..5de9fbfc4bc1 100644 --- a/src/lib/libast/features/vmalloc +++ b/src/lib/libast/features/vmalloc @@ -207,7 +207,7 @@ tst malloc_hook note{ gnu malloc hooks work }end execute{ cat{ #include "FEATURE/mmap" - #if _BLD_INSTRUMENT || cray || _UWIN && _BLD_ast + #if _AST_ksh_release || _BLD_INSTRUMENT || cray || _UWIN && _BLD_ast #undef _map_malloc #define _std_malloc 1 /* defer to standard malloc */ #endif