home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / tdb_config.tcl < prev    next >
Text File  |  1996-09-11  |  5KB  |  221 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. # Copyright (c) 1995-1996 by Cayenne Software, Inc.
  4. #
  5. # This software is furnished under a license and may be used only in
  6. # accordance with the terms of such license and with the inclusion of
  7. # the above copyright notice. This software or any other copies thereof
  8. # may not be provided or otherwise made available to any other person.
  9. # No title to and ownership of the software is hereby transferred.
  10. #
  11. # The information in this software is subject to change without notice
  12. # and should not be construed as a commitment by Cayenne Software, Inc.
  13. #
  14. #---------------------------------------------------------------------------
  15. #
  16. #    File        : @(#)tdb_config.tcl    /main/hindenburg/2
  17. #    Author        : edri
  18. #    Original date    : 16-01-1995
  19. #    Description    : Target DB dependent routines, called from */subcfg.tcl
  20. #
  21. #---------------------------------------------------------------------------
  22. #
  23.  
  24. require machdep.tcl
  25.  
  26. #
  27. # Gen
  28. #
  29. proc GEN::copy {} {
  30. }
  31.  
  32. proc GEN::config {} {
  33. }
  34.  
  35. #
  36. # Informix
  37. #
  38.  
  39. if {[osIdentification] == "WIN"} {
  40.     set INFORMIX::headers "sqlca.h sqlhdr.h sqlproto.h"
  41. } else {
  42.     set INFORMIX::headers "sqlhdr.h"
  43. }
  44.  
  45. proc INFORMIX::copy {} {
  46.     global projcf
  47.     if {$projcf == "0"} {
  48.         # Only do this at project configuration time, else m4create_env fails.
  49.         return
  50.     }
  51.  
  52.     #
  53.     # Copy the sqlhdr.h file from $INFORMIXDIR, so we can configure it for
  54.     # use with a C++ compiler.
  55.     #
  56.  
  57.     if {[osIdentification] == "WIN"} {
  58.     set inf [get env(INFORMIXDIR) [location C: INFORMIX]]
  59.     } else {
  60.     set inf [get env(INFORMIXDIR) [location /usr informix]]
  61.     }
  62.  
  63.     foreach baseName ${INFORMIX::headers} {
  64.     set fullName [path_name concat [location $inf incl esql] $baseName]
  65.  
  66.     #
  67.     # On PC include files are in different directory ...
  68.     #
  69.  
  70.     if {! [file exists $fullName]} {
  71.         set fullName [path_name concat [location $inf incl] $baseName]
  72.     }
  73.  
  74.     set m4sqlpath [location [m4basedir] include]
  75.     set m4hdrpath [path_name concat $m4sqlpath $baseName]
  76.  
  77.     if {! [file isdirectory $m4sqlpath]} {
  78.         mkdir $m4sqlpath
  79.     }
  80.  
  81.     puts "cp $fullName $m4hdrpath"
  82.  
  83.     if {[catch {copy_text_file $fullName $m4hdrpath} msg]} {
  84.         puts stderr ""
  85.         puts stderr "ERROR: Could not copy $fullName, set INFORMIXDIR properly!"
  86.         puts stderr "($msg)"
  87.         puts stderr ""
  88.         return
  89.     }
  90.     }
  91.  
  92.     global freshly_copied
  93.     set freshly_copied 1
  94. }
  95.  
  96. proc INFORMIX::config {} {
  97.     global projcf
  98.     if {$projcf == "0"} {
  99.         # Only do this at project configuration time, else m4create_env fails.
  100.         return
  101.     }
  102.  
  103.     global freshly_copied
  104.     if {![info exists freshly_copied] || $freshly_copied != "1"} { 
  105.         return
  106.     } else {
  107.         set freshly_copied 0
  108.     }
  109.  
  110.     if {[osIdentification] == "WIN"} {
  111.     return [INFORMIX::winConfig]
  112.     } else {
  113.     return [INFORMIX::unixConfig]
  114.     }
  115. }
  116.  
  117. proc INFORMIX::winConfig {} {
  118.     set m4sqlpath [location [m4basedir] include]
  119.  
  120.     set extern_patt {^extern }
  121.     set extern_sub {extern "C" }
  122.     set cfg(extern) [list $extern_patt $extern_sub]
  123.     set sqlret_patt {^SQLRET }
  124.     set sqlret_sub {extern "C" SQLRET }
  125.     set cfg(sqlret) [list $sqlret_patt $sqlret_sub]
  126.     set sqllps_patt {^_LPSQCURSOR }
  127.     set sqllps_sub {extern "C" _LPSQCURSOR }
  128.     set cfg(sqllps) [list $sqllps_patt $sqllps_sub]
  129.  
  130.     foreach baseName ${INFORMIX::headers} {
  131.     config_file include $baseName cfg
  132.     }
  133. }
  134.  
  135. proc INFORMIX::unixConfig {} {
  136.     #
  137.     # Fix up the Informix sqlhdr.h from $INFORMIXDIR/incl/esql/sqlhdr.h,
  138.     # because it contains K&R externs which can't be used with a C++
  139.     # compiler.
  140.     #
  141.  
  142.     #
  143.     # Remove K&R C externs
  144.     #
  145.     set pat {^extern.*();$}
  146.     set sub {}
  147.     set extern_cfg(externs) [list $pat $sub]
  148.  
  149.     #
  150.     # Add C++ prototypes
  151.     #
  152.     set pat {^#endif.*_SQLHDR.*$}
  153.     set sub "\n
  154. #ifdef __cplusplus
  155. extern \"C\" {
  156.     _SQCURSOR*      _iqnprep( ... );
  157.     _SQCURSOR*      _iqlocate_cursor( ... );
  158. }
  159. #endif
  160.  
  161. #endif /* _SQLHDR */\n"
  162.     set protos_cfg(protos) [list $pat $sub]
  163.  
  164.     puts ""
  165.     puts "Configuring sqlhdr.h ..."
  166.  
  167.     set m [config_file include sqlhdr.h extern_cfg]
  168.     if {$m == -1} {
  169.         puts "  Skipping because sqlhdr.h was not copied correctly!"
  170.     } else {
  171.         puts "  Removed $m K&R style externs"
  172.  
  173.     set m [config_file include sqlhdr.h protos_cfg]
  174.     if {$m == 1} {
  175.         puts "  Added C++ prototypes" 
  176.         puts "Done."
  177.     } elseif {$m == -1} {
  178.         puts "  Could not find sqlhdr.h!"
  179.     } else {
  180.             puts "  Could not find endline in sqlhdr.h; C++ prototypes not added!"
  181.             puts "  (last line of sqlhdr.h should look like '#endif /* _SQLHDR */')"
  182.         }
  183.     }
  184. }
  185.  
  186. #
  187. # Ingres
  188. #
  189. proc INGRES::copy {} {
  190. }
  191.  
  192. proc INGRES::config {} {
  193. }
  194.  
  195. #
  196. # Oracle
  197. #
  198. proc ORACLE::copy {} {
  199. }
  200.  
  201. proc ORACLE::config {} {
  202. }
  203.  
  204. #
  205. # Sybase
  206. #
  207. proc SYBASE::copy {} {
  208. }
  209.  
  210. proc SYBASE::config {} {
  211. }
  212.  
  213. #
  214. # Microsoft SQL server
  215. #
  216. proc SQLSERVER::copy {} {
  217. }
  218.  
  219. proc SQLSERVER::config {} {
  220. }
  221.