Changeset 917 for trunk/src


Ignore:
Timestamp:
May 25, 2007, 12:39:22 AM (18 years ago)
Author:
bird
Message:

PATH_KBUILD and PATH_KBUILD_BIN improvements. Avoid LOCALEDIR, ALIASDIR, LIBDIR and INCLUDEDIR.

Location:
trunk/src/gmakenew
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmakenew/kbuild.c

    r862 r917  
    2727/* No GNU coding style here! */
    2828
    29 #ifdef KMK_HELPERS
    30 
     29
     30/*******************************************************************************
     31*   Header Files                                                               *
     32*******************************************************************************/
    3133#include "make.h"
    3234#include "filedef.h"
     
    4345#endif
    4446
     47
     48/*******************************************************************************
     49*   Internal Functions                                                         *
     50*******************************************************************************/
    4551/* function.c */
    4652char * abspath(const char *name, char *apath);
     53
     54/*******************************************************************************
     55*   Global Variables                                                           *
     56*******************************************************************************/
     57/** The argv[0] passed to main. */
     58static const char *g_argv0 = "";
     59
     60
     61/**
     62 * Initialize kBuild stuff.
     63 *
     64 * @param   argc    Number of arguments to main().
     65 * @param   argv    The main() argument vector.
     66 */
     67void init_kbuild(int argc, char **argv)
     68{
     69    g_argv0 = argv[0];
     70}
     71
     72
     73/**
     74 * Determin the PATH_KBUILD value.
     75 *
     76 * @returns Pointer to static buffer to be treated as read only!
     77 */
     78const char *get_path_kbuild(void)
     79{
     80    static const char *s_pszPath = NULL;
     81    if (!s_pszPath)
     82    {
     83        PATH_VAR(szTmpPath);
     84        const char *pszEnvVar = getenv("PATH_KBUILD");
     85        if (    !pszEnvVar
     86            ||  !abspath(pszEnvVar, szTmpPath))
     87        {
     88#ifdef PATH_KBUILD
     89            return s_pszPath = PATH_KBUILD;
     90#else
     91            /* $(abspath $(PATH_KBUILD_BIN)/../..)*/
     92            size_t cch = strlen(get_path_kbuild_bin());
     93            char *pszTmp2 = alloca(cch + sizeof("/../.."));
     94            strcat(strcpy(pszTmp2, get_path_kbuild_bin()), "/../..");
     95            if (!abspath(pszTmp2, szTmpPath))
     96                fatal(NILF, _("failed to determin PATH_KBUILD"));
     97#endif
     98        }
     99        s_pszPath = xstrdup(szTmpPath);
     100    }
     101    return s_pszPath;
     102}
     103
     104
     105/**
     106 * Determin the PATH_KBUILD_BIN value.
     107 *
     108 * @returns Pointer to static buffer to be treated as read only!
     109 */
     110const char *get_path_kbuild_bin(void)
     111{
     112    static const char *s_pszPath = NULL;
     113    if (!s_pszPath)
     114    {
     115        PATH_VAR(szTmpPath);
     116        const char *pszEnvVar = getenv("PATH_KBUILD_BIN");
     117        if (    !pszEnvVar
     118            ||  !abspath(pszEnvVar, szTmpPath))
     119        {
     120#ifdef PATH_KBUILD
     121            return s_pszPath = PATH_KBUILD_BIN;
     122#else
     123            /* $(abspath $(ARGV0)/../../..) - the filename shouldn't cause trouble... */
     124            size_t cch = strlen(g_argv0);
     125            char *pszTmp2 = alloca(cch + sizeof("/../../.."));
     126            strcat(strcpy(pszTmp2, g_argv0), "/../../..");
     127            if (!abspath(pszTmp2, szTmpPath))
     128                fatal(NILF, _("failed to determin PATH_KBUILD_BIN"));
     129#endif
     130        }
     131        s_pszPath = xstrdup(szTmpPath);
     132    }
     133    return s_pszPath;
     134}
     135
     136
     137#ifdef KMK_HELPERS
    47138
    48139/**
     
    14751566
    14761567#endif /* KMK_HELPERS */
     1568
  • trunk/src/gmakenew/kbuild.h

    r903 r917  
    3434char *func_kbuild_source_one(char *o, char **argv, const char *pszFuncName);
    3535
     36void init_kbuild(int argc, char **argv);
     37const char *get_path_kbuild(void);
     38const char *get_path_kbuild_bin(void);
     39
    3640#endif
  • trunk/src/gmakenew/main.c

    r914 r917  
    2626#include "debug.h"
    2727#include "getopt.h"
     28#ifdef KMK
     29# include "kbuild.h"
     30#endif
    2831
    2932#include <assert.h>
     
    11131116  initialize_main(&argc, &argv);
    11141117
     1118#ifdef KMK
     1119  init_kbuild (argc, argv);
     1120#endif
     1121
    11151122  default_goal_file = 0;
    11161123  reading_file = 0;
     
    11301137  /* Set up gettext/internationalization support.  */
    11311138  setlocale (LC_ALL, "");
     1139#ifndef LOCALEDIR /* bird */
    11321140  bindtextdomain (PACKAGE, LOCALEDIR);
    11331141  textdomain (PACKAGE);
     1142#endif
    11341143
    11351144#ifdef  POSIX
     
    32443253# ifdef PATH_KBUILD
    32453254  printf (_("%s\n\
    3246 %sPATH_KBUILD default:     '%s'\n\
    3247 %sPATH_KBUILD_BIN default: '%s'\n"),
    3248           precede, precede, PATH_KBUILD, precede, PATH_KBUILD_BIN);
    3249 # endif /* PATH_KBUILD */
     3255%sPATH_KBUILD:     '%s' (default '%s')\n\
     3256%sPATH_KBUILD_BIN: '%s' (default '%s')\n"),
     3257          precede,
     3258          precede, get_path_kbuild(), PATH_KBUILD
     3259          precede, get_path_kbuild_bin(), PATH_KBUILD_BIN);
     3260# else  /* !PATH_KBUILD */
     3261  printf (_("%s\n\
     3262%sPATH_KBUILD:     '%s'\n\
     3263%sPATH_KBUILD_BIN: '%s'\n"),
     3264          precede,
     3265          precede, get_path_kbuild(),
     3266          precede, get_path_kbuild_bin());
     3267# endif /* !PATH_KBUILD */
    32503268  if (!remote_description || *remote_description == '\0')
    32513269    printf (_("\n%sThis program is built for %s/%s/%s [" __DATE__ " " __TIME__ "]\n"),
  • trunk/src/gmakenew/read.c

    r910 r917  
    3131#include "debug.h"
    3232#include "hash.h"
     33#ifdef KMK
     34# include "kbuild.h"
     35#endif
    3336
    3437
     
    9194static const char *default_include_directories[] =
    9295  {
     96#ifndef KMK
    9397#if defined(WINDOWS32) && !defined(INCLUDEDIR)
    9498/* This completely up to the user when they install MSVC or other packages.
     
    102106    "/usr/include",
    103107#endif
     108#endif /* !KMK */
    104109    0
    105110  };
     
    30063011  ++idx;
    30073012#endif
     3013#ifdef KMK
     3014  /* Add one for the kBuild directory. */
     3015  ++idx;
     3016#endif
    30083017
    30093018  dirs = xmalloc (idx * sizeof (const char *));
     
    30643073          max_incl_len = len;
    30653074      }
     3075  }
     3076#endif
     3077#ifdef KMK
     3078  /* Add $(PATH_KBUILD). */
     3079  {
     3080    size_t len = strlen (get_path_kbuild ());
     3081    dirs[idx++] = strcache_add_len (get_path_kbuild (), len);
     3082    if (len > max_incl_len)
     3083      max_incl_len = len;
    30663084  }
    30673085#endif
     
    32263244        {
    32273245          gl.gl_pathc = 1;
    3228           gl.gl_pathv = (char *)&gname;
     3246          gl.gl_pathv = (char **)&gname;
    32293247          rc = 0;
    32303248        }
  • trunk/src/gmakenew/remake.c

    r910 r917  
    14571457  static char *dirs[] =
    14581458    {
     1459#ifdef KMK
     1460      ".",
     1461#else /* !KMK */
    14591462#ifndef _AMIGA
    14601463      "/lib",
     
    14691472#endif
    14701473      LIBDIR,                   /* Defined by configuration.  */
     1474#endif /* !KMK */
    14711475      0
    14721476    };
  • trunk/src/gmakenew/variable.c

    r903 r917  
    3131#endif
    3232#include "hash.h"
     33#ifdef KMK
     34# include "kbuild.h"
     35#endif
    3336
    3437/* Chain of all pattern-specific variables.  */
     
    990993  /* Define KBUILD_VERSION* */
    991994  sprintf (buf, "%d", KBUILD_VERSION_MAJOR);
    992   (void) define_variable ("KBUILD_VERSION_MAJOR", sizeof("KBUILD_VERSION_MAJOR") - 1,
    993                           buf, o_default, 0);
     995  define_variable ("KBUILD_VERSION_MAJOR", sizeof ("KBUILD_VERSION_MAJOR") - 1,
     996                   buf, o_default, 0);
    994997  sprintf (buf, "%d", KBUILD_VERSION_MINOR);
    995   (void) define_variable ("KBUILD_VERSION_MINOR", sizeof("KBUILD_VERSION_MINOR") - 1,
    996                           buf, o_default, 0);
     998  define_variable ("KBUILD_VERSION_MINOR", sizeof("KBUILD_VERSION_MINOR") - 1,
     999                   buf, o_default, 0);
    9971000  sprintf (buf, "%d", KBUILD_VERSION_PATCH);
    998   (void) define_variable ("KBUILD_VERSION_PATCH", sizeof("KBUILD_VERSION_PATCH") - 1,
    999                           buf, o_default, 0);
     1001  define_variable ("KBUILD_VERSION_PATCH", sizeof ("KBUILD_VERSION_PATCH") - 1,
     1002                   buf, o_default, 0);
    10001003
    10011004  sprintf (buf, "%d.%d.%d", KBUILD_VERSION_MAJOR, KBUILD_VERSION_MINOR, KBUILD_VERSION_PATCH);
    1002   (void) define_variable ("KBUILD_VERSION", sizeof("KBUILD_VERSION") - 1,
    1003                           buf, o_default, 0);
     1005  define_variable ("KBUILD_VERSION", sizeof ("KBUILD_VERSION") - 1,
     1006                   buf, o_default, 0);
    10041007
    10051008  /* The build platform defaults. */
    10061009  envvar = getenv ("BUILD_PLATFORM");
    10071010  if (!envvar)
    1008       (void) define_variable ("BUILD_PLATFORM", sizeof("BUILD_PLATFORM") - 1,
    1009                               BUILD_PLATFORM, o_default, 0);
     1011      define_variable ("BUILD_PLATFORM", sizeof ("BUILD_PLATFORM") - 1,
     1012                       BUILD_PLATFORM, o_default, 0);
    10101013  envvar = getenv ("BUILD_PLATFORM_ARCH");
    10111014  if (!envvar)
    1012       (void) define_variable ("BUILD_PLATFORM_ARCH", sizeof("BUILD_PLATFORM_ARCH") - 1,
    1013                               BUILD_PLATFORM_ARCH, o_default, 0);
     1015      define_variable ("BUILD_PLATFORM_ARCH", sizeof ("BUILD_PLATFORM_ARCH") - 1,
     1016                       BUILD_PLATFORM_ARCH, o_default, 0);
    10141017  envvar = getenv ("BUILD_PLATFORM_CPU");
    10151018  if (!envvar)
    1016       (void) define_variable ("BUILD_PLATFORM_CPU", sizeof("BUILD_PLATFORM_CPU") - 1,
    1017                               BUILD_PLATFORM_CPU, o_default, 0);
    1018 
    1019 # ifdef PATH_KBUILD
    1020   /* define the installed. */
    1021   envvar = getenv("PATH_KBUILD");
    1022   if (!envvar)
    1023   {
    1024       (void) define_variable ("PATH_KBUILD", sizeof("PATH_KBUILD") - 1,
    1025                               PATH_KBUILD, o_default, 0);
    1026       envvar = getenv("PATH_KBUILD_BIN");
    1027       if (!envvar)
    1028           (void) define_variable ("PATH_KBUILD_BIN", sizeof("PATH_KBUILD_BIN") - 1,
    1029                                   PATH_KBUILD_BIN, o_default, 0);
    1030   }
    1031 # endif
    1032 
     1019      define_variable ("BUILD_PLATFORM_CPU", sizeof ("BUILD_PLATFORM_CPU") - 1,
     1020                       BUILD_PLATFORM_CPU, o_default, 0);
     1021
     1022  /* The kBuild locations. */
     1023  define_variable ("PATH_KBUILD", sizeof ("PATH_KBUILD") - 1,
     1024                   get_path_kbuild (), o_default, 0);
     1025  define_variable ("PATH_KBUILD_BIN", sizeof ("PATH_KBUILD_BIN") - 1,
     1026                   get_path_kbuild_bin (), o_default, 0);
    10331027
    10341028  /* Define KMK_FEATURES to indicate various working KMK features. */
     
    10531047                          , o_default, 0);
    10541048# else /* MSC can't deal with strings mixed with #if/#endif, thus the slow way. */
    1055   strcpy(buf, "append-dash-n abspath");
    1056 #  if defined(CONFIG_WITH_RSORT)
    1057   strcat(buf, " rsort");
     1049  strcpy (buf, "append-dash-n abspath");
     1050#  if defined (CONFIG_WITH_RSORT)
     1051  strcat (buf, " rsort");
    10581052#  endif
    1059 #  if defined(CONFIG_WITH_ABSPATHEX)
    1060   strcat(buf, " abspathex");
     1053#  if defined (CONFIG_WITH_ABSPATHEX)
     1054  strcat (buf, " abspathex");
    10611055#  endif
    1062 #  if defined(CONFIG_WITH_TOUPPER_TOLOWER)
    1063   strcat(buf, " toupper tolower");
     1056#  if defined (CONFIG_WITH_TOUPPER_TOLOWER)
     1057  strcat (buf, " toupper tolower");
    10641058#  endif
    1065 #  if defined(CONFIG_WITH_VALUE_LENGTH) && defined(CONFIG_WITH_COMPARE)
    1066   strcat(buf, " comp-vars comp-cmds");
     1059#  if defined (CONFIG_WITH_VALUE_LENGTH) && defined(CONFIG_WITH_COMPARE)
     1060  strcat (buf, " comp-vars comp-cmds");
    10671061#  endif
    1068 #  if defined(CONFIG_WITH_STACK)
    1069   strcat(buf, " stack");
     1062#  if defined (CONFIG_WITH_STACK)
     1063  strcat (buf, " stack");
    10701064#  endif
    1071 #  if defined(CONFIG_WITH_MATH)
    1072   strcat(buf, " math-int");
     1065#  if defined (CONFIG_WITH_MATH)
     1066  strcat (buf, " math-int");
    10731067#  endif
    1074 #  if defined(CONFIG_WITH_XARGS)
    1075   strcat(buf, " xargs");
     1068#  if defined (CONFIG_WITH_XARGS)
     1069  strcat (buf, " xargs");
    10761070#  endif
    10771071#  ifdef KMK_HELPERS
    1078   strcat(buf, " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one");
     1072  strcat (buf, " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one");
    10791073#  endif
    10801074  (void) define_variable ("KMK_FEATURES", 12, buf, o_default, 0);
Note: See TracChangeset for help on using the changeset viewer.