| 68 | # Create perl subports |
| 69 | proc perl5.create_subports {branches rootname} { |
| 70 | foreach v ${branches} { |
| 71 | subport p${v}-${rootname} { |
| 72 | depends_lib port:perl${v} |
| 73 | perl5.major ${v} |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | # Set perl variant options and defaults |
| 79 | options perl5.default_variant perl5.variant perl5.set_default_variant perl5.conflict_variants |
| 80 | default perl5.default_variant [string map {. _} perl${perl5.default_branch}] |
| 81 | default perl5.variant {[string map {. _} perl${perl5.major}]} |
| 82 | default perl5.set_default_variant {true} |
| 83 | default perl5.conflict_variants {true} |
| 84 | # Get variant names from branches |
| 85 | proc perl5.get_variant_names {branches} { |
| 86 | set ret {} |
| 87 | foreach branch ${branches} { |
| 88 | lappend ret "perl[string map {. _} ${branch}]" |
| 89 | } |
| 90 | return $ret |
| 91 | } |
| 92 | # Create perl variants |
| 93 | proc perl5.create_variants {branches} { |
| 94 | global perl5.major perl5.default_variant perl5.variant perl5.set_default_variant perl5.conflict_variants |
| 95 | set variants [perl5.get_variant_names ${branches}] |
| 96 | foreach branch ${branches} { |
| 97 | set index [lsearch ${branches} ${branch}] |
| 98 | set variant [lindex ${variants} ${index}] |
| 99 | # Add conflicts |
| 100 | set conflicts {} |
| 101 | if {${perl5.conflict_variants}} { |
| 102 | set conflicts "conflicts {[lreplace ${variants} ${index} ${index}]}" |
| 103 | } |
| 104 | eval "variant ${variant} ${conflicts} description Use MacPorts perl${branch} {}" |
| 105 | if {[variant_isset ${variant}]} { |
| 106 | perl5.variant ${variant} |
| 107 | } |
| 108 | } |
| 109 | # Set default perl variant |
| 110 | if {${perl5.default_variant} eq ${perl5.variant} && ${perl5.set_default_variant}} { |
| 111 | default_variants-append +${perl5.variant} |
| 112 | } |
| 113 | # Set perl version and deps |
| 114 | foreach branch ${branches} { |
| 115 | set index [lsearch ${branches} ${branch}] |
| 116 | set variant [lindex ${variants} ${index}] |
| 117 | if {[variant_isset ${variant}]} { |
| 118 | perl5.major ${branch} |
| 119 | depends_lib port:perl${branch} |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |