- Timestamp:
- Dec 1, 2006, 8:42:42 AM (19 years ago)
- Location:
- trunk/kBuild
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kBuild/footer.kmk
r594 r640 4 4 # kBuild - File included at top of makefile. 5 5 # 6 # Copyright (c) 2004-200 5knut st. osmundsen <bird-srcspam@anduin.net>6 # Copyright (c) 2004-2006 knut st. osmundsen <bird-srcspam@anduin.net> 7 7 # 8 8 # … … 50 50 # all targets. 51 51 ALL_TARGETS += \ 52 $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ 53 $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ 52 54 $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \ 53 55 $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ … … 61 63 # all $(BUILD_TARGET) targets. 62 64 _ALL_BUILD_TARGET_TARGETS += \ 63 $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \ 65 $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ 66 $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ 64 67 $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ 65 68 $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ … … 74 77 $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) 75 78 79 # all targets making use of srcname. 80 _ALL_SRCNAME_TARGETS += \ 81 $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ 82 $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) 83 76 84 # dependency files. 77 85 _DEPFILES := … … 91 99 # all of a type 92 100 _OBJS := 101 _FETCHES := 102 _DOWNLOADS:= 103 _UNPACKS := 104 _PATCHES := 93 105 _BLDPROGS := 94 106 _LIBS := … … 478 490 endef 479 491 492 define def_tools_srcname_target 493 _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg)) 494 _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch)) 495 _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu)) 496 497 $(foreach source, $(notdir\ 498 $($(target)_SOURCES.$(_bld_trg)) \ 499 $($(target)_SOURCES.$(_bld_trg_arch)) \ 500 $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \ 501 $($(target)_SOURCES.$(_bld_trg_cpu)) \ 502 $($(target)_SOURCES.$(BUILD_TYPE)) \ 503 $($(target)_SOURCES) \ 504 ), $(eval $(value def_tools_sdks_target_source))) 505 endef 506 480 507 bld_trg := $(BUILD_TARGET) 481 508 bld_trg_arch := $(BUILD_TARGET_ARCH) 482 509 bld_trg_cpu := $(BUILD_TARGET_CPU) 483 510 $(foreach target, $(_ALL_BUILD_TARGET_TARGETS), $(eval $(value def_tools_sdks_target))) 511 $(foreach target, $(_ALL_SRCNAME_TARGETS), $(eval $(value def_tools_srcname_target))) 484 512 485 513 bld_trg := $(BUILD_PLATFORM) … … 517 545 _SDKS := $(sort $(_SDKS)) 518 546 $(foreach sdk, $(_SDKS), $(eval $(value def_sdks_include_one))) 547 548 549 550 # 551 # Fetching Tools, Sources and Similar. 552 # 553 MD5SUM := md5sum 554 555 ## generates the fetch rule 556 define def_fetch_src_fetch_rule 557 # Indirect goal for downloading something. 558 $(out) $($(target)_$(srcname)_FETCH_OUTPUT_): | $($(target)_$(srcname)_FETCH_DEPORD_) 559 @$(ECHO) Downloading $(source)... 560 $$(RM) -f $(out) $(out).md5 ## @todo fancy stuff like download continuation 561 $($(target)_$(srcname)_FETCH_CMDS_) 562 @$(if $(md5),$(APPEND) $(out).md5 "$(subst 1,0,$(md5)) *$(out)") 563 $(if $(md5),$(MD5SUM) -c $(out).md5) 564 565 566 # Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary. 567 $(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_DEPEND_) | $($(target)_$(srcname)_FETCH_DEPORD_) 568 @$(ECHO) Checking $(out) ($(source))... 569 $$(RM) -f $$@ $(out).md5 570 @# creates the .md5 we pass to md5sum. 571 @$(if $(md5),$(APPEND) $(out).md5 "$(md5) *$(out)") 572 @# if the file exists, perform md5sum, otherwise just fetch it. 573 $(if $(wildcard $(out)),\ 574 $(MD5SUM) -c $(out).md5 || ( $(RM_EXT) -f $(out) && $(MAKE) -f $(MAKEFILE) $(out) ),\ 575 $(MAKE) -f $(MAKEFILE) $(out) ) 576 @$(APPEND) $$@ 577 578 _TARGET_$(target)_FETCHED += $(out).checked_$(md5)_$(size) 579 580 endef 581 582 ## generates the unpack rule 583 define def_fetch_src_unpack_rule 584 #$ (warning def_fetch_src_unpack_rule: source=$(source)) 585 586 # This is the unpack rule. it has an order-only dependency on the download check. 587 $(out) $($(target)_$(srcname)_UNPACK_OUTPUT_): $($(target)_$(srcname)_UNPACK_DEPEND_) \ 588 | $($(target)_$(srcname)_UNPACK_DEPORD_) $(archive).checked_$(md5)_$(size) 589 @$(ECHO) Unpacking $(source) into $(inst)... 590 $$(RM) -f $(out) 591 $($(target)_$(srcname)_UNPACK_CMDS_) 592 @$(APPEND) $(out) $(out) 593 @$(APPEND) $(out) $(out).check_$(md5)_$(size) 594 595 $(eval _TARGET_$(target)_UNPACKED += $(out)) 596 _TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size) 597 598 endef 599 600 ## Processes a fetch source 601 # 602 define def_fetch_src 603 #$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)') 604 605 # common 606 srcname := $(notdir $(source)) 607 inst := $(firstword \ 608 $($(target)_$(source)_INST)\ 609 $($(target)_$(srcname)_INST)\ 610 $($(source)_INST)\ 611 $($(srcname)_INST)\ 612 $($(target)_INST)\ 613 ) 614 ifneq ($(patsubst %/,ok,$(inst)),ok) 615 $(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst)) 616 endif 617 INSTARGET_$(target)_$(srcname) := $(inst) 618 fetchdir := $(firstword \ 619 $($(target)_$(source)_FETCHDIR)\ 620 $($(target)_$(srcname)_FETCHDIR)\ 621 $($(source)_FETCHDIR)\ 622 $($(srcname)_FETCHDIR)\ 623 $($(target)_FETCHDIR)\ 624 $(FETCHDIR)\ 625 $(PATH_TARGET)\ 626 ) 627 deps := \ 628 $($(target)_$(source)_DEPS)\ 629 $($(target)_$(srcname)_DEPS)\ 630 $($(source)_DEPS)\ 631 $($(srcname)_DEPS)\ 632 $($(target)_DEPS) 633 md5 := $(firstword \ 634 $($(target)_$(source)_MD5)\ 635 $($(target)_$(srcname)_MD5)\ 636 $($(source)_MD5)\ 637 $($(srcname)_MD5)\ 638 $($(target)_MD5)\ 639 ) 640 size := $(firstword \ 641 $($(target)_$(source)_SIZE)\ 642 $($(target)_$(srcname)_SIZE)\ 643 $($(source)_SIZE)\ 644 $($(srcname)_SIZE)\ 645 $($(target)_SIZE)\ 646 ) 647 dep := # not legal for fetch and unpack tools 648 649 650 # 651 # The fetching. 652 # 653 out := $(fetchdir)/$(srcname) 654 archive := $(out) 655 TARGET_$(target)_$(srcname) := $(out) 656 dirdep := $(call DIRDEP,$(fetchdir)) 657 tool := $(firstword \ 658 $($(target)_$(source)_FETCHTOOL)\ 659 $($(target)_$(srcname)_FETCHTOOL)\ 660 $($(target)_$(source)_TOOL)\ 661 $($(target)_$(srcname)_TOOL)\ 662 $($(source)_FETCHTOOL)\ 663 $($(srcname)_FETCHTOOL)\ 664 $($(source)_TOOL)\ 665 $($(srcname)_TOOL)\ 666 $($(target)_FETCHTOOL)\ 667 $($(target)_TOOL)\ 668 ) 669 flags :=\ 670 $(TOOL_$(tool)_FETCHFLAGS)\ 671 $(FETCHFLAGS)\ 672 $($(target)_FETCHFLAGS)\ 673 $($(srcname)_FETCHFLAGS)\ 674 $($(source)_FETCHFLAGS)\ 675 $($(target)_$(srcname)_FETCHFLAGS)\ 676 $($(target)_$(source)_FETCHFLAGS) 677 678 #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size)) 679 680 ifndef TOOL_$(tool)_FETCH_CMDS 681 $(warning kBuild: tools: \ 682 1 $($(target)_$(source)_FETCHTOOL)\ 683 2 $($(target)_$(srcname)_FETCHTOOL)\ 684 3 $($(target)_$(source)_TOOL)\ 685 4 $($(target)_$(srcname)_TOOL)\ 686 5 $($(source)_FETCHTOOL)\ 687 6 $($(srcname)_FETCHTOOL)\ 688 7 $($(source)_TOOL)\ 689 8 $($(srcname)_TOOL)\ 690 9 $($(target)_FETCHTOOL)\ 691 10 $($(target)_TOOL) ) 692 $(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) ) 693 endif 694 695 # call the tool 696 $(target)_$(srcname)_FETCH_CMDS_ := $(TOOL_$(tool)_FETCH_CMDS) 697 $(target)_$(srcname)_FETCH_OUTPUT_ := $(TOOL_$(tool)_FETCH_OUTPUT) 698 $(target)_$(srcname)_FETCH_DEPEND_ := $(TOOL_$(tool)_FETCH_DEPEND) $(deps) 699 $(target)_$(srcname)_FETCH_DEPORD_ := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep) 700 701 # generate the fetch rule. 702 $(eval $(def_fetch_src_fetch_rule)) 703 704 705 # 706 # The unpacking / installing. 707 # 708 out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst 709 dirdep := $(call DIRDEP,$(inst)) 710 tool := $(firstword \ 711 $($(target)_$(source)_UNPACKTOOL)\ 712 $($(target)_$(srcname)_UNPACKTOOL)\ 713 $($(target)_$(source)_TOOL)\ 714 $($(target)_$(srcname)_TOOL)\ 715 $($(source)_UNPACKTOOL)\ 716 $($(srcname)_UNPACKTOOL)\ 717 $($(source)_TOOL)\ 718 $($(srcname)_TOOL)\ 719 $($(target)_UNPACKTOOL)\ 720 $($(target)_TOOL) \ 721 ) 722 ifeq ($(tool),) 723 tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname))))) 724 $(eval $(value def_tools_include)) 725 endif 726 flags :=\ 727 $(TOOL_$(tool)_UNPACKFLAGS)\ 728 $(UNPACKFLAGS)\ 729 $($(target)_UNPACKFLAGS)\ 730 $($(srcname)_UNPACKFLAGS)\ 731 $($(source)_UNPACKFLAGS)\ 732 $($(target)_$(srcname)_UNPACKFLAGS)\ 733 $($(target)_$(source)_UNPACKFLAGS) 734 735 #$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size)) 736 ifndef TOOL_$(tool)_UNPACK_CMDS 737 $(warning kBuild: tools: \ 738 1 $($(target)_$(source)_UNPACKTOOL)\ 739 2 $($(target)_$(srcname)_UNPACKTOOL)\ 740 3 $($(target)_$(source)_TOOL)\ 741 4 $($(target)_$(srcname)_TOOL)\ 742 5 $($(source)_UNPACKTOOL)\ 743 6 $($(srcname)_UNPACKTOOL)\ 744 7 $($(source)_TOOL)\ 745 8 $($(srcname)_TOOL)\ 746 9 $($(target)_UNPACKTOOL)\ 747 10 $($(target)_TOOL) \ 748 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \ 749 ) 750 $(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) ) 751 endif 752 753 # call the tool 754 $(target)_$(srcname)_UNPACK_CMDS_ := $(TOOL_$(tool)_UNPACK_CMDS) 755 $(target)_$(srcname)_UNPACK_OUTPUT_ := $(TOOL_$(tool)_UNPACK_OUTPUT) 756 $(target)_$(srcname)_UNPACK_DEPEND_ := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps) 757 $(target)_$(srcname)_UNPACK_DEPORD_ := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep) 758 759 # generate the fetch rule. 760 $(eval $(def_fetch_src_unpack_rule)) 761 762 _DIRS += $(inst) $(fetchdir) 763 764 endef 765 766 767 ## 768 # Define the target level rules for a fetch. 769 # @param target 770 # @param out 771 # @param inst 772 # @param _TARGET_$(target)_FETCHED... 773 # @param bld_trg 774 # @param bld_trg_arch 775 define def_fetch_rules 776 777 $(out): $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst)) 778 @$(ECHO) Successfully fetched $(target) 779 $(RM) -f $$@ $$@.tmp 780 @$(APPEND) $$@.tmp "" 781 $(if $(_TARGET_$(target)_UNPACKED),$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp) 782 $(MV) -f $$@.tmp $$@ 783 784 $(out)_unfetched: 785 @$(ECHO) Unfetching $(target)... 786 $(RM) -f $$(shell $$(CAT_EXT) $(out) 2> /dev/null) 787 # figure out how to make this quiet... 788 -$(RMDIR) -p $(dir $(out)) $$(sort $$(dir $$(shell $$(CAT_EXT) $(out) 2> /dev/null))) 789 $(RM) -f $(out) 790 -$(RMDIR) -p $(dir $(out)) 791 792 endef 793 794 795 ## 796 # Deal with one fetch target. 797 # @param target 798 # @param bld_trg 799 # @param bld_trg_arch 800 define def_fetch 801 802 # common 803 INSTARGET_$(target) := $($(target)_INST) 804 ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok) 805 $(error kBuild: Bad or missing INST property for target '$(target)': $(INSTARGET_$(target))) 806 endif 807 _TARGET_$(target)_FETCHED := 808 _TARGET_$(target)_UNPACKED := 809 _TARGET_$(target)_DIGEST := 810 811 # The 'sources'. 812 #$ (warning dbg fetch: target=$(target) sources=$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))) 813 $(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\ 814 $(eval $(value def_fetch_src))) 815 816 # The target. 817 inst := $(INSTARGET_$(target)) 818 out := $(inst)_kBuild_fetch_$(target) 819 820 $(eval $(def_fetch_rules)) 821 822 _FETCHES += $(out) 823 _DOWNLOADS += $(_TARGET_$(target)_FETCHED) 824 _UNPACKS += $(_TARGET_$(target)_UNPACKED) 825 _UNFETCHES += $(out)_unfetched 826 _DIRS += $(inst) 827 828 endef 829 830 # Walk the FETCH target lists. 831 bld_trg := $(BUILD_TARGET) 832 bld_trg_arch := $(BUILD_TARGET_ARCH) 833 $(foreach target, $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \ 834 $(eval $(value def_fetch))) 835 836 # some aliases. 837 download: $(_DOWNLOADS) 838 unpack: $(_UNPACK) 839 fetches: $(_FETCHES) 840 unfetches: $(_UNFETCHES) 841 842 843 844 ## 845 ## Patching. 846 ## 847 ## 848 #define def_fetch_src 849 # 850 #endef 851 # 852 # 853 ## Deal with one patch target. 854 #define def_patch 855 # 856 #$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\ 857 # $(eval $(value def_patch_one))) 858 # 859 #_PATCHES += 860 #endef 861 # 862 #$(foreach target, $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \ 863 # $(eval $(value def_patch))) 864 # 519 865 520 866 -
trunk/kBuild/header.kmk
r601 r640 508 508 DEFAULT_MAKEFILE := Makefile.kmk makefile.kmk Makefile makefile 509 509 510 ## PROPS_TOOLS 511 # This is a subset of the other PROPS 512 PROPS_TOOLS := TOOL CTOOL CXXTOOL ASTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL 513 510 514 ## PROPS_SINGLE 511 515 # The list of non-accumulative target properties. 512 516 # A Config.kmk file can add it's own properties to this list and kBuild 513 517 # will do the necessary inheritance from templates to targets. 514 PROPS_SINGLE := TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL INST NOINST518 PROPS_SINGLE := $(PROPS_TOOLS) INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU FETCHDIR 515 519 516 520 ## PROPS_DEFERRED … … 528 532 ASOPTS ASFLAGS ASDEFS ASINCS \ 529 533 LDFLAGS LIBS LIBPATH \ 530 BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU \531 534 SYSSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \ 532 533 534 ## PROPS_TOOLS 535 # This is a subset of the other PROPS 536 PROPS_TOOLS := TOOL CTOOL CXXTOOL ASTOOL ARTOOL LDTOOL 535 FETCHFLAGS UNPACKFLAGS PATCHFLAGS 537 536 538 537 … … 544 543 # The PASS_<passname>_pass variable is the lowercased passname. 545 544 # 545 546 ## PASS: fetches 547 # This pass fetches and unpacks things needed to complete the build. 548 PASS_FETCHES := Fetches 549 PASS_FETCHES_trgs := 550 PASS_FETCHES_vars := _FETCHES 551 PASS_FETCHES_pass := fetches 552 553 ## PASS: patches 554 # This pass applies patches. 555 PASS_PATCHES := Patches 556 PASS_PATCHES_trgs := 557 PASS_PATCHES_vars := _PATCHES 558 PASS_PATCHES_pass := patches 546 559 547 560 ## PASS: bldprogs … … 621 634 # The passes that should be defined. This must include 622 635 # all passes mentioned by DEFAULT_PASSES. 623 PASSES := $(DEFAULT_PASSES) NOTHING CLEAN636 PASSES := FETCHES PATCHES $(DEFAULT_PASSES) NOTHING CLEAN 624 637 625 638
Note:
See TracChangeset
for help on using the changeset viewer.