1f08c3bdfSopenharmony_ci#!/bin/sh
2f08c3bdfSopenharmony_ci#
3f08c3bdfSopenharmony_ci# Generate generic POSIX compliant Makefiles.
4f08c3bdfSopenharmony_ci#
5f08c3bdfSopenharmony_ci# This means that there's a lot of unnecessary text (when using BSD or GNU
6f08c3bdfSopenharmony_ci# make, as I'm sure there are in other variants), and a lack of modularity,
7f08c3bdfSopenharmony_ci# but as long as you follow the criterion set in locate-test, then the
8f08c3bdfSopenharmony_ci# end-result for modifying and/or adding tests can be achieved by merely
9f08c3bdfSopenharmony_ci# rerunning this script.
10f08c3bdfSopenharmony_ci#
11f08c3bdfSopenharmony_ci# This script will remain around until (hopefully someday) POSIX make
12f08c3bdfSopenharmony_ci# becomes less braindead.
13f08c3bdfSopenharmony_ci#
14f08c3bdfSopenharmony_ci# See COPYING for more details.
15f08c3bdfSopenharmony_ci#
16f08c3bdfSopenharmony_ci# Ngie Cooper, June 2010
17f08c3bdfSopenharmony_ci#
18f08c3bdfSopenharmony_ci
19f08c3bdfSopenharmony_cireadonly buildonly_compiler_args="-c"
20f08c3bdfSopenharmony_ci
21f08c3bdfSopenharmony_cigenerate_locate_test_makefile() {
22f08c3bdfSopenharmony_ci
23f08c3bdfSopenharmony_ci	local maketype=$1; shift
24f08c3bdfSopenharmony_ci
25f08c3bdfSopenharmony_ci	echo "Generating $maketype Makefiles"
26f08c3bdfSopenharmony_ci
27f08c3bdfSopenharmony_ci	locate-test --$maketype | sed -e 's,^./,,g' | sort > make-gen.$maketype
28f08c3bdfSopenharmony_ci
29f08c3bdfSopenharmony_ci	generate_makefiles make-gen.$maketype $*
30f08c3bdfSopenharmony_ci
31f08c3bdfSopenharmony_ci	rm -f make-gen.$maketype
32f08c3bdfSopenharmony_ci}
33f08c3bdfSopenharmony_ci
34f08c3bdfSopenharmony_cigenerate_makefile() {
35f08c3bdfSopenharmony_ci
36f08c3bdfSopenharmony_ci	local link_libs=
37f08c3bdfSopenharmony_ci	local make_rule_prereq_cache=
38f08c3bdfSopenharmony_ci	local make_copy_prereq_cache=
39f08c3bdfSopenharmony_ci	local prereq_cache=
40f08c3bdfSopenharmony_ci	local tests=
41f08c3bdfSopenharmony_ci	local targets=
42f08c3bdfSopenharmony_ci
43f08c3bdfSopenharmony_ci	local makefile=$1
44f08c3bdfSopenharmony_ci	local prereq_dir=$2
45f08c3bdfSopenharmony_ci	local compiler_args=$3
46f08c3bdfSopenharmony_ci	shift 3
47f08c3bdfSopenharmony_ci
48f08c3bdfSopenharmony_ci	prereq_cache=$*
49f08c3bdfSopenharmony_ci
50f08c3bdfSopenharmony_ci	test_prefix=$(basename "$prereq_dir")
51f08c3bdfSopenharmony_ci
52f08c3bdfSopenharmony_ci	# special case for speculative testcases
53f08c3bdfSopenharmony_ci	if [ "$test_prefix" = "speculative" ]; then
54f08c3bdfSopenharmony_ci		test_prefix=$(basename $(echo "$prereq_dir" | sed s/speculative//))
55f08c3bdfSopenharmony_ci		test_prefix="${test_prefix}_speculative"
56f08c3bdfSopenharmony_ci	fi
57f08c3bdfSopenharmony_ci
58f08c3bdfSopenharmony_ci	# Add all source files to $make_target_prereq_cache.
59f08c3bdfSopenharmony_ci	for prereq in $prereq_cache; do
60f08c3bdfSopenharmony_ci		# Stuff that needs to be tested.
61f08c3bdfSopenharmony_ci		if echo "$prereq" | grep -Eq '\.(run-test|sh)'; then
62f08c3bdfSopenharmony_ci			if [ "$tests" != "" ]; then
63f08c3bdfSopenharmony_ci				tests="$tests "
64f08c3bdfSopenharmony_ci			fi
65f08c3bdfSopenharmony_ci
66f08c3bdfSopenharmony_ci			tests="$tests${test_prefix}_$prereq"
67f08c3bdfSopenharmony_ci		fi
68f08c3bdfSopenharmony_ci
69f08c3bdfSopenharmony_ci		# Stuff that needs to be compiled.
70f08c3bdfSopenharmony_ci		if echo "$prereq" | grep -Eq '\.(run-test|sh|test)'; then
71f08c3bdfSopenharmony_ci			if [ "$targets" != "" ]; then
72f08c3bdfSopenharmony_ci				targets="$targets "
73f08c3bdfSopenharmony_ci			fi
74f08c3bdfSopenharmony_ci
75f08c3bdfSopenharmony_ci			targets="$targets${test_prefix}_$prereq"
76f08c3bdfSopenharmony_ci		fi
77f08c3bdfSopenharmony_ci
78f08c3bdfSopenharmony_ci		# Cache for generating compile rules.
79f08c3bdfSopenharmony_ci		case "$prereq" in
80f08c3bdfSopenharmony_ci		*.sh)
81f08c3bdfSopenharmony_ci			# Note that the sh scripts are copied later in order to
82f08c3bdfSopenharmony_ci			# have the test_prefix as well
83f08c3bdfSopenharmony_ci			if [ "$make_copy_prereq_cache" != "" ]; then
84f08c3bdfSopenharmony_ci				make_copy_prereq_cache="$make_copy_prereq_cache "
85f08c3bdfSopenharmony_ci			fi
86f08c3bdfSopenharmony_ci			make_copy_prereq_cache="$make_copy_prereq_cache$prereq"
87f08c3bdfSopenharmony_ci			;;
88f08c3bdfSopenharmony_ci		*)
89f08c3bdfSopenharmony_ci			if [ "$make_rule_prereq_cache" != "" ]; then
90f08c3bdfSopenharmony_ci				make_rule_prereq_cache="$make_rule_prereq_cache "
91f08c3bdfSopenharmony_ci			fi
92f08c3bdfSopenharmony_ci			make_rule_prereq_cache="$make_rule_prereq_cache$prereq"
93f08c3bdfSopenharmony_ci			;;
94f08c3bdfSopenharmony_ci		esac
95f08c3bdfSopenharmony_ci	done
96f08c3bdfSopenharmony_ci
97f08c3bdfSopenharmony_ci	if [ ! -f "$makefile.1" ]; then
98f08c3bdfSopenharmony_ci
99f08c3bdfSopenharmony_ci		cat > "$makefile.1" <<EOF
100f08c3bdfSopenharmony_ci#
101f08c3bdfSopenharmony_ci# Automatically generated by `basename "$0"` -- DO NOT EDIT.
102f08c3bdfSopenharmony_ci#
103f08c3bdfSopenharmony_ci# Restrictions for `basename "$0"` apply to this file. See COPYING for
104f08c3bdfSopenharmony_ci# more details.
105f08c3bdfSopenharmony_ci#
106f08c3bdfSopenharmony_ci# $AUTHORDATE
107f08c3bdfSopenharmony_ci#
108f08c3bdfSopenharmony_ci
109f08c3bdfSopenharmony_ci# Path variables.
110f08c3bdfSopenharmony_ciCC := ${COMPILE_PATH}
111f08c3bdfSopenharmony_citop_srcdir?=		`echo "$prereq_dir" | awk '{ gsub(/[^\/]+/, "..", $0); print }'`
112f08c3bdfSopenharmony_cisubdir=			$prereq_cache_dir
113f08c3bdfSopenharmony_cisrcdir=			\$(top_srcdir)/\$(subdir)
114f08c3bdfSopenharmony_ci
115f08c3bdfSopenharmony_ciprefix?=		$PREFIX
116f08c3bdfSopenharmony_ciexec_prefix?=		\$(prefix)
117f08c3bdfSopenharmony_ciINSTALL_DIR=		\$(DESTDIR)/\$(exec_prefix)/\$(subdir)
118f08c3bdfSopenharmony_ciLOGFILE?=		logfile
119f08c3bdfSopenharmony_ci
120f08c3bdfSopenharmony_ci# Build variables
121f08c3bdfSopenharmony_ciCFLAGS+=		-I\$(top_srcdir)/include
122f08c3bdfSopenharmony_ciCFLAGS+=        --target=arm-liteos-ohos --sysroot=${SYSROOT_PATH} ${ARCH_CFLAGS}
123f08c3bdfSopenharmony_ci
124f08c3bdfSopenharmony_ci# XXX: for testfrmw.c -- needs to be moved into a library.
125f08c3bdfSopenharmony_ciCFLAGS+=		-I\$(srcdir)
126f08c3bdfSopenharmony_ci
127f08c3bdfSopenharmony_ciEOF
128f08c3bdfSopenharmony_ci
129f08c3bdfSopenharmony_ci		if [ -f "$GLOBAL_BOILERPLATE" ]; then
130f08c3bdfSopenharmony_ci			cat >> "$makefile.1" <<EOF
131f08c3bdfSopenharmony_ci# Top-level make definitions
132f08c3bdfSopenharmony_ci`cat $GLOBAL_BOILERPLATE`
133f08c3bdfSopenharmony_ciEOF
134f08c3bdfSopenharmony_ci		fi
135f08c3bdfSopenharmony_ci
136f08c3bdfSopenharmony_ci		cat >> "$makefile.1" <<EOF
137f08c3bdfSopenharmony_ci# Submake make definitions.
138f08c3bdfSopenharmony_ciEOF
139f08c3bdfSopenharmony_ci
140f08c3bdfSopenharmony_ci		for var in CFLAGS LDFLAGS LDLIBS; do
141f08c3bdfSopenharmony_ci			if [ -f "${TOP_SRCDIR}/$var" ]; then
142f08c3bdfSopenharmony_ci				cat >> "$makefile.1" <<EOF
143f08c3bdfSopenharmony_ci${var}+=		`cat "${prereq_cache_dir}/${var}" 2>/dev/null`
144f08c3bdfSopenharmony_ciEOF
145f08c3bdfSopenharmony_ci			fi
146f08c3bdfSopenharmony_ci		done
147f08c3bdfSopenharmony_ci
148f08c3bdfSopenharmony_ci		# Whitespace
149f08c3bdfSopenharmony_ci		echo "" >> "$makefile.1"
150f08c3bdfSopenharmony_ci
151f08c3bdfSopenharmony_ci	fi
152f08c3bdfSopenharmony_ci
153f08c3bdfSopenharmony_ci	if [ ! -z "${tests}" ]; then
154f08c3bdfSopenharmony_ci		cat >> "$makefile.2" <<EOF
155f08c3bdfSopenharmony_ciINSTALL_TARGETS+=	${tests}
156f08c3bdfSopenharmony_ciEOF
157f08c3bdfSopenharmony_ci	fi
158f08c3bdfSopenharmony_ci	cat >> "$makefile.2" <<EOF
159f08c3bdfSopenharmony_ciMAKE_TARGETS+=		${targets}
160f08c3bdfSopenharmony_ci
161f08c3bdfSopenharmony_ciifeq (\$V,1)
162f08c3bdfSopenharmony_ciVERBOSE=1
163f08c3bdfSopenharmony_ciendif
164f08c3bdfSopenharmony_ci
165f08c3bdfSopenharmony_ciifndef VERBOSE
166f08c3bdfSopenharmony_civ=@
167f08c3bdfSopenharmony_ciendif
168f08c3bdfSopenharmony_ci
169f08c3bdfSopenharmony_ciEOF
170f08c3bdfSopenharmony_ci
171f08c3bdfSopenharmony_ci	if [ ! -f "$makefile.3" ]; then
172f08c3bdfSopenharmony_ci
173f08c3bdfSopenharmony_ci		cat > "$makefile.3" <<EOF
174f08c3bdfSopenharmony_ciall: \$(MAKE_TARGETS)
175f08c3bdfSopenharmony_ci	@if [ -d speculative ]; then \$(MAKE) -C speculative all; fi
176f08c3bdfSopenharmony_ci
177f08c3bdfSopenharmony_ciclean:
178f08c3bdfSopenharmony_ci	rm -f \$(MAKE_TARGETS) logfile* run.sh *.core
179f08c3bdfSopenharmony_ci	@if [ -d speculative ]; then \$(MAKE) -C speculative clean; fi
180f08c3bdfSopenharmony_ci
181f08c3bdfSopenharmony_ciinstall: \$(INSTALL_DIR) run.sh
182f08c3bdfSopenharmony_ci	set -e; for file in \$(INSTALL_TARGETS) run.sh; do	\\
183f08c3bdfSopenharmony_ci		if [ -f "\$\$file" ] ; then			\\
184f08c3bdfSopenharmony_ci			install -m 00755 \$\$file		\\
185f08c3bdfSopenharmony_ci				\$(INSTALL_DIR)/\$\$file;	\\
186f08c3bdfSopenharmony_ci		fi;						\\
187f08c3bdfSopenharmony_ci	done
188f08c3bdfSopenharmony_ci	@if [ -d speculative ]; then \$(MAKE) -C speculative install; fi
189f08c3bdfSopenharmony_ci
190f08c3bdfSopenharmony_citest: run.sh
191f08c3bdfSopenharmony_ci	\$(v)./run.sh
192f08c3bdfSopenharmony_ci
193f08c3bdfSopenharmony_ci\$(INSTALL_DIR):
194f08c3bdfSopenharmony_ci	mkdir -p \$@
195f08c3bdfSopenharmony_ci
196f08c3bdfSopenharmony_ciEOF
197f08c3bdfSopenharmony_ci
198f08c3bdfSopenharmony_ci	fi
199f08c3bdfSopenharmony_ci
200f08c3bdfSopenharmony_ci	if ! grep -q '^run.sh' "$makefile.3"; then
201f08c3bdfSopenharmony_ci		cat >> "$makefile.3" <<EOF
202f08c3bdfSopenharmony_cirun.sh:
203f08c3bdfSopenharmony_ci	@echo '#!/bin/sh' > \$@
204f08c3bdfSopenharmony_ci	@echo "\$(top_srcdir)/bin/run-tests.sh \$(subdir) \$(INSTALL_TARGETS)" >> \$@
205f08c3bdfSopenharmony_ci	@chmod +x run.sh
206f08c3bdfSopenharmony_ci
207f08c3bdfSopenharmony_ciEOF
208f08c3bdfSopenharmony_ci	fi
209f08c3bdfSopenharmony_ci
210f08c3bdfSopenharmony_ci	# Only pass along libraries to link if `-c` was not specified in `$compiler_args`.
211f08c3bdfSopenharmony_ci	if [ "$compiler_args" = "$buildonly_compiler_args" ]; then
212f08c3bdfSopenharmony_ci		link_libs=false
213f08c3bdfSopenharmony_ci	else
214f08c3bdfSopenharmony_ci		link_libs=true
215f08c3bdfSopenharmony_ci	fi
216f08c3bdfSopenharmony_ci
217f08c3bdfSopenharmony_ci	# Produce _awesome_ target rules for everything that needs it.
218f08c3bdfSopenharmony_ci	for prereq in ${make_rule_prereq_cache}; do
219f08c3bdfSopenharmony_ci
220f08c3bdfSopenharmony_ci		test_name="$prereq"
221f08c3bdfSopenharmony_ci		if [ "$suffix" != "" ]; then
222f08c3bdfSopenharmony_ci			test_name=`echo "$test_name" | sed -e "s,$suffix,,"`
223f08c3bdfSopenharmony_ci		fi
224f08c3bdfSopenharmony_ci
225f08c3bdfSopenharmony_ci		c_file="$test_name.c"
226f08c3bdfSopenharmony_ci		bin_file="${test_prefix}_$prereq"
227f08c3bdfSopenharmony_ci
228f08c3bdfSopenharmony_ci		case "$suffix" in
229f08c3bdfSopenharmony_ci		.run-test)
230f08c3bdfSopenharmony_ci			grep -q 'main' "$prereq_dir/$c_file" || echo >&2 "$prereq_dir/$c_file should be test."
231f08c3bdfSopenharmony_ci			;;
232f08c3bdfSopenharmony_ci		.test)
233f08c3bdfSopenharmony_ci			grep -q 'main' "$prereq_dir/$c_file" && echo >&2 "$prereq_dir/$c_file should be run-test."
234f08c3bdfSopenharmony_ci			;;
235f08c3bdfSopenharmony_ci		esac
236f08c3bdfSopenharmony_ci
237f08c3bdfSopenharmony_ci		COMPILE_STR="\$(CC) $compiler_args \$(CFLAGS) \$(LDFLAGS) -o \$@ \$(srcdir)/$c_file"
238f08c3bdfSopenharmony_ci		if $link_libs; then
239f08c3bdfSopenharmony_ci			COMPILE_STR="$COMPILE_STR \$(LDLIBS)"
240f08c3bdfSopenharmony_ci		fi
241f08c3bdfSopenharmony_ci
242f08c3bdfSopenharmony_ci		cat >> "$makefile.3" <<EOF
243f08c3bdfSopenharmony_ci$bin_file: \$(srcdir)/$c_file
244f08c3bdfSopenharmony_ci	\$(v)if $COMPILE_STR > logfile.\$\$\$\$ 2>&1; then \\
245f08c3bdfSopenharmony_ci		 cat logfile.\$\$\$\$; \\
246f08c3bdfSopenharmony_ci		 echo "\$(subdir)/$test_name compile PASSED"; \\
247f08c3bdfSopenharmony_ci		 echo "\$(subdir)/$test_name compile PASSED" >> \$(LOGFILE); \\
248f08c3bdfSopenharmony_ci	else \\
249f08c3bdfSopenharmony_ci		 cat logfile.\$\$\$\$; \\
250f08c3bdfSopenharmony_ci		 echo "\$(subdir)/$test_name compile FAILED; SKIPPING"; \\
251f08c3bdfSopenharmony_ci		(echo "\$(subdir)/$test_name compile FAILED; SKIPPING"; cat logfile.\$\$\$\$) >> \$(LOGFILE); \\
252f08c3bdfSopenharmony_ci	fi; \\
253f08c3bdfSopenharmony_ci	rm -f logfile.\$\$\$\$
254f08c3bdfSopenharmony_ci
255f08c3bdfSopenharmony_ciEOF
256f08c3bdfSopenharmony_ci	done
257f08c3bdfSopenharmony_ci
258f08c3bdfSopenharmony_ci	# Produce copy rules for .sh scripts.
259f08c3bdfSopenharmony_ci	for prereq in ${make_copy_prereq_cache}; do
260f08c3bdfSopenharmony_ci		src="$prereq"
261f08c3bdfSopenharmony_ci		dst="${test_prefix}_$prereq"
262f08c3bdfSopenharmony_ci
263f08c3bdfSopenharmony_ci		cat >> "$makefile.3" <<EOF
264f08c3bdfSopenharmony_ci$dst: \$(srcdir)/$src
265f08c3bdfSopenharmony_ci	@cp \$(srcdir)/$src \$@
266f08c3bdfSopenharmony_ci
267f08c3bdfSopenharmony_ciEOF
268f08c3bdfSopenharmony_ci	done
269f08c3bdfSopenharmony_ci}
270f08c3bdfSopenharmony_ci
271f08c3bdfSopenharmony_cigenerate_makefiles() {
272f08c3bdfSopenharmony_ci
273f08c3bdfSopenharmony_ci	local prereq_cache=
274f08c3bdfSopenharmony_ci
275f08c3bdfSopenharmony_ci	local make_gen_list=$1
276f08c3bdfSopenharmony_ci	local suffix=$2
277f08c3bdfSopenharmony_ci	local compiler_args="$3"
278f08c3bdfSopenharmony_ci
279f08c3bdfSopenharmony_ci	while read filename; do
280f08c3bdfSopenharmony_ci
281f08c3bdfSopenharmony_ci		prereq_dir=`dirname "$filename"`
282f08c3bdfSopenharmony_ci
283f08c3bdfSopenharmony_ci		# First run.
284f08c3bdfSopenharmony_ci		if [ "$prereq_cache_dir" = "" ] ; then
285f08c3bdfSopenharmony_ci			prereq_cache_dir="$prereq_dir"
286f08c3bdfSopenharmony_ci		elif [ "$prereq_cache_dir" != "$prereq_dir" ]; then
287f08c3bdfSopenharmony_ci
288f08c3bdfSopenharmony_ci			generate_makefile "$prereq_cache_dir/Makefile" "$prereq_cache_dir" "$compiler_args" $prereq_cache
289f08c3bdfSopenharmony_ci
290f08c3bdfSopenharmony_ci			# Prep for the next round..
291f08c3bdfSopenharmony_ci			prereq_cache=
292f08c3bdfSopenharmony_ci			prereq_cache_dir="$prereq_dir"
293f08c3bdfSopenharmony_ci
294f08c3bdfSopenharmony_ci		fi
295f08c3bdfSopenharmony_ci
296f08c3bdfSopenharmony_ci		# Cache the entries to punt out all of the data at
297f08c3bdfSopenharmony_ci		# once for a single Makefile.
298f08c3bdfSopenharmony_ci		if [ "$prereq_cache" != "" ] ; then
299f08c3bdfSopenharmony_ci			prereq_cache="$prereq_cache "
300f08c3bdfSopenharmony_ci		fi
301f08c3bdfSopenharmony_ci		prereq_cache="$prereq_cache"`basename "$filename" | sed "s,.c\$,$suffix,g"`
302f08c3bdfSopenharmony_ci
303f08c3bdfSopenharmony_ci	done < $make_gen_list
304f08c3bdfSopenharmony_ci
305f08c3bdfSopenharmony_ci	# Dump the last Makefile data cached up.
306f08c3bdfSopenharmony_ci	generate_makefile "$prereq_cache_dir/Makefile" $prereq_cache_dir "$compiler_args" $prereq_cache
307f08c3bdfSopenharmony_ci
308f08c3bdfSopenharmony_ci}
309f08c3bdfSopenharmony_ci
310f08c3bdfSopenharmony_ciexport PATH="$PATH:`dirname "$0"`"
311f08c3bdfSopenharmony_ci
312f08c3bdfSopenharmony_ciAUTHORDATE=`grep "Ngie Cooper" "$0" | head -n 1 | sed 's,# *,,'`
313f08c3bdfSopenharmony_ciPREFIX=`print-prefix.sh`
314f08c3bdfSopenharmony_ciEXEC_PREFIX="${PREFIX}/bin"
315f08c3bdfSopenharmony_ciTOP_SRCDIR=${TOP_SRCDIR:=`dirname "$0"`/..}
316f08c3bdfSopenharmony_ci
317f08c3bdfSopenharmony_ciGLOBAL_BOILERPLATE="${TOP_SRCDIR}/.global_boilerplate"
318f08c3bdfSopenharmony_ci
319f08c3bdfSopenharmony_ciCONFIG_MK="../../include/mk/config-openposix.mk"
320f08c3bdfSopenharmony_ciCOMPILE_PATH=$1
321f08c3bdfSopenharmony_ciBUILD_ROOT_PATH=$2
322f08c3bdfSopenharmony_ciSYSROOT_PATH=$3
323f08c3bdfSopenharmony_ciARCH_CFLAGS=$4
324f08c3bdfSopenharmony_ci
325f08c3bdfSopenharmony_cirm -f "$GLOBAL_BOILERPLATE"
326f08c3bdfSopenharmony_ci
327f08c3bdfSopenharmony_cifor var in CFLAGS LDFLAGS LDLIBS; do
328f08c3bdfSopenharmony_ci	if [ -f "$TOP_SRCDIR/$var" ]; then
329f08c3bdfSopenharmony_ci		cat >> "$GLOBAL_BOILERPLATE" <<EOF
330f08c3bdfSopenharmony_ci$var+=		`cat "$TOP_SRCDIR/$var"`
331f08c3bdfSopenharmony_ciEOF
332f08c3bdfSopenharmony_ci	fi
333f08c3bdfSopenharmony_cidone
334f08c3bdfSopenharmony_ci
335f08c3bdfSopenharmony_ciif [ -f "$CONFIG_MK" ]; then
336f08c3bdfSopenharmony_ci	cat "$CONFIG_MK" >> "$GLOBAL_BOILERPLATE"
337f08c3bdfSopenharmony_cifi
338f08c3bdfSopenharmony_ci
339f08c3bdfSopenharmony_ci# For the generic cases.
340f08c3bdfSopenharmony_cigenerate_locate_test_makefile buildonly '.test' "$buildonly_compiler_args"
341f08c3bdfSopenharmony_cigenerate_locate_test_makefile runnable '.run-test'
342f08c3bdfSopenharmony_cigenerate_locate_test_makefile test-tools ''
343f08c3bdfSopenharmony_ci
344f08c3bdfSopenharmony_cirm -f "$GLOBAL_BOILERPLATE"
345f08c3bdfSopenharmony_ci
346f08c3bdfSopenharmony_cifind . -name Makefile.1 -exec dirname {} \; | while read dir; do
347f08c3bdfSopenharmony_ci	if [ -f "$dir/Makefile.2" ]; then
348f08c3bdfSopenharmony_ci		cat $dir/Makefile.1 $dir/Makefile.2 $dir/Makefile.3 > $dir/Makefile
349f08c3bdfSopenharmony_ci	fi
350f08c3bdfSopenharmony_ci	rm $dir/Makefile.1 $dir/Makefile.2 $dir/Makefile.3
351f08c3bdfSopenharmony_cidone
352