1#!/bin/sh
2cwd=`pwd`
3dir=`basename ${cwd}`
4#
5# When compiling a file that goes into libunwind, we only
6# need to compile it when we really do support UNW_LOCAL_ONLY.
7# In contrast, libunwind-tests should always get compiled.
8#
9if test $dir = "tests"; then
10  local_only_test=""
11else
12  local_only_test="defined(UNW_LOCAL_ONLY) && "
13fi
14for gname in `ls G*.c G*.cxx G*.S 2>/dev/null`; do
15	lname="L$(expr $gname : '.\(.*\)')"
16	bk edit $lname >/dev/null 2>&1
17	ext=$(expr $gname : '[^.]*[.]\(.*\)')
18	if [ "$ext" = "S" ]; then
19	    include=""
20	else
21	    include="#include <libunwind.h>"
22	fi
23	echo -e "\
24#define UNW_LOCAL_ONLY\n\
25$include\n\
26#if ${local_only_test}!defined(UNW_REMOTE_ONLY)\n\
27#include \"$gname\"\n\
28#endif" > $lname
29	echo created $lname
30done
31