VirtualBox

Changeset 1503 in kBuild


Ignore:
Timestamp:
Apr 8, 2008 11:16:53 PM (17 years ago)
Author:
bird
Message:

Environment / globals cleanup. The new policy is to use KBUILD_ and KMK_ prefixes for things that is put into or/and picked from the environment. This will take a good while to complete.

Renamed (old still valid for some versions):
PATH_KBUILD -> KBUILD_PATH
PATH_KBUILD_BIN -> KBUILD_BIN_PATH
BUILD_PLATFORM -> KBUILD_HOST
BUILD_PLATFORM_ARCH -> KBUILD_HOST_ARCH
BUILD_PLATFORM_CPU -> KBUILD_HOST_CPU

Renamed - old not checked:
MAKELEVEL -> KMK_LEVEL
KMKFLAGS -> KMK_FLAGS
MAKEFLAGS -> KMK_FLAGS
MAKEOVERRIDES -> KMK_OVERRIDES

Removed:
MAKE_VERSION
MFLAGS

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Config.kmk

    r1498 r1503  
    6464NIX_INSTALL_DIR_SHARE := $(patsubst /%,%,$(NIX_INSTALL_DIR))/share/kBuild
    6565DEFS += \
    66         PATH_KBUILD=\"/$(NIX_INSTALL_DIR_SHARE)\" \
    67         PATH_KBUILD_BIN=\"/$(NIX_INSTALL_DIR_BIN)\"
     66        KBUILD_PATH=\"/$(NIX_INSTALL_DIR_SHARE)\" \
     67        KBUILD_PATH_BIN=\"/$(NIX_INSTALL_DIR_BIN)\"
    6868endif
    6969
  • trunk/src/kmk/Makefile.am

    r1440 r1503  
    129129        -DCONFIG_PRETTY_COMMAND_PRINTING \
    130130        \
    131         -DBUILD_PLATFORM=\"$(BUILD_TARGET)\" \
    132         -DBUILD_PLATFORM_ARCH=\"$(BUILD_TARGET_ARCH)\" \
    133         -DBUILD_PLATFORM_CPU=\"$(BUILD_TARGET_CPU)\" \
     131        -DKBUILD_HOST=\"$(BUILD_TARGET)\" \
     132        -DKBUILD_HOST_ARCH=\"$(BUILD_TARGET_ARCH)\" \
     133        -DKBUILD_HOST_CPU=\"$(BUILD_TARGET_CPU)\" \
    134134        \
    135135        -DKBUILD_VERSION_MAJOR=0 \
  • trunk/src/kmk/Makefile.kmk

    r1454 r1503  
    133133        CONFIG_PRETTY_COMMAND_PRINTING \
    134134        \
    135         BUILD_PLATFORM=\"$(BUILD_TARGET)\" \
    136         BUILD_PLATFORM_ARCH=\"$(BUILD_TARGET_ARCH)\" \
    137         BUILD_PLATFORM_CPU=\"$(BUILD_TARGET_CPU)\"
     135        KBUILD_HOST=\"$(BUILD_TARGET)\" \
     136        KBUILD_HOST_ARCH=\"$(BUILD_TARGET_ARCH)\" \
     137        KBUILD_HOST_CPU=\"$(BUILD_TARGET_CPU)\"
    138138kmk_DEFS.x86 = CONFIG_WITH_OPTIMIZATION_HACKS
    139139kmk_DEFS.amd64 = CONFIG_WITH_OPTIMIZATION_HACKS
  • trunk/src/kmk/kbuild.c

    r1484 r1503  
    205205
    206206/**
    207  * Determin the PATH_KBUILD value.
     207 * Determin the KBUILD_PATH value.
    208208 *
    209209 * @returns Pointer to static a buffer containing the value (consider it read-only).
    210210 */
    211 const char *get_path_kbuild(void)
     211const char *get_kbuild_path(void)
    212212{
    213213    static const char *s_pszPath = NULL;
     
    215215    {
    216216        PATH_VAR(szTmpPath);
    217         const char *pszEnvVar = getenv("PATH_KBUILD");
     217        const char *pszEnvVar = getenv("KBUILD_PATH");
    218218        if (    !pszEnvVar
    219219            ||  !my_abspath(pszEnvVar, szTmpPath))
    220220        {
    221 #ifdef PATH_KBUILD
    222             return s_pszPath = PATH_KBUILD;
     221            const char *pszEnvVar = getenv("PATH_KBUILD");
     222            if (    !pszEnvVar
     223                ||  !my_abspath(pszEnvVar, szTmpPath))
     224            {
     225#ifdef KBUILD_PATH
     226                return s_pszPath = KBUILD_PATH;
    223227#else
    224             /* $(abspath $(PATH_KBUILD_BIN)/../..)*/
    225             size_t cch = strlen(get_path_kbuild_bin());
    226             char *pszTmp2 = alloca(cch + sizeof("/../.."));
    227             strcat(strcpy(pszTmp2, get_path_kbuild_bin()), "/../..");
    228             if (!my_abspath(pszTmp2, szTmpPath))
    229                 fatal(NILF, _("failed to determin PATH_KBUILD"));
    230 #endif
     228                /* $(abspath $(KBUILD_BIN_PATH)/../..)*/
     229                size_t cch = strlen(get_kbuild_bin_path());
     230                char *pszTmp2 = alloca(cch + sizeof("/../.."));
     231                strcat(strcpy(pszTmp2, get_kbuild_bin_path()), "/../..");
     232                if (!my_abspath(pszTmp2, szTmpPath))
     233                    fatal(NILF, _("failed to determin KBUILD_PATH"));
     234#endif
     235            }
    231236        }
    232237        s_pszPath = xstrdup(szTmpPath);
     
    237242
    238243/**
    239  * Determin the PATH_KBUILD_BIN value.
     244 * Determin the KBUILD_BIN_PATH value.
    240245 *
    241246 * @returns Pointer to static a buffer containing the value (consider it read-only).
    242247 */
    243 const char *get_path_kbuild_bin(void)
     248const char *get_kbuild_bin_path(void)
    244249{
    245250    static const char *s_pszPath = NULL;
     
    247252    {
    248253        PATH_VAR(szTmpPath);
    249         const char *pszEnvVar = getenv("PATH_KBUILD_BIN");
     254
     255        const char *pszEnvVar = getenv("KBUILD_BIN_PATH");
    250256        if (    !pszEnvVar
    251257            ||  !my_abspath(pszEnvVar, szTmpPath))
    252258        {
    253 #ifdef PATH_KBUILD
    254             return s_pszPath = PATH_KBUILD_BIN;
     259            const char *pszEnvVar = getenv("PATH_KBUILD_BIN");
     260            if (    !pszEnvVar
     261                ||  !my_abspath(pszEnvVar, szTmpPath))
     262            {
     263#ifdef KBUILD_PATH
     264                return s_pszPath = KBUILD_BIN_PATH;
    255265#else
    256             /* $(abspath $(dir $(ARGV0)).) */
    257             size_t cch = strlen(g_pszExeName);
    258             char *pszTmp2 = alloca(cch + sizeof("."));
    259             char *pszSep = pszTmp2 + cch - 1;
    260             memcpy(pszTmp2, g_pszExeName, cch);
    261 #ifdef HAVE_DOS_PATHS
    262             while (pszSep >= pszTmp2 && *pszSep != '/' && *pszSep != '\\' && *pszSep != ':')
    263 #else
    264             while (pszSep >= pszTmp2 && *pszSep != '/')
    265 #endif
    266                 pszSep--;
    267             if (pszSep >= pszTmp2)
    268               strcpy(pszSep + 1, ".");
    269             else
    270               strcpy(pszTmp2, ".");
    271 
    272             if (!my_abspath(pszTmp2, szTmpPath))
    273                 fatal(NILF, _("failed to determin PATH_KBUILD_BIN (pszTmp2=%s szTmpPath=%s)"), pszTmp2, szTmpPath);
    274 #endif
     266                /* $(abspath $(dir $(ARGV0)).) */
     267                size_t cch = strlen(g_pszExeName);
     268                char *pszTmp2 = alloca(cch + sizeof("."));
     269                char *pszSep = pszTmp2 + cch - 1;
     270                memcpy(pszTmp2, g_pszExeName, cch);
     271# ifdef HAVE_DOS_PATHS
     272                while (pszSep >= pszTmp2 && *pszSep != '/' && *pszSep != '\\' && *pszSep != ':')
     273# else
     274                while (pszSep >= pszTmp2 && *pszSep != '/')
     275# endif
     276                    pszSep--;
     277                if (pszSep >= pszTmp2)
     278                  strcpy(pszSep + 1, ".");
     279                else
     280                  strcpy(pszTmp2, ".");
     281   
     282                if (!my_abspath(pszTmp2, szTmpPath))
     283                    fatal(NILF, _("failed to determin KBUILD_BIN_PATH (pszTmp2=%s szTmpPath=%s)"), pszTmp2, szTmpPath);
     284#endif /* !KBUILD_PATH */
     285            }
    275286        }
    276287        s_pszPath = xstrdup(szTmpPath);
     
    289300    static char *s_pszDefaultShell = NULL;
    290301    if (!s_pszDefaultShell)
    291       {
     302    {
    292303#if defined(__OS2__) || defined(_WIN32) || defined(WINDOWS32)
    293304        static const char s_szShellName[] = "/kmk_ash.exe";
     
    295306        static const char s_szShellName[] = "/kmk_ash";
    296307#endif
    297         const char *pszBin = get_path_kbuild_bin();
     308        const char *pszBin = get_kbuild_bin_path();
    298309        size_t cchBin = strlen(pszBin);
    299310        s_pszDefaultShell = xmalloc(cchBin + sizeof(s_szShellName));
    300311        memcpy(s_pszDefaultShell, pszBin, cchBin);
    301312        memcpy(&s_pszDefaultShell[cchBin], s_szShellName, sizeof(s_szShellName));
    302       }
     313    }
    303314    return s_pszDefaultShell;
    304315}
  • trunk/src/kmk/kbuild.h

    r1298 r1503  
    3535
    3636void init_kbuild(int argc, char **argv);
    37 const char *get_path_kbuild(void);
    38 const char *get_path_kbuild_bin(void);
     37const char *get_kbuild_path(void);
     38const char *get_kbuild_bin_path(void);
    3939const char *get_default_kbuild_shell(void);
    4040
  • trunk/src/kmk/main.c

    r1461 r1503  
    12941294    argv[0] = "";
    12951295  if (argv[0][0] == '\0')
     1296#ifdef KMK
     1297    program = "kmk";
     1298#else
    12961299    program = "make";
     1300#endif
    12971301  else
    12981302    {
     
    14991503
    15001504#ifdef KMK
    1501   decode_env_switches (STRING_SIZE_TUPLE ("KMKFLAGS"));
    1502 #endif
     1505  decode_env_switches (STRING_SIZE_TUPLE ("KMK_FLAGS"));
     1506#else /* !KMK */
    15031507  decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS"));
    15041508#if 0
     
    15081512  decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS"));
    15091513#endif
     1514#endif /* !KMK */
    15101515  decode_switches (argc, argv, 0);
    15111516#ifdef WINDOWS32
     
    16431648         allow the user's setting of MAKEOVERRIDES to affect MAKEFLAGS, so
    16441649         a reference to this hidden variable is written instead. */
     1650#ifdef KMK
     1651      (void) define_variable ("KMK_OVERRIDES", 13,
     1652#else
    16451653      (void) define_variable ("MAKEOVERRIDES", 13,
     1654#endif
    16461655                              "${-*-command-variables-*-}", o_env, 1);
    16471656    }
     
    17531762  {
    17541763    extern char *default_shell;
    1755     const char *bin = get_path_kbuild_bin();
     1764    const char *bin = get_kbuild_bin_path();
    17561765    size_t len = strlen (bin);
    17571766    default_shell = xmalloc (len + sizeof("/kmk_ash.exe"));
     
    19942003  /* Decode switches again, in case the variables were set by the makefile.  */
    19952004#ifdef KMK
    1996   decode_env_switches (STRING_SIZE_TUPLE ("KMKFLAGS"));
    1997 #endif
     2005  decode_env_switches (STRING_SIZE_TUPLE ("KMK_FLAGS"));
     2006#else /* !KMK */
    19982007  decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS"));
    19992008#if 0
    20002009  decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS"));
    20012010#endif
     2011#endif /* !KMK */
    20022012
    20032013#if defined (__MSDOS__) || defined (__EMX__)
     
    27662776  if (!remote_description || *remote_description == '\0')
    27672777    printf (_("\nThis program is built for %s/%s/%s [" __DATE__ " " __TIME__ "]\n"),
    2768             BUILD_PLATFORM, BUILD_PLATFORM_ARCH, BUILD_PLATFORM_CPU, remote_description);
     2778            KBUILD_HOST, KBUILD_HOST_ARCH, KBUILD_HOST_CPU, remote_description);
    27692779  else
    27702780    printf (_("\nThis program is built for %s/%s/%s (%s) [" __DATE__ " " __TIME__ "]\n"),
    2771             BUILD_PLATFORM, BUILD_PLATFORM_ARCH, BUILD_PLATFORM_CPU, remote_description);
     2781            KBUILD_HOST, KBUILD_HOST_ARCH, KBUILD_HOST_CPU, remote_description);
    27722782#else  /* !KMK */
    27732783  if (!remote_description || *remote_description == '\0')
     
    30513061define_makeflags (int all, int makefile)
    30523062{
     3063#ifdef KMK
     3064  static const char ref[] = "$(KMK_OVERRIDES)";
     3065#else
    30533066  static const char ref[] = "$(MAKEOVERRIDES)";
     3067#endif
    30543068  static const char posixref[] = "$(-*-command-variables-*-)";
    30553069  register const struct command_switch *cs;
     
    32413255    *p = '\0';
    32423256
     3257#ifdef KMK
    32433258  /* Since MFLAGS is not parsed for flags, there is no reason to
    32443259     override any makefile redefinition.  */
    32453260  (void) define_variable ("MFLAGS", 6, flagstring, o_env, 1);
     3261#endif /* !KMK */
    32463262
    32473263  if (all && command_variables != 0)
     
    32903306  *p = '\0';
    32913307
     3308#ifdef KMK
     3309  v = define_variable ("KMK_FLAGS", 9,
     3310#else
    32923311  v = define_variable ("MAKEFLAGS", 9,
     3312#endif
    32933313                       /* If there are switches, omit the leading dash
    32943314                          unless it is a single long option with two
     
    33813401
    33823402#ifdef KMK
    3383 # ifdef PATH_KBUILD
     3403# ifdef KBUILD_PATH
    33843404  printf (_("%s\n\
    3385 %sPATH_KBUILD:     '%s' (default '%s')\n\
    3386 %sPATH_KBUILD_BIN: '%s' (default '%s')\n"),
     3405%sKBUILD_PATH:     '%s' (default '%s')\n\
     3406%sKBUILD_BIN_PATH: '%s' (default '%s')\n"),
    33873407          precede,
    3388           precede, get_path_kbuild(), PATH_KBUILD,
    3389           precede, get_path_kbuild_bin(), PATH_KBUILD_BIN);
    3390 # else  /* !PATH_KBUILD */
     3408          precede, get_kbuild_path(), KBUILD_PATH,
     3409          precede, get_kbuild_bin_path(), KBUILD_BIN_PATH);
     3410# else  /* !KBUILD_PATH */
    33913411  printf (_("%s\n\
    3392 %sPATH_KBUILD:     '%s'\n\
    3393 %sPATH_KBUILD_BIN: '%s'\n"),
     3412%sKBUILD_PATH:     '%s'\n\
     3413%sKBUILD_BIN_PATH: '%s'\n"),
    33943414          precede,
    3395           precede, get_path_kbuild(),
    3396           precede, get_path_kbuild_bin());
    3397 # endif /* !PATH_KBUILD */
     3415          precede, get_kbuild_path(),
     3416          precede, get_kbuild_bin_path());
     3417# endif /* !KBUILD_PATH */
    33983418  if (!remote_description || *remote_description == '\0')
    33993419    printf (_("\n%sThis program is built for %s/%s/%s [" __DATE__ " " __TIME__ "]\n"),
    3400             precede, BUILD_PLATFORM, BUILD_PLATFORM_ARCH, BUILD_PLATFORM_CPU, remote_description);
     3420            precede, KBUILD_HOST, KBUILD_HOST_ARCH, KBUILD_HOST_CPU, remote_description);
    34013421  else
    34023422    printf (_("\n%sThis program is built for %s/%s/%s (%s) [" __DATE__ " " __TIME__ "]\n"),
    3403             precede, BUILD_PLATFORM, BUILD_PLATFORM_ARCH, BUILD_PLATFORM_CPU, remote_description);
     3423            precede, KBUILD_HOST, KBUILD_HOST_ARCH, KBUILD_HOST_CPU, remote_description);
    34043424#else
    34053425  if (!remote_description || *remote_description == '\0')
  • trunk/src/kmk/read.c

    r1499 r1503  
    36513651#endif
    36523652#ifdef KMK
    3653   /* Add $(PATH_KBUILD). */
     3653  /* Add $(KBUILD_PATH). */
    36543654  {
    3655     size_t len = strlen (get_path_kbuild ());
    3656     dirs[idx++] = strcache_add_len (get_path_kbuild (), len);
     3655    size_t len = strlen (get_kbuild_path ());
     3656    dirs[idx++] = strcache_add_len (get_kbuild_path (), len);
    36573657    if (len > max_incl_len)
    36583658      max_incl_len = len;
  • trunk/src/kmk/variable.c

    r1451 r1503  
    11241124#else
    11251125  char buf[1024];
    1126   const char *envvar;
     1126  const char *val;
     1127  struct variable *envvar1;
     1128  struct variable *envvar2;
    11271129#endif
    11281130
     
    11361138           (remote_description == 0 || remote_description[0] == '\0')
    11371139           ? "" : remote_description);
     1140#ifndef KMK
    11381141  (void) define_variable ("MAKE_VERSION", 12, buf, o_default, 0);
    1139 
    1140 #ifdef KMK
     1142#else /* KMK */
     1143
    11411144  /* Define KMK_VERSION to indicate kMk. */
    11421145  (void) define_variable ("KMK_VERSION", 11, buf, o_default, 0);
     
    11571160                   buf, o_default, 0);
    11581161
    1159   /* The build platform defaults. */
    1160   envvar = getenv ("BUILD_PLATFORM");
    1161   if (!envvar)
    1162       define_variable ("BUILD_PLATFORM", sizeof ("BUILD_PLATFORM") - 1,
    1163                        BUILD_PLATFORM, o_default, 0);
    1164   envvar = getenv ("BUILD_PLATFORM_ARCH");
    1165   if (!envvar)
    1166       define_variable ("BUILD_PLATFORM_ARCH", sizeof ("BUILD_PLATFORM_ARCH") - 1,
    1167                        BUILD_PLATFORM_ARCH, o_default, 0);
    1168   envvar = getenv ("BUILD_PLATFORM_CPU");
    1169   if (!envvar)
    1170       define_variable ("BUILD_PLATFORM_CPU", sizeof ("BUILD_PLATFORM_CPU") - 1,
    1171                        BUILD_PLATFORM_CPU, o_default, 0);
     1162  /* The host defaults. The BUILD_* stuff will be replaced by KBUILD_* soon. */
     1163  envvar1 = lookup_variable (STRING_SIZE_TUPLE ("KBUILD_HOST"));
     1164  envvar2 = lookup_variable (STRING_SIZE_TUPLE ("BUILD_PLATFORM"));
     1165  val = envvar1 ? envvar1->value : envvar2 ? envvar2->value : KBUILD_HOST;
     1166  if (envvar1 && envvar2 && strcmp (envvar1->value, envvar2->value))
     1167    error (NULL, _("KBUILD_HOST and BUILD_PLATFORM differs, using KBUILD_HOST=%s."), val);
     1168  if (!envvar1)
     1169    define_variable ("KBUILD_HOST", sizeof ("KBUILD_HOST") - 1,
     1170                     val, o_default, 0);
     1171  if (!envvar2)
     1172    define_variable ("BUILD_PLATFORM", sizeof ("BUILD_PLATFORM") - 1,
     1173                     val, o_default, 0);
     1174
     1175  envvar1 = lookup_variable (STRING_SIZE_TUPLE ("KBUILD_HOST_ARCH"));
     1176  envvar2 = lookup_variable (STRING_SIZE_TUPLE ("BUILD_PLATFORM_ARCH"));
     1177  val = envvar1 ? envvar1->value : envvar2 ? envvar2->value : KBUILD_HOST_ARCH;
     1178  if (envvar1 && envvar2 && strcmp (envvar1->value, envvar2->value))
     1179    error (NULL, _("KBUILD_HOST_ARCH and BUILD_PLATFORM_ARCH differs, using KBUILD_HOST_ARCH=%s."), val);
     1180  if (!envvar1)
     1181    define_variable ("KBUILD_HOST_ARCH", sizeof ("KBUILD_HOST_ARCH") - 1,
     1182                     val, o_default, 0);
     1183  if (!envvar2)
     1184    define_variable ("BUILD_PLATFORM_ARCH", sizeof ("BUILD_PLATFORM_ARCH") - 1,
     1185                     val, o_default, 0);
     1186
     1187  envvar1 = lookup_variable (STRING_SIZE_TUPLE ("KBUILD_HOST_CPU"));
     1188  envvar2 = lookup_variable (STRING_SIZE_TUPLE ("BUILD_PLATFORM_CPU"));
     1189  val = envvar1 ? envvar1->value : envvar2 ? envvar2->value : KBUILD_HOST_CPU;
     1190  if (envvar1 && envvar2 && strcmp (envvar1->value, envvar2->value))
     1191    error (NULL, _("KBUILD_HOST_CPU and BUILD_PLATFORM_CPU differs, using KBUILD_HOST_CPU=%s."), val);
     1192  if (!envvar1)
     1193    define_variable ("KBUILD_HOST_CPU", sizeof ("KBUILD_HOST_CPU") - 1,
     1194                     val, o_default, 0);
     1195  if (!envvar2)
     1196    define_variable ("BUILD_PLATFORM_CPU", sizeof ("BUILD_PLATFORM_CPU") - 1,
     1197                     val, o_default, 0);
    11721198
    11731199  /* The kBuild locations. */
     1200  define_variable ("KBUILD_PATH", sizeof ("KBUILD_PATH") - 1,
     1201                   get_kbuild_path (), o_default, 0);
     1202  define_variable ("KBUILD_BIN_PATH", sizeof ("KBUILD_BIN_PATH") - 1,
     1203                   get_kbuild_bin_path (), o_default, 0);
     1204
    11741205  define_variable ("PATH_KBUILD", sizeof ("PATH_KBUILD") - 1,
    1175                    get_path_kbuild (), o_default, 0);
     1206                   get_kbuild_path (), o_default, 0);
    11761207  define_variable ("PATH_KBUILD_BIN", sizeof ("PATH_KBUILD_BIN") - 1,
    1177                    get_path_kbuild_bin (), o_default, 0);
     1208                   get_kbuild_bin_path (), o_default, 0);
    11781209
    11791210  /* Define KMK_FEATURES to indicate various working KMK features. */
  • trunk/src/kmk/variable.h

    r1440 r1503  
    279279extern int export_all_variables;
    280280
     281#ifdef KMK
     282# define MAKELEVEL_NAME "KMK_LEVEL"
     283#else
    281284#define MAKELEVEL_NAME "MAKELEVEL"
     285#endif
    282286#define MAKELEVEL_LENGTH (sizeof (MAKELEVEL_NAME) - 1)
Note: See TracChangeset for help on using the changeset viewer.

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