- Timestamp:
- May 25, 2007, 12:39:22 AM (18 years ago)
- Location:
- trunk/src/gmakenew
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmakenew/kbuild.c
r862 r917 27 27 /* No GNU coding style here! */ 28 28 29 #ifdef KMK_HELPERS 30 29 30 /******************************************************************************* 31 * Header Files * 32 *******************************************************************************/ 31 33 #include "make.h" 32 34 #include "filedef.h" … … 43 45 #endif 44 46 47 48 /******************************************************************************* 49 * Internal Functions * 50 *******************************************************************************/ 45 51 /* function.c */ 46 52 char * abspath(const char *name, char *apath); 53 54 /******************************************************************************* 55 * Global Variables * 56 *******************************************************************************/ 57 /** The argv[0] passed to main. */ 58 static 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 */ 67 void 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 */ 78 const 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 */ 110 const 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 47 138 48 139 /** … … 1475 1566 1476 1567 #endif /* KMK_HELPERS */ 1568 -
trunk/src/gmakenew/kbuild.h
r903 r917 34 34 char *func_kbuild_source_one(char *o, char **argv, const char *pszFuncName); 35 35 36 void init_kbuild(int argc, char **argv); 37 const char *get_path_kbuild(void); 38 const char *get_path_kbuild_bin(void); 39 36 40 #endif -
trunk/src/gmakenew/main.c
r914 r917 26 26 #include "debug.h" 27 27 #include "getopt.h" 28 #ifdef KMK 29 # include "kbuild.h" 30 #endif 28 31 29 32 #include <assert.h> … … 1113 1116 initialize_main(&argc, &argv); 1114 1117 1118 #ifdef KMK 1119 init_kbuild (argc, argv); 1120 #endif 1121 1115 1122 default_goal_file = 0; 1116 1123 reading_file = 0; … … 1130 1137 /* Set up gettext/internationalization support. */ 1131 1138 setlocale (LC_ALL, ""); 1139 #ifndef LOCALEDIR /* bird */ 1132 1140 bindtextdomain (PACKAGE, LOCALEDIR); 1133 1141 textdomain (PACKAGE); 1142 #endif 1134 1143 1135 1144 #ifdef POSIX … … 3244 3253 # ifdef PATH_KBUILD 3245 3254 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 */ 3250 3268 if (!remote_description || *remote_description == '\0') 3251 3269 printf (_("\n%sThis program is built for %s/%s/%s [" __DATE__ " " __TIME__ "]\n"), -
trunk/src/gmakenew/read.c
r910 r917 31 31 #include "debug.h" 32 32 #include "hash.h" 33 #ifdef KMK 34 # include "kbuild.h" 35 #endif 33 36 34 37 … … 91 94 static const char *default_include_directories[] = 92 95 { 96 #ifndef KMK 93 97 #if defined(WINDOWS32) && !defined(INCLUDEDIR) 94 98 /* This completely up to the user when they install MSVC or other packages. … … 102 106 "/usr/include", 103 107 #endif 108 #endif /* !KMK */ 104 109 0 105 110 }; … … 3006 3011 ++idx; 3007 3012 #endif 3013 #ifdef KMK 3014 /* Add one for the kBuild directory. */ 3015 ++idx; 3016 #endif 3008 3017 3009 3018 dirs = xmalloc (idx * sizeof (const char *)); … … 3064 3073 max_incl_len = len; 3065 3074 } 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; 3066 3084 } 3067 3085 #endif … … 3226 3244 { 3227 3245 gl.gl_pathc = 1; 3228 gl.gl_pathv = (char * )&gname;3246 gl.gl_pathv = (char **)&gname; 3229 3247 rc = 0; 3230 3248 } -
trunk/src/gmakenew/remake.c
r910 r917 1457 1457 static char *dirs[] = 1458 1458 { 1459 #ifdef KMK 1460 ".", 1461 #else /* !KMK */ 1459 1462 #ifndef _AMIGA 1460 1463 "/lib", … … 1469 1472 #endif 1470 1473 LIBDIR, /* Defined by configuration. */ 1474 #endif /* !KMK */ 1471 1475 0 1472 1476 }; -
trunk/src/gmakenew/variable.c
r903 r917 31 31 #endif 32 32 #include "hash.h" 33 #ifdef KMK 34 # include "kbuild.h" 35 #endif 33 36 34 37 /* Chain of all pattern-specific variables. */ … … 990 993 /* Define KBUILD_VERSION* */ 991 994 sprintf (buf, "%d", KBUILD_VERSION_MAJOR); 992 (void) define_variable ("KBUILD_VERSION_MAJOR", sizeof("KBUILD_VERSION_MAJOR") - 1,993 995 define_variable ("KBUILD_VERSION_MAJOR", sizeof ("KBUILD_VERSION_MAJOR") - 1, 996 buf, o_default, 0); 994 997 sprintf (buf, "%d", KBUILD_VERSION_MINOR); 995 (void)define_variable ("KBUILD_VERSION_MINOR", sizeof("KBUILD_VERSION_MINOR") - 1,996 998 define_variable ("KBUILD_VERSION_MINOR", sizeof("KBUILD_VERSION_MINOR") - 1, 999 buf, o_default, 0); 997 1000 sprintf (buf, "%d", KBUILD_VERSION_PATCH); 998 (void) define_variable ("KBUILD_VERSION_PATCH", sizeof("KBUILD_VERSION_PATCH") - 1,999 1001 define_variable ("KBUILD_VERSION_PATCH", sizeof ("KBUILD_VERSION_PATCH") - 1, 1002 buf, o_default, 0); 1000 1003 1001 1004 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 1005 define_variable ("KBUILD_VERSION", sizeof ("KBUILD_VERSION") - 1, 1006 buf, o_default, 0); 1004 1007 1005 1008 /* The build platform defaults. */ 1006 1009 envvar = getenv ("BUILD_PLATFORM"); 1007 1010 if (!envvar) 1008 (void) define_variable ("BUILD_PLATFORM", sizeof("BUILD_PLATFORM") - 1,1009 1011 define_variable ("BUILD_PLATFORM", sizeof ("BUILD_PLATFORM") - 1, 1012 BUILD_PLATFORM, o_default, 0); 1010 1013 envvar = getenv ("BUILD_PLATFORM_ARCH"); 1011 1014 if (!envvar) 1012 (void) define_variable ("BUILD_PLATFORM_ARCH", sizeof("BUILD_PLATFORM_ARCH") - 1,1013 1015 define_variable ("BUILD_PLATFORM_ARCH", sizeof ("BUILD_PLATFORM_ARCH") - 1, 1016 BUILD_PLATFORM_ARCH, o_default, 0); 1014 1017 envvar = getenv ("BUILD_PLATFORM_CPU"); 1015 1018 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); 1033 1027 1034 1028 /* Define KMK_FEATURES to indicate various working KMK features. */ … … 1053 1047 , o_default, 0); 1054 1048 # 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"); 1058 1052 # endif 1059 # if defined (CONFIG_WITH_ABSPATHEX)1060 strcat (buf, " abspathex");1053 # if defined (CONFIG_WITH_ABSPATHEX) 1054 strcat (buf, " abspathex"); 1061 1055 # 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"); 1064 1058 # 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"); 1067 1061 # endif 1068 # if defined (CONFIG_WITH_STACK)1069 strcat (buf, " stack");1062 # if defined (CONFIG_WITH_STACK) 1063 strcat (buf, " stack"); 1070 1064 # endif 1071 # if defined (CONFIG_WITH_MATH)1072 strcat (buf, " math-int");1065 # if defined (CONFIG_WITH_MATH) 1066 strcat (buf, " math-int"); 1073 1067 # endif 1074 # if defined (CONFIG_WITH_XARGS)1075 strcat (buf, " xargs");1068 # if defined (CONFIG_WITH_XARGS) 1069 strcat (buf, " xargs"); 1076 1070 # endif 1077 1071 # 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"); 1079 1073 # endif 1080 1074 (void) define_variable ("KMK_FEATURES", 12, buf, o_default, 0);
Note:
See TracChangeset
for help on using the changeset viewer.