| 762 | # Helper function for set_compiler_dependencies. Used to force |
| 763 | # "depends_FOO" to act like "depends_FOO-append"; otherwise portfiles |
| 764 | # would overwrite the automatic compiler dependencies with their |
| 765 | # "depends_FOO" statements. |
| 766 | proc portconfigure::hijack_option {option} { |
| 767 | if {[exists $option]} {return} |
| 768 | interp alias {} $option {} handle_option-append $option |
| 769 | } |
| 770 | |
| 771 | # Automatically add the necessary dependency when setting the compiler. |
| 772 | proc portconfigure::set_compiler_dependencies {option action args} { |
| 773 | switch $action { |
| 774 | read { |
| 775 | if {$option ne "configure.compiler"} {return} |
| 776 | if {![info exists ::option_defaults(configure.compiler)]} {return} |
| 777 | if {[info exists portconfigure::compiler_port]} {return} |
| 778 | } |
| 779 | set { |
| 780 | if {$option ne "configure.compiler" && |
| 781 | ![info exists ::option_defaults(configure.compiler)] |
| 782 | } then { |
| 783 | return |
| 784 | } |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | if {[info exists portconfigure::compiler_port]} { |
| 789 | depends_lib-delete port:$portconfigure::compiler_port |
| 790 | depends_build-delete port:$portconfigure::compiler_port |
| 791 | depends_skip_archcheck-delete $portconfigure::compiler_port |
| 792 | unset portconfigure::compiler_port |
| 793 | } |
| 794 | |
| 795 | global configure.compiler |
| 796 | set compiler [subst ${configure.compiler}] |
| 797 | |
| 798 | # For the compiler lists, triggering the configure.compiler read |
| 799 | # trace is sufficient. |
| 800 | if {$option ne "configure.compiler" || ![compiler_is_port $compiler]} { |
| 801 | return |
| 802 | } |
| 803 | |
| 804 | variable compiler_port $portconfigure::compiler_name_map($compiler) |
| 805 | if {[string match "macports-gcc*" $compiler]} { |
| 806 | hijack_option depends_lib |
| 807 | depends_lib-append port:$portconfigure::compiler_port |
| 808 | } else { |
| 809 | hijack_option depends_build |
| 810 | depends_build-append port:$portconfigure::compiler_port |
| 811 | } |
| 812 | if {[arch_flag_supported $compiler]} { |
| 813 | hijack_option depends_skip_archcheck |
| 814 | depends_skip_archcheck-append $portconfigure::compiler_port |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | # Set traces on all values that might affect the compiler selection. |
| 819 | option_proc compiler.fallback portconfigure::set_compiler_dependencies |
| 820 | option_proc compiler.blacklist portconfigure::set_compiler_dependencies |
| 821 | option_proc compiler.whitelist portconfigure::set_compiler_dependencies |
| 822 | option_proc configure.compiler portconfigure::set_compiler_dependencies |
| 823 | |
| 824 | default configure.compiler {[portconfigure::configure_get_default_compiler]} |
| 825 | |
| 826 | |