1#! /usr/bin/perl 2############################################################################ 3# SIM's Autopain Microsoft Visual Studio Project Generation, v2.0 4# 5# This is a perl rewrite (sorry python-guys) of my original Bourne Shell 6# implementation to get more speed, and also to be able to restructure the 7# system to generate project files for all the targeted versions of 8# Microsoft Visual Studio at the same time, to save even more time. Even 9# more speed will be saved if this could be performed on a Unix server, 10# since those are generally faster running make. 11# Sorry about the 'old-school' perl - I know I should update myself on 12# perl modules and such, but perl is not a language I really invest that 13# much in, it just is the language that is most available to me when I need 14# to do the occasional hack in something faster and better than 15# Bourne Shell. 16# /Lars J 17# 18# Authors: 19# 20# Lars J. Aas <larsa@sim.no> 21# 22# History: 23# 24# 2006-12-26 1st perl rewrite (with additions) completed. (larsa) 25# 2005-01-05 Initial Bourne Shell version. (larsa) 26# 27# Plans: 28# 29# - output msvc7 and msvc8 files directly, don't use the upgrade feature 30# - fork off the first instance to serve as a server that collects all 31# necessary data through some IPC and then dumps the project files when 32# everything is gathered... 33# - put most msvc8-settings into property pages 34# - add support for precompiled headers 35# 36 37require "pwd.pl"; 38 39$date = `date`; 40$cwd = $ENV{'PWD'}; 41 42$me = $0; 43$cwd = $ENV{'PWD'}; 44if ( $me =~ m%^[^/\\]% ) { 45 $me = $cwd . "/" . $me; 46 $me =~ s%/./%/%g; 47} 48 49# Environment variables to back-substitute from value to variable reference 50# in the project files to make the project moveable 51@reversevars = ("QTDIR", "COINDIR"); 52 53# List of files that should be entered into the "Documents" project file 54# group if they exist. 55@docfiles = ("README", "README.WIN32", "NEWS", "RELNOTES", 56 "COPYING", "THANKS", "ChangeLog"); 57 58############################################################################ 59 60$prefix = "@prefix@"; 61$build_dir = "@abs_top_builddir@"; 62while ( $build_dir =~ m%[\\/][^\\/]*[^\\/.][\\/]\.\.% ) { 63 $build_dir =~ s%[\\/][^\\/]*[^\\/\.][\\/]\.\.%%g; 64} 65$build_dir =~ s%[\\/]\.$%%g; 66$src_dir = "@abs_top_srcdir@"; 67while ( $src_dir =~ m%[\\/][^\\/]*[^\\/.][\\/]\.\.% ) { 68 $src_dir =~ s%[\\/][^\\/]*[^\\/\.][\\/]\.\.%%g; 69} 70$src_dir =~ s%[\\/]\.$%%; 71$ac_unique_file = "@ac_unique_file@"; 72$sim_ac_relative_src_dir = "@sim_ac_relative_src_dir@"; 73$sim_ac_relative_src_dir_p = @sim_ac_relative_src_dir_p@; # true or false 74if ($sim_ac_relative_src_dir_p) { 75 $sim_ac_relative_src_dir_win = Unix2Dos($sim_ac_relative_src_dir); 76} 77$src_dir_win = Cygpath2Win($src_dir); 78$build_dir_win = Cygpath2Win($build_dir); 79 80$src_dir_win =~ s/\\/\\\\/g; 81$build_dir_win =~ s/\\/\\\\/g; 82# print "SOURCE DIR: ${src_dir}\n"; 83# print "SOURCE DIR WIN: ${src_dir_win}\n"; 84# print "BUILD DIR WIN: ${build_dir_win}\n"; 85 86$me_u = Dos2Unix($me); 87$medir_u = $me; 88$medir_u =~ s,[^/]*$,,g; 89$srcdir_u = $medir_u; 90$srcdir_u =~ s,[^/]*/$,,g; 91$thisdir_u = Dos2Unix($cwd); 92 93if ( $sim_ac_relative_src_dir_p ) { 94 local $filename = "${srcdir_u}/${sim_ac_relative_src_dir}/${ac_unique_file}"; 95 $filename = Dos2Unix($filename); 96 if ( ! -f $filename ) { 97 die "error: directories have been moved relative to each other since the last configure run. expected to find '$filename'."; 98 } 99} else { 100 die "error: dsp generation is not supported when absolute paths are necessary to locate files."; 101} 102 103############################################################################ 104 105$group = ""; 106$prev_group = ""; 107 108sub LoadVars { 109 local $filename = "@abs_top_builddir@/gendsp-vars.txt"; 110 open(IN, "${filename}"); 111 while (<IN>) { 112 $line = $_; 113 chop($line); 114 if ( $line =~ m%^group = (.*)% ) { 115 $prev_group = $1; 116 } 117 } 118 close(IN); 119} 120 121sub SaveVars { 122 local $filename = "@abs_top_builddir@/gendsp-vars.txt"; 123 open(OUT, ">${filename}"); 124 print OUT "group = ${group}\n"; 125 close(OUT); 126} 127 128sub ClearVars { 129 $prev_group = ""; 130 $group = ""; 131 SaveVars(); 132 LoadVars(); 133} 134 135sub Dos2Unix { 136 local $path = $_[0]; 137 $path =~ s,\\,/,g; 138 return $path; 139} 140 141sub Unix2Dos { 142 local $path = $_[0]; 143 $path =~ s,/,\\,g; 144 return $path; 145} 146 147sub Cygpath2Win { 148 local $path = $_[0]; 149 $path =~ s,^/cygdrive/([a-zA-Z])/,$1:/,; 150 $path =~ s,/,\\,g; 151 return $path; 152} 153 154sub Cygpath2Unix { 155 local $path = $_[0]; 156 $path =~ s,^([a-zA-Z]):,/cygdrive/$1/,; 157 $path =~ s,\\,/,g; 158 return $path; 159} 160 161sub Dirname { 162 local $path = $_[0]; 163 $path =~ s,[\\/][^\\/]*$,,g; 164 return $path; 165} 166 167sub Filename { 168 local $path = $_[0]; 169 $path =~ s,^.*[\\/]([^\\/]*)$,$1,g; 170 return $path; 171} 172 173sub Basename { 174 local $path = $_[0]; 175 local $extension = $_[1]; 176 $path =~ s,^.*[\\/]([^\\/]*)$,$1,g; 177 $path =~ s,${extension}$,,g; 178 return $path; 179} 180 181sub SubstFile { 182 local $filename = $_[0]; 183 local @vars, @vals, %dict, $num = 0; 184 open(MAKE, "Makefile"); 185 local $starting = true; 186 while (<MAKE>) { 187 $line = $_; 188 if ($starting) { 189 if ( $line =~ m/^$/ || $line =~ m/^\#/ ) { next; } 190 $starting = false; 191 } 192 if ( $line =~ m/^SUBDIRS/ ) { # exit variable reading when we get to the SUBDIRS directive 193 break; 194 } elsif ( $line =~ m/^([a-zA-Z0-9_]+) = ?(.*)?/ ) { 195 $vars[$num] = $1; 196 $vals[$num] = $2; 197 $dict{$1} = $2; 198 ++$num; 199 } 200 } 201 close(MAKE); 202 local %envvars = (); 203 for $var (@reversevars) { 204 $envvars{$var} = $ENV{$var}; 205 $envvars{$var} =~ s%\\%\\\\%g; 206 $envvars{$var} =~ s%\.%\\.%g; 207 } 208 # variables are loaded 209 local $backup = $filename . ".bak"; 210 rename($filename, $backup); 211 open(OUT, ">$filename"); 212 open(IN, "$backup"); 213 while(<IN>) { 214 $line = $_; 215 if ($line =~ m/@([^@]*)@/) { 216 if (defined($dict{$1})) { 217 # does the (g)lobal tag enable multi-substs-per-line? 218 # does @ occur naturally in Visual Studio project files? 219 $line =~ s/@([^@]*)@/$dict{$1}/g; 220 } 221 } 222 223 if ($line =~ m%${build_dir_win}\\%o) { 224 $line =~ s%${build_dir_win}\\%%g; 225 } 226 if ($line =~ m%${build_dir_win}%o) { 227 $line =~ s%${build_dir_win}%.%g; 228 } 229 if ($line =~ m%${src_dir_win}[\\]?%o) { 230 $line =~ s%${src_dir_win}([\\]?)%${sim_ac_relative_src_dir_win}$1%g; 231 } 232 233 for $var (@reversevars) { 234 if ($line =~ m%$envvars{$var}%) { 235 $line =~ s%$envvars{$var}%\$(${var})%g; 236 } 237 } 238 239 print OUT $line; 240 } 241 close(IN); 242 close(OUT); 243} 244 245sub SubstBatFile { 246 local $filename = $_[0]; 247 local %envvars = (); 248 for $var (@reversevars) { 249 $envvars{$var} = $ENV{$var}; 250 $envvars{$var} =~ s%\\%\\\\%g; 251 $envvars{$var} =~ s%\.%\\.%g; 252 } 253 # variables are loaded 254 local $backup = $filename . ".bak"; 255 rename($filename, $backup); 256 open(OUT, ">$filename"); 257 open(IN, "$backup"); 258 while(<IN>) { 259 $line = $_; 260 for $var (@reversevars) { 261 if ( $line =~ m%$envvars{$var}% ) { 262 $line =~ s,$envvars{$var},%${var}%,g; 263 } 264 } 265 print OUT $line; 266 } 267 close(IN); 268 close(OUT); 269} 270 271sub CRLFFile { 272 local $path = $_[0]; 273 local $backup = $path . ".old"; 274 rename($path, $backup); 275 open(IN, $backup); 276 open(OUT, ">$path"); 277 while(<IN>) { 278 $line = $_; 279 chop($line); 280 print OUT "${line}\r\n"; 281 } 282 close(IN); 283 close(OUT); 284 return true; 285} 286 287sub CreateScriptDSP { 288 local ($scriptdspfilename, $projectname, $script, @resourcefiles) = @_; 289 290 open(SCRIPTDSP, ">${scriptdspfilename}"); 291 print SCRIPTDSP <<"_EODSP"; 292# Microsoft Developer Studio Project File - Name="${projectname}" - Package Owner=<4> 293# Microsoft Developer Studio Generated Build File, Format Version 6.00 294# ** DO NOT EDIT ** 295 296# TARGTYPE "Win32 (x86) External Target" 0x0106 297 298CFG=${projectname} - Win32 DLL (Debug) 299!MESSAGE This is not a valid makefile. To build this project using NMAKE, 300!MESSAGE use the Export Makefile command and run 301!MESSAGE 302!MESSAGE NMAKE /f "${projectname}.mak". 303!MESSAGE 304!MESSAGE You can specify a configuration when running NMAKE 305!MESSAGE by defining the macro CFG on the command line. For example: 306!MESSAGE 307!MESSAGE NMAKE /f "${projectname}.mak" CFG="${projectname} - Win32 DLL (Debug)" 308!MESSAGE 309!MESSAGE Possible choices for configuration are: 310!MESSAGE 311!MESSAGE "${projectname} - Win32 LIB (Release)" (based on "Win32 (x86) External Target") 312!MESSAGE "${projectname} - Win32 LIB (Debug)" (based on "Win32 (x86) External Target") 313!MESSAGE "${projectname} - Win32 DLL (Release)" (based on "Win32 (x86) External Target") 314!MESSAGE "${projectname} - Win32 DLL (Debug)" (based on "Win32 (x86) External Target") 315!MESSAGE 316 317# Begin Project 318# PROP AllowPerConfigDependencies 0 319# PROP Scc_ProjName "" 320# PROP Scc_LocalPath "" 321 322!IF "\$(CFG)" == "${projectname} - Win32 LIB (Release)" 323 324# PROP BASE Use_MFC 325# PROP BASE Use_Debug_Libraries 0 326# PROP BASE Output_Dir "StaticRelease" 327# PROP BASE Intermediate_Dir "StaticRelease" 328# PROP BASE Cmd_Line "${script} lib release ${msvc} ${library}\@${LIBRARY}_MAJOR_VERSION\@" 329# PROP BASE Rebuild_Opt "" 330# PROP BASE Target_File "" 331# PROP BASE Bsc_Name "" 332# PROP BASE Target_Dir "" 333# PROP Use_MFC 334# PROP Use_Debug_Libraries 0 335# PROP Output_Dir "StaticRelease" 336# PROP Intermediate_Dir "StaticRelease" 337# PROP Cmd_Line "${script} lib release ${msvc} ${library}\@${LIBRARY}_MAJOR_VERSION\@" 338# PROP Rebuild_Opt "" 339# PROP Target_File "" 340# PROP Bsc_Name "" 341# PROP Target_Dir "" 342 343!ELSEIF "\$(CFG)" == "${projectname} - Win32 LIB (Debug)" 344 345# PROP BASE Use_MFC 346# PROP BASE Use_Debug_Libraries 1 347# PROP BASE Output_Dir "StaticDebug" 348# PROP BASE Intermediate_Dir "StaticDebug" 349# PROP BASE Cmd_Line "${script} lib debug ${msvc} ${library}\@${LIBRARY}_MAJOR_VERSION\@" 350# PROP BASE Rebuild_Opt "" 351# PROP BASE Target_File "" 352# PROP BASE Bsc_Name "" 353# PROP BASE Target_Dir "" 354# PROP Use_MFC 355# PROP Use_Debug_Libraries 1 356# PROP Output_Dir "StaticDebug" 357# PROP Intermediate_Dir "StaticDebug" 358# PROP Cmd_Line "${script} lib debug ${msvc} ${library}\@${LIBRARY}_MAJOR_VERSION\@" 359# PROP Rebuild_Opt "" 360# PROP Target_File "" 361# PROP Bsc_Name "" 362# PROP Target_Dir "" 363 364!ELSEIF "\$(CFG)" == "${projectname} - Win32 DLL (Release)" 365 366# PROP BASE Use_MFC 367# PROP BASE Use_Debug_Libraries 0 368# PROP BASE Output_Dir "Release" 369# PROP BASE Intermediate_Dir "Release" 370# PROP BASE Cmd_Line "${script} dll release ${msvc} ${library}\@${LIBRARY}_MAJOR_VERSION\@" 371# PROP BASE Rebuild_Opt "" 372# PROP BASE Target_File "" 373# PROP BASE Bsc_Name "" 374# PROP BASE Target_Dir "" 375# PROP Use_MFC 376# PROP Use_Debug_Libraries 0 377# PROP Output_Dir "Release" 378# PROP Intermediate_Dir "Release" 379# PROP Cmd_Line "${script} dll release ${msvc} ${library}\@${LIBRARY}_MAJOR_VERSION\@" 380# PROP Rebuild_Opt "" 381# PROP Target_File "" 382# PROP Bsc_Name "" 383# PROP Target_Dir "" 384 385!ELSEIF "\$(CFG)" == "${projectname} - Win32 DLL (Debug)" 386 387# PROP BASE Use_MFC 388# PROP BASE Use_Debug_Libraries 1 389# PROP BASE Output_Dir "Debug" 390# PROP BASE Intermediate_Dir "Debug" 391# PROP BASE Cmd_Line "${script} dll debug ${msvc} ${library}\@${LIBRARY}_MAJOR_VERSION\@" 392# PROP BASE Rebuild_Opt "" 393# PROP BASE Target_File "" 394# PROP BASE Bsc_Name "" 395# PROP BASE Target_Dir "" 396# PROP Use_MFC 397# PROP Use_Debug_Libraries 1 398# PROP Output_Dir "Debug" 399# PROP Intermediate_Dir "Debug" 400# PROP Cmd_Line "${script} dll debug ${msvc} ${library}\@${LIBRARY}_MAJOR_VERSION\@" 401# PROP Rebuild_Opt "" 402# PROP Target_File "" 403# PROP Bsc_Name "" 404# PROP Target_Dir "" 405 406!ENDIF 407 408# Begin Target 409 410# Name "${projectname} - Win32 LIB (Release)" 411# Name "${projectname} - Win32 LIB (Debug)" 412# Name "${projectname} - Win32 DLL (Release)" 413# Name "${projectname} - Win32 DLL (Debug)" 414 415!IF "\$(CFG)" == "${projectname} - Win32 LIB (Release)" 416 417!ELSEIF "\$(CFG)" == "${projectname} - Win32 LIB (Debug)" 418 419!ELSEIF "\$(CFG)" == "${projectname} - Win32 DLL (Release)" 420 421!ELSEIF "\$(CFG)" == "${projectname} - Win32 DLL (Debug)" 422 423!ENDIF 424 425# Begin Group "Resource Files" 426 427# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;bat" 428_EODSP 429 430 for $file (@resourcefiles) { 431 print SCRIPTDSP "# Begin Source File\n\n"; 432 print SCRIPTDSP "SOURCE=${file}\n"; 433 print SCRIPTDSP "# End Source File\n"; 434 } 435 436 print SCRIPTDSP <<"_EODSP"; 437# End Group 438# End Target 439# End Project 440_EODSP 441 close(SCRIPTDSP); 442} 443 444############################################################################ 445 446LoadVars(); 447 448# ************************************************************************** 449# The following block (the --registar-public-header part) generates 450# 1) the public headers part of the .dsp file 451# 2) the install-headers.bat file 452# It is invoked from a "make ... install-data"-command far down in this script 453 454if ( $ARGV[0] eq "--register-public-header" ) { 455 $studiofile = $ARGV[1]; 456 $headerfile = $ARGV[2]; 457 $installpath = $ARGV[3]; 458 $finalheader = $installpath; 459 $finalheader =~ s,.*${prefix}/(include|data),$ENV{'COINDIR'}/$1,; 460 $finalheader =~ s,/\./,/,g; 461 $finalheader = &Unix2Dos($finalheader); 462 463 $sim_ac_relative_src_dir_q = "@sim_ac_relative_src_dir@"; 464 $sim_ac_relative_src_dir_q =~ s,\.,\\.,g; 465 466 $tested = true; 467 468 if ( $headerfile =~ m,.*${sim_ac_relative_src_dir}/.*, ) { 469 $headerfile =~ 470 s%.*${sim_ac_relative_src_dir_q}/([^.])%${sim_ac_relative_src_dir}/$1%; 471 } elsif ( $headerfile =~ m,^${build_dir}/.*, ) { 472 $tested = false; 473 print "EXPLICIT IN BUILD DIR"; 474 $headerfile =~ s%${build_dir}/%%; 475 } elsif ( $headerfile =~ m/^${src_dir}.*/ ) { 476 $tested = false; 477 print "EXPLICIT IN SOURCE DIR - CONVERT TO RELATIVE"; 478 $headerfile =~ s%${src_dir}%${sim_ac_relative_src_dir}%; 479 } else { 480 $headerfile = $cwd . "/" . $headerfile; 481 $headerfile =~ s%${build_dir}/%%; 482 } 483 484 # echo "final header: $headerfile" 485 # echo "FINAL header: $finalheader" 486 # echo "=========================" 487 488 $headerfile = Cygpath2Win($headerfile); 489 490 $headerfile =~ s%^${build_dir}[\\/]?%.\\%; 491 $headerfile =~ s%^${build_dir_win}[\\/]?%.\\%; 492 if ($sim_ac_relative_src_dir_p) { 493 $headerfile =~ s%^${src_dir}[\\/]?%${sim_ac_relative_src_dir_win}\\%; 494 $headerfile =~ s%^${src_dir_win}[\\/]?%${sim_ac_relative_src_dir_win}\\%; 495 } 496 497 if ( ! $tested ) { 498 die "untested case - manual inspection required"; 499 } 500 501 open(DSP, ">>${studiofile}"); 502 $group = Dirname($headerfile); 503 $group =~ s%.*lib[\\/]?%%g; 504 $group =~ s%.*src[\\/]?%%g; 505 $group =~ s%.*include[\\/]?%%g; 506 $group =~ s%^Inventor[\\/]annex[\\/]%%g; 507 508 SaveVars(); 509 if ($prev_group ne $group) { 510 if ($prev_group ne "") { 511 print DSP "# End Group\n"; 512 } 513 if ($group ne "") { 514 print DSP "# Begin Group \"${group} headers\"\n"; 515 print DSP "# Set Default_Filter \"h\"\n"; 516 } 517 } 518 519 print DSP "# Begin Source File\n"; 520 print DSP "\n"; 521 print DSP "SOURCE=${headerfile}\n"; 522 print DSP "# End Source File\n"; 523 close(DSP); 524 525 # and the installation script 526 $installheadersfile = $studiofile; 527 $installheadersfile =~ s,([^\\/0-9]*)[0-9][^\\/]*\.dsp,install-headers.bat,; 528 529 $installheadersfile =~ m,(msvc[6789]),; 530 $msvc = $1; 531 532 # don't generate inside misc/ to be able to generate concurrently in several 533 # msvc*/-directories... 534 # $installheadersfile =~ s,msvc[6789]/,misc/,; 535 536 # sourcedirq=`echo "$sourcedir" | sed -e 's,\\\\,\\\\,g'` 537 # builddirq=`echo "$builddir" | sed -e 's,\\\\,\\\\,g'` 538 # relheader=`echo "$headerfile" | sed -e "s,$builddirq,.,g" -e "s,$sourcedirq,..\\\\..,g" -e 's,\\\\,\\\\\\\\,g'` 539 # finalheader=`echo "$relheader" | sed -e 's,.*include,include,g'` 540 # relheader=`echo "$relheader"` 541 # finalheader=`echo "$finalheader"` 542 543 $createheader = 0; 544 if ( ! -e $installheadersfile ) { 545 $createheader = 1; 546 } 547 if ( $headerfile !~ m/^${sim_ac_relative_src_dir_win}/ ) { 548 $headerfile = "..\\%msvc%\\${headerfile}"; 549 } 550 open(BAT, ">>${installheadersfile}"); 551 if ( $createheader ) { 552 print BAT <<"_EOBAT"; 553rem ************************************************************************ 554rem * install-headers.bat - generated by gendsp.pl 555rem * 556set msvc=%1 557_EOBAT 558 } 559 print BAT "copy /Y ${headerfile} ${finalheader} >nul:\n"; 560 close(BAT); 561 562 $uninstallheadersfile = $installheadersfile; 563 $uninstallheadersfile =~ s/install-hea/uninstall-hea/; 564 565 open(BAT2, ">>${uninstallheadersfile}"); 566 if ( $createheader ) { 567 print BAT2 <<"_EOBAT"; 568rem ************************************************************************ 569rem * uninstall-headers.bat - generated by gendsp.pl 570rem * 571set msvc=%1 572_EOBAT 573 } 574 print BAT2 "del ${finalheader}\n"; 575 close(BAT2); 576 577 exit 0; 578} 579 580# ************************************************************************** 581 582# this variable should contain the list of variables we want to use in the 583# project file setup, instead of just having the values. 584 585$sourcefile = ""; 586$objectfile = ""; 587$dependfile = ""; 588$studiofile = ""; 589$installstudiofile = ""; 590$uninstallstudiofile = ""; 591$docstudiofile = ""; 592$outputfile = ""; 593 594$LIBRARY = ""; 595$library = ""; 596$Library = ""; 597 598for $arg (@ARGV) { 599 if ( $outputfile eq "next" ) { 600 $outputfile = $arg; 601 } else { 602 if ( $arg eq "-c" ) { 603 # -c only means _compile_ some file, not that the source file is 604 # the next argument, hence we need to do it differently than for 605 # the -o option 606 $sourcefile = "get"; 607 } elsif ( $arg eq "-o" ) { 608 $outputfile = "next"; 609 } elsif ( $arg eq "-MF" || $arg eq "-MD" || $arg eq "-MP" ) { 610 # haven't investigated if one of these are defined to be last 611 # before the dep-file, so i've done it this way. 612 $dependfile = "get"; 613 } elsif ( $arg =~ m/^-Wp,-MD,.*/ ) { 614 $dependfile = substr($arg, 9); 615 } elsif ( $arg =~ m/^-D.*_INTERNAL/ ) { 616 $LIBRARY = $arg; 617 $LIBRARY =~ s/^-D//; 618 $LIBRARY =~ s/_INTERNAL//; 619 $library = $LIBRARY; 620 $library =~ y/A-Z/a-z/; 621 $Library = substr($LIBRARY, 0, 1) . substr($library, 1); 622 if ( $Library =~ m/^So/o ) { 623 $Library = substr($Library, 0, 2) . substr($LIBRARY, 3, 1) . substr($library, 4, -1); 624 } elsif ( $Library =~ m/^Coin../o ) { 625 $Library = substr($Library, 0, 4) . substr($LIBRARY, 5, 1) . substr($library, 6, -1); 626 } 627 } elsif ( $arg =~ m/^-Ddspfile=/ || $arg =~ m/^-Wl,-Ddspfile=/ ) { 628 # the build system is hacked to pass us the path to the .dsp file 629 # this way. 630 $studiofile = $arg; 631 $studiofile =~ s/^.*=//g; 632 $installstudiofile = $studiofile; 633 $uninstallstudiofile = $studiofile; 634 $docstudiofile = $studiofile; 635 $installstudiofile =~ s/.dsp/_install.dsp/; 636 $uninstallstudiofile =~ s/.dsp/_uninstall.dsp/; 637 $docstudiofile =~ s/.dsp/_docs.dsp/; 638 # FIXME: we don't get the -D*_INTERNAL flag when closing, so we 639 # have to set up the variables here too. 640 $library = $studiofile; 641 $library =~ s,.*[\\/],,g; 642 $library =~ s,[0-9].*$,,; 643 $LIBRARY = $library; 644 $LIBRARY =~ y/a-z/A-Z/; 645 $Library = substr($LIBRARY, 0, 1) . substr($library, 1); 646 if ( $Library =~ m/^So/o ) { 647 $Library = substr($Library, 0, 2) . substr($LIBRARY, 3, 1) . substr($library, 4); 648 } elsif ( $Library =~ m/^Coin../o ) { 649 $Library = substr($Library, 0, 4) . substr($LIBRARY, 5, 1) . substr($library, 6, -1); 650 } 651 } elsif ( $arg =~ m/^-/ ) { 652 # nada - no other options for us 653 } else { 654 if ( $sourcefile eq "get" ) { 655 $sourcefile = $arg; 656 } elsif ( $dependfile eq "get" ) { 657 $dependfile = $arg; 658 } 659 } 660 } 661} 662 663if ( $studiofile eq "" ) { 664 print STDERR "Error? No studiofile in command - exiting.\n"; 665 exit 0; 666} 667 668$vcproj7file = $studiofile; 669$vcproj7file =~ s/msvc6/msvc7/; 670$vcproj7file =~ s/\.dsp$/.vcproj/; 671$vcproj8file = $studiofile; 672$vcproj8file =~ s/msvc6/msvc8/; 673$vcproj8file =~ s/\.dsp$/.vcproj/; 674$vcproj9file = $studiofile; 675$vcproj9file =~ s/msvc6/msvc9/; 676$vcproj9file =~ s/\.dsp$/.vcproj/; 677 678if ( $sourcefile ne "" ) { 679 if ( $objectfile eq "" ) { 680 $objectfile = $sourcefile; 681 $objectfile =~ s%^.*[/\\\\]%%g; 682 $objectfile =~ s%\.(cpp|c)$%.o%; 683 } 684} 685 686if ( $objectfile ne "" ) { 687 open(OBJ, ">${objectfile}"); 688 print OBJ $date; 689 close(OBJ); 690} 691 692if ( $dependfile ne "" ) { 693 open(DEP, ">${dependfile}"); 694 print DEP "\n"; 695 close(DEP); 696} 697 698if ( -f $studiofile ) { 699 open(DSP, ">>${studiofile}"); 700} else { 701 # files do not exist yet, open project 702 ClearVars(); 703 704 $studiofile =~ m,(msvc[6789]),; 705 $msvc = $1; 706 707 @installrcfiles = ( 708 "..\\misc\\install-sdk.bat", 709 "..\\misc\\install-headers.bat", 710 "..\\misc\\create-directories.bat" 711 ); 712 713 @uninstallrcfiles = ( 714 "..\\misc\\uninstall-sdk.bat", 715 "..\\misc\\uninstall-headers.bat" 716 ); 717 718 @docsrcfiles = ( 719 "..\\misc\\build-docs.bat", 720 "docs\\${library}\@${LIBRARY}_MAJOR_VERSION\@.doxygen", 721 "..\\html\\index.html" 722 ); 723 724 &CreateScriptDSP($installstudiofile, 725 "${library}\@${LIBRARY}_MAJOR_VERSION\@_install", 726 "..\\misc\\install-sdk.bat", 727 @installrcfiles); 728 729 &CreateScriptDSP($uninstallstudiofile, 730 "${library}\@${LIBRARY}_MAJOR_VERSION\@_uninstall", 731 "..\\misc\\uninstall-sdk.bat", 732 @uninstallrcfiles); 733 734 &CreateScriptDSP($docstudiofile, 735 "${library}\@${LIBRARY}_MAJOR_VERSION\@_docs", 736 "..\\misc\\build-docs.bat", 737 @docsrcfiles); 738 739 open(DSP, ">${studiofile}"); 740 print DSP <<"_EODSP"; 741# Microsoft Developer Studio Project File - Name="${library}\@${LIBRARY}_MAJOR_VERSION\@" - Package Owner=<4> 742# Microsoft Developer Studio Generated Build File, Format Version 6.00 743# ** DO NOT EDIT ** 744 745# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 746 747CFG=${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Release) 748!MESSAGE This is not a valid makefile. To build this project using NMAKE, 749!MESSAGE use the Export Makefile command and run 750!MESSAGE 751!MESSAGE NMAKE /f "${library}\@${LIBRARY}_MAJOR_VERSION\@.mak". 752!MESSAGE 753!MESSAGE You can specify a configuration when running NMAKE 754!MESSAGE by defining the macro CFG on the command line. For example: 755!MESSAGE 756!MESSAGE NMAKE /f "${library}\@${LIBRARY}_MAJOR_VERSION\@.mak" CFG="${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Debug)" 757!MESSAGE 758!MESSAGE Possible choices for configuration are: 759!MESSAGE 760!MESSAGE "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 LIB (Release)" (based on "Win32 (x86) Static Library") 761!MESSAGE "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 LIB (Debug)" (based on "Win32 (x86) Static Library") 762!MESSAGE "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Release)" (based on "Win32 (x86) Dynamic-Link Library") 763!MESSAGE "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Debug)" (based on "Win32 (x86) Dynamic-Link Library") 764!MESSAGE 765 766# Begin Project 767# PROP AllowPerConfigDependencies 0 768# PROP Scc_ProjName "" 769# PROP Scc_LocalPath "" 770CPP=cl.exe 771MTL=midl.exe 772RSC=rc.exe 773 774!IF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 LIB (Release)" 775 776# PROP BASE Use_MFC 0 777# PROP BASE Use_Debug_Libraries 0 778# PROP BASE Output_Dir "StaticRelease" 779# PROP BASE Intermediate_Dir "StaticRelease" 780# PROP BASE Target_Dir "" 781# PROP Use_MFC 0 782# PROP Use_Debug_Libraries 0 783# PROP Output_Dir "StaticRelease" 784# PROP Intermediate_Dir "StaticRelease" 785# PROP Target_Dir "" 786MTL=midl.exe 787CPP=cl.exe 788# ADD BASE CPP /nologo /MD /W3 /GX /Ox /Gy /Zi \@${LIBRARY}_DSP_INCS\@ /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_LIB" /D ${LIBRARY}_DEBUG=0 \@${LIBRARY}_LIB_DSP_DEFS\@ /FD /c 789# ADD CPP /nologo /MD /W3 /GX /Ox /Gy /Zi \@${LIBRARY}_DSP_INCS\@ /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_LIB" /D ${LIBRARY}_DEBUG=0 \@${LIBRARY}_LIB_DSP_DEFS\@ /FD /c 790RSC=rc.exe 791# ADD BASE RSC /l 0x414 /d "NDEBUG" 792# ADD RSC /l 0x414 /d "NDEBUG" 793BSC32=bscmake.exe 794# ADD BASE BSC32 /nologo 795# ADD BSC32 /nologo 796LIB32=link.exe -lib 797# ADD BASE LIB32 /nologo /machine:I386 /out:"${library}\@${LIBRARY}_MAJOR_VERSION\@s.lib" 798# ADD LIB32 /nologo /machine:I386 /out:"${library}\@${LIBRARY}_MAJOR_VERSION\@s.lib" 799 800!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 LIB (Debug)" 801 802# PROP BASE Use_MFC 0 803# PROP BASE Use_Debug_Libraries 1 804# PROP BASE Output_Dir "StaticDebug" 805# PROP BASE Intermediate_Dir "StaticDebug" 806# PROP BASE Target_Dir "" 807# PROP Use_MFC 0 808# PROP Use_Debug_Libraries 1 809# PROP Output_Dir "StaticDebug" 810# PROP Intermediate_Dir "StaticDebug" 811# PROP Target_Dir "" 812MTL=midl.exe 813CPP=cl.exe 814# ADD BASE CPP /nologo /MDd /W3 /GX /GZ /Od /Zi \@${LIBRARY}_DSP_INCS\@ /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_LIB" /D ${LIBRARY}_DEBUG=1 \@${LIBRARY}_LIB_DSP_DEFS\@ /FD /c 815# ADD CPP /nologo /MDd /W3 /GX /GZ /Od /Zi \@${LIBRARY}_DSP_INCS\@ /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_LIB" /D ${LIBRARY}_DEBUG=1 \@${LIBRARY}_LIB_DSP_DEFS\@ /FD /c 816RSC=rc.exe 817# ADD BASE RSC /l 0x414 /d "_DEBUG" 818# ADD RSC /l 0x414 /d "_DEBUG" 819BSC32=bscmake.exe 820# ADD BASE BSC32 /nologo 821# ADD BSC32 /nologo 822LIB32=link.exe -lib 823# ADD BASE LIB32 /nologo /machine:I386 /out:"${library}\@${LIBRARY}_MAJOR_VERSION\@sd.lib" 824# ADD LIB32 /nologo /machine:I386 /out:"${library}\@${LIBRARY}_MAJOR_VERSION\@sd.lib" 825 826!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Release)" 827 828# PROP BASE Use_MFC 0 829# PROP BASE Use_Debug_Libraries 0 830# PROP BASE Output_Dir "Release" 831# PROP BASE Intermediate_Dir "Release" 832# PROP BASE Target_Dir "" 833# PROP Use_MFC 0 834# PROP Use_Debug_Libraries 0 835# PROP Output_Dir "Release" 836# PROP Intermediate_Dir "Release" 837# PROP Ignore_Export_Lib 0 838# PROP Target_Dir "" 839CPP=cl.exe 840# ADD BASE CPP /nologo /MD /W3 /GX /Ox /Gy /Zi \@${LIBRARY}_DSP_INCS\@ /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D ${LIBRARY}_DEBUG=0 \@${LIBRARY}_DSP_DEFS\@ /FD /c 841# ADD CPP /nologo /MD /W3 /GX /Ox /Gy /Zi \@${LIBRARY}_DSP_INCS\@ /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D ${LIBRARY}_DEBUG=0 \@${LIBRARY}_DSP_DEFS\@ /FD /c 842MTL=midl.exe 843# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 844# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 845RCS=rc.exe 846# ADD BASE RSC /l 0x409 /d "NDEBUG" 847# ADD RSC /l 0x409 /d "NDEBUG" 848BSC32=bscmake.exe 849# ADD BASE BSC32 /nologo 850# ADD BSC32 /nologo 851LINK32=link.exe 852# ADD BASE LINK32 \@${LIBRARY}_DSP_LIBS\@ /nologo /dll /release /machine:I386 /pdbtype:sept 853# ADD LINK32 \@${LIBRARY}_DSP_LIBS\@ /nologo /dll /release /machine:I386 /pdbtype:sept /out:"${library}\@${LIBRARY}_MAJOR_VERSION\@.dll" /opt:nowin98 854# SUBTRACT LINK32 /pdb:none 855 856!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION@ - Win32 DLL (Debug)" 857 858# PROP BASE Use_MFC 0 859# PROP BASE Use_Debug_Libraries 1 860# PROP BASE Output_Dir "Debug" 861# PROP BASE Intermediate_Dir "Debug" 862# PROP BASE Target_Dir "" 863# PROP Use_MFC 0 864# PROP Use_Debug_Libraries 1 865# PROP Output_Dir "Debug" 866# PROP Intermediate_Dir "Debug" 867# PROP Target_Dir "" 868CPP=cl.exe 869# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /GZ /Zi /Od \@${LIBRARY}_DSP_INCS\@ /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D ${LIBRARY}_DEBUG=1 \@${LIBRARY}_DSP_DEFS\@ /FD /c 870# ADD CPP /nologo /MDd /W3 /Gm /GX /GZ /Zi /Od \@${LIBRARY}_DSP_INCS\@ /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D ${LIBRARY}_DEBUG=1 \@${LIBRARY}_DSP_DEFS\@ /FD /c 871MTL=midl.exe 872# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 873# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 874RCS=rc.exe 875# ADD BASE RSC /l 0x409 /d "_DEBUG" 876# ADD RSC /l 0x409 /d "_DEBUG" 877BSC32=bscmake.exe 878# ADD BASE BSC32 /nologo 879# ADD BSC32 /nologo 880LINK32=link.exe 881# ADD BASE LINK32 \@${LIBRARY}_DSP_LIBS\@ /nologo /dll /debug /machine:I386 /pdbtype:sept 882# ADD LINK32 \@${LIBRARY}_DSP_LIBS\@ /nologo /dll /debug /machine:I386 /pdbtype:sept /out:"${library}\@${LIBRARY}_MAJOR_VERSION\@d.dll" /opt:nowin98 883 884!ENDIF 885 886# Begin Target 887 888# Name "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Release)" 889# Name "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Debug)" 890# Name "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 LIB (Release)" 891# Name "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 LIB (Debug)" 892# Begin Group "Documents" 893# PROP Default_Filter ";txt" 894_EODSP 895 896 for $docfile (@docfiles) { 897 if ( -f "${src_dir}/${docfile}" ) { 898 print DSP <<"_EODSP"; 899# Begin Source File 900 901SOURCE=${sim_ac_relative_src_dir_win}\\${docfile} 902# End Source File 903_EODSP 904 } 905 } 906 print DSP <<"_EODSP"; 907# End Group 908# Begin Group "Template Files" 909# PROP Default_Filter "in" 910_EODSP 911 912 # FIXME: figure out which is the template files, and set up 913 # csubst.exe-based build-rules for them... 914 915 # print STDERR "\n\n\n\nATTENTION\n\n\n\n\n"; 916 917 open(FILES, "cd ${build_dir} && find src/Inventor " . '-name "*.h" -o -name "*.cpp" -o -name "*.c" | xargs grep "Generated from .* by configure" |'); 918 @lines = <FILES>; 919 close(FILES); 920 921 for $line (@lines) { 922 $line =~ m/^([^:]*):.*Generated from (.*) by configure/; 923 $file = &Unix2Dos($1); 924 $template = $2; 925 open(FILE, "cd ${src_dir} && find src/Inventor -name '${template}' |"); 926 $templatepath = <FILE>; 927 chop($templatepath); 928 next if (!$templatepath); 929 $templatepath = &Unix2Dos("../../${templatepath}"); 930 close(FILE); 931 # print STDERR "TEMPLATE '${template}' - $templatepath\n :: TARGET '${file}'\n"; 932 print DSP <<"_EODSP"; 933# Begin Source File 934 935SOURCE=${templatepath} 936 937!IF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Release)" 938 939# PROP IgnoreDefaultTool 1 940#Begin Custom Build - subst'ing \$(InputPath) 941InputPath=${templatepath} 942 943"${file}" : \$(SOURCE) "\$(INTDIR)" "\$(OUTDIR)" 944 ..\\..\\cfg\\csubst --file=${templatepath}:${file} 945 946# End Custom Build 947 948!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Debug)" 949 950# PROP IgnoreDefaultTool 1 951#Begin Custom Build - subst'ing \$(InputPath) 952InputPath=${headerfile} 953 954"${file}" : \$(SOURCE) "\$(INTDIR)" "\$(OUTDIR)" 955 ..\\..\\cfg\\csubst --file=${templatepath}:${file} 956 957# End Custom Build 958 959!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 LIB (Release)" 960 961# PROP IgnoreDefaultTool 1 962#Begin Custom Build - subst'ing \$(InputPath) 963InputPath=${headerfile} 964 965"${file}" : \$(SOURCE) "\$(INTDIR)" "\$(OUTDIR)" 966 ..\\..\\cfg\\csubst --file=${templatepath}:${file} 967 968# End Custom Build 969 970!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 LIB (Debug)" 971 972# PROP IgnoreDefaultTool 1 973#Begin Custom Build - subst'ing \$(InputPath) 974InputPath=${headerfile} 975 976"${file}" : \$(SOURCE) "\$(INTDIR)" "\$(OUTDIR)" 977 ..\\..\\cfg\\csubst --file=${templatepath}:${file} 978 979# End Custom Build 980 981!ENDIF 982 983# End Source File 984_EODSP 985 } 986 987 print DSP <<"_EODSP"; 988# End Group 989# Begin Group "Source Files" 990# PROP Default_Filter "c;cpp;ic;icc;h" 991 992_EODSP 993 994} 995 996# 997# if test `grep -c "# End Project" "$studiofile"` -gt 0; then 998# me=`echo $me | sed 's%^.*/%%g'` 999# echo >&2 "$me: error: project file is closed - you must start from scratch (make clean)" 1000# exit 1 1001# fi 1002# 1003 1004if ( $sourcefile ne "" ) { 1005 # set up section for the source file 1006 if ( $sourcefile =~ m/^[a-zA-Z]:.*/ || $sourcefile =~ m%^/.*% ) { 1007 } else { 1008 # this is a relative path 1009 $sourcefile = "${cwd}/${sourcefile}"; 1010 } 1011 $sourcefile = Cygpath2Win($sourcefile); 1012 $sourcefileunixname = Cygpath2Unix($sourcefile); 1013 $sourcefiledir = Dirname($sourcefileunixname); 1014 $sourcefiledirdir = Dirname($sourcefiledir); 1015 $sourcefiledirdirdir = Dirname($sourcefiledirdir); 1016 $targetdir = $sourcefiledir; 1017 $targetdir =~ s%^${sourcefiledirdirdir}[/\\]?%%g; 1018 $targetdir =~ s%.*src[/\\]?%%g; 1019 $targetdir =~ s%.*lib[/\\]?%%g; 1020 $group = $targetdir; 1021 $targetdir = Unix2Dos($targetdir); 1022 SaveVars(); 1023 1024 if ($group ne $prev_group) { 1025 if ($prev_group ne "") { 1026 print DSP "# End Group\n"; 1027 } 1028 if ($group ne "") { 1029 print DSP <<"_EODSP"; 1030# Begin Group "${group} sources" 1031# PROP Default_Filter "c;cpp;ic;icc;h" 1032_EODSP 1033 } 1034 } 1035 1036 $sourcefile = Cygpath2Win($sourcefile); 1037 1038 $sourcefile =~ s%^${build_dir}[\\/]?%.\\%; 1039 $sourcefile =~ s%^${build_dir_win}[\\/]?%.\\%; 1040 if ($sim_ac_relative_src_dir_p) { 1041 $sim_ac_relative_src_dir_win = Unix2Dos($sim_ac_relative_src_dir); 1042 $sourcefile =~ s%^${src_dir}[\\/]?%${sim_ac_relative_src_dir_win}\\%; 1043 $sourcefile =~ s%^${src_dir_win}[\\/]?%${sim_ac_relative_src_dir_win}\\%; 1044 } 1045 1046 print DSP <<"_EODSP"; 1047# Begin Source File 1048 1049SOURCE=${sourcefile} 1050_EODSP 1051 if ($group ne "") { 1052 print DSP <<"_EODSP"; 1053!IF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Release)" 1054# PROP Intermediate_Dir "Release\\${targetdir}" 1055!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Debug)" 1056# PROP Intermediate_Dir "Debug\\${targetdir}" 1057!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION@ - Win32 LIB (Release)" 1058# PROP Intermediate_Dir "StaticRelease\\${targetdir}" 1059!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 LIB (Debug)" 1060# PROP Intermediate_Dir "StaticDebug\\${targetdir}" 1061!ENDIF 1062_EODSP 1063 } else { 1064 print DSP <<"_EODSP"; 1065!IF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Release)" 1066# PROP Intermediate_Dir "Release" 1067!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Debug)" 1068# PROP Intermediate_Dir "Debug" 1069!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION@ - Win32 LIB (Release)" 1070# PROP Intermediate_Dir "StaticRelease" 1071!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 LIB (Debug)" 1072# PROP Intermediate_Dir "StaticDebug" 1073!ENDIF 1074_EODSP 1075 } 1076 1077 print DSP <<"_EODSP"; 1078# End Source File 1079_EODSP 1080 1081 open(SRC, "${sourcefileunixname}"); 1082 @matches = grep(/moc_.*\.icc/, <SRC>); 1083 close(SRC); 1084 if (scalar(@matches) > 0) { 1085 # The sourcefile needs MOC to be executed before building. 1086 # The assumptions here are that the header is in the same directory in the 1087 # hierarchy, and that the moc file contains the magic text telling the 1088 # header file name. It is also assumed that the moc file is not built 1089 # on its own but included in the source file, and named moc_*.icc. 1090 $mocfile = $matches[0]; 1091 $mocfile =~ m%.*<(.*icc)>.*%; 1092 $mocfile = $1; 1093 $mocfile =~ s,.*/,,; 1094 open(MOC, $mocfile); 1095 @mocmatches = grep(/from reading C/, <MOC>); 1096 close(MOC); 1097 $headerfile = $mocmatches[0]; 1098 $headerfile =~ m%.*\'(.*)\'%; 1099 $headerfile = $1; 1100 $mocfile = "${cwd}/${mocfile}"; 1101 $mocfile =~ s%${build_dir}/%%; 1102 $mocfile = Unix2Dos($mocfile); 1103 $headerfilepath = "${cwd}/${headerfile}"; 1104 $headerfilepath =~ s%${build_dir}/%%; 1105 1106 if ( -f $headerfile ) { 1107 $headerfile = $headerfilepath; 1108 } else { 1109 $headerfile = "${sim_ac_relative_src_dir}/${headerfilepath}"; 1110 } 1111 1112 $headerfile = Cygpath2Win($headerfile); 1113 1114 $headerfile =~ s%^${build_dir}[\\/]?%.\\%; 1115 $headerfile =~ s%^${build_dir_win}[\\/]?%.\\%; 1116 if ($sim_ac_relative_src_dir_p) { 1117 $sim_ac_relative_src_dir_win = Unix2Dos($sim_ac_relative_src_dir); 1118 $headerfile =~ s%^${src_dir}[\\/]?%${sim_ac_relative_src_dir_win}\\%; 1119 $headerfile =~ s%^${src_dir_win}[\\/]?%${sim_ac_relative_src_dir_win}\\%; 1120 } 1121 1122 # FIXME: this seems awfully redundant - check if the moc-rules can be 1123 # folded to one config-independent rule. 1124 print DSP <<"_EODSP"; 1125# Begin Source File 1126 1127SOURCE=${headerfile} 1128 1129!IF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Release)" 1130 1131# PROP IgnoreDefaultTool 1 1132#Begin Custom Build - moc'ing \$(InputPath) 1133InputPath=${headerfile} 1134 1135"${mocfile}" : \$(SOURCE) "\$(INTDIR)" "\$(OUTDIR)" 1136 \$(QTDIR)\\bin\\moc -o ${mocfile} ${headerfile} 1137 1138# End Custom Build 1139 1140!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 DLL (Debug)" 1141 1142# PROP IgnoreDefaultTool 1 1143#Begin Custom Build - moc'ing \$(InputPath) 1144InputPath=${headerfile} 1145 1146"${mocfile}" : \$(SOURCE) "\$(INTDIR)" "\$(OUTDIR)" 1147 \$(QTDIR)\\bin\\moc -o ${mocfile} ${headerfile} 1148 1149# End Custom Build 1150 1151!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 LIB (Release)" 1152 1153# PROP IgnoreDefaultTool 1 1154#Begin Custom Build - moc'ing \$(InputPath) 1155InputPath=${headerfile} 1156 1157"${mocfile}" : \$(SOURCE) "\$(INTDIR)" "\$(OUTDIR)" 1158 \$(QTDIR)\\bin\\moc -o ${mocfile} ${headerfile} 1159 1160# End Custom Build 1161 1162!ELSEIF "\$(CFG)" == "${library}\@${LIBRARY}_MAJOR_VERSION\@ - Win32 LIB (Debug)" 1163 1164# PROP IgnoreDefaultTool 1 1165#Begin Custom Build - moc'ing \$(InputPath) 1166InputPath=${headerfile} 1167 1168"${mocfile}" : \$(SOURCE) "\$(INTDIR)" "\$(OUTDIR)" 1169 \$(QTDIR)\\bin\\moc -o ${mocfile} ${headerfile} 1170 1171# End Custom Build 1172 1173!ENDIF 1174 1175# End Source File 1176_EODSP 1177 1178 } 1179} 1180 1181if ( $outputfile =~ /\.so\./ ) { 1182 # this is how we detect the last command in the build process 1183 1184 # fix dependency first 1185 open(OUT, ">${outputfile}"); 1186 print OUT $date; 1187 close(OUT); 1188 1189 # "close" the dsp file 1190 print DSP "# End Group\n"; 1191 print DSP "# End Group\n"; 1192 1193 # We need to know about the root build dir and source dir to trigger the 1194 # header installation rule, and to locate the additional source files we 1195 # should put in the .dsp file 1196 $builddir = $studiofile; 1197 $builddir =~ s%/[^/]*$%%; 1198 $builddir_unix = $builddir; 1199 $builddir = Cygpath2Win($builddir); 1200 1201 $sourcedir = $me; 1202 $sourcedir =~ s%[\\/]cfg[\\/]gendsp\..*$%%; 1203 $sourcedir_unix = $sourcedir; 1204 $sourcedir = Cygpath2Win($sourcedir); 1205 1206 # PUBLIC HEADERS 1207 # To get the list of public header files, we run "make install" into a 1208 # temporary directory, while overriding the header-install program to be 1209 # this script with a magic option as the first argument. Afterwards we 1210 # clean out the temporary install dir. 1211 ClearVars(); 1212 print DSP "# Begin Group \"Public Headers\"\n"; 1213 print DSP "\n"; 1214 print DSP "# PROP Default_Filter \"h;ic;icc\"\n"; 1215 close(DSP); # .dsp is appended to from subprocesses here... 1216 $tmpdir = "/tmp/dsp-install.tmp"; 1217 system("cd ${builddir_unix}; make INSTALL_HEADER=\"$me --register-public-header ${studiofile}\" DESTDIR=\"${tmpdir}\" install-data"); 1218 system("rm -rf ${tmpdir}"); 1219 LoadVars(); 1220 open(DSP, ">>${studiofile}"); 1221 if ( $prev_group ne "" ) { 1222 print DSP "# End Group\n"; 1223 } 1224 print DSP "# End Group\n"; 1225 1226 # PRIVATE HEADERS 1227 # I don't know how to properly construct a list of private headers yet, 1228 # but we can for sure assume that all .ic/.icc source files are includes 1229 # used from other source files. We also assume that header files that 1230 # check for <lib>_INTERNAL and emits a #error with a message containing 1231 # "private" or "internal" is an internal header file. 1232 ClearVars(); 1233 print DSP "# Begin Group \"Private Headers\"\n"; 1234 print DSP "\n"; 1235 print DSP "# PROP Default_Filter \"h;ic;icc\"\n"; 1236 open(FIND, "(find ${src_dir}/src ${src_dir}/include ${src_dir}/data ${src_dir}/lib ${build_dir} -name \"*.h\" | xargs grep -l \"_INTERNAL\\\$\" | xargs grep -i -l \"#error.*private\"; find ${src_dir}/src ${src_dir}/lib ${build_dir} -name \"*.ic\" -o -name \"*.icc\" ) | sort | uniq |"); 1237 @files = <FIND>; 1238 close(FIND); 1239 1240 $prev_group = ""; 1241 for $file (@files) { 1242 LoadVars(); 1243 # $filename = Basename($file, ""); 1244 next if ($file =~ m/config-wrapper.h/o); 1245 next if ($file =~ m/discard.h/o); 1246 1247 $group = Dirname($file); 1248 $group =~ s%^.*[\\/]%%g; 1249 if ($group eq "include") { 1250 if ($file =~ m/${build_dir}/) { 1251 $group = "[setup]"; 1252 } else { 1253 $group = "root"; 1254 } 1255 } 1256 SaveVars(); 1257 1258 $filepath = Cygpath2Win($file); 1259 1260 $filepath =~ s%^${build_dir}[\\/]?%.\\%; 1261 $filepath =~ s%^${build_dir_win}[\\/]?%.\\%; 1262 if ($sim_ac_relative_src_dir_p) { 1263 $sim_ac_relative_src_dir_win = Unix2Dos($sim_ac_relative_src_dir); 1264 $filepath =~ s%^${src_dir}[\\/]?%${sim_ac_relative_src_dir_win}\\%; 1265 $filepath =~ s%^${src_dir_win}[\\/]?%${sim_ac_relative_src_dir_win}\\%; 1266 } 1267 1268 if ( $group ne $prev_group ) { 1269 if ($prev_group ne "") { 1270 print DSP "# End Group\n"; 1271 } 1272 if ($filepath =~ m/include/o) { 1273 print DSP "# Begin Group \"${group} headers\"\n"; 1274 } else { 1275 print DSP "# Begin Group \"${group} local includes\"\n"; 1276 } 1277 print DSP "\n"; 1278 print DSP "# PROP Default_Filter \"h;ic;icc\"\n"; 1279 } 1280 print DSP <<"_EODSP"; 1281# Begin Source File 1282 1283SOURCE=${filepath} 1284# PROP Exclude_From_Build 1 1285# End Source File 1286_EODSP 1287 } 1288 1289# open(FIND, "find ${src_dir}/src ${build_dir} -name \"*.ic\" -o -name \"*.icc\" |"); 1290# @files = <FIND>; 1291# close(FIND); 1292# for $file (@files) { 1293# 1294# $filepath = $file; 1295# 1296# $filepath = Cygpath2Win($filepath); 1297# 1298# $filepath =~ s%^${build_dir}[\\/]?%.\\%; 1299# $filepath =~ s%^${build_dir_win}[\\/]?%.\\%; 1300# if ($sim_ac_relative_src_dir_p) { 1301# $sim_ac_relative_src_dir_win = Unix2Dos($sim_ac_relative_src_dir); 1302# $filepath =~ s%^${src_dir}[\\/]?%${sim_ac_relative_src_dir_win}\\%; 1303# $filepath =~ s%^${src_dir_win}[\\/]?%${sim_ac_relative_src_dir_win}\\%; 1304# } 1305# 1306# print DSP <<"_EODSP"; 1307## Begin Source File 1308# 1309#SOURCE=${filepath} 1310## PROP Exclude_From_Build 1 1311## End Source File 1312#_EODSP 1313# } 1314 1315 if ($group ne "") { 1316 print DSP "# End Group\n"; 1317 } 1318 print DSP <<"_EODSP"; 1319# End Group 1320# End Target 1321# End Project 1322_EODSP 1323 close(DSP); 1324 1325 # create the .dsw file 1326 $workspacefile = Dirname($studiofile) . "/" . Basename($studiofile, ".dsp") . ".dsw"; 1327 1328 open(DSW, ">${workspacefile}"); 1329 print DSW <<"_EODSW"; 1330Microsoft Developer Studio Workspace File, Format Version 6.00 1331# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 1332 1333############################################################################### 1334 1335Project: "${library}\@${LIBRARY}_MAJOR_VERSION\@"=.\\${library}\@${LIBRARY}_MAJOR_VERSION\@.dsp - Package Owner=<4> 1336 1337Package=<5> 1338{{{ 1339}}} 1340 1341Package=<4> 1342{{{ 1343}}} 1344 1345############################################################################### 1346 1347Project: "${library}\@${LIBRARY}_MAJOR_VERSION\@_install"=.\\${library}\@${LIBRARY}_MAJOR_VERSION\@_install.dsp - Package Owner=<4> 1348 1349Package=<5> 1350{{{ 1351}}} 1352 1353Package=<4> 1354{{{ 1355 Begin Project Dependency 1356 Project_Dep_Name ${library}\@${LIBRARY}_MAJOR_VERSION\@ 1357 End Project Dependency 1358}}} 1359 1360############################################################################### 1361 1362Project: "${library}\@${LIBRARY}_MAJOR_VERSION\@_uninstall"=.\\${library}\@${LIBRARY}_MAJOR_VERSION\@_uninstall.dsp - Package Owner=<4> 1363 1364Package=<5> 1365{{{ 1366}}} 1367 1368Package=<4> 1369{{{ 1370}}} 1371 1372############################################################################### 1373 1374Project: "${library}\@${LIBRARY}_MAJOR_VERSION\@_docs"=.\\${library}\@${LIBRARY}_MAJOR_VERSION\@_docs.dsp - Package Owner=<4> 1375 1376Package=<5> 1377{{{ 1378}}} 1379 1380Package=<4> 1381{{{ 1382}}} 1383 1384############################################################################### 1385 1386Global: 1387 1388Package=<5> 1389{{{ 1390}}} 1391 1392Package=<3> 1393{{{ 1394}}} 1395 1396############################################################################### 1397 1398_EODSW 1399 close(DSW); 1400 1401 # Make everything peachy for MS DOS 1402 1403 SubstFile($studiofile); 1404 SubstFile($installstudiofile); 1405 SubstFile($uninstallstudiofile); 1406 SubstFile($docstudiofile); 1407 SubstFile($workspacefile); 1408 $installheadersfile = $studiofile; 1409 $installheadersfile =~ s,([^\\/0-9]*)[0-9][^\\/]*\.dsp,install-headers.bat,; 1410 # don't generate install-headers inside misc/ to be able to generate 1411 # concurrently inside several msvc*/-directories. 1412 # $installheadersfile =~ s,msvc[6789]/,misc/,; 1413 $uninstallheadersfile = $installheadersfile; 1414 $uninstallheadersfile =~ s/install-hea/uninstall-hea/; 1415 SubstBatFile($installheadersfile); 1416 SubstBatFile($uninstallheadersfile); 1417 1418 # Transform paths to be relative paths for non-installer-builds too. 1419 # This should probably be configurable in some way though. 1420 if ( $sourcedir eq $builddir ) { 1421 $relsourcedir = "."; 1422 } else { 1423 $num = 1; 1424 while ( true ) { 1425 $presource = `echo ${sourcedir} | cut -d'\' -f1-$num`; 1426 $prebuild = `echo ${builddir} | cut -d'\' -f1-$num`; 1427 if ( $presource ne $prebuild ) { 1428 break; 1429 } 1430 ++$num; 1431 } 1432 --$num; 1433 1434 if ( $num == 0 ) { 1435 # relative path impossible 1436 $relsourcedir = $sourcedirregexp; 1437 } else { 1438 $numplus = $num + 1; 1439 $upfix = `echo "${builddir}\\\\" | cut -d'\' -f${numplus}- | sed -e 's%[^\\\\]*\\\\%..\\\\%g' -e 's%\\\\%\\\\\\\\%g'`; 1440 $postfix = `echo ${sourcedir} | cut -d'\' -f${numplus}- | sed -e 's%\\\\%\\\\\\\\%g'`; 1441 $relsourcedir = "${upfix}${postfix}"; 1442 } 1443 } 1444 1445 # FIXME: update paths to relative paths 1446 #sed -e "s%$sourcedirregexp%$relsourcedir%g" \ 1447 # -e "s%$builddirregexp\\\\%.\\\\%g" \ 1448 # -e "s%$builddirregexp%.\\\\%g" \ 1449 # <"$studiofile.txt2" >"$studiofile.txt" 1450 1451 # here we try to reverse some environment variable values back to their 1452 # variable references, to make the project less system-dependent. 1453 for $var (@reversevars) { 1454 $varval = $ENV{$var}; 1455 $varval = Cygpath2Win($varval); 1456 # FIXME: reverse variable values in the project files 1457 } 1458 1459 # we want to link debug versions of this project with debug versions of the 1460 # libs they depend on. we only do this for our own known libraries though. 1461 @debuglibs = ( 1462 "coin[0-9]", 1463 "soqt[0-9]", 1464 "sowin[0-9]", 1465 "nutsnbolts[0-9]", 1466 "smallchange[0-9]", 1467 "simvoleon[0-9]" 1468 ); 1469 for $lib (@debuglibs) { 1470 # FIXME: rewrite debuglibs ($?.lib -> $?d.lib) for lines matching "/debug" 1471 } 1472 1473 # do unix2dos conversion (\n -> \r\n) on the DevStudio files 1474 CRLFFile($studiofile); 1475 CRLFFile($installstudiofile); 1476 CRLFFile($uninstallstudiofile); 1477 CRLFFile($docstudiofile); 1478 CRLFFile($workspacefile); 1479 # clean out temporary files 1480 1481} 1482