home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # Copyright (c) 1993-1996 by Cayenne Software, Inc.
- #
- # This software is furnished under a license and may be used only in
- # accordance with the terms of such license and with the inclusion of
- # the above copyright notice. This software or any other copies thereof
- # may not be provided or otherwise made available to any other person.
- # No title to and ownership of the software is hereby transferred.
- #
- # The information in this software is subject to change without notice
- # and should not be construed as a commitment by Cayenne Software, Inc.
- #
- #---------------------------------------------------------------------------
- #
- # File : @(#)config.tcl /main/hindenburg/5
- # Author : peku
- # Original date : 17-11-1993
- # Description : script for C++ configuration
- #
- #---------------------------------------------------------------------------
- #
-
- source [m4_path_name tcl cginit.tcl]
-
- require wmt_util.tcl
- require machdep.tcl
-
- source [m4_path_name config tdb_config.tcl]
-
- #
- # Return base directory to install stuff
- #
-
- proc m4basedir {} {
- set clientContext [ClientContext::global]
-
- set configV [$clientContext currentConfig]
-
- if {[$configV isNil]} {
- return [m4_var get M4_home]
- }
-
- return [$configV path]
- }
-
- proc select_config {} {
- set configBase [location [m4_var get M4_home] config]
- cd $configBase
-
- global projcf
- set header_line "C++ configuration for "
-
- set clientContext [ClientContext::global]
- set configV [$clientContext currentConfig]
-
- if {[$configV isNil]} {
- set corp [$clientContext currentCorporate]
- append header_line "corporate environment '[$corp name]'"
- set projcf 0
- if {! [file writable $configBase]} {
- puts "You have no write permission in $configBase directory"
- puts "Select a project to configure first"
- return
- }
- } else {
- set confName [[$configV config] name]
- set confVersion [$configV versionName]
- append header_line "configuration version '${confName}.${confVersion}'"
- set projcf 1
- }
-
- while {"true"} {
- puts "\n\t$header_line"
- puts "\t[print_n [string length $header_line] -]"
- puts "\n\t\tC++ compiler\tClass Library\n"
- set dirs [glob cf_*]
- set count 1
- foreach dir $dirs {
- puts -nonewline "\t$count."
- incr count
- print_config $dir
- }
- puts "\n\tr.\tRemove C++ Configuration"
- puts -nonewline "\n\tChoice (q to quit): "
-
- set answer 1
- set answer [gets stdin]
- if {$answer == "q"} {
- return
- }
- if {$answer == "r"} {
- do_rm
- continue
- }
- set idx [check_answer $answer $count]
- if {$idx == "NOT_OK"} {
- continue
- }
- puts ""
- global choice_dir
- set choice_dir [lvarpop dirs $idx]
- set olddir [pwd]
- cd $choice_dir
- source subcfg.tcl
- do_config
- cd $olddir
- }
- }
-
- # return symbol 'count' times
-
- proc print_n {count symbol} {
- if {$count <= 0} {
- return
- }
- set result ""
- while {$count} {
- incr count -1
- append result $symbol
- }
- append result $symbol
- }
-
- proc check_answer {answer max} {
- if [catch {incr answer -1}] {
- # not a numeric
- return NOT_OK
- }
- incr max -1
- if {$answer >= 0 && $answer < $max} {
- return $answer
- }
- return NOT_OK
- }
-
- proc print_config {dir} {
- set fd [open [location $dir TITLE]]
- # skip first line
- gets $fd
- puts "\t[format "%-16s%-16s" [gets $fd] [gets $fd]]"
- close $fd
- }
-
- proc get_config_var {prompt var} {
- upvar $var lvar
- puts $prompt
- puts -nonewline "\[$lvar\]: "
- set tmp_def [string trim [gets stdin]]
- if {$tmp_def != ""} {
- set lvar $tmp_def
- }
- }
-
- proc findCustomizationFile {fullName {create 0}} {
- set name [lindex [split $fullName .] 0]
- set type [lindex [split $fullName .] 1]
- set clientContext [ClientContext::global]
-
- if {$projcf} {
- set configV [$clientContext currentConfig]
-
- set customFileV [$configV findCustomFileVersion $name $type]
-
- if {$create && [$customFileV isNil]} {
- puts "Creating customization file '$fullName' at configuration level"
- set customFileV [$configV createCustomFileVersion $name $type]
- }
-
- return $customFileV
- } else {
- set corporate [$clientContext currentCorporate]
-
- set customFileV [$corporate findCustomFileVersion $name $type]
-
- if {$create && [$customFileV isNil]} {
- puts "Creating customization file '$fullName' at corporate level"
-
- set customFileV [$corporate createCustomFileVersion $name $type] }
-
- return $customFileV
- }
- }
-
- proc config_file {dir custName cfg {fsName ""}} {
- upvar $cfg mycfg
-
- if {$fsName == ""} {
- set fsName $custName
- }
-
- set dirfile ""
- set result ""
- set matches 0
-
- set customFileV [findCustomizationFile $custName]
-
- if {[$customFileV isNil]} {
- set dirfile [path_name concat [location [m4basedir] $dir] $fsName]
-
- if {![file exists $dirfile]} {
- return -1
- }
- } else {
- set dirfile [args_file {}]
-
- $customFileV lockForWrite "Configure C++ Environment"
-
- $customFileV downLoad $dirfile
- }
-
- set fd [open $dirfile r]
-
- while {[gets $fd line] >= 0} {
- foreach subst [array names mycfg] {
- set patt [lindex $mycfg($subst) 0]
- set subspec [lindex $mycfg($subst) 1]
- if [regsub -all $patt $line $subspec line] {
- incr matches
- }
- }
- append result "$line\n"
- }
-
- close $fd
- unlink $dirfile
- set fd [open $dirfile w]
- puts -nonewline $fd $result
- close $fd
-
- if {! [$customFileV isNil] } {
- $customFileV upLoad $dirfile
-
- $customFileV unlock
-
- unlink $dirfile
- }
-
- return $matches
- }
-
- #
- # Add a config_file entry to remove any ranlib commands if
- # the current platform does not require any post-processing of
- # link libraries. Requires machdep.tcl to be loaded.
- #
- proc add_ranlib_config {cfg_ref} {
- upvar $cfg_ref cfg
- if {[processLibrary "libdummy.a"] == ""} {
- set ranlib_line ""
- set ranlib_patt ".*ranlib.*"
- set cfg(ranlib) [list $ranlib_patt $ranlib_line]
- }
- }
-
- #
- # Modify default Unix commands for windows compilers
- #
-
- proc add_win_config {cfg_ref} {
- upvar $cfg_ref cfg
-
- #
- # Configure filename extensions
- #
-
- set lib_patt {^LIBEXT =.*$}
- set lib_line "LIBEXT =\tlib"
- set obj_patt {^OBJEXT =.*$}
- set obj_line "OBJEXT =\tobj"
-
- set cfg(libext) [list $lib_patt $lib_line]
- set cfg(objext) [list $obj_patt $obj_line]
-
- #
- # Configure OS/compiler commands
- #
-
- set cp_patt {^CP =.*$}
- set cp_line "CP =\t\tcopy"
- set cxx_patt {^CXX =.*$}
- set cxx_line "CXX =\t\t$cxx_def"
- set mv_patt {^MV =.*$}
- set mv_line "MV =\t\trename"
- set rm_patt {^RM =.*$}
- set rm_line "RM =\t\trmf"
- set sh_patt {^SHELL=.*$}
- set sh_line ""
-
- set cfg(cp) [list $cp_patt $cp_line]
- set cfg(cxx) [list $cxx_patt $cxx_line]
- set cfg(mv) [list $mv_patt $mv_line]
- set cfg(rm) [list $rm_patt $rm_line]
- set cfg(sh) [list $sh_patt $sh_line]
-
- #
- # Default Informix incl directory is $INFORMIXDIR/incl/esql on Unix
- # and $INFORMIXDIR/incl on PC ...
- #
-
- if { [info exists env(INFORMIXDIR)] &&
- [file exists [location $env(INFORMIXDIR) incl]]} {
-
- if { [file exists [location $env(INFORMIXDIR) incl esql]] } {
- set infincdir_def [location $env(INFORMIXDIR) incl esql]
- set infincdir_line "INFINCDIR =\t$infincdir_def"
- } else {
- set infincdir_def [location $env(INFORMIXDIR) incl]
- set infincdir_line "INFINCDIR =\t$infincdir_def"
- }
-
- set infincdir_patt {^INFINCDIR =.*$}
- set cfg(infincdir) [list $infincdir_patt $infincdir_line]
- }
-
- #
- # Oracle preprocessor may be called proc or proc22 ...
- #
-
- if {[osIdentification] == "WIN"} {
- set oraHome [get env(ORACLE_HOME) [location C: ORACLE]]
- set procExt ".exe"
- } else {
- set oraHome [get env(ORACLE_HOME) [location /usr oracle]]
- set procExt ""
- }
-
- set oraBin [location $oraHome bin]
-
- if {[file exists [path_name concat $oraBin proc$procExt]]} {
- set proc_patt {^PROC =.*$}
- set proc_line "PROC =\t\t[path_name concat $oraBin proc]"
- set cfg(proc) [list $proc_patt $proc_line]
- } else {
- if {[file exists [path_name concat $oraBin proc22$procExt]]} {
- set proc_patt {^PROC =.*$}
- set proc_line "PROC =\t\t[path_name concat $oraBin proc22]"
- set cfg(proc) [list $proc_patt $proc_line]
- }
- }
-
- #
- # Remove chmod commands
- #
-
- set chmod_patt "^.*chmod.*$"
- set chmod_line ""
-
- set cfg(chmod) [list $chmod_patt $chmod_line]
-
- #
- # Modify conditional mkdir commands
- #
-
- set mkdir_patt "^\tif.*mkdir.*fi$"
- set mkdir_line "\t-mkdir $(INSTALLDIR)"
-
- set cfg(mkdir) [list $mkdir_patt $mkdir_line]
- }
-
- proc m4copyfile {dir custName {fsName ""}} {
- if {$fsName == ""} {
- set fsName $custName
- }
-
- if [file exists $fsName] {
- set sourcefile $fsName
- } else {
- set sourcefile [m4_path_name $dir $fsName]
- }
-
- set customFileV [findCustomizationFile $custName 1]
-
- $customFileV lockForWrite "Configure C++ Environment"
-
- $customFileV upLoad $sourcefile
-
- $customFileV unlock
- }
-
- proc m4copydir {dir} {
- set save_dir [pwd]
- set subdir [location config $dir]
-
- if [catch {set cddir [m4_path_name $subdir Makefile]}] {
- return
- }
-
- cd [path_name directory $cddir]
-
- set base [m4basedir]
-
- set files [glob -nocomplain Makefile *.{c,cxx,cp,ec,pc,sc}]
- set dest [location $base $dir]
- if {! [file exist $dest]} {
- mkdir -path [list $dest]
- }
-
- foreach file $files {
- puts "cp $file $dest"
- copy_text_file $file [location $dest $file]
- }
- set files [glob -nocomplain *.{h,hxx} ]
- set dest [location $base include]
- if {! [file exist $dest]} {
- mkdir -path [list $dest]
- }
- foreach file $files {
- puts "cp $file $dest"
- copy_text_file $file [location $dest $file]
- }
-
- cd $save_dir
- }
-
- proc do_config {} {
- foreach action [concat $set_default_actions $ask_actions] {
- $action
- }
- # next actions may have been reset by previous ones
- #
- foreach action [concat $copy_actions $config_actions $msg_actions] {
- $action
- }
- }
-
- proc puts_unlink {file} {
- if [file exists $file] {
- puts "rm $file"
- unlink -nocomplain $file
- }
- }
-
- proc do_rm {} {
- set verbose 1
- puts ""
-
- set cppconfCustomFileV [findCustomizationFile cpp_config.tcl]
- set maketmplCustomFileV [findCustomizationFile maketmpl.maketmpl]
- set clientContext [ClientContext::global]
- set customLevel ""
-
- if $projcf {
- set customLevel [$clientContext currentConfig]
- } else {
- set customLevel [$clientContext currentCorporate]
- }
-
- if {! [$cppconfCustomFileV isNil]} {
- puts "Removing customization file cpp_config.tcl"
- $customLevel remove $cppconfCustomFileV
- }
-
- if {! [$maketmplCustomFileV isNil]} {
- puts stderr "Removing customization file maketmpl.maketmpl"
- $customLevel remove $maketmplCustomFileV
- }
-
- set pdir [m4basedir]
-
- if [file exists [location $pdir src]] {
- puts stderr "Removing directory [location $pdir src]"
- BasicFS::removeDirAll [location $pdir src]
- }
-
- if [file exists [location $pdir include]] {
- puts stderr "Removing directory [location $pdir include]"
- BasicFS::removeDirAll [location $pdir include]
- }
-
- ###puts_unlink [location $pdir lib libdbobj.a]
- ###puts_unlink [location $pdir lib libwmt4omt.a]
-
- if {! [catch {rmdir [location $pdir lib] $verbose}]} {
- puts "rmdir [location $pdir lib]"
- }
- }
-
- unpack_package
- select_config
-