summaryrefslogtreecommitdiff
path: root/src/kmk/variable.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kmk/variable.c')
-rw-r--r--src/kmk/variable.c101
1 files changed, 99 insertions, 2 deletions
diff --git a/src/kmk/variable.c b/src/kmk/variable.c
index ffa0a25..02dca60 100644
--- a/src/kmk/variable.c
+++ b/src/kmk/variable.c
@@ -32,6 +32,11 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "hash.h"
#ifdef KMK
# include "kbuild.h"
+# ifdef WINDOWS32
+# include <Windows.h>
+# else
+# include <sys/utsname.h>
+# endif
#endif
#ifdef CONFIG_WITH_STRCACHE2
# include <stddef.h>
@@ -1072,6 +1077,30 @@ merge_variable_set_lists (struct variable_set_list **setlist0,
}
}
+#if defined(KMK) && !defined(WINDOWS32)
+/* Parses out the next number from the uname release level string. Fast
+ forwards to the end of the string when encountering some non-conforming
+ chars. */
+
+static unsigned long parse_release_number (const char **ppsz)
+{
+ unsigned long ul;
+ char *psz = (char *)*ppsz;
+ if (ISDIGIT (*psz))
+ {
+ ul = strtoul (psz, &psz, 10);
+ if (psz != NULL && *psz == '.')
+ psz++;
+ else
+ psz = strchr (*ppsz, '\0');
+ *ppsz = psz;
+ }
+ else
+ ul = 0;
+ return ul;
+}
+#endif
+
/* Define the automatic variables, and record the addresses
of their structures so we can change their values quickly. */
@@ -1091,6 +1120,12 @@ define_automatic_variables (void)
const char *val;
struct variable *envvar1;
struct variable *envvar2;
+# ifdef WINDOWS32
+ OSVERSIONINFOEX oix;
+# else
+ struct utsname uts;
+# endif
+ unsigned long ulMajor = 0, ulMinor = 0, ulPatch = 0, ul4th = 0;
#endif
sprintf (buf, "%u", makelevel);
@@ -1165,6 +1200,58 @@ define_automatic_variables (void)
define_variable ("BUILD_PLATFORM_CPU", sizeof ("BUILD_PLATFORM_CPU") - 1,
val, o_default, 0);
+ /* The host kernel version. */
+#if defined(WINDOWS32)
+ memset (&oix, '\0', sizeof (oix));
+ oix.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ if (!GetVersionEx ((LPOSVERSIONINFO)&oix))
+ {
+ memset (&oix, '\0', sizeof (oix));
+ oix.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+ GetVersionEx ((LPOSVERSIONINFO)&oix);
+ }
+ if (oix.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ {
+ ulMajor = oix.dwMajorVersion;
+ ulMinor = oix.dwMinorVersion;
+ ulPatch = oix.wServicePackMajor;
+ ul4th = oix.wServicePackMinor;
+ }
+ else
+ {
+ ulMajor = oix.dwPlatformId == 1 ? 0 /*Win95/98/ME*/
+ : oix.dwPlatformId == 3 ? 1 /*WinCE*/
+ : 2; /*??*/
+ ulMinor = oix.dwMajorVersion;
+ ulPatch = oix.dwMinorVersion;
+ ul4th = oix.wServicePackMajor;
+ }
+#else
+ memset (&uts, 0, sizeof(uts));
+ uname (&uts);
+ val = uts.release;
+ ulMajor = parse_release_number (&val);
+ ulMinor = parse_release_number (&val);
+ ulPatch = parse_release_number (&val);
+ ul4th = parse_release_number (&val);
+#endif
+
+ sprintf (buf, "%lu.%lu.%lu.%lu", ulMajor, ulMinor, ulPatch, ul4th);
+ define_variable ("KBUILD_HOST_VERSION", sizeof ("KBUILD_HOST_VERSION") - 1,
+ buf, o_default, 0);
+
+ sprintf (buf, "%lu", ulMajor);
+ define_variable ("KBUILD_HOST_VERSION_MAJOR", sizeof ("KBUILD_HOST_VERSION_MAJOR") - 1,
+ buf, o_default, 0);
+
+ sprintf (buf, "%lu", ulMinor);
+ define_variable ("KBUILD_HOST_VERSION_MINOR", sizeof ("KBUILD_HOST_VERSION_MINOR") - 1,
+ buf, o_default, 0);
+
+ sprintf (buf, "%lu", ulPatch);
+ define_variable ("KBUILD_HOST_VERSION_PATCH", sizeof ("KBUILD_HOST_VERSION_PATCH") - 1,
+ buf, o_default, 0);
+
/* The kBuild locations. */
define_variable ("KBUILD_PATH", sizeof ("KBUILD_PATH") - 1,
get_kbuild_path (), o_default, 0);
@@ -1191,6 +1278,7 @@ define_automatic_variables (void)
&& defined (CONFIG_WITH_SET_CONDITIONALS) \
&& defined (CONFIG_WITH_DATE) \
&& defined (CONFIG_WITH_FILE_SIZE) \
+ && defined (CONFIG_WITH_WHERE_FUNCTION) \
&& defined (CONFIG_WITH_WHICH) \
&& defined (CONFIG_WITH_EVALPLUS) \
&& (defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS)) \
@@ -1199,9 +1287,10 @@ define_automatic_variables (void)
&& defined (CONFIG_WITH_LOOP_FUNCTIONS) \
&& defined (CONFIG_WITH_ROOT_FUNC) \
&& defined (CONFIG_WITH_STRING_FUNCTIONS) \
+ && defined (CONFIG_WITH_DEFINED_FUNCTIONS) \
&& defined (KMK_HELPERS)
(void) define_variable ("KMK_FEATURES", 12,
- "append-dash-n abspath includedep-queue"
+ "append-dash-n abspath includedep-queue install-hard-linking"
" rsort"
" abspathex"
" toupper tolower"
@@ -1217,6 +1306,7 @@ define_automatic_variables (void)
" date"
" file-size"
" expr if-expr select"
+ " where"
" which"
" evalctx evalval evalvalctx evalcall evalcall2 eval-opt-var"
" make-stats"
@@ -1226,10 +1316,11 @@ define_automatic_variables (void)
" root"
" length insert pos lastpos substr translate"
" kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one kb-exp-tmpl "
+ " firstdefined lastdefined "
, o_default, 0);
# else /* MSC can't deal with strings mixed with #if/#endif, thus the slow way. */
# error "All features should be enabled by default!"
- strcpy (buf, "append-dash-n abspath includedep-queue");
+ strcpy (buf, "append-dash-n abspath includedep-queue install-hard-linking");
# if defined (CONFIG_WITH_RSORT)
strcat (buf, " rsort");
# endif
@@ -1275,6 +1366,9 @@ define_automatic_variables (void)
# if defined (CONFIG_WITH_IF_CONDITIONALS)
strcat (buf, " expr if-expr select");
# endif
+# if defined (CONFIG_WITH_WHERE_FUNCTION)
+ strcat (buf, " where");
+# endif
# if defined (CONFIG_WITH_WHICH)
strcat (buf, " which");
# endif
@@ -1299,6 +1393,9 @@ define_automatic_variables (void)
# if defined (CONFIG_WITH_STRING_FUNCTIONS)
strcat (buf, " length insert pos lastpos substr translate");
# endif
+# if defined (CONFIG_WITH_DEFINED_FUNCTIONS)
+ strcat (buf, " firstdefined lastdefined");
+# endif
# if defined (KMK_HELPERS)
strcat (buf, " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one kb-exp-tmpl");
# endif