#!/bin/sh


if [ "x$TAU_CCOM" = "x" ] 
then
  export TAU_CCOM=cc
fi

if [ `uname -s ` = "Darwin" ] 
then
  export TAU_CCOM=c++
fi

echo "/* trace_impl.h  Generated by TAU */"
echo
echo "/* Define to 1 if you have the <dlfcn.h> header file. */"
cat <<EOF > tau$$.c
#include <dlfcn.h>

int foo(void)
{ 
  return 0;
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define HAVE_DLFCN_H 1"
else
  echo "/* #undef HAVE_DLFCN_H */"
fi
/bin/rm -f tau$$.c


echo
echo "/* Define to 1 if you have the <inttypes.h> header file. */"
cat <<EOF > tau$$.c
#include <inttypes.h>

int foo(void)
{ 
  return 0;
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define HAVE_INTTYPES_H 1"
else
  echo "/* #undef HAVE_INTTYPES_H */"
fi
/bin/rm -f tau$$.c

echo
echo "/* Define if <jni.h> is found */"

if [ -r $1/include/jni.h ]
then 
  echo "#define HAVE_JNI_H 1"
else
  echo "/* #undef HAVE JNI_H */"
fi

echo
echo "/* Define to 1 if you have the <memory.h> header file. */"
cat <<EOF > tau$$.c
#include <memory.h>

int foo(void)
{ 
  return 0;
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define HAVE_MEMORY_H 1"
else
  echo "/* #undef HAVE_MEMORY_H */"
fi
/bin/rm -f tau$$.c


echo
echo "/* Define to 1 if you have the <stdint.h> header file. */"
cat <<EOF > tau$$.c
#include <stdint.h>

int foo(void)
{ 
  return 0;
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define HAVE_STDINT_H 1"
else
  echo "/* #undef HAVE_STDINT_H */"
fi
/bin/rm -f tau$$.c


echo
echo "/* Define to 1 if you have the <stdio.h> header file. */"
cat <<EOF > tau$$.c
#include <stdio.h>

int foo(void)
{ 
  return 0;
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define HAVE_STDIO_H 1"
else
  echo "/* #undef HAVE_STDIO_H */"
fi
/bin/rm -f tau$$.c


echo
echo "/* Define to 1 if you have the <stdlib.h> header file. */"
cat <<EOF > tau$$.c
#include <stdlib.h>

int foo(void)
{ 
  return 0;
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define HAVE_STDLIB_H 1"
else
  echo "/* #undef HAVE_STDLIB_H */"
fi
/bin/rm -f tau$$.c


echo
echo "/* Define to 1 if you have the <strings.h> header file. */"
cat <<EOF > tau$$.c
#include <strings.h>

int foo(void)
{ 
  return 0;
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define HAVE_STRINGS_H 1"
else
  echo "/* #undef HAVE_STRINGS_H */"
fi
/bin/rm -f tau$$.c


echo
echo "/* Define to 1 if you have the <string.h> header file. */"
cat <<EOF > tau$$.c
#include <string.h>

int foo(void)
{ 
  return 0;
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define HAVE_STRING_H 1"
else
  echo "/* #undef HAVE_STRING_H */"
fi
/bin/rm -f tau$$.c


echo
echo "/* Define to 1 if you have the strstr function. */"
cat <<EOF > tau$$.c
#include <string.h>

int foo(void)
{ 
  char str[] ="This is a simple string";
  char * pch;
  pch = strstr (str,"simple");
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define HAVE_STRSTR 1"
else
  echo "/* #undef HAVE_STRSTR */"
fi
/bin/rm -f tau$$.c


echo
echo "/* Define to 1 if you have the <sys/stat.h> header file. */"
cat <<EOF > tau$$.c
#include <sys/stat.h>

int foo(void)
{ 
  return 0;
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define HAVE_SYS_STAT_H 1"
else
  echo "/* #undef HAVE_SYS_STAT_H */"
fi
/bin/rm -f tau$$.c


echo
echo "/* Define to 1 if you have the <sys/types.h> header file. */"
cat <<EOF > tau$$.c
#include <sys/types.h>

int foo(void)
{ 
  return 0;
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define HAVE_SYS_TYPES_H 1"
else
  echo "/* #undef HAVE_SYS_TYPES_H */"
fi
/bin/rm -f tau$$.c


echo
echo "/* Define to 1 if you have the <unistd.h> header file. */"
cat <<EOF > tau$$.c
#include <unistd.h>

int foo(void)
{ 
  return 0;
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define HAVE_UNISTD_H 1"
else
  echo "/* #undef HAVE_UNISTD_H */"
fi
/bin/rm -f tau$$.c

echo


cat <<EOF > tau$$.c
#include <stdio.h>

int main(void)
{

	printf("/* Define to the address where bug reports for this package should be sent. */\n");
	printf("#define PACKAGE_BUGREPORT \042\042\n\n");

	printf("/* Define to the full name of this package. */\n");
	printf("#define PACKAGE_NAME \042\042\n\n");
        
	printf("/* Define to the full name and version of this package. */\n");
	printf("#define PACKAGE_STRING \042\042\n\n");

	printf("/* Define to the one symbol short name of this package. */\n");
	printf("#define PACKAGE_TARNAME \042\042\n\n");

	printf("/* Define to the version of this package. */\n");
	printf("#define PACKAGE_VERSION \042\042\n\n");

	return 0;
}
EOF
$TAU_CCOM -o a.out tau$$.c
./a.out
/bin/rm -f tau$$.c
/bin/rm -f a.out  


cat <<EOF > mk
include include/Makefile

a.out :
	\$(TAU_CC) \$(USER_OPT) -o a.out tau$$.c
EOF


cat <<EOF > tau$$.c
#include <stdio.h>

int main(void)
{
	printf("/* The size of a \`int\', as computed by sizeof. */\n");
	printf("#define SIZEOF_INT %d\n\n", sizeof(int));

	printf("/* The size of a \`long\', as computed by sizeof. */\n");
	printf("#define SIZEOF_LONG %d\n\n",sizeof(long));

        printf("/* The size of a \`long long\', as computed by sizeof. */\n");
        printf("#define SIZEOF_LONG_LONG %d\n\n",sizeof(long long));

        printf("/* The size of a \`void*\', as computed by sizeof. */\n");
        printf("#define SIZEOF_VOIDP %d\n\n",sizeof(void*));

	return 0;
}
EOF
make -f mk > /dev/null
#$TAU_CCOM tau$$.c
./a.out
/bin/rm -f tau$$.c
/bin/rm -f a.out
/bin/rm -f mk

cat <<EOF > tau$$.c  
#include <stdio.h>
int main(void)
{
        printf("/* The size of a \`__int64\', as computed by sizeof. */\n");
        printf("#define SIZEOF___INT64 %d\n\n",sizeof(__int64));
 
        return 0;
}
EOF
if $TAU_CCOM -o a.out tau$$.c > /dev/null 2>&1
then
	./a.out
	/bin/rm -f a.out
else
        echo "/* The size of a __int64, as computed by sizeof. */"
        echo "#define SIZEOF___INT64 0"
fi
/bin/rm -f tau$$.c

echo
echo "/* Define to 1 if you have the ANSI C header files. */"

cat <<EOF > tau$$.c
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int foo(void)
{ 
  return 0;
}
EOF
if  $TAU_CCOM -c tau$$.c > /dev/null 2>&1  
then 
  echo "#define STDC_HEADERS 1"
else
  echo "/* #undef STDC_HEADERS */"
fi

/bin/rm -f tau$$.c

echo
echo "/* Define to 1 if your processor stores words with the most significant byte"
echo "   first (like Motorola and SPARC, unlike Intel and VAX). */"


cat <<EOF > tau$$.c
#include <stdio.h>

int main(void)
{
	unsigned char SwapTest[2] = { 1, 0 };
  
	if( *(short *) SwapTest == 1 )
	{
    /* little endian */
		/* BigEndianSystem = false; */
		printf("/* #undef WORDS_BIGENDIAN */\n\n");
	}
	else
	{
    /* big endian */
		/* BigEndianSystem = true; */
		printf("#define WORDS_BIGENDIAN 1\n\n");
	}
}
EOF
$TAU_CCOM -o a.out tau$$.c
./a.out
/bin/rm -f tau$$.c
/bin/rm -f a.out
/bin/rm -f tau$$.o
/bin/rm -f t2.o


echo "/* Define to empty if const does not conform to ANSI C. */"
echo "/* #undef const */"
echo " "
