VirtualBox

Changeset 2451 in kBuild


Ignore:
Timestamp:
Jul 7, 2011 7:29:02 PM (14 years ago)
Author:
bird
Message:

kmk: Adding host version variables: KBUILD_HOST_VERSION, KBUILD_HOST_VERSION_MAJOR, KBUILD_HOST_VERSION_MINOR and KBUILD_HOST_VERSION_PATCH. KBUILD_HOST_VERSION is four numbers separated by dots, the other are unsigned integer numbers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/variable.c

    r2172 r2451  
    3333#ifdef KMK
    3434# include "kbuild.h"
     35# ifdef WINDOWS32
     36#  include <Windows.h>
     37# else
     38#  include <sys/utsname.h>
     39# endif
    3540#endif
    3641#ifdef CONFIG_WITH_STRCACHE2
     
    10821087
    10831088
     1089#if defined(KMK) && !defined(WINDOWS32)
     1090/* Parses out the next number from the uname release level string.  Fast
     1091   forwards to the end of the string when encountering some non-conforming
     1092   chars. */
     1093 
     1094static unsigned long parse_release_number (const char **ppsz)
     1095{
     1096  unsigned long ul;
     1097  char *psz = (char *)*ppsz;
     1098  if (ISDIGIT (*psz))
     1099  {
     1100      ul = strtoul (psz, &psz, 10);
     1101      if (psz != NULL && *psz == '.')
     1102          psz++;
     1103      else
     1104          psz = strchr (*ppsz, '\0');
     1105      *ppsz = psz;
     1106  }
     1107  else
     1108      ul = 0;
     1109  return ul;
     1110}
     1111#endif
     1112
     1113
    10841114/* Define the automatic variables, and record the addresses
    10851115   of their structures so we can change their values quickly.  */
     
    11011131  struct variable *envvar1;
    11021132  struct variable *envvar2;
     1133# ifdef WINDOWS32
     1134  OSVERSIONINFOEX vix;
     1135# else
     1136  struct utsname uts;
     1137# endif
     1138  unsigned long ulMajor = 0, ulMinor = 0, ulPatch = 0, ul4th = 0;
    11031139#endif
    11041140
     
    11741210    define_variable ("BUILD_PLATFORM_CPU", sizeof ("BUILD_PLATFORM_CPU") - 1,
    11751211                     val, o_default, 0);
     1212
     1213  /* The host kernel version. */
     1214#if defined(WINDOWS32)
     1215  memset (&oix, sizeof (oix));
     1216  oix.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
     1217  if (!GetVersionEx ((LPOSVERSIONINFO)&oix))
     1218    {
     1219      memset (&oix, '\0', sizeof (oix));
     1220      oix.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
     1221      GetVersionEx ((LPOSVERSIONINFO)&oix);
     1222    }
     1223  if (oix.dwPlatformId == VER_PLATFORM_WIN32_NT)
     1224    {
     1225      ulMajor = oix.dwMajorVersion;
     1226      ulMinor = oix.dwMinorVersion;
     1227      ulPatch = oix.wServicePackMajor;
     1228      ul4th   = oix.wServicePackMinor;
     1229    }
     1230  else
     1231    {
     1232      ulMajor = oix.dwPlatformId == 1 ? 0 /*Win95/98/ME*/
     1233              ? oix.dwPlatformId == 3 ? 1 /*WinCE*/
     1234              : 2; /*??*/
     1235      ulMinor = oix.dwMajorVersion;
     1236      ulPatch = oix.dwMinorVersion;
     1237      ul4th   = oix.WservicePackMajor;
     1238    }
     1239#else
     1240  memset (&uts, 0, sizeof(uts));
     1241  uname (&uts);
     1242  val = uts.release;
     1243  ulMajor = parse_release_number (&val);
     1244  ulMinor = parse_release_number (&val);
     1245  ulPatch = parse_release_number (&val);
     1246  ul4th   = parse_release_number (&val);
     1247#endif
     1248
     1249  sprintf (buf, "%lu.%lu.%lu.%lu", ulMajor, ulMinor, ulPatch, ul4th);
     1250  define_variable ("KBUILD_HOST_VERSION", sizeof ("KBUILD_HOST_VERSION") - 1,
     1251                   buf, o_default, 0);
     1252
     1253  sprintf (buf, "%lu", ulMajor);
     1254  define_variable ("KBUILD_HOST_VERSION_MAJOR", sizeof ("KBUILD_HOST_VERSION_MAJOR") - 1,
     1255                   buf, o_default, 0);
     1256
     1257  sprintf (buf, "%lu", ulMinor);
     1258  define_variable ("KBUILD_HOST_VERSION_MINOR", sizeof ("KBUILD_HOST_VERSION_MINOR") - 1,
     1259                   buf, o_default, 0);
     1260
     1261  sprintf (buf, "%lu", ulPatch);
     1262  define_variable ("KBUILD_HOST_VERSION_PATCH", sizeof ("KBUILD_HOST_VERSION_PATCH") - 1,
     1263                   buf, o_default, 0);
    11761264
    11771265  /* The kBuild locations. */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette