Changeset 1503 in kBuild
- Timestamp:
- Apr 8, 2008 11:16:53 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Config.kmk
r1498 r1503 64 64 NIX_INSTALL_DIR_SHARE := $(patsubst /%,%,$(NIX_INSTALL_DIR))/share/kBuild 65 65 DEFS += \ 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)\" 68 68 endif 69 69 -
trunk/src/kmk/Makefile.am
r1440 r1503 129 129 -DCONFIG_PRETTY_COMMAND_PRINTING \ 130 130 \ 131 -D BUILD_PLATFORM=\"$(BUILD_TARGET)\" \132 -D BUILD_PLATFORM_ARCH=\"$(BUILD_TARGET_ARCH)\" \133 -D BUILD_PLATFORM_CPU=\"$(BUILD_TARGET_CPU)\" \131 -DKBUILD_HOST=\"$(BUILD_TARGET)\" \ 132 -DKBUILD_HOST_ARCH=\"$(BUILD_TARGET_ARCH)\" \ 133 -DKBUILD_HOST_CPU=\"$(BUILD_TARGET_CPU)\" \ 134 134 \ 135 135 -DKBUILD_VERSION_MAJOR=0 \ -
trunk/src/kmk/Makefile.kmk
r1454 r1503 133 133 CONFIG_PRETTY_COMMAND_PRINTING \ 134 134 \ 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)\" 138 138 kmk_DEFS.x86 = CONFIG_WITH_OPTIMIZATION_HACKS 139 139 kmk_DEFS.amd64 = CONFIG_WITH_OPTIMIZATION_HACKS -
trunk/src/kmk/kbuild.c
r1484 r1503 205 205 206 206 /** 207 * Determin the PATH_KBUILDvalue.207 * Determin the KBUILD_PATH value. 208 208 * 209 209 * @returns Pointer to static a buffer containing the value (consider it read-only). 210 210 */ 211 const char *get_ path_kbuild(void)211 const char *get_kbuild_path(void) 212 212 { 213 213 static const char *s_pszPath = NULL; … … 215 215 { 216 216 PATH_VAR(szTmpPath); 217 const char *pszEnvVar = getenv(" PATH_KBUILD");217 const char *pszEnvVar = getenv("KBUILD_PATH"); 218 218 if ( !pszEnvVar 219 219 || !my_abspath(pszEnvVar, szTmpPath)) 220 220 { 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; 223 227 #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 } 231 236 } 232 237 s_pszPath = xstrdup(szTmpPath); … … 237 242 238 243 /** 239 * Determin the PATH_KBUILD_BINvalue.244 * Determin the KBUILD_BIN_PATH value. 240 245 * 241 246 * @returns Pointer to static a buffer containing the value (consider it read-only). 242 247 */ 243 const char *get_ path_kbuild_bin(void)248 const char *get_kbuild_bin_path(void) 244 249 { 245 250 static const char *s_pszPath = NULL; … … 247 252 { 248 253 PATH_VAR(szTmpPath); 249 const char *pszEnvVar = getenv("PATH_KBUILD_BIN"); 254 255 const char *pszEnvVar = getenv("KBUILD_BIN_PATH"); 250 256 if ( !pszEnvVar 251 257 || !my_abspath(pszEnvVar, szTmpPath)) 252 258 { 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; 255 265 #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 } 275 286 } 276 287 s_pszPath = xstrdup(szTmpPath); … … 289 300 static char *s_pszDefaultShell = NULL; 290 301 if (!s_pszDefaultShell) 291 302 { 292 303 #if defined(__OS2__) || defined(_WIN32) || defined(WINDOWS32) 293 304 static const char s_szShellName[] = "/kmk_ash.exe"; … … 295 306 static const char s_szShellName[] = "/kmk_ash"; 296 307 #endif 297 const char *pszBin = get_ path_kbuild_bin();308 const char *pszBin = get_kbuild_bin_path(); 298 309 size_t cchBin = strlen(pszBin); 299 310 s_pszDefaultShell = xmalloc(cchBin + sizeof(s_szShellName)); 300 311 memcpy(s_pszDefaultShell, pszBin, cchBin); 301 312 memcpy(&s_pszDefaultShell[cchBin], s_szShellName, sizeof(s_szShellName)); 302 313 } 303 314 return s_pszDefaultShell; 304 315 } -
trunk/src/kmk/kbuild.h
r1298 r1503 35 35 36 36 void init_kbuild(int argc, char **argv); 37 const char *get_ path_kbuild(void);38 const char *get_ path_kbuild_bin(void);37 const char *get_kbuild_path(void); 38 const char *get_kbuild_bin_path(void); 39 39 const char *get_default_kbuild_shell(void); 40 40 -
trunk/src/kmk/main.c
r1461 r1503 1294 1294 argv[0] = ""; 1295 1295 if (argv[0][0] == '\0') 1296 #ifdef KMK 1297 program = "kmk"; 1298 #else 1296 1299 program = "make"; 1300 #endif 1297 1301 else 1298 1302 { … … 1499 1503 1500 1504 #ifdef KMK 1501 decode_env_switches (STRING_SIZE_TUPLE ("KMK FLAGS"));1502 #e ndif1505 decode_env_switches (STRING_SIZE_TUPLE ("KMK_FLAGS")); 1506 #else /* !KMK */ 1503 1507 decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS")); 1504 1508 #if 0 … … 1508 1512 decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS")); 1509 1513 #endif 1514 #endif /* !KMK */ 1510 1515 decode_switches (argc, argv, 0); 1511 1516 #ifdef WINDOWS32 … … 1643 1648 allow the user's setting of MAKEOVERRIDES to affect MAKEFLAGS, so 1644 1649 a reference to this hidden variable is written instead. */ 1650 #ifdef KMK 1651 (void) define_variable ("KMK_OVERRIDES", 13, 1652 #else 1645 1653 (void) define_variable ("MAKEOVERRIDES", 13, 1654 #endif 1646 1655 "${-*-command-variables-*-}", o_env, 1); 1647 1656 } … … 1753 1762 { 1754 1763 extern char *default_shell; 1755 const char *bin = get_ path_kbuild_bin();1764 const char *bin = get_kbuild_bin_path(); 1756 1765 size_t len = strlen (bin); 1757 1766 default_shell = xmalloc (len + sizeof("/kmk_ash.exe")); … … 1994 2003 /* Decode switches again, in case the variables were set by the makefile. */ 1995 2004 #ifdef KMK 1996 decode_env_switches (STRING_SIZE_TUPLE ("KMK FLAGS"));1997 #e ndif2005 decode_env_switches (STRING_SIZE_TUPLE ("KMK_FLAGS")); 2006 #else /* !KMK */ 1998 2007 decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS")); 1999 2008 #if 0 2000 2009 decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS")); 2001 2010 #endif 2011 #endif /* !KMK */ 2002 2012 2003 2013 #if defined (__MSDOS__) || defined (__EMX__) … … 2766 2776 if (!remote_description || *remote_description == '\0') 2767 2777 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); 2769 2779 else 2770 2780 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); 2772 2782 #else /* !KMK */ 2773 2783 if (!remote_description || *remote_description == '\0') … … 3051 3061 define_makeflags (int all, int makefile) 3052 3062 { 3063 #ifdef KMK 3064 static const char ref[] = "$(KMK_OVERRIDES)"; 3065 #else 3053 3066 static const char ref[] = "$(MAKEOVERRIDES)"; 3067 #endif 3054 3068 static const char posixref[] = "$(-*-command-variables-*-)"; 3055 3069 register const struct command_switch *cs; … … 3241 3255 *p = '\0'; 3242 3256 3257 #ifdef KMK 3243 3258 /* Since MFLAGS is not parsed for flags, there is no reason to 3244 3259 override any makefile redefinition. */ 3245 3260 (void) define_variable ("MFLAGS", 6, flagstring, o_env, 1); 3261 #endif /* !KMK */ 3246 3262 3247 3263 if (all && command_variables != 0) … … 3290 3306 *p = '\0'; 3291 3307 3308 #ifdef KMK 3309 v = define_variable ("KMK_FLAGS", 9, 3310 #else 3292 3311 v = define_variable ("MAKEFLAGS", 9, 3312 #endif 3293 3313 /* If there are switches, omit the leading dash 3294 3314 unless it is a single long option with two … … 3381 3401 3382 3402 #ifdef KMK 3383 # ifdef PATH_KBUILD3403 # ifdef KBUILD_PATH 3384 3404 printf (_("%s\n\ 3385 %s PATH_KBUILD: '%s' (default '%s')\n\3386 %s PATH_KBUILD_BIN: '%s' (default '%s')\n"),3405 %sKBUILD_PATH: '%s' (default '%s')\n\ 3406 %sKBUILD_BIN_PATH: '%s' (default '%s')\n"), 3387 3407 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 */ 3391 3411 printf (_("%s\n\ 3392 %s PATH_KBUILD: '%s'\n\3393 %s PATH_KBUILD_BIN: '%s'\n"),3412 %sKBUILD_PATH: '%s'\n\ 3413 %sKBUILD_BIN_PATH: '%s'\n"), 3394 3414 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 */ 3398 3418 if (!remote_description || *remote_description == '\0') 3399 3419 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); 3401 3421 else 3402 3422 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); 3404 3424 #else 3405 3425 if (!remote_description || *remote_description == '\0') -
trunk/src/kmk/read.c
r1499 r1503 3651 3651 #endif 3652 3652 #ifdef KMK 3653 /* Add $( PATH_KBUILD). */3653 /* Add $(KBUILD_PATH). */ 3654 3654 { 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); 3657 3657 if (len > max_incl_len) 3658 3658 max_incl_len = len; -
trunk/src/kmk/variable.c
r1451 r1503 1124 1124 #else 1125 1125 char buf[1024]; 1126 const char *envvar; 1126 const char *val; 1127 struct variable *envvar1; 1128 struct variable *envvar2; 1127 1129 #endif 1128 1130 … … 1136 1138 (remote_description == 0 || remote_description[0] == '\0') 1137 1139 ? "" : remote_description); 1140 #ifndef KMK 1138 1141 (void) define_variable ("MAKE_VERSION", 12, buf, o_default, 0); 1139 1140 #ifdef KMK 1142 #else /* KMK */ 1143 1141 1144 /* Define KMK_VERSION to indicate kMk. */ 1142 1145 (void) define_variable ("KMK_VERSION", 11, buf, o_default, 0); … … 1157 1160 buf, o_default, 0); 1158 1161 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); 1172 1198 1173 1199 /* 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 1174 1205 define_variable ("PATH_KBUILD", sizeof ("PATH_KBUILD") - 1, 1175 get_ path_kbuild(), o_default, 0);1206 get_kbuild_path (), o_default, 0); 1176 1207 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); 1178 1209 1179 1210 /* Define KMK_FEATURES to indicate various working KMK features. */ -
trunk/src/kmk/variable.h
r1440 r1503 279 279 extern int export_all_variables; 280 280 281 #ifdef KMK 282 # define MAKELEVEL_NAME "KMK_LEVEL" 283 #else 281 284 #define MAKELEVEL_NAME "MAKELEVEL" 285 #endif 282 286 #define MAKELEVEL_LENGTH (sizeof (MAKELEVEL_NAME) - 1)
Note:
See TracChangeset
for help on using the changeset viewer.