AC_MSG_RESULT(no))
fi
])dnl
+
+## AC_BZ_SET_COMPILER: Addition by Theodore Papadopoulo
+## Patch by Jim McKelvey: change sed -e 's/ /@/g' to sed -e 's/ /@/'
+AC_DEFUN(AC_SG_SET_COMPILER,
+ [cxxwith=`echo $1 | sed -e 's/ /@/'`
+ case "$cxxwith" in
+ *:*@*) # Full initialization syntax
+ CXX=`echo "$cxxwith" | sed -n -e 's/.*:\(.*\)@.*/\1/p'`
+ CXXFLAGS=`echo "$cxxwith" | sed -n -e 's/.*:.*@\(.*\)/\1/p'`
+ ;;
+ *:*) # Simple initialization syntax
+ CXX=`echo "$cxxwith" | sed -n -e 's/.*:\(.*\)/\1/p'`
+ CXXFLAGS=$3
+ ;;
+ *) # Default values
+ CXX=$2
+ CXXFLAGS=$3
+ CC="$2 --c"
+## CFLAGS=
+ ;;
+ esac])
dnl Initialize the automake stuff
AM_INIT_AUTOMAKE(SimGear, 0.0.14)
+dnl Specify KAI C++ compiler and flags.
+dnl Borrowed with slight modification from blitz distribution.
+AC_ARG_WITH(cxx,
+ [ --with-cxx=COMPILER[:name-flags] set options for COMPILER (KCC)],
+ [case "$withval" in
+ KCC*) # KAI C++ http://www.kai.com/
+ echo "Configuring for KAI C++"
+ AC_SG_SET_COMPILER($withval,"KCC","--restrict --strict_warnings")
+ CXX_OPTIMIZE_FLAGS=="+K3 -O3"
+ CXX_DEBUG_FLAGS="-g +K0"
+ ;;
+ esac
+])
+
+echo CXX = $CXX
+echo CC = $CC
+
dnl Checks for programs.
AC_PROG_MAKE_SET
AC_PROG_CC
# endif
#endif
+/* KAI C++ */
+#if defined(__KCC)
+
+# define FG_NAMESPACES
+# define FG_HAVE_STD
+# define FG_HAVE_STREAMBUF
+# define FG_HAVE_TRAITS
+# define FG_HAVE_STD_INCLUDES
+
+# define STL_ALGORITHM <algorithm>
+# define STL_FUNCTIONAL <functional>
+# define STL_IOMANIP <iomanip>
+# define STL_IOSTREAM <iostream>
+# define STL_FSTREAM <fstream>
+# define STL_STDEXCEPT <stdexcept>
+# define STL_STRING <string>
+# define STL_STRSTREAM <strstream>
+#endif
+
//
// Metrowerks
//
bool SGFile::open( SGProtocolDir dir ) {
if ( dir == SG_IO_OUT ) {
#ifdef _MSC_VER
- fp = _open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC,
- 00666 );
+ int mode = 00666;
#else
- fp = std::open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP |
- S_IROTH | S_IWOTH );
+ mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
#endif
+ fp = ::open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC, mode );
} else if ( dir == SG_IO_IN ) {
-#ifdef _MSC_VER
- fp = _open( file_name.c_str(), O_RDONLY );
-#else
- fp = std::open( file_name.c_str(), O_RDONLY );
-#endif
+ fp = ::open( file_name.c_str(), O_RDONLY );
} else {
FG_LOG( FG_IO, FG_ALERT,
"Error: bidirection mode not available for files." );
// read a block of data of specified size
int SGFile::read( char *buf, int length ) {
// read a chunk
-#ifdef _MSC_VER
- int result = _read( fp, buf, length );
-#else
- int result = std::read( fp, buf, length );
-#endif
-
- return result;
+ return ::read( fp, buf, length );
}
int pos = lseek( fp, 0, SEEK_CUR );
// read a chunk
-#ifdef _MSC_VER
- int result = _read( fp, buf, length );
-#else
- int result = std::read( fp, buf, length );
-#endif
+ int result = ::read( fp, buf, length );
// find the end of line and reset position
int i;
// write data to a file
int SGFile::write( char *buf, int length ) {
-#ifdef _MSC_VER
- int result = _write( fp, buf, length );
-#else
- int result = std::write( fp, buf, length );
-#endif
+ int result = ::write( fp, buf, length );
if ( result != length ) {
FG_LOG( FG_IO, FG_ALERT, "Error writing data: " << file_name );
}
// close the port
bool SGFile::close() {
-#ifdef _MSC_VER
- if ( _close( fp ) == -1 ) {
-#else
- if ( std::close( fp ) == -1 ) {
-#endif
+ if ( ::close( fp ) == -1 ) {
return false;
}