home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
makemake.tcl
< prev
next >
Wrap
Text File
|
1997-11-17
|
7KB
|
286 lines
#---------------------------------------------------------------------------
#
# Copyright (c) 1992-1995 by Cadre Technologies 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 Cadre Technologies Inc.
#
#---------------------------------------------------------------------------
#
# File : @(#)makemake.tcl /main/titanic/11 (1.12)
# Author : frmo
# Original date : 1-8-1992
# Description : makefile generator
#
#---------------------------------------------------------------------------
#
if {[info procs require] == ""} {
source [m4_path_name tcl cginit.tcl]
}
OTShRegister::tdbOp
require legacy.tcl
require make_msg.tcl
require wmt_util.tcl
require machdep.tcl
require makedefs.tcl
if {[info procs fstorage::dir] == ""} {
require fstorage.tcl
}
# Type en source info
#
global SRC_TYPES
global TGT_TYPES
global SOURCES
# Make info
#
global make_tmpl_type
global make_type
# Client context
#
global clientContext; set clientContext [ClientContext::global]
# Main function
#
proc makemake {} {
m4_message $M_GEN_MAKEFILE
if {![$clientContext customFileExists maketmpl maketmpl etc 1]} {
if [$clientContext customFileExists configure tcl tcl 1] {
require "configure.tcl"
}
}
if {![$clientContext customFileExists maketmpl maketmpl etc 1]} {
m4_error $E_NO_MAKETMPL
return -1
}
if {[init_make_globs] == -1} {
return -1
}
read_file_types
if {[catch {set fp [fstorage::open makefile.$make_type w]} reason]} {
puts stderr $reason
m4_error $E_FILE_OPEN_WRITE makefile.$make_type
return -1
}
set sect [TextSection new]
expandHeaderIntoSection makefile $make_type $sect
set contents [$clientContext getCustomFileContents maketmpl maketmpl etc]
expand_text $sect $contents
$sect write $fp
fstorage::close $fp
return 0
}
# Determine the make globals: make_tmpl_type and make_type
#
proc init_make_globs {} {
global make_type; set make_type makefile
global make_tmpl_type; set make_tmpl_type maketmpl
return 0
}
# Determine types of all files and build the global type lists, also build
# source file list
#
proc read_file_types {} {
global SRC_TYPES; set SRC_TYPES ""
global TGT_TYPES; set TGT_TYPES ""
global SOURCES; set SOURCES ""
set modHandler [ModuleHandler new]
$modHandler setCurrentContext
set custObjHandler [CustObjHandler new $modHandler]
foreach objSpec [$custObjHandler currentObjectSpecSet] {
switch [$objSpec makeType] {
source {lappend SRC_TYPES [$objSpec browserType]}
target {lappend TGT_TYPES [$objSpec browserType]}
}
}
set SOURCES [lsort [fstorage::dir $SRC_TYPES]]
}
# make file names out of a list of pdb name.type entries
#
proc file_names {list} {
set result ""
foreach file $list {
lappend result [fstorage::get_uenv_path $file]
}
return $result
}
# Expand 'text' for each target of type 'type'
#
proc mm_foreach_target {type_list text} {
upvar current_section current_section
foreach target [fstorage::dir $type_list] {
expand_text $current_section $text
}
}
# Return the dependencies of 'target' that have a type that is in 'typelist'.
# Format the dependencies by replacing their extension with 'ext' and
# separating them with 'sep'. The dependencies are kept in a global list
# so that a dependency list can be generated later
# Only add a dependency to the global list if 'ext' is in SRC_TYPES
#
proc mm_dependencies {{types -} {ext .$OBJ_EXT} {sep ""}} {
set all_deps ""
set result ""
if {$types == "-"} {
set all_deps $SOURCES
} else {
return $result
}
foreach dep $all_deps {
set depfile "[nt_get_name [fstorage::get_uenv_path $dep]]$ext"
append result "$sep $depfile"
}
return $result
}
# Return the files of a certain type, possibly prefixed (sorted)
#
proc mm_files {{types -} {prefix ""}} {
if {$types == "-"} {
set types $TGT_TYPES
}
set result ""
if {$prefix == ""} {
set result [file_names [fstorage::dir $types]]
} else {
foreach file [file_names [fstorage::dir $types]] {
append result "$prefix$file "
}
}
return [lsort $result]
}
# Return a suitable name for an OBJ macro
#
proc mm_obj_name {} {
upvar target target
return "OBJ[nt_get_name $target][nt_get_type $target]"
}
# Return the name of the target
#
proc mm_tgt_name {} {
upvar target target
return [nt_get_name $target]
}
# Return the path to the target
#
proc mm_tgt_path {} {
upvar target target
return [fstorage::get_uenv_path $target]
}
# Return the path to the installation directory, depending on target
#
proc mm_install_path {target} {
global clientContext
set sysV [$clientContext currentSystem]
if [$sysV isNil] {
return ""
}
return [$sysV path]
}
# Construct the ranlib command
#
# Requires 'proc processLibrary' to be defined in machdep.tcl
#
proc mm_process_lib {args} {
return [processLibrary $args]
}
# Return the X Window System include directory
#
# Requires 'proc XIncludeDir' to be defined in machdep.tcl
#
proc mm_x_include_dir {} {
return [XIncludeDir]
}
# Return an identification of the current platform.
#
# Result is a list with as first element the OS, as
# second element the OS version.
#
# Requires 'proc osIdentification' to be defined in machdep.tcl
#
proc mm_os_ident {} {
return [osIdentification]
}
# Return the libraries to linked to a TDB dependent application
#
# Already contains any -l and -L options needed.
#
# Requires 'proc dbmsLinkLibrary' to be defined in machdep.tcl
#
proc mm_dbms_libs {} {
return [dbmsLinkLibrary]
}
# Return the complete dependency list for all objects
#
proc mm_all_deps {} {
set result ""
if [file exists depend.h] {
read_file_into_text depend.h result
return $result
}
}
# Look for the customization u_makemake.tcl file
#
if {[$clientContext customFileExists u_makemake tcl "" 0]} {
require u_makemake.tcl
}
# Just call makemake
#
if {![info exists dontCallMakeMake]} {
if [catch {makemake}] {
puts stderr $errorInfo
}
}