2019-08-17 19:35:52 +00:00
|
|
|
IN="$1"
|
|
|
|
OUT="$2"
|
2014-09-24 23:47:49 +00:00
|
|
|
|
2014-09-25 20:50:22 +00:00
|
|
|
# Make Mac OS X's tr and sed not complain that the files are not UTF-8
|
2019-03-19 17:05:08 +00:00
|
|
|
export LC_ALL=C
|
2014-09-25 20:50:22 +00:00
|
|
|
|
2019-08-17 19:35:52 +00:00
|
|
|
for file in $(cd "$IN"; ls *.h); do
|
2019-08-18 11:21:00 +00:00
|
|
|
# Filter by file names.
|
|
|
|
# Some CIncludes packages include the MPW standard library.
|
|
|
|
# Header files from that standard library would overwrite
|
|
|
|
# newlib header files and stop things from working.
|
|
|
|
case $file in
|
|
|
|
# Apple/MPW standard library internals
|
|
|
|
*Def.h|FSpio.h)
|
|
|
|
USE=false
|
|
|
|
;;
|
|
|
|
|
|
|
|
# whitelist all uppercase headers
|
|
|
|
[A-Z]*.h)
|
|
|
|
USE=true
|
|
|
|
;;
|
|
|
|
|
|
|
|
# whitelist OpenTransport
|
|
|
|
cred.h|dlpi.h|miioccom.h|mistream.h|modnames.h)
|
|
|
|
USE=true
|
|
|
|
;;
|
|
|
|
# whitelist OpenTransport (continued)
|
|
|
|
strlog.h|stropts.h|strstat.h|tihdr.h)
|
|
|
|
USE=true
|
|
|
|
;;
|
|
|
|
|
|
|
|
# Non-standard floating point headers that don't conflict
|
|
|
|
ddrt.h|fp.h)
|
|
|
|
USE=true
|
|
|
|
;;
|
|
|
|
# newlib does not provide fenv.h, so use Apple's
|
|
|
|
fenv.h)
|
|
|
|
USE=true
|
|
|
|
;;
|
|
|
|
|
|
|
|
# veclib headers
|
|
|
|
v*.h)
|
|
|
|
USE=true
|
|
|
|
;;
|
|
|
|
|
|
|
|
# unsupported: intrinsics.h perf.h
|
|
|
|
|
|
|
|
# all other (lowercase) headers: conflict with GCC or newlib headers
|
|
|
|
*)
|
|
|
|
USE=false
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ $USE = true ]; then
|
|
|
|
sed 's/\r$//' < "$IN/$file" | tr '\r' '\n' > "$OUT/$file"
|
|
|
|
fi
|
2014-09-24 23:47:49 +00:00
|
|
|
done
|
|
|
|
|
2015-09-12 22:42:07 +00:00
|
|
|
############################# ConditionalMacros.h #############################
|
2019-08-17 19:35:52 +00:00
|
|
|
cat > "$OUT/ConditionalMacros.h" <<END_MARKER
|
2014-09-24 23:47:49 +00:00
|
|
|
|
|
|
|
#ifndef __CONDITIONALMACROS__WRAP__
|
|
|
|
#define __CONDITIONALMACROS__WRAP__
|
|
|
|
|
2015-08-30 23:17:52 +00:00
|
|
|
#if #cpu(powerpc)
|
|
|
|
#define TARGET_CPU_PPC 1
|
|
|
|
#define TARGET_OS_MAC 1
|
|
|
|
#define TARGET_RT_MAC_CFM 1
|
|
|
|
#define TARGET_RT_MAC_MACHO 0
|
|
|
|
#else
|
2014-09-24 23:47:49 +00:00
|
|
|
#define TARGET_CPU_68K 1
|
|
|
|
#define TARGET_OS_MAC 1
|
|
|
|
#define TARGET_RT_MAC_CFM 0
|
|
|
|
#define TARGET_RT_MAC_MACHO 0
|
2015-08-30 23:17:52 +00:00
|
|
|
#endif
|
|
|
|
|
2015-09-08 16:01:57 +00:00
|
|
|
#define PRAGMA_STRUCT_PACKPUSH 1
|
2014-09-24 23:47:49 +00:00
|
|
|
#define FUNCTION_PASCAL 1
|
2015-08-30 23:17:52 +00:00
|
|
|
#define TYPE_LONGLONG 1
|
2014-09-24 23:47:49 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#define TYPE_BOOL 1
|
|
|
|
#endif
|
2016-07-08 00:08:33 +00:00
|
|
|
|
|
|
|
#define __DEBUGGING__ /* HACK: Disable Debugging.h because its vdprintf conflicts with stdio.h */
|
2014-09-24 23:47:49 +00:00
|
|
|
END_MARKER
|
|
|
|
|
2019-08-17 19:35:52 +00:00
|
|
|
sed 's/\r$//' < "$IN/ConditionalMacros.h" | tr '\r' '\n' | sed 's/__GNUC__/__GNUC_DISABLED__/g' >> "$OUT/ConditionalMacros.h"
|
2014-09-24 23:47:49 +00:00
|
|
|
|
2019-08-17 19:35:52 +00:00
|
|
|
cat >> "$OUT/ConditionalMacros.h" <<END_MARKER
|
2014-09-24 23:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* __CONDITIONALMACROS__WRAP__ */
|
|
|
|
END_MARKER
|
|
|
|
|
2015-09-12 22:42:07 +00:00
|
|
|
############################# fp.h #############################
|
2019-08-17 19:35:52 +00:00
|
|
|
if [ -r "$IN/fp.h" ]; then
|
2015-09-12 22:42:07 +00:00
|
|
|
|
2019-08-17 19:35:52 +00:00
|
|
|
cat > "$OUT/fp.h" <<END_MARKER
|
2015-09-12 22:42:07 +00:00
|
|
|
|
|
|
|
#ifndef __FP__WRAP__
|
|
|
|
#define __FP__WRAP__
|
|
|
|
|
|
|
|
#include "math.h"
|
|
|
|
|
|
|
|
#pragma push_macro("__MWERKS__")
|
|
|
|
#define __MWERKS__ 0x6666
|
|
|
|
#define __cmath__
|
|
|
|
|
|
|
|
short relation(double x, double y);
|
|
|
|
|
|
|
|
END_MARKER
|
|
|
|
|
2016-07-08 00:08:33 +00:00
|
|
|
sed 's/\r$//' < $IN/fp.h | tr '\r' '\n' >> $OUT/fp.h
|
2015-09-12 22:42:07 +00:00
|
|
|
|
|
|
|
cat >> $OUT/fp.h <<END_MARKER
|
|
|
|
|
|
|
|
#pragma pop_macro("__MWERKS__")
|
|
|
|
#undef __cmath__
|
|
|
|
|
|
|
|
#endif /* __FP__WRAP__ */
|
|
|
|
END_MARKER
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
############################# MixedMode.h #############################
|
2019-08-17 19:35:52 +00:00
|
|
|
sed 's/\r$//' < "$IN/MixedMode.h" | tr '\r' '\n' | sed 's/Opaque\#\#name\#\#\*/Opaque\#\#name \*/g' > "$OUT/MixedMode.h"
|
2015-09-12 22:42:07 +00:00
|
|
|
|
|
|
|
############################# CGBase.h #############################
|
2019-08-17 19:35:52 +00:00
|
|
|
if [ -r "$IN/CGBase.h" ]; then
|
|
|
|
cat > "$OUT/CGBase.h" <<END_MARKER
|
2015-09-12 22:42:07 +00:00
|
|
|
|
|
|
|
#ifndef __CGBASE__WRAP__
|
|
|
|
#define __CGBASE__WRAP__
|
|
|
|
|
2017-10-07 14:09:00 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <sys/types.h>
|
2015-09-12 22:42:07 +00:00
|
|
|
|
|
|
|
/* CGBase contains a hardcoded #ifdef that decides that stdint.h is available in MWERKS > 0x2300.
|
|
|
|
... otherwise, it contains an incompatible redefinition. */
|
|
|
|
#pragma push_macro("__MWERKS__")
|
|
|
|
#define __MWERKS__ 0x6666
|
|
|
|
|
2017-10-07 14:09:00 +00:00
|
|
|
#define u_int32_t __cgbase_incompatible_u_int32_t
|
|
|
|
|
2015-09-12 22:42:07 +00:00
|
|
|
END_MARKER
|
|
|
|
|
2019-08-17 19:35:52 +00:00
|
|
|
sed 's/\r$//' < "$IN/CGBase.h" | tr '\r' '\n' >> "$OUT/CGBase.h"
|
2015-09-12 22:42:07 +00:00
|
|
|
|
2019-08-17 19:35:52 +00:00
|
|
|
cat >> "$OUT/CGBase.h" <<END_MARKER
|
2015-09-12 22:42:07 +00:00
|
|
|
|
2017-10-07 14:09:00 +00:00
|
|
|
#undef u_int32_t __cgbase_incompatible_u_int32_t
|
|
|
|
|
2015-09-12 22:42:07 +00:00
|
|
|
#pragma pop_macro("__MWERKS__")
|
|
|
|
|
|
|
|
#endif /* __CGBASE__WRAP__ */
|
|
|
|
END_MARKER
|
|
|
|
|
|
|
|
fi
|
2016-07-08 00:08:33 +00:00
|
|
|
|
|
|
|
for f in Types.h Memory.h Windows.h Errors.h; do
|
2019-08-18 11:21:00 +00:00
|
|
|
if [ ! -r "$IN/$f" ]; then
|
|
|
|
echo "#include \"Mac$f\"" > "$OUT/$f"
|
|
|
|
elif [ ! -r "$IN/Mac$f" ]; then
|
|
|
|
echo "#include \"$f\"" > "$OUT/Mac$f"
|
|
|
|
fi
|
2016-07-08 00:08:33 +00:00
|
|
|
done
|
|
|
|
|
2019-08-17 19:35:52 +00:00
|
|
|
if [ -d "$IN/CoreFoundation" ]; then
|
2019-08-18 11:21:00 +00:00
|
|
|
mkdir -p "$OUT/CoreFoundation"
|
|
|
|
for file in $(cd "$IN"; ls CoreFoundation/*.h); do
|
|
|
|
sed 's/\r$//' < "$IN/$file" | tr '\r' '\n' > "$OUT/$file"
|
|
|
|
done
|
2016-07-08 00:08:33 +00:00
|
|
|
fi
|