diff --git a/fpc/library/target.cpp b/fpc/library/target.cpp index c82defc..474281d 100644 --- a/fpc/library/target.cpp +++ b/fpc/library/target.cpp @@ -1,7 +1,14 @@ #include "target.h" #include "tier0/commandline.h" #include "tier1/utlstring.h" - +#include "sys/utsname.h" + +// see Target_t::HostTarget +#if defined(__i386__) && defined(POSIX) +static utsname s_uname; +static int s_iuNameRes = uname(&s_uname); +#endif + //----------------------------------------------------------------------------- // Generates triplet suitable for most compilers. //----------------------------------------------------------------------------- @@ -112,6 +119,8 @@ const char *Target_t::GetDynamicLibraryFileFormat() } //---------------------------------------------------------------------------- // Returns target on which fpc is being run +// +// For targets such as i386, i486, i586 //---------------------------------------------------------------------------- Target_t Target_t::HostTarget() { @@ -136,17 +145,19 @@ ETargetCPU cpu = #endif #if defined(__i386__) TARGET_CPU_80386 -#endif -#if defined(__i486__) - TARGET_CPU_80486 -#endif -#if defined(__i586__) - TARGET_CPU_80586 -#endif -#if defined(__i686__) - TARGET_CPU_80686 #endif ; +// POSIX doesn't know about these +// use uname to get them +#if defined(__i386__) && defined(POSIX) + if (!V_strcmp("i486", s_uname.machine)) + cpu = TARGET_CPU_80486; + if (!V_strcmp("i586", s_uname.machine)) + cpu = TARGET_CPU_80486; + if (!V_strcmp("i686", s_uname.machine)) + cpu = TARGET_CPU_80486; +#endif + return { .kernel = kernel, .cpu = cpu,