~m-grant-prg/libmgesysutils/focal-trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#! /usr/bin/env bash
#########################################################################
#									#
#	gen-gnulib.sh is automatically generated,			#
#		please do not modify!					#
#									#
#########################################################################

#########################################################################
#									#
# Script ID: gen-gnulib.sh						#
# Author: Copyright (C) 2018  Mark Grant				#
#									#
# Released under the GPLv3 only.					#
# SPDX-License-Identifier: GPL-3.0					#
#									#
# Purpose:								#
# To perform initial gnulib setup for the project.			#
#									#
# Syntax:	bootstrap.sh	[ -h || --help ] ||			#
#				[ -V || --version ] ||			#
#				[ Project root directory ]		#
# Exit Codes:	0 - success						#
#		1 - failure.						#
#									#
# Further Info:								#
#									#
#########################################################################

#########################################################################
#									#
# Changelog								#
#									#
# Date		Author	Version	Description				#
#									#
# 07/02/2018	MG	1.0.1	Created.				#
#									#
#########################################################################

##################
# Init variables #
##################
script_exit_code=0
version="1.0.1"			# set version variable
packageversion=v1.0.1-4-g7222bec	# Version of the complete package

basedir="."


#############
# Functions #
#############

# Output $1 to stdout or stderr depending on $2.
output()
{
	if [ $2 = 0 ]
	then
		echo "$1"
	else
		echo "$1" 1>&2
	fi
}

# Standard function to test command error ($1 is $?) and exit if non-zero
std_cmd_err_handler()
{
	if [ $1 != 0 ]
	then
		script_exit_code=$1
		script_exit
	fi
}

# Standard function to cleanup and return exit code
script_exit()
{
	exit $script_exit_code
}

# Standard trap exit function
trap_exit()
{
script_exit_code=1
output "Script terminating due to trap received." 1
script_exit
}

# Setup trap
trap trap_exit SIGHUP SIGINT SIGTERM


########
# Main #
########
# Process command line arguments with GNU getopt.
GETOPTTEMP=`getopt -o hV --long help,version -n "$0" -- "$@"`
std_cmd_err_handler $?

eval set -- "$GETOPTTEMP"
std_cmd_err_handler $?

while true
do
	case "$1" in
	-h|--help)
		echo "Usage is [ Option ] [ Project root directory ]:-"
		echo "	-h or --help displays usage information"
		echo "	-V or --version displays version information"
		echo "	Project root directory, defaults to current directory."
		shift
		script_exit_code=0
		script_exit
		;;
	-V|--version)
		echo "$0 Script version "$version
		echo "$0 Package version "$packageversion
		shift
		script_exit_code=0
		script_exit
		;;
	--)	shift
		break
		;;
	*)	script_exit_code=1
		output "Internal error." 1
		script_exit
		;;
	esac
done

# Script can accept 1 other argument, the base directory.
if [ $# -gt 1 ]
then
	script_exit_code=1
	output "Invalid argument." 1
	script_exit
fi

if [ $# -eq 1 ]
then
	basedir=$1
fi


gnulib-tool --import --dir=$basedir --source-base=src/prg/c/gen/lib \
	--no-conditional-dependencies --no-libtool --no-vc-files configmake
script_exit_code=$?
script_exit