Changeset 1126 in kBuild
- Timestamp:
- Sep 26, 2007 4:41:31 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/main.c
r940 r1126 1576 1576 } 1577 1577 1578 #ifdef KMK1579 /* If there wasn't any -C or -f flags, check for Makefile.kup and1580 insert a fake -C argument.1581 Makefile.kmk overrides Makefile.kup but not plain Makefile. */1582 if (makefiles == 0 && directories == 0)1583 {1584 struct stat st;1585 if (( stat ("Makefile.kup", &st) == 01586 && S_ISREG (st.st_mode) )1587 || ( stat ("makefile.kup", &st) == 01588 && S_ISREG (st.st_mode) )1589 && stat ("Makefile.kmk", &st) < 01590 && stat ("makefile.kmk", &st) < 0)1591 {1592 static char fake_path[3*16 + 32] = "..";1593 static const char *fake_list[2] = { &fake_path[0], NULL };1594 struct stringlist fake_directories = { &fake_list[0], 1, 0 };1595 1596 char *cur = &fake_path[2];1597 int up_levels = 1;1598 1599 while (up_levels < 16)1600 {1601 /* File with higher precedence.s */1602 strcpy (cur, "/Makefile.kmk");1603 if (stat (fake_path, &st) == 0)1604 break;1605 strcpy (cur, "/makefile.kmk");1606 if (stat (fake_path, &st) == 0)1607 break;1608 1609 /* the .kup files */1610 strcpy (cur, "/Makefile.kup");1611 if ( stat (fake_path, &st) != 01612 || !S_ISREG (st.st_mode))1613 {1614 strcpy (cur, "/makefile.kup");1615 if ( stat (fake_path, &st) != 01616 || !S_ISREG (st.st_mode))1617 break;1618 }1619 1620 /* ok */1621 strcpy (cur, "/..");1622 cur += 3;1623 up_levels++;1624 }1625 1626 if (up_levels >= 16)1627 fatal (NILF, _("Makefile.kup recursion is too deep."));1628 1629 *cur = '\0';1630 directories = &fake_directories;1631 }1632 }1633 #endif /* KMK */1634 1635 1578 /* If there were -C flags, move ourselves about. */ 1636 1579 if (directories != 0) … … 1654 1597 } 1655 1598 } 1599 1600 #ifdef KMK 1601 /* Check for [Mm]akefile.kup and change directory when found. 1602 Makefile.kmk overrides Makefile.kup but not plain Makefile. 1603 If no -C arguments were given, fake one to indicate chdir. */ 1604 if (makefiles == 0) 1605 { 1606 struct stat st; 1607 if (( stat ("Makefile.kup", &st) == 0 1608 && S_ISREG (st.st_mode) ) 1609 || ( stat ("makefile.kup", &st) == 0 1610 && S_ISREG (st.st_mode) ) 1611 && stat ("Makefile.kmk", &st) < 0 1612 && stat ("makefile.kmk", &st) < 0) 1613 { 1614 static char fake_path[3*16 + 32] = ".."; 1615 char *cur = &fake_path[2]; 1616 int up_levels = 1; 1617 while (up_levels < 16) 1618 { 1619 /* File with higher precedence.s */ 1620 strcpy (cur, "/Makefile.kmk"); 1621 if (stat (fake_path, &st) == 0) 1622 break; 1623 strcpy (cur, "/makefile.kmk"); 1624 if (stat (fake_path, &st) == 0) 1625 break; 1626 1627 /* the .kup files */ 1628 strcpy (cur, "/Makefile.kup"); 1629 if ( stat (fake_path, &st) != 0 1630 || !S_ISREG (st.st_mode)) 1631 { 1632 strcpy (cur, "/makefile.kup"); 1633 if ( stat (fake_path, &st) != 0 1634 || !S_ISREG (st.st_mode)) 1635 break; 1636 } 1637 1638 /* ok */ 1639 strcpy (cur, "/.."); 1640 cur += 3; 1641 up_levels++; 1642 } 1643 1644 if (up_levels >= 16) 1645 fatal (NILF, _("Makefile.kup recursion is too deep.")); 1646 1647 /* attempt to change to the directory. */ 1648 *cur = '\0'; 1649 if (chdir (fake_path) < 0) 1650 pfatal_with_name (fake_path); 1651 1652 /* add the string to the directories. */ 1653 if (!directories) 1654 { 1655 directories = xmalloc (sizeof(*directories)); 1656 directories->list = xmalloc (5 * sizeof (char *)); 1657 directories->max = 5; 1658 directories->idx = 0; 1659 } 1660 else if (directories->idx == directories->max - 1) 1661 { 1662 directories->max += 5; 1663 directories->list = xrealloc ((void *)directories->list, 1664 directories->max * sizeof (char *)); 1665 } 1666 directories->list[directories->idx++] = fake_path; 1667 } 1668 } 1669 #endif /* KMK */ 1656 1670 1657 1671 #ifdef WINDOWS32
Note:
See TracChangeset
for help on using the changeset viewer.