summaryrefslogtreecommitdiff
path: root/project/config/cfgdefs.sh
blob: 4cf1ebc5460fd395ab922b3c3959493379e8ed14 (plain)
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
# in projects where [ $mb_use_custom_cfgdefs = yes ],
# cfgdefs.sh is invoked from within ./configure via
# . $mb_project_dir/project/cfgdefs.sh

# this file is covered by COPYING.BAUTOMAKE.

# a successful return from cfgdefs.sh will be followed
# by a second invocation of the config_copy() function,
# reflecting any changes to common config variables
# made by cfgdefs.sh.

# finally, cfgdefs.sh may update the contents of the
# config-time generated cfgdefs.mk.

mb_manifest=MANIFEST.rawball

for arg ; do
	case "$arg" in
		--with-host-perl=*)
			mb_host_perl=${arg#*=}
			;;

		--with-host-sh=*)
			mb_host_sh=${arg#*=}
			;;

		*)
			error_msg ${arg#}: "unsupported config argument."
			exit 2
	esac
done


cfgdefs_detect_automake_version()
{
	automake_ver=$(grep 'VERSION' "$mb_source_dir/doc/version.texi")
	automake_ver=${automake_ver##* }

	automake_year=$(grep 'UPDATED-MONTH' "$mb_source_dir/doc/version.texi")
	automake_year=${automake_year##* }

	automake_major=$(printf '%s' "$automake_ver" | cut -d'.' -f1)
	automake_minor=$(printf '%s' "$automake_ver" | cut -d'.' -f2)
	automake_micro=$(printf '%s' "$automake_ver" | cut -d'.' -f3)

	if [ -z "$automake_major" ] || [ -z "$automake_minor" ]; then
		error_msg "Could not properly parse automake's version.texi"
		exit 2
	fi
}


cfgdefs_output_custom_defs()
{
	mb_host_perl=${mb_host_perl:-/usr/bin/perl}
	mb_host_sh=${mb_host_sh:-/usr/bin/sh}
	mb_makeinfo=$(command -v makeinfo || true)

	if [ -n "$mb_makeinfo" ]; then
		mb_all_info='all-info-docs'
		mb_install_info='install-info-docs'
	else
		mb_all_info=
		mb_install_info=
	fi

	sed \
			-e 's/@automake_ver@/'"$automake_ver"'/g'       \
			-e 's/@automake_year@/'"$automake_year"'/g'     \
			-e 's/@automake_major@/'"$automake_major"'/g'   \
			-e 's/@automake_minor@/'"$automake_minor"'/g'   \
			-e 's/@automake_micro@/'"$automake_micro"'/g'   \
			-e 's!@host_perl@!'"$mb_host_perl"'!g'          \
			-e 's!@host_sh@!'"$mb_host_sh"'!g'              \
			-e 's!@makeinfo@!'"$mb_makeinfo"'!g'            \
			-e 's!@all_info@!'"$mb_all_info"'!g'            \
			-e 's!@install_info@!'"$mb_install_info"'!g'    \
		"$mb_project_dir/project/config/cfgdefs.in"         \
	| sed -e 's/[ \t]*$//g'                                     \
			>> "$mb_pwd/cfgdefs.mk"
}


cfgdefs_output_source_lists()
{
	# raw m4 macros
	printf '\n\nAUTOMAKE_M4_SOURCE_FILES = \\\n' \
			>> "$mb_pwd/cfgdefs.mk"

	printf '\t$(SOURCE_DIR)/%s \\\n'                       \
		$(grep '/m4/' "$mb_source_dir/$mb_manifest"     \
			| grep -v -e '/acdir/' -e '/internal/'   \
			| grep -v -e '/amversion.in'              \
			| cut -d' ' -f3)                           \
			>> "$mb_pwd/cfgdefs.mk"


	# raw am snippets
	printf '\n\nAUTOMAKE_AM_SOURCE_FILES = \\\n' \
			>> "$mb_pwd/cfgdefs.mk"

	printf '\t$(SOURCE_DIR)/%s \\\n'                    \
		$(grep '/am/' "$mb_source_dir/$mb_manifest"  \
			| cut -d' ' -f3)                      \
			>> "$mb_pwd/cfgdefs.mk"


	# raw perl scripts
	printf '\n\nAUTOMAKE_PM_SOURCE_FILES = \\\n' \
			>> "$mb_pwd/cfgdefs.mk"

	printf '\t$(SOURCE_DIR)/%s \\\n'                             \
		$(grep '/Automake/' "$mb_source_dir/$mb_manifest"     \
			| cut -d' ' -f3)                               \
			>> "$mb_pwd/cfgdefs.mk"


	# raw automake scripts
	printf '\n\nAUTOMAKE_LIB_SOURCE_FILES = \\\n' \
			>> "$mb_pwd/cfgdefs.mk"

	printf '\t$(SOURCE_DIR)/%s \\\n'                        \
		$(grep '/lib/' "$mb_source_dir/$mb_manifest"     \
			| grep -v -e '/am/' -e '/Automake/'       \
			| cut -d' ' -f3)                           \
			>> "$mb_pwd/cfgdefs.mk"

	printf '\n\n'   >> "$mb_pwd/cfgdefs.mk"
}


# automake version info
cfgdefs_detect_automake_version

# cfgdefs.in --> cfgdefs.mk
cfgdefs_output_custom_defs

# create a list of raw files to install
cfgdefs_output_source_lists

# all done
return 0