Ignore:
Timestamp:
Apr 9, 2008, 1:16:53 AM (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.