| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| if {[is-defined defaultprefix]} { |
| user-notice "Note: defaultprefix is deprecated. Use options-defaults to set default options" |
| options-defaults [list prefix [get-define defaultprefix]] |
| } |
|
|
| options { |
| host:host-alias => {a complete or partial cpu-vendor-opsys for the system where |
| the application will run (defaults to the same value as --build)} |
| build:build-alias => {a complete or partial cpu-vendor-opsys for the system |
| where the application will be built (defaults to the |
| result of running config.guess)} |
| prefix:dir=/usr/local => {the target directory for the build (default: '@default@')} |
|
|
| |
| exec-prefix: |
| bindir: |
| sbindir: |
| includedir: |
| mandir: |
| infodir: |
| libexecdir: |
| datadir: |
| libdir: |
| sysconfdir: |
| sharedstatedir: |
| localstatedir: |
| runstatedir: |
| maintainer-mode=0 |
| dependency-tracking=0 |
| silent-rules=0 |
| program-prefix: |
| program-suffix: |
| program-transform-name: |
| x-includes: |
| x-libraries: |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| proc check-feature {name code} { |
| msg-checking "Checking for $name..." |
| set r [uplevel 1 $code] |
| define-feature $name $r |
| if {$r} { |
| msg-result "ok" |
| } else { |
| msg-result "not found" |
| } |
| return $r |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| proc have-feature {name {default 0}} { |
| get-define [feature-define-name $name] $default |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| proc define-feature {name {value 1}} { |
| define [feature-define-name $name] $value |
| } |
|
|
| |
| |
| |
| |
| proc feature-checked {name} { |
| is-defined [feature-define-name $name] |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| proc feature-define-name {name {prefix HAVE_}} { |
| string toupper $prefix[regsub -all {[^a-zA-Z0-9]} [regsub -all {[*]} $name p] _] |
| } |
|
|
| |
| |
| |
| |
| |
| |
| proc write-if-changed {file buf {script {}}} { |
| set old [readfile $file ""] |
| if {$old eq $buf && [file exists $file]} { |
| msg-result "$file is unchanged" |
| } else { |
| writefile $file $buf\n |
| uplevel 1 $script |
| } |
| } |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| proc include-file {infile mapping} { |
| |
| |
| set condstack {1} |
| set result {} |
| set linenum 0 |
| foreach line [split [readfile $infile] \n] { |
| incr linenum |
| if {[regexp {^@(if|else|endif)(\s*)(.*)} $line -> condtype condspace condargs]} { |
| if {$condtype eq "if"} { |
| if {[string length $condspace] == 0} { |
| autosetup-error "$infile:$linenum: Invalid expression: $line" |
| } |
| if {[llength $condargs] == 1} { |
| |
| |
| lassign $condargs condvar |
| if {[regexp {^!(.*)} $condvar -> condvar]} { |
| set op in |
| } else { |
| set op ni |
| } |
| set condexpr "\[[list get-define $condvar]\] $op {0 {}}" |
| } else { |
| |
| |
| regsub -all {([A-Z][[:alnum:]_]*)} $condargs {[get-define \1]} condexpr |
| } |
| if {[catch [list expr $condexpr] condval]} { |
| dputs $condval |
| autosetup-error "$infile:$linenum: Invalid expression: $line" |
| } |
| dputs "@$condtype: $condexpr => $condval" |
| } |
| if {$condtype ne "if"} { |
| if {[llength $condstack] <= 1} { |
| autosetup-error "$infile:$linenum: Error: @$condtype missing @if" |
| } elseif {[string length $condargs] && [string index $condargs 0] ne "#"} { |
| autosetup-error "$infile:$linenum: Error: Extra arguments after @$condtype" |
| } |
| } |
| switch -exact $condtype { |
| if { |
| |
| lappend condstack $condval |
| } |
| else { |
| |
| set condval [lpop condstack] |
| set condval [expr {!$condval}] |
| lappend condstack $condval |
| } |
| endif { |
| if {[llength $condstack] == 0} { |
| user-notice "$infile:$linenum: Error: @endif missing @if" |
| } |
| lpop condstack |
| } |
| } |
| continue |
| } |
| |
| if {"0" in $condstack} { |
| continue |
| } |
| if {[regexp {^@include\s+(.*)} $line -> filearg]} { |
| set incfile [string map $mapping $filearg] |
| if {[file exists $incfile]} { |
| lappend ::autosetup(deps) [file-normalize $incfile] |
| lappend result {*}[include-file $incfile $mapping] |
| } else { |
| user-error "$infile:$linenum: Include file $incfile is missing" |
| } |
| continue |
| } |
| if {[regexp {^@define\s+(\w+)\s+(.*)} $line -> var val]} { |
| define $var $val |
| continue |
| } |
| lappend result $line |
| } |
| return $result |
| } |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| proc make-template {template {out {}}} { |
| set infile [file join $::autosetup(srcdir) $template] |
|
|
| if {![file exists $infile]} { |
| user-error "Template $template is missing" |
| } |
|
|
| |
| define AUTODEPS $::autosetup(deps) |
|
|
| if {$out eq ""} { |
| if {[file ext $template] ne ".in"} { |
| autosetup-error "make_template $template has no target file and can't guess" |
| } |
| set out [file rootname $template] |
| } |
|
|
| set outdir [file dirname $out] |
|
|
| |
| file mkdir $outdir |
|
|
| |
| define srcdir [relative-path [file join $::autosetup(srcdir) $outdir] $outdir] |
| define top_srcdir [relative-path $::autosetup(srcdir) $outdir] |
|
|
| |
| |
| proc build-define-mapping {} { |
| set mapping {} |
| foreach {n v} [array get ::define] { |
| lappend mapping @$n@ $v |
| } |
| return $mapping |
| } |
| set mapping [build-define-mapping] |
|
|
| set result [include-file $infile $mapping] |
|
|
| |
| |
| |
| set mapping [build-define-mapping] |
| write-if-changed $out [string map $mapping [join $result \n]] { |
| msg-result "Created [relative-path $out] from [relative-path $template]" |
| } |
| } |
|
|
| proc system-init {} { |
| global autosetup |
|
|
| |
| opt-str build build "" |
| define build_alias $build |
| if {$build eq ""} { |
| define build [config_guess] |
| } else { |
| define build [config_sub $build] |
| } |
|
|
| opt-str host host "" |
| define host_alias $host |
| if {$host eq ""} { |
| define host [get-define build] |
| set cross "" |
| } else { |
| define host [config_sub $host] |
| set cross $host- |
| } |
| define cross [get-env CROSS $cross] |
|
|
| |
| foreach type {build host} { |
| set v [get-define $type] |
| if {![regexp {^([^-]+)-([^-]+)-(.*)$} $v -> cpu vendor os]} { |
| user-error "Invalid canonical $type: $v" |
| } |
| define ${type}_cpu $cpu |
| define ${type}_vendor $vendor |
| define ${type}_os $os |
| } |
|
|
| opt-str prefix prefix /usr/local |
|
|
| |
| define target [get-define host] |
| define prefix $prefix |
| define builddir $autosetup(builddir) |
| define srcdir $autosetup(srcdir) |
| define top_srcdir $autosetup(srcdir) |
| define abs_top_srcdir [file-normalize $autosetup(srcdir)] |
| define abs_top_builddir [file-normalize $autosetup(builddir)] |
|
|
| |
| define exec_prefix [opt-str exec-prefix exec_prefix $prefix] |
| foreach {name defpath} { |
| bindir /bin |
| sbindir /sbin |
| libexecdir /libexec |
| libdir /lib |
| } { |
| define $name [opt-str $name o $exec_prefix$defpath] |
| } |
| foreach {name defpath} { |
| datadir /share |
| sharedstatedir /com |
| infodir /share/info |
| mandir /share/man |
| includedir /include |
| } { |
| define $name [opt-str $name o $prefix$defpath] |
| } |
| if {$prefix ne {/usr}} { |
| opt-str sysconfdir sysconfdir $prefix/etc |
| } else { |
| opt-str sysconfdir sysconfdir /etc |
| } |
| define sysconfdir $sysconfdir |
|
|
| define localstatedir [opt-str localstatedir o /var] |
| define runstatedir [opt-str runstatedir o /run] |
|
|
| define SHELL [get-env SHELL [find-an-executable sh bash ksh]] |
|
|
| |
| define AM_SILENT_RULES [opt-bool silent-rules] |
| define AM_MAINTAINER_MODE [opt-bool maintainer-mode] |
| define AM_DEPENDENCY_TRACKING [opt-bool dependency-tracking] |
|
|
| |
| switch -glob -- [get-define host] { |
| *-*-ming* - *-*-cygwin - *-*-msys { |
| define-feature windows |
| define EXEEXT .exe |
| } |
| default { |
| define EXEEXT "" |
| } |
| } |
|
|
| |
| msg-result "Host System...[get-define host]" |
| msg-result "Build System...[get-define build]" |
| } |
|
|
| system-init |
|
|