Changeset 338 for trunk/src/kDepPre/kDepPre.c
- Timestamp:
- Nov 7, 2005, 8:16:08 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kDepPre/kDepPre.c
r332 r338 37 37 #if !defined(__WIN32__) && !defined(__OS2__) 38 38 # include <dirent.h> 39 #endif 39 #endif 40 40 41 41 #ifdef HAVE_FGETC_UNLOCKED … … 74 74 /** List of dependencies. */ 75 75 static PDEP g_pDeps = NULL; 76 /** Whether or not to fixup win32 casing. */ 77 static int g_fFixCase = 0; 76 77 78 /******************************************************************************* 79 * Internal Functions * 80 *******************************************************************************/ 81 static PDEP depAdd(const char *pszFilename, size_t cchFilename); 82 static void depOptimize(int fFixCase); 83 static void depPrint(FILE *pOutput); 84 static void depPrintStubs(FILE *pOutput); 78 85 79 86 … … 198 205 /** 199 206 * Corrects all slashes to unix slashes. 200 * 207 * 201 208 * @returns pszFilename. 202 209 * @param pszFilename The filename to correct. … … 309 316 310 317 311 312 318 /** 313 * Prints the dependency chain. 314 * 315 * @returns Pointer to the allocated dependency. 316 * @param pOutput Output stream. 319 * 'Optimizes' and corrects the dependencies. 317 320 */ 318 static void depPrint(FILE *pOutput) 319 { 321 static void depOptimize(int fFixCase) 322 { 323 /* 324 * Walk the list correct the names and re-insert them. 325 */ 326 PDEP pDepOrg = g_pDeps; 320 327 PDEP pDep = g_pDeps; 321 for (pDep = g_pDeps; pDep; pDep = pDep->pNext) 322 { 328 g_pDeps = NULL; 329 for (; pDep; pDep = pDep->pNext) 330 { 331 #ifdef __WIN32__ 332 char szFilename[_MAX_PATH + 1]; 333 #else 334 char szFilename[PATH_MAX + 1]; 335 #endif 336 char *pszFilename; 323 337 struct stat s; 324 #ifdef __WIN32__325 char szFilename[_MAX_PATH + 1];326 #else327 char szFilename[PATH_MAX + 1];328 #endif329 char *pszFilename;330 char *psz;331 338 332 339 /* … … 344 351 if (pszFilename[1] == ':') 345 352 pszFilename += 2; 346 #endif 353 #endif 347 354 348 355 /* 349 356 * The microsoft compilers are notoriously screwing up the casing. 350 * This will screw with kmk (/ GNU Make) on case sensitive systems, it 351 * may even do so on win32... 357 * This will screw up kmk (/ GNU Make). 352 358 */ 353 if ( g_fFixCase)359 if (fFixCase) 354 360 { 355 361 #ifdef __WIN32__ … … 372 378 } 373 379 374 fprintf(pOutput, " \\\n\t%s", pszFilename); 375 } /* foreach dependency */ 380 /* 381 * Insert the corrected dependency. 382 */ 383 depAdd(pszFilename, strlen(pszFilename)); 384 } 385 386 #if 0 /* waste of time */ 387 /* 388 * Free the old ones. 389 */ 390 while (pDepOrg) 391 { 392 pDep = pDepOrg; 393 pDepOrg = pDepOrg->pNext; 394 free(pDep); 395 } 396 #endif 397 } 398 399 400 /** 401 * Prints the dependency chain. 402 * 403 * @returns Pointer to the allocated dependency. 404 * @param pOutput Output stream. 405 */ 406 static void depPrint(FILE *pOutput) 407 { 408 PDEP pDep; 409 for (pDep = g_pDeps; pDep; pDep = pDep->pNext) 410 fprintf(pOutput, " \\\n\t%s", pDep->szFilename); 376 411 fprintf(pOutput, "\n\n"); 412 } 413 414 415 /** 416 * Prints empty dependency stubs for all dependencies. 417 */ 418 static void depPrintStubs(FILE *pOutput) 419 { 420 PDEP pDep; 421 for (pDep = g_pDeps; pDep; pDep = pDep->pNext) 422 fprintf(pOutput, "%s:\n\n", pDep->szFilename); 377 423 } 378 424 … … 614 660 static void usage(const char *argv0) 615 661 { 616 printf("syntax: %s [-l=c] -o <output> -t <target> [-f] < - | <filename> | -e <cmdline> >\n", argv0);662 printf("syntax: %s [-l=c] -o <output> -t <target> [-f] [-s] < - | <filename> | -e <cmdline> >\n", argv0); 617 663 } 618 664 … … 627 673 FILE *pInput = NULL; 628 674 const char *pszTarget = NULL; 675 int fStubs = 0; 676 int fFixCase = 0; 629 677 /* Argument parsing. */ 630 678 int fInput = 0; /* set when we've found input argument. */ … … 747 795 case 'f': 748 796 { 749 g_fFixCase = 1; 797 fFixCase = 1; 798 break; 799 } 800 801 /* 802 * Generate stubs. 803 */ 804 case 's': 805 { 806 fStubs = 1; 750 807 break; 751 808 } … … 831 888 if (!i) 832 889 { 890 depOptimize(fFixCase); 833 891 fprintf(pOutput, "%s:", pszTarget); 834 892 depPrint(pOutput); 893 if (fStubs) 894 depPrintStubs(pOutput); 835 895 } 836 896
Note:
See TracChangeset
for help on using the changeset viewer.