1 # Makefile.sh - POSIX Makefile scripting adjunct for TopGit
2 # Copyright (C) 2017 Kyle J. McKay
6 # Set MAKEFILESH_DEBUG to get:
7 # 1. All defined environment variales saved to Makefile.var
9 # 3. set -v if MAKEFILESH_DEBUG contains "v"
11 if [ -n "$MAKEFILESH_DEBUG" ]; then
13 case "$MAKEFILESH_DEBUG" in *"v"*) _setcmd
="set -vx"; esac
14 eval "$_setcmd && unset _setcmd"
17 # prevent crazy "sh" implementations from exporting functions into environment
20 # common defines for all makefile(s)
24 # Update if you add any code that requires a newer version of git
25 : "${GIT_MINIMUM_VERSION:=1.8.5}"
27 # This avoids having this in no less than three different places!
28 TG_STATUS_HELP_USAGE
="st[atus] [-v] [--exit-code]"
30 # These are initialized here so config.sh or config.mak can change them
31 # They are deliberately left with '$(...)' constructs for make to expand
32 # so that if config.mak just sets prefix they all automatically change
33 [ -n "$prefix" ] || prefix
="$HOME"
34 [ -n "$bindir" ] || bindir
='$(prefix)/bin'
35 [ -n "$cmddir" ] || cmddir
='$(prefix)/libexec/topgit'
36 [ -n "$sharedir" ] || sharedir
='$(prefix)/share/topgit'
37 [ -n "$hooksdir" ] || hooksdir
='$(cmddir)/hooks'
40 # wrap it up for safe returns
41 # "$@" is the current build target(s), if any
44 v_wildcard commands_in
'tg-[!-]*.sh'
45 v_wildcard utils_in
'tg--*.sh'
46 v_wildcard awk_in
'awk/*.awk'
47 v_wildcard hooks_in
'hooks/*.sh'
48 v_wildcard helpers_in
't/helper/*.sh'
50 v_strip_sfx commands_out .sh
$commands_in
51 v_strip_sfx utils_out .sh
$utils_in
52 v_strip_sfx awk_out .
awk $awk_in
53 v_strip_sfx hooks_out .sh
$hooks_in
54 v_strip_sfx helpers_out .sh
$helpers_in
56 v_stripadd_sfx help_out .sh .txt tg-help.sh tg-status.sh
$commands_in
57 v_stripadd_sfx html_out .sh .html tg-help.sh tg-status.sh tg-tg.sh
$commands_in
59 DEPFILE
="Makefile.dep"
61 write_auto_deps
'' '.sh' tg
$commands_out $utils_out $hooks_out $helpers_out
62 write_auto_deps
'' '.awk' $awk_out
65 : "${SHELL_PATH:=/bin/sh}" "${AWK_PATH:=awk}"
67 test -d .git && git describe --match "topgit-
[0-9]*" --abbrev=4 --dirty 2>/dev/null |
68 sed -e 's/^topgit-//')" ||
:
70 # config.sh is wrapped up for return safety
73 # config.sh may not unset these
74 : "${SHELL_PATH:=/bin/sh}" "${AWK_PATH:=awk}"
76 case "$AWK_PATH" in */*) AWK_PREFIX
=;; *) AWK_PREFIX
="/usr/bin/"; esac
77 quotevar SHELL_PATH SHELL_PATH_SQ
78 quotevar AWK_PATH AWK_PATH_SQ
80 v_strip version
"$version"
82 [ -z "$version" ] || version_arg
="-e 's/TG_VERSION=.*/TG_VERSION=\"$version\"/'"
85 [ -z "$DESTDIR" ] || DESTDIRBOOL
="Yes"
87 [ -z "$MAKEFILESH_DEBUG" ] ||
{
88 printenv | LC_ALL
=C
grep '^[_A-Za-z][_A-Za-z0-9]*=' | LC_ALL
=C
sort
91 # Force TG-BUILD-SETTINGS to be updated now if needed
92 ${MAKE:-make} ${GNO_PD_OPT} -e -f Makefile.mak FORCE_SETTINGS_BUILD
=FORCE TG-BUILD-SETTINGS
98 ## Run "makefile" now unless MKTOP is set
103 test -n "$MKTOP" ||
{