Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1 | #!/usr/bin/perl -w |
| 2 | |
| 3 | # Copyright 2000 Francois Gouget for CodeWeavers |
| 4 | # fgouget@codeweavers.com |
| 5 | # |
François Gouget | a62703e | 2001-02-12 01:22:58 +0000 | [diff] [blame] | 6 | my $version="0.5.6"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 7 | |
| 8 | use Cwd; |
| 9 | use File::Basename; |
| 10 | use File::Copy; |
| 11 | |
| 12 | |
| 13 | |
| 14 | ##### |
| 15 | # |
| 16 | # Options |
| 17 | # |
| 18 | ##### |
| 19 | |
| 20 | # The following constants define what we do with the case of filenames |
| 21 | |
| 22 | ## |
| 23 | # Never rename a file to lowercase |
| 24 | my $OPT_LOWER_NONE=0; |
| 25 | |
| 26 | ## |
| 27 | # Rename all files to lowercase |
| 28 | my $OPT_LOWER_ALL=1; |
| 29 | |
| 30 | ## |
| 31 | # Rename only files that are all uppercase to lowercase |
| 32 | my $OPT_LOWER_UPPERCASE=2; |
| 33 | |
| 34 | |
| 35 | # The following constants define whether to ask questions or not |
| 36 | |
| 37 | ## |
| 38 | # No (synonym of never) |
| 39 | my $OPT_ASK_NO=0; |
| 40 | |
| 41 | ## |
| 42 | # Yes (always) |
| 43 | my $OPT_ASK_YES=1; |
| 44 | |
| 45 | ## |
| 46 | # Skip the questions till the end of this scope |
| 47 | my $OPT_ASK_SKIP=-1; |
| 48 | |
| 49 | |
| 50 | # General options |
| 51 | |
| 52 | ## |
François Gouget | c1f016b | 2001-01-10 22:43:21 +0000 | [diff] [blame] | 53 | # This is the directory in which winemaker will operate. |
| 54 | my $opt_work_dir; |
| 55 | |
| 56 | ## |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 57 | # Make a backup of the files |
| 58 | my $opt_backup; |
| 59 | |
| 60 | ## |
| 61 | # Defines which files to rename |
| 62 | my $opt_lower; |
| 63 | |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 64 | ## |
| 65 | # If we don't find the file referenced by an include, lower it |
| 66 | my $opt_lower_include; |
| 67 | |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 68 | |
| 69 | # Options for the 'Source' method |
| 70 | |
| 71 | ## |
| 72 | # Specifies that we have only one target so that all sources relate |
| 73 | # to this target. By default this variable is left undefined which |
| 74 | # means winemaker should try to find out by itself what the targets |
| 75 | # are. If not undefined then this contains the name of the default |
| 76 | # target (without the extension). |
| 77 | my $opt_single_target; |
| 78 | |
| 79 | ## |
| 80 | # If '$opt_single_target' has been specified then this is the type of |
| 81 | # that target. Otherwise it specifies whether the default target type |
| 82 | # is guiexe or cuiexe. |
| 83 | my $opt_target_type; |
| 84 | |
| 85 | ## |
| 86 | # Contains the default set of flags to be used when creating a new target. |
| 87 | my $opt_flags; |
| 88 | |
| 89 | ## |
| 90 | # If true then winemaker should ask questions to the user as it goes |
| 91 | # along. |
| 92 | my $opt_is_interactive; |
| 93 | my $opt_ask_project_options; |
| 94 | my $opt_ask_target_options; |
| 95 | |
| 96 | ## |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 97 | # If false then winemaker should not generate any file, i.e. |
| 98 | # no makefiles, but also no .spec files, no configure.in, etc. |
| 99 | my $opt_no_generated_files; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 100 | |
| 101 | ## |
| 102 | # Specifies not to print the banner if set. |
| 103 | my $opt_no_banner; |
| 104 | |
| 105 | |
| 106 | |
| 107 | ##### |
| 108 | # |
| 109 | # Target modelization |
| 110 | # |
| 111 | ##### |
| 112 | |
| 113 | # The description of a target is stored in an array. The constants |
| 114 | # below identify what is stored at each index of the array. |
| 115 | |
| 116 | ## |
| 117 | # This is the name of the target. |
| 118 | my $T_NAME=0; |
| 119 | |
| 120 | ## |
| 121 | # Defines the type of target we want to build. See the TT_xxx |
| 122 | # constants below |
| 123 | my $T_TYPE=1; |
| 124 | |
| 125 | ## |
| 126 | # Defines the target's enty point, i.e. the function that is called |
| 127 | # on startup. |
| 128 | my $T_INIT=2; |
| 129 | |
| 130 | ## |
| 131 | # This is a bitfield containing flags refining the way the target |
| 132 | # should be handled. See the TF_xxx constants below |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 133 | my $T_FLAGS=3; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 134 | |
| 135 | ## |
| 136 | # This is a reference to an array containing the list of the |
| 137 | # resp. C, C++, RC, other (.h, .hxx, etc.) source files. |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 138 | my $T_SOURCES_C=4; |
| 139 | my $T_SOURCES_CXX=5; |
| 140 | my $T_SOURCES_RC=6; |
| 141 | my $T_SOURCES_MISC=7; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 142 | |
| 143 | ## |
| 144 | # This is a reference to an array containing the list of macro |
| 145 | # definitions |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 146 | my $T_DEFINES=8; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 147 | |
| 148 | ## |
| 149 | # This is a reference to an array containing the list of directory |
| 150 | # names that constitute the include path |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 151 | my $T_INCLUDE_PATH=9; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 152 | |
| 153 | ## |
| 154 | # Same as T_INCLUDE_PATH but for the library search path |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 155 | my $T_LIBRARY_PATH=10; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 156 | |
| 157 | ## |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 158 | # The list of Windows libraries to import |
| 159 | my $T_IMPORTS=11; |
| 160 | |
| 161 | ## |
| 162 | # The list of Unix libraries to link with |
| 163 | my $T_LIBRARIES=12; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 164 | |
| 165 | ## |
| 166 | # The list of dependencies between targets |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 167 | my $T_DEPENDS=13; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 168 | |
| 169 | |
| 170 | # The following constants define the recognized types of target |
| 171 | |
| 172 | ## |
| 173 | # This is not a real target. This type of target is used to collect |
| 174 | # the sources that don't seem to belong to any other target. Thus no |
| 175 | # real target is generated for them, we just put the sources of the |
| 176 | # fake target in the global source list. |
| 177 | my $TT_SETTINGS=0; |
| 178 | |
| 179 | ## |
| 180 | # For executables in the windows subsystem |
| 181 | my $TT_GUIEXE=1; |
| 182 | |
| 183 | ## |
| 184 | # For executables in the console subsystem |
| 185 | my $TT_CUIEXE=2; |
| 186 | |
| 187 | ## |
| 188 | # For dynamically linked libraries |
| 189 | my $TT_DLL=3; |
| 190 | |
| 191 | |
| 192 | # The following constants further refine how the target should be handled |
| 193 | |
| 194 | ## |
| 195 | # This target needs a wrapper |
| 196 | my $TF_WRAP=1; |
| 197 | |
| 198 | ## |
| 199 | # This target is a wrapper |
| 200 | my $TF_WRAPPER=2; |
| 201 | |
| 202 | ## |
| 203 | # This target is an MFC-based target |
| 204 | my $TF_MFC=4; |
| 205 | |
| 206 | ## |
| 207 | # Initialize a target: |
| 208 | # - set the target type to TT_SETTINGS, i.e. no real target will |
| 209 | # be generated. |
| 210 | sub target_init |
| 211 | { |
| 212 | my $target=$_[0]; |
| 213 | |
| 214 | @$target[$T_TYPE]=$TT_SETTINGS; |
| 215 | # leaving $T_INIT undefined |
| 216 | @$target[$T_FLAGS]=$opt_flags; |
| 217 | @$target[$T_SOURCES_C]=[]; |
| 218 | @$target[$T_SOURCES_CXX]=[]; |
| 219 | @$target[$T_SOURCES_RC]=[]; |
| 220 | @$target[$T_SOURCES_MISC]=[]; |
| 221 | @$target[$T_DEFINES]=[]; |
| 222 | @$target[$T_INCLUDE_PATH]=[]; |
| 223 | @$target[$T_LIBRARY_PATH]=[]; |
| 224 | @$target[$T_IMPORTS]=[]; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 225 | @$target[$T_LIBRARIES]=[]; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 226 | @$target[$T_DEPENDS]=[]; |
| 227 | } |
| 228 | |
| 229 | sub get_default_init |
| 230 | { |
| 231 | my $type=$_[0]; |
| 232 | if ($type == $TT_GUIEXE) { |
| 233 | return "WinMain"; |
| 234 | } elsif ($type == $TT_CUIEXE) { |
| 235 | return "main"; |
| 236 | } elsif ($type == $TT_DLL) { |
| 237 | return "DllMain"; |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | |
| 242 | |
| 243 | ##### |
| 244 | # |
| 245 | # Project modelization |
| 246 | # |
| 247 | ##### |
| 248 | |
| 249 | # First we have the notion of project. A project is described by an |
| 250 | # array (since we don't have structs in perl). The constants below |
| 251 | # identify what is stored at each index of the array. |
| 252 | |
| 253 | ## |
| 254 | # This is the path in which this project is located. In other |
| 255 | # words, this is the path to the Makefile. |
| 256 | my $P_PATH=0; |
| 257 | |
| 258 | ## |
| 259 | # This index contains a reference to an array containing the project-wide |
| 260 | # settings. The structure of that arrray is actually identical to that of |
| 261 | # a regular target since it can also contain extra sources. |
| 262 | my $P_SETTINGS=1; |
| 263 | |
| 264 | ## |
| 265 | # This index contains a reference to an array of targets for this |
| 266 | # project. Each target describes how an executable or library is to |
| 267 | # be built. For each target this description takes the same form as |
| 268 | # that of the project: an array. So this entry is an array of arrays. |
| 269 | my $P_TARGETS=2; |
| 270 | |
| 271 | ## |
| 272 | # Initialize a project: |
| 273 | # - set the project's path |
| 274 | # - initialize the target list |
| 275 | # - create a default target (will be removed later if unnecessary) |
| 276 | sub project_init |
| 277 | { |
| 278 | my $project=$_[0]; |
| 279 | my $path=$_[1]; |
| 280 | |
| 281 | my $project_settings=[]; |
| 282 | target_init($project_settings); |
| 283 | |
| 284 | @$project[$P_PATH]=$path; |
| 285 | @$project[$P_SETTINGS]=$project_settings; |
| 286 | @$project[$P_TARGETS]=[]; |
| 287 | } |
| 288 | |
| 289 | |
| 290 | |
| 291 | ##### |
| 292 | # |
| 293 | # Global variables |
| 294 | # |
| 295 | ##### |
| 296 | |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 297 | my %warnings; |
| 298 | |
| 299 | my %templates; |
| 300 | |
| 301 | ## |
| 302 | # Contains the list of all projects. This list tells us what are |
| 303 | # the subprojects of the main Makefile and where we have to generate |
| 304 | # Makefiles. |
| 305 | my @projects=(); |
| 306 | |
| 307 | ## |
| 308 | # This is the main project, i.e. the one in the "." directory. |
| 309 | # It may well be empty in which case the main Makefile will only |
| 310 | # call out subprojects. |
| 311 | my @main_project; |
| 312 | |
| 313 | ## |
| 314 | # Contains the defaults for the include path, etc. |
| 315 | # We store the defaults as if this were a target except that we only |
| 316 | # exploit the defines, include path, library path, library list and misc |
| 317 | # sources fields. |
| 318 | my @global_settings; |
| 319 | |
| 320 | ## |
| 321 | # If one of the projects requires the MFc then we set this global variable |
| 322 | # to true so that configure asks the user to provide a path tothe MFC |
| 323 | my $needs_mfc=0; |
| 324 | |
| 325 | |
| 326 | |
| 327 | ##### |
| 328 | # |
| 329 | # Utility functions |
| 330 | # |
| 331 | ##### |
| 332 | |
| 333 | ## |
| 334 | # Cleans up a name to make it an acceptable Makefile |
| 335 | # variable name. |
| 336 | sub canonize |
| 337 | { |
| 338 | my $name=$_[0]; |
| 339 | |
| 340 | $name =~ tr/a-zA-Z0-9_/_/c; |
| 341 | return $name; |
| 342 | } |
| 343 | |
| 344 | ## |
| 345 | # Returns true is the specified pathname is absolute. |
| 346 | # Note: pathnames that start with a variable '$' or |
| 347 | # '~' are considered absolute. |
| 348 | sub is_absolute |
| 349 | { |
| 350 | my $path=$_[0]; |
| 351 | |
| 352 | return ($path =~ /^[\/~\$]/); |
| 353 | } |
| 354 | |
| 355 | ## |
| 356 | # Performs a binary search looking for the specified item |
| 357 | sub bsearch |
| 358 | { |
| 359 | my $array=$_[0]; |
| 360 | my $item=$_[1]; |
| 361 | my $last=@{$array}-1; |
| 362 | my $first=0; |
| 363 | |
| 364 | while ($first<=$last) { |
| 365 | my $index=int(($first+$last)/2); |
| 366 | my $cmp=@$array[$index] cmp $item; |
| 367 | if ($cmp<0) { |
| 368 | $first=$index+1; |
| 369 | } elsif ($cmp>0) { |
| 370 | $last=$index-1; |
| 371 | } else { |
| 372 | return $index; |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | |
| 378 | |
| 379 | ##### |
| 380 | # |
| 381 | # 'Source'-based Project analysis |
| 382 | # |
| 383 | ##### |
| 384 | |
| 385 | ## |
| 386 | # Allows the user to specify makefile and target specific options |
| 387 | # - target: the structure in which to store the results |
| 388 | # - options: the string containing the options |
| 389 | sub source_set_options |
| 390 | { |
| 391 | my $target=$_[0]; |
| 392 | my $options=$_[1]; |
| 393 | |
| 394 | #FIXME: we must deal with escaping of stuff and all |
| 395 | foreach $option (split / /,$options) { |
| 396 | if (@$target[$T_TYPE] == $TT_SETTINGS and $option =~ /^-D/) { |
| 397 | push @{@$target[$T_DEFINES]},$option; |
| 398 | } elsif (@$target[$T_TYPE] == $TT_SETTINGS and $option =~ /^-I/) { |
| 399 | push @{@$target[$T_INCLUDE_PATH]},$option; |
| 400 | } elsif ($option =~ /^-L/) { |
| 401 | push @{@$target[$T_LIBRARY_PATH]},$option; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 402 | } elsif ($option =~ /^-i/) { |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 403 | push @{@$target[$T_IMPORTS]},$'; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 404 | } elsif ($option =~ /^-l/) { |
| 405 | push @{@$target[$T_LIBRARIES]},$'; |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 406 | } elsif (@$target[$T_TYPE] != $TT_DLL and |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 407 | $option =~ /^--wrap/) { |
Francois Gouget | afa36ce | 2001-03-01 22:11:10 +0000 | [diff] [blame] | 408 | @$target[$T_FLAGS]|=$TF_WRAP; |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 409 | } elsif (@$target[$T_TYPE] != $TT_DLL and |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 410 | $option =~ /^--nowrap/) { |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 411 | @$target[$T_FLAGS]&=~$TF_WRAP; |
| 412 | } elsif ($option =~ /^--mfc/) { |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 413 | @$target[$T_FLAGS]|=$TF_MFC; |
Francois Gouget | afa36ce | 2001-03-01 22:11:10 +0000 | [diff] [blame] | 414 | if (@$target[$T_TYPE] != $TT_DLL) { |
| 415 | @$target[$T_FLAGS]|=$TF_WRAP; |
| 416 | } |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 417 | } elsif ($option =~ /^--nomfc/) { |
| 418 | @$target[$T_FLAGS]&=~$TF_MFC; |
Francois Gouget | afa36ce | 2001-03-01 22:11:10 +0000 | [diff] [blame] | 419 | @$target[$T_FLAGS]&=~($TF_MFC|$TF_WRAP); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 420 | } else { |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 421 | print STDERR "error: unknown option \"$option\"\n"; |
| 422 | return 0; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 423 | } |
| 424 | } |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 425 | return 1; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | ## |
| 429 | # Scans the specified directory to: |
| 430 | # - see if we should create a Makefile in this directory. We normally do |
| 431 | # so if we find a project file and sources |
| 432 | # - get a list of targets for this directory |
| 433 | # - get the list of source files |
| 434 | sub source_scan_directory |
| 435 | { |
| 436 | # a reference to the parent's project |
| 437 | my $parent_project=$_[0]; |
| 438 | # the full relative path to the current directory, including a |
| 439 | # trailing '/', or an empty string if this is the top level directory |
| 440 | my $path=$_[1]; |
| 441 | # the name of this directory, including a trailing '/', or an empty |
| 442 | # string if this is the top level directory |
| 443 | my $dirname=$_[2]; |
Francois Gouget | 3266b88 | 2001-03-03 00:17:11 +0000 | [diff] [blame] | 444 | # if set then no targets will be looked for and the sources will all |
| 445 | # end up in the parent_project's 'misc' bucket |
| 446 | my $no_target=$_[3]; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 447 | |
| 448 | # reference to the project for this directory. May not be used |
| 449 | my $project; |
| 450 | # list of targets found in the 'current' directory |
| 451 | my %targets; |
| 452 | # list of sources found in the current directory |
| 453 | my @sources_c=(); |
| 454 | my @sources_cxx=(); |
| 455 | my @sources_rc=(); |
| 456 | my @sources_misc=(); |
| 457 | # true if this directory contains a Windows project |
| 458 | my $has_win_project=0; |
| 459 | # If we don't find any executable/library then we might make up targets |
| 460 | # from the list of .dsp/.mak files we find since they usually have the |
| 461 | # same name as their target. |
| 462 | my @dsp_files=(); |
| 463 | my @mak_files=(); |
| 464 | |
| 465 | if (defined $opt_single_target or $dirname eq "") { |
| 466 | # Either there is a single target and thus a single project, |
| 467 | # or we are in the top level directory for which a project |
| 468 | # already exists |
| 469 | $project=$parent_project; |
| 470 | } else { |
| 471 | $project=[]; |
| 472 | project_init($project,$path); |
| 473 | } |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 474 | my $project_settings=@$project[$P_SETTINGS]; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 475 | |
| 476 | # First find out what this directory contains: |
| 477 | # collect all sources, targets and subdirectories |
| 478 | my $directory=get_directory_contents($path); |
| 479 | foreach $dentry (@$directory) { |
| 480 | if ($dentry =~ /^\./) { |
| 481 | next; |
| 482 | } |
| 483 | my $fullentry="$path$dentry"; |
| 484 | if (-d "$fullentry") { |
| 485 | if ($dentry =~ /^(Release|Debug)/i) { |
| 486 | # These directories are often used to store the object files and the |
| 487 | # resulting executable/library. They should not contain anything else. |
| 488 | my @candidates=grep /\.(exe|dll)$/i, @{get_directory_contents("$fullentry")}; |
| 489 | foreach $candidate (@candidates) { |
| 490 | if ($candidate =~ s/\.exe$//i) { |
| 491 | $targets{$candidate}=1; |
| 492 | } elsif ($candidate =~ s/^(.*)\.dll$/lib$1.so/i) { |
| 493 | $targets{$candidate}=1; |
| 494 | } |
| 495 | } |
Francois Gouget | 4ec1059 | 2000-12-02 20:12:45 +0000 | [diff] [blame] | 496 | } elsif ($dentry =~ /^include/i) { |
| 497 | # This directory must contain headers we're going to need |
| 498 | push @{@$project_settings[$T_INCLUDE_PATH]},"-I$dentry"; |
Francois Gouget | 3266b88 | 2001-03-03 00:17:11 +0000 | [diff] [blame] | 499 | source_scan_directory($project,"$fullentry/","$dentry/",1); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 500 | } else { |
| 501 | # Recursively scan this directory. Any source file that cannot be |
Francois Gouget | 3266b88 | 2001-03-03 00:17:11 +0000 | [diff] [blame] | 502 | # attributed to a project in one of the subdirectories will be |
| 503 | # attributed to this project. |
| 504 | source_scan_directory($project,"$fullentry/","$dentry/",$no_target); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 505 | } |
| 506 | } elsif (-f "$fullentry") { |
| 507 | if ($dentry =~ s/\.exe$//i) { |
| 508 | $targets{$dentry}=1; |
| 509 | } elsif ($dentry =~ s/^(.*)\.dll$/lib$1.so/i) { |
| 510 | $targets{$dentry}=1; |
| 511 | } elsif ($dentry =~ /\.c$/i and $dentry !~ /\.spec\.c$/) { |
| 512 | push @sources_c,"$dentry"; |
| 513 | } elsif ($dentry =~ /\.(cpp|cxx)$/i) { |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 514 | if ($dentry =~ /^stdafx.cpp$/i) { |
| 515 | push @sources_misc,"$dentry"; |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 516 | @$project_settings[$T_FLAGS]|=$TF_MFC; |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 517 | } else { |
| 518 | push @sources_cxx,"$dentry"; |
| 519 | } |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 520 | } elsif ($dentry =~ /\.rc$/i) { |
| 521 | push @sources_rc,"$dentry"; |
| 522 | } elsif ($dentry =~ /\.(h|hxx|inl|rc2|dlg)$/i) { |
| 523 | push @sources_misc,"$dentry"; |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 524 | if ($dentry =~ /^stdafx.h$/i) { |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 525 | @$project_settings[$T_FLAGS]|=$TF_MFC; |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 526 | } |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 527 | } elsif ($dentry =~ /\.dsp$/i) { |
| 528 | push @dsp_files,"$dentry"; |
| 529 | $has_win_project=1; |
| 530 | } elsif ($dentry =~ /\.mak$/i) { |
| 531 | push @mak_files,"$dentry"; |
| 532 | $has_win_project=1; |
| 533 | } elsif ($dentry =~ /^makefile/i) { |
| 534 | $has_win_project=1; |
| 535 | } |
| 536 | } |
| 537 | } |
| 538 | closedir(DIRECTORY); |
| 539 | |
| 540 | # If we have a single target then all we have to do is assign |
| 541 | # all the sources to it and we're done |
| 542 | # FIXME: does this play well with the --interactive mode? |
| 543 | if ($opt_single_target) { |
| 544 | my $target=@{@$project[$P_TARGETS]}[0]; |
| 545 | push @{@$target[$T_SOURCES_C]},map "$path$_",@sources_c; |
| 546 | push @{@$target[$T_SOURCES_CXX]},map "$path$_",@sources_cxx; |
| 547 | push @{@$target[$T_SOURCES_RC]},map "$path$_",@sources_rc; |
| 548 | push @{@$target[$T_SOURCES_MISC]},map "$path$_",@sources_misc; |
| 549 | return; |
| 550 | } |
Francois Gouget | 3266b88 | 2001-03-03 00:17:11 +0000 | [diff] [blame] | 551 | if ($no_target) { |
| 552 | my $parent_settings=@$parent_project[$P_SETTINGS]; |
| 553 | push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_c; |
| 554 | push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_cxx; |
| 555 | push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_rc; |
| 556 | push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_misc; |
| 557 | return; |
| 558 | } |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 559 | |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 560 | my $source_count=@sources_c+@sources_cxx+@sources_rc+ |
| 561 | @{@$project_settings[$T_SOURCES_C]}+ |
| 562 | @{@$project_settings[$T_SOURCES_CXX]}+ |
| 563 | @{@$project_settings[$T_SOURCES_RC]}; |
| 564 | if ($source_count == 0) { |
| 565 | # A project without real sources is not a project, get out! |
| 566 | if ($project!=$parent_project) { |
Francois Gouget | 3266b88 | 2001-03-03 00:17:11 +0000 | [diff] [blame] | 567 | my $parent_settings=@$parent_project[$P_SETTINGS]; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 568 | push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_misc; |
| 569 | push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@{@$project_settings[$T_SOURCES_MISC]}; |
| 570 | } |
| 571 | return; |
| 572 | } |
| 573 | #print "targets=",%targets,"\n"; |
| 574 | #print "target_count=$target_count\n"; |
| 575 | #print "has_win_project=$has_win_project\n"; |
| 576 | #print "dirname=$dirname\n"; |
| 577 | |
| 578 | my $target_count; |
| 579 | if (($has_win_project != 0) or ($dirname eq "")) { |
| 580 | # Deal with cases where we could not find any executable/library, and |
| 581 | # thus have no target, although we did find some sort of windows project. |
| 582 | $target_count=keys %targets; |
| 583 | if ($target_count == 0) { |
| 584 | # Try to come up with a target list based on .dsp/.mak files |
| 585 | my $prj_list; |
| 586 | if (@dsp_files > 0) { |
| 587 | $prj_list=\@dsp_files; |
| 588 | } else { |
| 589 | $prj_list=\@mak_files; |
| 590 | } |
| 591 | foreach $filename (@$prj_list) { |
| 592 | $filename =~ s/\.(dsp|mak)$//i; |
| 593 | if ($opt_target_type == $TT_DLL) { |
| 594 | $filename = "lib$filename.so"; |
| 595 | } |
| 596 | $targets{$filename}=1; |
| 597 | } |
| 598 | $target_count=keys %targets; |
| 599 | if ($target_count == 0) { |
| 600 | # Still nothing, try the name of the directory |
| 601 | my $name; |
| 602 | if ($dirname eq "") { |
| 603 | # Bad luck, this is the top level directory! |
| 604 | $name=(split /\//, cwd)[-1]; |
| 605 | } else { |
| 606 | $name=$dirname; |
| 607 | # Remove the trailing '/'. Also eliminate whatever is after the last |
| 608 | # '.' as it is likely to be meaningless (.orig, .new, ...) |
| 609 | $name =~ s+(/|\.[^.]*)$++; |
| 610 | if ($name eq "src") { |
| 611 | # 'src' is probably a subdirectory of the real project directory. |
| 612 | # Try again with the parent (if any). |
| 613 | my $parent=$path; |
| 614 | if ($parent =~ s+([^/]*)/[^/]*/$+$1+) { |
| 615 | $name=$parent; |
| 616 | } else { |
| 617 | $name=(split /\//, cwd)[-1]; |
| 618 | } |
| 619 | } |
| 620 | } |
| 621 | $name =~ s+(/|\.[^.]*)$++; |
| 622 | if ($opt_target_type == $TT_DLL) { |
| 623 | $name = "lib$name.so"; |
| 624 | } |
| 625 | $targets{$name}=1; |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | # Ask confirmation to the user if he wishes so |
| 630 | if ($opt_is_interactive == $OPT_ASK_YES) { |
| 631 | my $target_list=join " ",keys %targets; |
Francois Gouget | fb5b590 | 2000-11-30 20:34:39 +0000 | [diff] [blame] | 632 | print "\n*** In ",($path?$path:"./"),"\n"; |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 633 | print "* winemaker found the following list of (potential) targets\n"; |
| 634 | print "* $target_list\n"; |
| 635 | print "* Type enter to use it as is, your own comma-separated list of\n"; |
| 636 | print "* targets, 'none' to assign the source files to a parent directory,\n"; |
| 637 | print "* or 'ignore' to ignore everything in this directory tree.\n"; |
| 638 | print "* Target list:\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 639 | $target_list=<STDIN>; |
| 640 | chomp $target_list; |
| 641 | if ($target_list eq "") { |
| 642 | # Keep the target list as is, i.e. do nothing |
| 643 | } elsif ($target_list eq "none") { |
| 644 | # Empty the target list |
| 645 | undef %targets; |
| 646 | } elsif ($target_list eq "ignore") { |
| 647 | # Ignore this subtree altogether |
| 648 | return; |
| 649 | } else { |
| 650 | undef %targets; |
| 651 | foreach $target (split /,/,$target_list) { |
| 652 | $target =~ s+^\s*++; |
| 653 | $target =~ s+\s*$++; |
| 654 | # Also accept .exe and .dll as a courtesy |
| 655 | $target =~ s+(.*)\.dll$+lib$1.so+; |
| 656 | $target =~ s+\.exe$++; |
| 657 | $targets{$target}=1; |
| 658 | } |
| 659 | } |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | # If we have no project at this level, then transfer all |
| 664 | # the sources to the parent project |
| 665 | $target_count=keys %targets; |
| 666 | if ($target_count == 0) { |
| 667 | if ($project!=$parent_project) { |
| 668 | my $parent_settings=@$parent_project[$P_SETTINGS]; |
| 669 | push @{@$parent_settings[$T_SOURCES_C]},map "$dirname$_",@sources_c; |
| 670 | push @{@$parent_settings[$T_SOURCES_CXX]},map "$dirname$_",@sources_cxx; |
| 671 | push @{@$parent_settings[$T_SOURCES_RC]},map "$dirname$_",@sources_rc; |
| 672 | push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@sources_misc; |
| 673 | push @{@$parent_settings[$T_SOURCES_MISC]},map "$dirname$_",@{@$project_settings[$T_SOURCES_MISC]}; |
| 674 | } |
| 675 | return; |
| 676 | } |
| 677 | |
| 678 | # Otherwise add this project to the project list, except for |
| 679 | # the main project which is already in the list. |
| 680 | if ($dirname ne "") { |
| 681 | push @projects,$project; |
| 682 | } |
| 683 | |
| 684 | # Ask for project-wide options |
| 685 | if ($opt_ask_project_options == $OPT_ASK_YES) { |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 686 | my $flag_desc=""; |
| 687 | if ((@$project_settings[$T_FLAGS] & $TF_MFC)!=0) { |
| 688 | $flag_desc="mfc"; |
| 689 | } |
| 690 | if ((@$project_settings[$T_FLAGS] & $TF_WRAP)!=0) { |
| 691 | if ($flag_desc ne "") { |
| 692 | $flag_desc.=", "; |
| 693 | } |
| 694 | $flag_desc.="wrapped"; |
| 695 | } |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 696 | print "* Type any project-wide options (-D/-I/-L/-i/-l/--mfc/--wrap),\n"; |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 697 | if (defined $flag_desc) { |
| 698 | print "* (currently $flag_desc)\n"; |
| 699 | } |
| 700 | print "* or 'skip' to skip the target specific options,\n"; |
| 701 | print "* or 'never' to not be asked this question again:\n"; |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 702 | while (1) { |
| 703 | my $options=<STDIN>; |
| 704 | chomp $options; |
| 705 | if ($options eq "skip") { |
| 706 | $opt_ask_target_options=$OPT_ASK_SKIP; |
| 707 | last; |
| 708 | } elsif ($options eq "never") { |
| 709 | $opt_ask_project_options=$OPT_ASK_NO; |
| 710 | last; |
| 711 | } elsif (source_set_options($project_settings,$options)) { |
| 712 | last; |
| 713 | } |
| 714 | print "Please re-enter the options:\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 715 | } |
| 716 | } |
| 717 | |
| 718 | # - Create the targets |
| 719 | # - Check if we have both libraries and programs |
| 720 | # - Match each target with source files (sort in reverse |
| 721 | # alphabetical order to get the longest matches first) |
| 722 | my @local_imports=(); |
| 723 | my @local_depends=(); |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 724 | my @exe_list=(); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 725 | foreach $target_name (sort { $b cmp $a } keys %targets) { |
| 726 | # Create the target... |
| 727 | my $basename; |
| 728 | my $target=[]; |
| 729 | target_init($target); |
| 730 | @$target[$T_NAME]=$target_name; |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 731 | @$target[$T_FLAGS]|=@$project_settings[$T_FLAGS]; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 732 | if ($target_name =~ /^lib(.*)\.so$/) { |
| 733 | @$target[$T_TYPE]=$TT_DLL; |
| 734 | @$target[$T_INIT]=get_default_init($TT_DLL); |
| 735 | @$target[$T_FLAGS]&=~$TF_WRAP; |
| 736 | $basename=$1; |
| 737 | push @local_depends,$target_name; |
| 738 | push @local_imports,$basename; |
| 739 | } else { |
| 740 | @$target[$T_TYPE]=$opt_target_type; |
| 741 | @$target[$T_INIT]=get_default_init($opt_target_type); |
| 742 | $basename=$target_name; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 743 | push @exe_list,$target; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 744 | } |
Francois Gouget | 73995e2 | 2000-12-15 22:58:55 +0000 | [diff] [blame] | 745 | # This is the default link list of Visual Studio, except odbccp32 |
| 746 | # which we don't have in Wine. Also I add ntdll which seems |
Francois Gouget | 4ec1059 | 2000-12-02 20:12:45 +0000 | [diff] [blame] | 747 | # necessary for Winelib. |
Francois Gouget | 49fc317 | 2001-03-10 19:15:16 +0000 | [diff] [blame^] | 748 | my @std_imports=qw(advapi32.dll comdlg32.dll gdi32.dll kernel32.dll ntdll.dll odbc32.dll ole32.dll oleaut32.dll shell32.dll user32.dll winspool.drv); |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 749 | @$target[$T_IMPORTS]=\@std_imports; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 750 | push @{@$project[$P_TARGETS]},$target; |
| 751 | |
| 752 | # Ask for target-specific options |
| 753 | if ($opt_ask_target_options == $OPT_ASK_YES) { |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 754 | my $flag_desc=""; |
| 755 | if ((@$target[$T_FLAGS] & $TF_MFC)!=0) { |
| 756 | $flag_desc=" (mfc"; |
| 757 | } |
| 758 | if ((@$target[$T_FLAGS] & $TF_WRAP)!=0) { |
| 759 | if ($flag_desc ne "") { |
| 760 | $flag_desc.=", "; |
| 761 | } else { |
| 762 | $flag_desc=" ("; |
| 763 | } |
| 764 | $flag_desc.="wrapped"; |
| 765 | } |
| 766 | if ($flag_desc ne "") { |
| 767 | $flag_desc.=")"; |
| 768 | } |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 769 | print "* Specify any link option (-L/-i/-l/--mfc/--wrap) specific to the target\n"; |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 770 | print "* \"$target_name\"$flag_desc or 'never' to not be asked this question again:\n"; |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 771 | while (1) { |
| 772 | my $options=<STDIN>; |
| 773 | chomp $options; |
| 774 | if ($options eq "never") { |
| 775 | $opt_ask_target_options=$OPT_ASK_NO; |
| 776 | last; |
| 777 | } elsif (source_set_options($target,$options)) { |
| 778 | last; |
| 779 | } |
| 780 | print "Please re-enter the options:\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 781 | } |
| 782 | } |
| 783 | if (@$target[$T_FLAGS] & $TF_MFC) { |
| 784 | @$project_settings[$T_FLAGS]|=$TF_MFC; |
| 785 | push @{@$target[$T_LIBRARY_PATH]},"\$(MFC_LIBRARY_PATH)"; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 786 | push @{@$target[$T_IMPORTS]},"mfc.dll"; |
| 787 | # FIXME: Link with the MFC in the Unix sense, until we |
| 788 | # start exporting the functions properly. |
| 789 | push @{@$target[$T_LIBRARIES]},"mfc"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | # Match sources... |
| 793 | if ($target_count == 1) { |
Francois Gouget | 4ec1059 | 2000-12-02 20:12:45 +0000 | [diff] [blame] | 794 | push @{@$target[$T_SOURCES_C]},@{@$project_settings[$T_SOURCES_C]},@sources_c; |
| 795 | @$project_settings[$T_SOURCES_C]=[]; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 796 | @sources_c=(); |
Francois Gouget | 4ec1059 | 2000-12-02 20:12:45 +0000 | [diff] [blame] | 797 | |
| 798 | push @{@$target[$T_SOURCES_CXX]},@{@$project_settings[$T_SOURCES_CXX]},@sources_cxx; |
| 799 | @$project_settings[$T_SOURCES_CXX]=[]; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 800 | @sources_cxx=(); |
Francois Gouget | 4ec1059 | 2000-12-02 20:12:45 +0000 | [diff] [blame] | 801 | |
| 802 | push @{@$target[$T_SOURCES_RC]},@{@$project_settings[$T_SOURCES_RC]},@sources_rc; |
| 803 | @$project_settings[$T_SOURCES_RC]=[]; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 804 | @sources_rc=(); |
Francois Gouget | 4ec1059 | 2000-12-02 20:12:45 +0000 | [diff] [blame] | 805 | |
| 806 | push @{@$target[$T_SOURCES_MISC]},@{@$project_settings[$T_SOURCES_MISC]},@sources_misc; |
| 807 | # No need for sorting these sources |
| 808 | @$project_settings[$T_SOURCES_MISC]=[]; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 809 | @sources_misc=(); |
| 810 | } else { |
| 811 | foreach $source (@sources_c) { |
| 812 | if ($source =~ /^$basename/i) { |
| 813 | push @{@$target[$T_SOURCES_C]},$source; |
| 814 | $source=""; |
| 815 | } |
| 816 | } |
| 817 | foreach $source (@sources_cxx) { |
| 818 | if ($source =~ /^$basename/i) { |
| 819 | push @{@$target[$T_SOURCES_CXX]},$source; |
| 820 | $source=""; |
| 821 | } |
| 822 | } |
| 823 | foreach $source (@sources_rc) { |
| 824 | if ($source =~ /^$basename/i) { |
| 825 | push @{@$target[$T_SOURCES_RC]},$source; |
| 826 | $source=""; |
| 827 | } |
| 828 | } |
| 829 | foreach $source (@sources_misc) { |
| 830 | if ($source =~ /^$basename/i) { |
| 831 | push @{@$target[$T_SOURCES_MISC]},$source; |
| 832 | $source=""; |
| 833 | } |
| 834 | } |
| 835 | } |
| 836 | @$target[$T_SOURCES_C]=[sort @{@$target[$T_SOURCES_C]}]; |
| 837 | @$target[$T_SOURCES_CXX]=[sort @{@$target[$T_SOURCES_CXX]}]; |
| 838 | @$target[$T_SOURCES_RC]=[sort @{@$target[$T_SOURCES_RC]}]; |
| 839 | @$target[$T_SOURCES_MISC]=[sort @{@$target[$T_SOURCES_MISC]}]; |
| 840 | } |
| 841 | if ($opt_ask_target_options == $OPT_ASK_SKIP) { |
| 842 | $opt_ask_target_options=$OPT_ASK_YES; |
| 843 | } |
| 844 | |
| 845 | if (@$project_settings[$T_FLAGS] & $TF_MFC) { |
| 846 | push @{@$project_settings[$T_INCLUDE_PATH]},"\$(MFC_INCLUDE_PATH)"; |
| 847 | } |
| 848 | # The sources that did not match, if any, go to the extra |
| 849 | # source list of the project settings |
| 850 | foreach $source (@sources_c) { |
| 851 | if ($source ne "") { |
| 852 | push @{@$project_settings[$T_SOURCES_C]},$source; |
| 853 | } |
| 854 | } |
| 855 | @$project_settings[$T_SOURCES_C]=[sort @{@$project_settings[$T_SOURCES_C]}]; |
| 856 | foreach $source (@sources_cxx) { |
| 857 | if ($source ne "") { |
| 858 | push @{@$project_settings[$T_SOURCES_CXX]},$source; |
| 859 | } |
| 860 | } |
| 861 | @$project_settings[$T_SOURCES_CXX]=[sort @{@$project_settings[$T_SOURCES_CXX]}]; |
| 862 | foreach $source (@sources_rc) { |
| 863 | if ($source ne "") { |
| 864 | push @{@$project_settings[$T_SOURCES_RC]},$source; |
| 865 | } |
| 866 | } |
| 867 | @$project_settings[$T_SOURCES_RC]=[sort @{@$project_settings[$T_SOURCES_RC]}]; |
| 868 | foreach $source (@sources_misc) { |
| 869 | if ($source ne "") { |
| 870 | push @{@$project_settings[$T_SOURCES_MISC]},$source; |
| 871 | } |
| 872 | } |
| 873 | @$project_settings[$T_SOURCES_MISC]=[sort @{@$project_settings[$T_SOURCES_MISC]}]; |
| 874 | |
| 875 | # Finally if we are building both libraries and programs in |
| 876 | # this directory, then the programs should be linked with all |
| 877 | # the libraries |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 878 | if (@local_imports > 0 and @exe_list > 0) { |
| 879 | foreach $target (@exe_list) { |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 880 | push @{@$target[$T_LIBRARY_PATH]},"-L."; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 881 | push @{@$target[$T_IMPORTS]},map { "$_.dll" } @local_imports; |
| 882 | # Also link in the Unix sense since none of the functions |
| 883 | # will be exported. |
| 884 | push @{@$target[$T_LIBRARIES]},@local_imports; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 885 | push @{@$target[$T_DEPENDS]},@local_depends; |
| 886 | } |
| 887 | } |
| 888 | } |
| 889 | |
| 890 | ## |
| 891 | # Scan the source directories in search of things to build |
| 892 | sub source_scan |
| 893 | { |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 894 | # If there's a single target then this is going to be the default target |
| 895 | if (defined $opt_single_target) { |
François Gouget | 38b3ac5 | 2001-01-11 20:17:42 +0000 | [diff] [blame] | 896 | # Create the main target |
| 897 | my $main_target=[]; |
| 898 | target_init($main_target); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 899 | if ($opt_target_type == $TT_DLL) { |
| 900 | @$main_target[$T_NAME]="lib$opt_single_target.so"; |
| 901 | } else { |
| 902 | @$main_target[$T_NAME]="$opt_single_target"; |
| 903 | } |
| 904 | @$main_target[$T_TYPE]=$opt_target_type; |
François Gouget | 38b3ac5 | 2001-01-11 20:17:42 +0000 | [diff] [blame] | 905 | |
| 906 | # Add it to the list |
| 907 | push @{$main_project[$P_TARGETS]},$main_target; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | # The main directory is always going to be there |
| 911 | push @projects,\@main_project; |
| 912 | |
| 913 | # Now scan the directory tree looking for source files and, maybe, targets |
| 914 | print "Scanning the source directories...\n"; |
Francois Gouget | 3266b88 | 2001-03-03 00:17:11 +0000 | [diff] [blame] | 915 | source_scan_directory(\@main_project,"","",0); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 916 | |
| 917 | @projects=sort { @$a[$P_PATH] cmp @$b[$P_PATH] } @projects; |
| 918 | } |
| 919 | |
| 920 | |
| 921 | |
| 922 | ##### |
| 923 | # |
| 924 | # 'vc.dsp'-based Project analysis |
| 925 | # |
| 926 | ##### |
| 927 | |
| 928 | #sub analyze_vc_dsp |
| 929 | #{ |
| 930 | # |
| 931 | #} |
| 932 | |
| 933 | |
| 934 | |
| 935 | ##### |
| 936 | # |
| 937 | # Creating the wrapper targets |
| 938 | # |
| 939 | ##### |
| 940 | |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 941 | sub postprocess_targets |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 942 | { |
| 943 | foreach $project (@projects) { |
| 944 | foreach $target (@{@$project[$P_TARGETS]}) { |
| 945 | if ((@$target[$T_FLAGS] & $TF_WRAP) != 0) { |
| 946 | my $wrapper=[]; |
| 947 | target_init($wrapper); |
| 948 | @$wrapper[$T_NAME]=@$target[$T_NAME]; |
| 949 | @$wrapper[$T_TYPE]=@$target[$T_TYPE]; |
| 950 | @$wrapper[$T_INIT]=get_default_init(@$target[$T_TYPE]); |
| 951 | @$wrapper[$T_FLAGS]=$TF_WRAPPER | (@$target[$T_FLAGS] & $TF_MFC); |
| 952 | push @{@$wrapper[$T_SOURCES_C]},"@$wrapper[$T_NAME]_wrapper.c"; |
| 953 | |
| 954 | my $index=bsearch(@$target[$T_SOURCES_C],"@$wrapper[$T_NAME]_wrapper.c"); |
| 955 | if (defined $index) { |
| 956 | splice(@{@$target[$T_SOURCES_C]},$index,1); |
| 957 | } |
| 958 | @$target[$T_NAME]="lib@$target[$T_NAME].so"; |
| 959 | @$target[$T_TYPE]=$TT_DLL; |
| 960 | |
| 961 | push @{@$project[$P_TARGETS]},$wrapper; |
| 962 | } |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 963 | if ((@$target[$T_FLAGS] & $TF_MFC) != 0) { |
| 964 | @{@$project[$P_SETTINGS]}[$T_FLAGS]|=$TF_MFC; |
| 965 | $needs_mfc=1; |
| 966 | } |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 967 | } |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | |
| 972 | |
| 973 | ##### |
| 974 | # |
| 975 | # Source search |
| 976 | # |
| 977 | ##### |
| 978 | |
| 979 | ## |
| 980 | # Performs a directory traversal and renames the files so that: |
| 981 | # - they have the case desired by the user |
| 982 | # - their extension is of the appropriate case |
| 983 | # - they don't contain annoying characters like ' ', '$', '#', ... |
| 984 | sub fix_file_and_directory_names |
| 985 | { |
| 986 | my $dirname=$_[0]; |
| 987 | |
| 988 | if (opendir(DIRECTORY, "$dirname")) { |
| 989 | foreach $dentry (readdir DIRECTORY) { |
| 990 | if ($dentry =~ /^\./ or $dentry eq "CVS") { |
| 991 | next; |
| 992 | } |
| 993 | # Set $warn to 1 if the user should be warned of the renaming |
| 994 | my $warn=0; |
| 995 | |
| 996 | # autoconf and make don't support these characters well |
| 997 | my $new_name=$dentry; |
| 998 | $new_name =~ s/[ \$]/_/g; |
| 999 | |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 1000 | # Only all lowercase extensions are supported (because of the |
| 1001 | # transformations ':.c=.o') . |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1002 | if (-f "$dirname/$new_name") { |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 1003 | if ($new_name =~ /\.C$/) { |
| 1004 | $new_name =~ s/\.C$/.c/; |
| 1005 | } |
| 1006 | if ($new_name =~ /\.cpp$/i) { |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1007 | $new_name =~ s/\.cpp$/.cpp/i; |
| 1008 | } |
| 1009 | if ($new_name =~ s/\.cxx$/.cpp/i) { |
| 1010 | $warn=1; |
| 1011 | } |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 1012 | if ($new_name =~ /\.rc$/i) { |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1013 | $new_name =~ s/\.rc$/.rc/i; |
| 1014 | } |
| 1015 | # And this last one is to avoid confusion then running make |
| 1016 | if ($new_name =~ s/^makefile$/makefile.win/) { |
| 1017 | $warn=1; |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | # Adjust the case to the user's preferences |
| 1022 | if (($opt_lower == $OPT_LOWER_ALL and $dentry =~ /[A-Z]/) or |
| 1023 | ($opt_lower == $OPT_LOWER_UPPERCASE and $dentry !~ /[a-z]/) |
| 1024 | ) { |
| 1025 | $new_name=lc $new_name; |
| 1026 | } |
| 1027 | |
| 1028 | # And finally, perform the renaming |
| 1029 | if ($new_name ne $dentry) { |
| 1030 | if ($warn) { |
| 1031 | print STDERR "warning: in \"$dirname\", renaming \"$dentry\" to \"$new_name\"\n"; |
| 1032 | } |
| 1033 | if (!rename("$dirname/$dentry","$dirname/$new_name")) { |
| 1034 | print STDERR "error: in \"$dirname\", unable to rename \"$dentry\" to \"$new_name\"\n"; |
| 1035 | print STDERR " $!\n"; |
| 1036 | $new_name=$dentry; |
| 1037 | } |
| 1038 | } |
| 1039 | if (-d "$dirname/$new_name") { |
| 1040 | fix_file_and_directory_names("$dirname/$new_name"); |
| 1041 | } |
| 1042 | } |
| 1043 | closedir(DIRECTORY); |
| 1044 | } |
| 1045 | } |
| 1046 | |
| 1047 | |
| 1048 | |
| 1049 | ##### |
| 1050 | # |
| 1051 | # Source fixup |
| 1052 | # |
| 1053 | ##### |
| 1054 | |
| 1055 | ## |
| 1056 | # This maps a directory name to a reference to an array listing |
| 1057 | # its contents (files and directories) |
| 1058 | my %directories; |
| 1059 | |
| 1060 | ## |
| 1061 | # Retrieves the contents of the specified directory. |
| 1062 | # We either get it from the directories hashtable which acts as a |
| 1063 | # cache, or use opendir, readdir, closedir and store the result |
| 1064 | # in the hashtable. |
| 1065 | sub get_directory_contents |
| 1066 | { |
| 1067 | my $dirname=$_[0]; |
| 1068 | my $directory; |
| 1069 | |
| 1070 | #print "getting the contents of $dirname\n"; |
| 1071 | |
| 1072 | # check for a cached version |
| 1073 | $dirname =~ s+/$++; |
| 1074 | if ($dirname eq "") { |
| 1075 | $dirname=cwd; |
| 1076 | } |
| 1077 | $directory=$directories{$dirname}; |
| 1078 | if (defined $directory) { |
| 1079 | #print "->@$directory\n"; |
| 1080 | return $directory; |
| 1081 | } |
| 1082 | |
| 1083 | # Read this directory |
| 1084 | if (opendir(DIRECTORY, "$dirname")) { |
| 1085 | my @files=readdir DIRECTORY; |
| 1086 | closedir(DIRECTORY); |
| 1087 | $directory=\@files; |
| 1088 | } else { |
| 1089 | # Return an empty list |
| 1090 | #print "error: cannot open $dirname\n"; |
| 1091 | my @files; |
| 1092 | $directory=\@files; |
| 1093 | } |
| 1094 | #print "->@$directory\n"; |
| 1095 | $directories{$dirname}=$directory; |
| 1096 | return $directory; |
| 1097 | } |
| 1098 | |
| 1099 | ## |
| 1100 | # Try to find a file for the specified filename. The attempt is |
| 1101 | # case-insensitive which is why it's not trivial. If a match is |
| 1102 | # found then we return the pathname with the correct case. |
| 1103 | sub search_from |
| 1104 | { |
| 1105 | my $dirname=$_[0]; |
| 1106 | my $path=$_[1]; |
| 1107 | my $real_path=""; |
| 1108 | |
| 1109 | if ($dirname eq "" or $dirname eq ".") { |
| 1110 | $dirname=cwd; |
| 1111 | } elsif ($dirname =~ m+^[^/]+) { |
| 1112 | $dirname=cwd . "/" . $dirname; |
| 1113 | } |
| 1114 | if ($dirname !~ m+/$+) { |
| 1115 | $dirname.="/"; |
| 1116 | } |
| 1117 | |
| 1118 | foreach $component (@$path) { |
Francois Gouget | b430295 | 2000-11-07 20:27:16 +0000 | [diff] [blame] | 1119 | #print " looking for $component in \"$dirname\"\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1120 | if ($component eq ".") { |
| 1121 | # Pass it as is |
| 1122 | $real_path.="./"; |
| 1123 | } elsif ($component eq "..") { |
| 1124 | # Go up one level |
| 1125 | $dirname=dirname($dirname) . "/"; |
| 1126 | $real_path.="../"; |
| 1127 | } else { |
| 1128 | my $directory=get_directory_contents $dirname; |
| 1129 | my $found; |
| 1130 | foreach $dentry (@$directory) { |
| 1131 | if ($dentry =~ /^$component$/i) { |
| 1132 | $dirname.="$dentry/"; |
| 1133 | $real_path.="$dentry/"; |
| 1134 | $found=1; |
| 1135 | last; |
| 1136 | } |
| 1137 | } |
| 1138 | if (!defined $found) { |
| 1139 | # Give up |
Francois Gouget | b430295 | 2000-11-07 20:27:16 +0000 | [diff] [blame] | 1140 | #print " could not find $component in $dirname\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1141 | return; |
| 1142 | } |
| 1143 | } |
| 1144 | } |
| 1145 | $real_path=~ s+/$++; |
Francois Gouget | b430295 | 2000-11-07 20:27:16 +0000 | [diff] [blame] | 1146 | #print " -> found $real_path\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1147 | return $real_path; |
| 1148 | } |
| 1149 | |
| 1150 | ## |
| 1151 | # Performs a case-insensitive search for the specified file in the |
| 1152 | # include path. |
| 1153 | # $line is the line number that should be referenced when an error occurs |
| 1154 | # $filename is the file we are looking for |
| 1155 | # $dirname is the directory of the file containing the '#include' directive |
| 1156 | # if '"' was used, it is an empty string otherwise |
| 1157 | # $project and $target specify part of the include path |
| 1158 | sub get_real_include_name |
| 1159 | { |
| 1160 | my $line=$_[0]; |
| 1161 | my $filename=$_[1]; |
| 1162 | my $dirname=$_[2]; |
| 1163 | my $project=$_[3]; |
| 1164 | my $target=$_[4]; |
| 1165 | |
| 1166 | if ($filename =~ /^([a-zA-Z]:)?[\/]/ or $filename =~ /^[a-zA-Z]:[\/]?/) { |
| 1167 | # This is not a relative path, we cannot make any check |
| 1168 | my $warning="path:$filename"; |
| 1169 | if (!defined $warnings{$warning}) { |
| 1170 | $warnings{$warning}="1"; |
| 1171 | print STDERR "warning: cannot check the case of absolute pathnames:\n"; |
| 1172 | print STDERR "$line: $filename\n"; |
| 1173 | } |
| 1174 | } else { |
| 1175 | # Here's how we proceed: |
| 1176 | # - split the filename we look for into its components |
| 1177 | # - then for each directory in the include path |
| 1178 | # - trace the directory components starting from that directory |
| 1179 | # - if we fail to find a match at any point then continue with |
| 1180 | # the next directory in the include path |
| 1181 | # - otherwise, rejoice, our quest is over. |
| 1182 | my @file_components=split /[\/\\]+/, $filename; |
Francois Gouget | b430295 | 2000-11-07 20:27:16 +0000 | [diff] [blame] | 1183 | #print " Searching for $filename from @$project[$P_PATH]\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1184 | |
| 1185 | my $real_filename; |
| 1186 | if ($dirname ne "") { |
Francois Gouget | b430295 | 2000-11-07 20:27:16 +0000 | [diff] [blame] | 1187 | # This is an 'include ""' -> look in dirname first. |
| 1188 | #print " in $dirname (include \"\")\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1189 | $real_filename=search_from($dirname,\@file_components); |
| 1190 | if (defined $real_filename) { |
| 1191 | return $real_filename; |
| 1192 | } |
| 1193 | } |
| 1194 | my $project_settings=@$project[$P_SETTINGS]; |
Francois Gouget | b430295 | 2000-11-07 20:27:16 +0000 | [diff] [blame] | 1195 | foreach $include (@{@$target[$T_INCLUDE_PATH]}, @{@$project_settings[$T_INCLUDE_PATH]}) { |
| 1196 | my $dirname=$include; |
| 1197 | $dirname=~ s+^-I++; |
| 1198 | if (!is_absolute($dirname)) { |
| 1199 | $dirname="@$project[$P_PATH]$dirname"; |
| 1200 | } else { |
| 1201 | $dirname=~ s+^\$\(TOPSRCDIR\)/++; |
| 1202 | } |
| 1203 | #print " in $dirname\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1204 | $real_filename=search_from("$dirname",\@file_components); |
| 1205 | if (defined $real_filename) { |
| 1206 | return $real_filename; |
| 1207 | } |
| 1208 | } |
| 1209 | my $dotdotpath=@$project[$P_PATH]; |
| 1210 | $dotdotpath =~ s/[^\/]+/../g; |
Francois Gouget | b430295 | 2000-11-07 20:27:16 +0000 | [diff] [blame] | 1211 | foreach $include (@{$global_settings[$T_INCLUDE_PATH]}) { |
| 1212 | my $dirname=$include; |
| 1213 | $dirname=~ s+^-I++; |
| 1214 | $dirname=~ s+^\$\(TOPSRCDIR\)\/++; |
| 1215 | #print " in $dirname (global setting)\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1216 | $real_filename=search_from("$dirname",\@file_components); |
| 1217 | if (defined $real_filename) { |
| 1218 | return $real_filename; |
| 1219 | } |
| 1220 | } |
| 1221 | } |
| 1222 | $filename =~ s+\\\\+/+g; # in include "" |
| 1223 | $filename =~ s+\\+/+g; # in include <> ! |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 1224 | if ($opt_lower_include) { |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1225 | return lc "$filename"; |
| 1226 | } |
| 1227 | return $filename; |
| 1228 | } |
| 1229 | |
| 1230 | ## |
| 1231 | # 'Parses' a source file and fixes constructs that would not work with |
| 1232 | # Winelib. The parsing is rather simple and not all non-portable features |
| 1233 | # are corrected. The most important feature that is corrected is the case |
| 1234 | # and path separator of '#include' directives. This requires that each |
| 1235 | # source file be associated to a project & target so that the proper |
| 1236 | # include path is used. |
Francois Gouget | b430295 | 2000-11-07 20:27:16 +0000 | [diff] [blame] | 1237 | # Also note that the include path is relative to the directory in which the |
| 1238 | # compiler is run, i.e. that of the project, not to that of the file. |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1239 | sub fix_file |
| 1240 | { |
| 1241 | my $filename=$_[0]; |
| 1242 | my $project=$_[1]; |
| 1243 | my $target=$_[2]; |
| 1244 | $filename="@$project[$P_PATH]$filename"; |
| 1245 | if (! -e $filename) { |
| 1246 | return; |
| 1247 | } |
| 1248 | |
| 1249 | my $is_rc=($filename =~ /\.(rc2?|dlg)$/i); |
| 1250 | my $dirname=dirname($filename); |
| 1251 | my $is_mfc=0; |
| 1252 | if (defined $target and (@$target[$T_FLAGS] & $TF_MFC)) { |
| 1253 | $is_mfc=1; |
| 1254 | } |
| 1255 | |
| 1256 | print " $filename\n"; |
| 1257 | #FIXME:assuming that because there is a .bak file, this is what we want is |
| 1258 | #probably flawed. Or is it??? |
| 1259 | if (! -e "$filename.bak") { |
| 1260 | if (!copy("$filename","$filename.bak")) { |
| 1261 | print STDERR "error: unable to make a backup of $filename:\n"; |
| 1262 | print STDERR " $!\n"; |
| 1263 | return; |
| 1264 | } |
| 1265 | } |
| 1266 | if (!open(FILEI,"$filename.bak")) { |
| 1267 | print STDERR "error: unable to open $filename.bak for reading:\n"; |
| 1268 | print STDERR " $!\n"; |
| 1269 | return; |
| 1270 | } |
| 1271 | if (!open(FILEO,">$filename")) { |
| 1272 | print STDERR "error: unable to open $filename for writing:\n"; |
| 1273 | print STDERR " $!\n"; |
| 1274 | return; |
| 1275 | } |
| 1276 | my $line=0; |
| 1277 | my $modified=0; |
| 1278 | my $rc_block_depth=0; |
| 1279 | my $rc_textinclude_state=0; |
| 1280 | while (<FILEI>) { |
| 1281 | $line++; |
François Gouget | a62703e | 2001-02-12 01:22:58 +0000 | [diff] [blame] | 1282 | s/\r\n$/\n/; |
| 1283 | if (!/\n$/) { |
| 1284 | # Make sure all files are '\n' terminated |
| 1285 | $_ .= "\n"; |
| 1286 | } |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1287 | if ($is_rc and !$is_mfc and /^(\s*\#\s*include\s*)\"afxres\.h\"/) { |
| 1288 | # VC6 automatically includes 'afxres.h', an MFC specific header, in |
| 1289 | # the RC files it generates (even in non-MFC projects). So we replace |
| 1290 | # it with 'winres.h' its very close standard cousin so that non MFC |
François Gouget | a62703e | 2001-02-12 01:22:58 +0000 | [diff] [blame] | 1291 | # projects can compile in Wine without the MFC sources. |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1292 | my $warning="mfc:afxres.h"; |
| 1293 | if (!defined $warnings{$warning}) { |
| 1294 | $warnings{$warning}="1"; |
| 1295 | print STDERR "warning: In non-MFC projects, winemaker replaces the MFC specific header 'afxres.h' with 'winres.h'\n"; |
| 1296 | print STDERR "warning: the above warning is issued only once\n"; |
| 1297 | } |
| 1298 | print FILEO "/* winemaker: $1\"afxres.h\" */\n"; |
| 1299 | print FILEO "$1\"winres.h\"$'"; |
| 1300 | $modified=1; |
| 1301 | } elsif (/^(\s*\#\s*include\s*)([\"<])([^\"]+)([\">])/) { |
| 1302 | my $from_file=($2 eq "<"?"":$dirname); |
| 1303 | my $real_include_name=get_real_include_name($line,$3,$from_file,$project,$target); |
| 1304 | print FILEO "$1$2$real_include_name$4$'"; |
| 1305 | $modified|=($real_include_name ne $3); |
| 1306 | } elsif (/^(\s*\#\s*pragma\s*pack\s*\((\s*push\s*,?)?\s*)(\w*)(\s*\))/) { |
| 1307 | my $pragma_header=$1; |
| 1308 | my $size=$3; |
| 1309 | my $pragma_trailer=$4; |
| 1310 | #print "$pragma_header$size$pragma_trailer$'"; |
| 1311 | #print "pragma push: size=$size\n"; |
| 1312 | print FILEO "/* winemaker: $pragma_header$size$pragma_trailer */\n"; |
| 1313 | $line++; |
| 1314 | if ($size eq "pop") { |
| 1315 | print FILEO "#include <poppack.h>$'"; |
| 1316 | } elsif ($size eq "1") { |
| 1317 | print FILEO "#include <pshpack1.h>$'"; |
| 1318 | } elsif ($size eq "2") { |
| 1319 | print FILEO "#include <pshpack2.h>$'"; |
| 1320 | } elsif ($size eq "8") { |
| 1321 | print FILEO "#include <pshpack8.h>$'"; |
| 1322 | } elsif ($size eq "4" or $size eq "") { |
| 1323 | print FILEO "#include <pshpack4.h>$'"; |
| 1324 | } else { |
| 1325 | my $warning="pack:$size"; |
| 1326 | if (!defined $warnings{$warning}) { |
| 1327 | $warnings{$warning}="1"; |
| 1328 | print STDERR "warning: assuming that the value of $size is 4 in\n"; |
| 1329 | print STDERR "$line: $pragma_header$size$pragma_trailer\n"; |
| 1330 | print STDERR "warning: the above warning is issued only once\n"; |
| 1331 | } |
| 1332 | print FILEO "#include <pshpack4.h>$'"; |
| 1333 | $modified=1; |
| 1334 | } |
| 1335 | } elsif ($is_rc) { |
François Gouget | a62703e | 2001-02-12 01:22:58 +0000 | [diff] [blame] | 1336 | if ($rc_block_depth == 0 and /^(\w+\s+(BITMAP|CURSOR|FONT|FONTDIR|ICON|MESSAGETABLE|TEXT)\s+((DISCARDABLE|FIXED|IMPURE|LOADONCALL|MOVEABLE|PRELOAD|PURE|RTF)\s+)*)([\"<]?)([^\">\r\n]+)([\">]?)/) { |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1337 | my $from_file=($5 eq "<"?"":$dirname); |
| 1338 | my $real_include_name=get_real_include_name($line,$6,$from_file,$project,$target); |
| 1339 | print FILEO "$1$5$real_include_name$7$'"; |
| 1340 | $modified|=($real_include_name ne $6); |
| 1341 | } elsif (/^(\s*RCINCLUDE\s*)([\"<]?)([^\">\r\n]+)([\">]?)/) { |
| 1342 | my $from_file=($2 eq "<"?"":$dirname); |
| 1343 | my $real_include_name=get_real_include_name($line,$3,$from_file,$project,$target); |
| 1344 | print FILEO "$1$2$real_include_name$4$'"; |
| 1345 | $modified|=($real_include_name ne $3); |
| 1346 | } elsif ($is_rc and !$is_mfc and $rc_block_depth == 0 and /^\s*\d+\s+TEXTINCLUDE\s*/) { |
| 1347 | $rc_textinclude_state=1; |
| 1348 | print FILEO; |
| 1349 | } elsif ($rc_textinclude_state == 3 and /^(\s*\"\#\s*include\s*\"\")afxres\.h(\"\"\\r\\n\")/) { |
| 1350 | print FILEO "$1winres.h$2$'"; |
| 1351 | $modified=1; |
| 1352 | } elsif (/^\s*BEGIN(\W.*)?$/) { |
| 1353 | $rc_textinclude_state|=2; |
| 1354 | $rc_block_depth++; |
| 1355 | print FILEO; |
| 1356 | } elsif (/^\s*END(\W.*)?$/) { |
| 1357 | $rc_textinclude_state=0; |
| 1358 | if ($rc_block_depth>0) { |
| 1359 | $rc_block_depth--; |
| 1360 | } |
| 1361 | print FILEO; |
| 1362 | } else { |
| 1363 | print FILEO; |
| 1364 | } |
| 1365 | } else { |
| 1366 | print FILEO; |
| 1367 | } |
| 1368 | } |
| 1369 | close(FILEI); |
| 1370 | close(FILEO); |
| 1371 | if ($opt_backup == 0 or $modified == 0) { |
| 1372 | if (!unlink("$filename.bak")) { |
| 1373 | print STDERR "error: unable to delete $filename.bak:\n"; |
| 1374 | print STDERR " $!\n"; |
| 1375 | } |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | ## |
| 1380 | # Analyzes each source file in turn to find and correct issues |
| 1381 | # that would cause it not to compile. |
| 1382 | sub fix_source |
| 1383 | { |
| 1384 | print "Fixing the source files...\n"; |
| 1385 | foreach $project (@projects) { |
| 1386 | foreach $target (@$project[$P_SETTINGS],@{@$project[$P_TARGETS]}) { |
| 1387 | if (@$target[$T_FLAGS] & $TF_WRAPPER) { |
| 1388 | next; |
| 1389 | } |
| 1390 | foreach $source (@{@$target[$T_SOURCES_C]}, @{@$target[$T_SOURCES_CXX]}, @{@$target[$T_SOURCES_RC]}, @{@$target[$T_SOURCES_MISC]}) { |
| 1391 | fix_file($source,$project,$target); |
| 1392 | } |
| 1393 | } |
| 1394 | } |
| 1395 | } |
| 1396 | |
| 1397 | |
| 1398 | |
| 1399 | ##### |
| 1400 | # |
| 1401 | # File generation |
| 1402 | # |
| 1403 | ##### |
| 1404 | |
| 1405 | ## |
| 1406 | # Generates a target's .spec file |
| 1407 | sub generate_spec_file |
| 1408 | { |
| 1409 | my $path=$_[0]; |
| 1410 | my $target=$_[1]; |
| 1411 | my $project_settings=$_[2]; |
| 1412 | |
| 1413 | my $basename=@$target[$T_NAME]; |
| 1414 | $basename =~ s+\.so$++; |
| 1415 | if (@$target[$T_FLAGS] & $TF_WRAP) { |
| 1416 | $basename =~ s+^lib++; |
| 1417 | } elsif (@$target[$T_FLAGS] & $TF_WRAPPER) { |
| 1418 | $basename.="_wrapper"; |
| 1419 | } |
| 1420 | |
| 1421 | if (!open(FILEO,">$path$basename.spec")) { |
| 1422 | print STDERR "error: could not open \"$path$basename.spec\" for writing\n"; |
| 1423 | print STDERR " $!\n"; |
| 1424 | return; |
| 1425 | } |
| 1426 | |
Francois Gouget | a11664c | 2000-12-07 23:13:23 +0000 | [diff] [blame] | 1427 | my $module=$basename; |
| 1428 | $module =~ s+^lib++; |
| 1429 | $module=canonize($module); |
| 1430 | print FILEO "name $module\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1431 | print FILEO "type win32\n"; |
| 1432 | if (@$target[$T_TYPE] == $TT_GUIEXE) { |
| 1433 | print FILEO "mode guiexe\n"; |
| 1434 | } elsif (@$target[$T_TYPE] == $TT_CUIEXE) { |
| 1435 | print FILEO "mode cuiexe\n"; |
| 1436 | } else { |
| 1437 | print FILEO "mode dll\n"; |
| 1438 | } |
| 1439 | if (defined @$target[$T_INIT] and ((@$target[$T_FLAGS] & $TF_WRAP) == 0)) { |
| 1440 | print FILEO "init @$target[$T_INIT]\n"; |
| 1441 | } |
| 1442 | if (@{@$target[$T_SOURCES_RC]} > 0) { |
| 1443 | if (@{@$target[$T_SOURCES_RC]} > 1) { |
| 1444 | print STDERR "warning: the target $basename has more than one RC file. Modify the Makefile.in to remove redundant RC files, and fix the spec file\n"; |
| 1445 | } |
| 1446 | my $rcname=@{@$target[$T_SOURCES_RC]}[0]; |
| 1447 | $rcname =~ s+\.rc$++i; |
| 1448 | print FILEO "rsrc $rcname.res\n"; |
| 1449 | } |
| 1450 | print FILEO "\n"; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1451 | my %imports; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1452 | foreach $library (@{$global_settings[$T_IMPORTS]}) { |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1453 | if (!defined $imports{$library}) { |
| 1454 | print FILEO "import $library\n"; |
| 1455 | $imports{$library}=1; |
| 1456 | } |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1457 | } |
| 1458 | if (defined $project_settings) { |
| 1459 | foreach $library (@{@$project_settings[$T_IMPORTS]}) { |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1460 | if (!defined $imports{$library}) { |
| 1461 | print FILEO "import $library\n"; |
| 1462 | $imports{$library}=1; |
| 1463 | } |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1464 | } |
| 1465 | } |
| 1466 | foreach $library (@{@$target[$T_IMPORTS]}) { |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1467 | if (!defined $imports{$library}) { |
| 1468 | print FILEO "import $library\n"; |
| 1469 | $imports{$library}=1; |
| 1470 | } |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1471 | } |
| 1472 | |
| 1473 | # Don't forget to export the 'Main' function for wrapped executables, |
| 1474 | # except for MFC ones! |
| 1475 | if (@$target[$T_FLAGS] == $TF_WRAP) { |
| 1476 | if (@$target[$T_TYPE] == $TT_GUIEXE) { |
| 1477 | print FILEO "\n@ stdcall @$target[$T_INIT](long long ptr long) @$target[$T_INIT]\n"; |
| 1478 | } elsif (@$target[$T_TYPE] == $TT_CUIEXE) { |
| 1479 | print FILEO "\n@ stdcall @$target[$T_INIT](long ptr ptr) @$target[$T_INIT]\n"; |
| 1480 | } else { |
| 1481 | print FILEO "\n@ stdcall @$target[$T_INIT](ptr long ptr) @$target[$T_INIT]\n"; |
| 1482 | } |
| 1483 | } |
| 1484 | |
| 1485 | close(FILEO); |
| 1486 | } |
| 1487 | |
| 1488 | ## |
| 1489 | # Generates a target's wrapper file |
| 1490 | sub generate_wrapper_file |
| 1491 | { |
| 1492 | my $path=$_[0]; |
| 1493 | my $target=$_[1]; |
| 1494 | |
| 1495 | if (!defined $templates{"wrapper.c"}) { |
| 1496 | print STDERR "winemaker: internal error: No template called 'wrapper.c'\n"; |
| 1497 | return; |
| 1498 | } |
| 1499 | |
| 1500 | if (!open(FILEO,">$path@$target[$T_NAME]_wrapper.c")) { |
| 1501 | print STDERR "error: unable to open \"$path$basename.c\" for writing:\n"; |
| 1502 | print STDERR " $!\n"; |
| 1503 | return; |
| 1504 | } |
| 1505 | my $app_name="\"@$target[$T_NAME]\""; |
| 1506 | my $app_type=(@$target[$T_TYPE]==$TT_GUIEXE?"GUIEXE":"CUIEXE"); |
| 1507 | my $app_init=(@$target[$T_TYPE]==$TT_GUIEXE?"\"WinMain\"":"\"main\""); |
| 1508 | my $app_mfc=(@$target[$T_FLAGS] & $TF_MFC?"\"mfc\"":NULL); |
| 1509 | foreach $line (@{$templates{"wrapper.c"}}) { |
| 1510 | $line =~ s/\#\#WINEMAKER_APP_NAME\#\#/$app_name/; |
| 1511 | $line =~ s/\#\#WINEMAKER_APP_TYPE\#\#/$app_type/; |
| 1512 | $line =~ s/\#\#WINEMAKER_APP_INIT\#\#/$app_init/; |
| 1513 | $line =~ s/\#\#WINEMAKER_APP_MFC\#\#/$app_mfc/; |
| 1514 | print FILEO $line; |
| 1515 | } |
| 1516 | close(FILEO); |
| 1517 | } |
| 1518 | |
| 1519 | ## |
| 1520 | # A convenience function to generate all the lists (defines, |
| 1521 | # C sources, C++ source, etc.) in the Makefile |
| 1522 | sub generate_list |
| 1523 | { |
| 1524 | my $name=$_[0]; |
| 1525 | my $last=$_[1]; |
| 1526 | my $list=$_[2]; |
| 1527 | my $data=$_[3]; |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1528 | my $first=$name; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1529 | |
| 1530 | if ($name) { |
Francois Gouget | fb5b590 | 2000-11-30 20:34:39 +0000 | [diff] [blame] | 1531 | printf FILEO "%-22s=",$name; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1532 | } |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1533 | if (defined $list) { |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1534 | foreach $item (@$list) { |
| 1535 | my $value; |
| 1536 | if (defined $data) { |
| 1537 | $value=&$data($item); |
| 1538 | } else { |
| 1539 | $value=$item; |
| 1540 | } |
| 1541 | if ($value ne "") { |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1542 | if ($first) { |
| 1543 | print FILEO " $value"; |
| 1544 | $first=0; |
| 1545 | } else { |
| 1546 | print FILEO " \\\n\t\t\t$value"; |
| 1547 | } |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1548 | } |
| 1549 | } |
| 1550 | } |
| 1551 | if ($last) { |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1552 | print FILEO "\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1553 | } |
| 1554 | } |
| 1555 | |
| 1556 | ## |
| 1557 | # Generates a project's Makefile.in and all the target files |
| 1558 | sub generate_project_files |
| 1559 | { |
| 1560 | my $project=$_[0]; |
| 1561 | my $project_settings=@$project[$P_SETTINGS]; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1562 | my @dll_list=(); |
| 1563 | my @exe_list=(); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1564 | |
| 1565 | # Then sort the targets and separate the libraries from the programs |
| 1566 | foreach $target (sort { @$a[$T_NAME] cmp @$b[$T_NAME] } @{@$project[$P_TARGETS]}) { |
| 1567 | if (@$target[$T_TYPE] == $TT_DLL) { |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1568 | push @dll_list,$target; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1569 | } else { |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1570 | push @exe_list,$target; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1571 | } |
| 1572 | } |
| 1573 | @$project[$P_TARGETS]=[]; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1574 | push @{@$project[$P_TARGETS]}, @dll_list; |
| 1575 | push @{@$project[$P_TARGETS]}, @exe_list; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1576 | |
| 1577 | if (!open(FILEO,">@$project[$P_PATH]Makefile.in")) { |
| 1578 | print STDERR "error: could not open \"@$project[$P_PATH]/Makefile.in\" for writing\n"; |
| 1579 | print STDERR " $!\n"; |
| 1580 | return; |
| 1581 | } |
| 1582 | |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1583 | print FILEO "### Generated by Winemaker\n"; |
| 1584 | print FILEO "\n\n"; |
| 1585 | |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1586 | print FILEO "### Generic autoconf variables\n\n"; |
Francois Gouget | fb5b590 | 2000-11-30 20:34:39 +0000 | [diff] [blame] | 1587 | generate_list("TOPSRCDIR",1,[ "\@top_srcdir\@" ]); |
| 1588 | generate_list("TOPOBJDIR",1,[ "." ]); |
| 1589 | generate_list("SRCDIR",1,[ "\@srcdir\@" ]); |
| 1590 | generate_list("VPATH",1,[ "\@srcdir\@" ]); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1591 | print FILEO "\n"; |
| 1592 | if (@$project[$P_PATH] eq "") { |
| 1593 | # This is the main project. It is also responsible for recursively |
| 1594 | # calling the other projects |
| 1595 | generate_list("SUBDIRS",1,\@projects,sub |
| 1596 | { |
| 1597 | if ($_[0] != \@main_project) { |
| 1598 | my $subdir=@{$_[0]}[$P_PATH]; |
| 1599 | $subdir =~ s+/$++; |
| 1600 | return $subdir; |
| 1601 | } |
| 1602 | # Eliminating the main project by returning undefined! |
| 1603 | }); |
| 1604 | } |
| 1605 | if (@{@$project[$P_TARGETS]} > 0) { |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1606 | generate_list("DLLS",1,\@dll_list,sub |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1607 | { |
| 1608 | return @{$_[0]}[$T_NAME]; |
| 1609 | }); |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1610 | generate_list("EXES",1,\@exe_list,sub |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1611 | { |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1612 | return "@{$_[0]}[$T_NAME]"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1613 | }); |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1614 | print FILEO "\n\n\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1615 | |
| 1616 | print FILEO "### Global settings\n\n"; |
| 1617 | # Make it so that the project-wide settings override the global settings |
| 1618 | generate_list("DEFINES",0,@$project_settings[$T_DEFINES],sub |
| 1619 | { |
| 1620 | return "$_[0]"; |
| 1621 | }); |
| 1622 | generate_list("",1,$global_settings[$T_DEFINES],sub |
| 1623 | { |
| 1624 | return "$_[0]"; |
| 1625 | }); |
| 1626 | generate_list("INCLUDE_PATH",$no_extra,@$project_settings[$T_INCLUDE_PATH],sub |
| 1627 | { |
| 1628 | return "$_[0]"; |
| 1629 | }); |
| 1630 | generate_list("",1,$global_settings[$T_INCLUDE_PATH],sub |
| 1631 | { |
| 1632 | if ($_[0] !~ /^-I/) { |
| 1633 | return "$_[0]"; |
| 1634 | } |
| 1635 | if (is_absolute($')) { |
| 1636 | return "$_[0]"; |
| 1637 | } |
Francois Gouget | fb5b590 | 2000-11-30 20:34:39 +0000 | [diff] [blame] | 1638 | return "-I\$(TOPSRCDIR)/$'"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1639 | }); |
| 1640 | generate_list("LIBRARY_PATH",$no_extra,@$project_settings[$T_LIBRARY_PATH],sub |
| 1641 | { |
| 1642 | return "$_[0]"; |
| 1643 | }); |
| 1644 | generate_list("",1,$global_settings[$T_LIBRARY_PATH],sub |
| 1645 | { |
| 1646 | if ($_[0] !~ /^-L/) { |
| 1647 | return "$_[0]"; |
| 1648 | } |
| 1649 | if (is_absolute($')) { |
| 1650 | return "$_[0]"; |
| 1651 | } |
Francois Gouget | fb5b590 | 2000-11-30 20:34:39 +0000 | [diff] [blame] | 1652 | return "-L\$(TOPSRCDIR)/$'"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1653 | }); |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1654 | generate_list("LIBRARIES",$no_extra,@$project_settings[$T_LIBRARIES],sub |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1655 | { |
| 1656 | return "$_[0]"; |
| 1657 | }); |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1658 | generate_list("",1,$global_settings[$T_LIBRARIES],sub |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1659 | { |
| 1660 | return "$_[0]"; |
| 1661 | }); |
| 1662 | print FILEO "\n\n"; |
| 1663 | |
| 1664 | my $extra_source_count=@{@$project_settings[$T_SOURCES_C]}+ |
| 1665 | @{@$project_settings[$T_SOURCES_CXX]}+ |
| 1666 | @{@$project_settings[$T_SOURCES_RC]}; |
| 1667 | my $no_extra=($extra_source_count == 0); |
| 1668 | if (!$no_extra) { |
| 1669 | print FILEO "### Extra source lists\n\n"; |
| 1670 | generate_list("EXTRA_C_SRCS",1,@$project_settings[$T_SOURCES_C]); |
| 1671 | generate_list("EXTRA_CXX_SRCS",1,@$project_settings[$T_SOURCES_CXX]); |
| 1672 | generate_list("EXTRA_RC_SRCS",1,@$project_settings[$T_SOURCES_RC]); |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1673 | print FILEO "\n"; |
| 1674 | generate_list("EXTRA_OBJS",1,["\$(EXTRA_C_SRCS:.c=.o)","\$(EXTRA_CXX_SRCS:.cpp=.o)"]); |
| 1675 | print FILEO "\n\n\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1676 | } |
| 1677 | |
| 1678 | # Iterate over all the targets... |
| 1679 | foreach $target (@{@$project[$P_TARGETS]}) { |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1680 | print FILEO "### @$target[$T_NAME] sources and settings\n\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1681 | my $canon=canonize("@$target[$T_NAME]"); |
| 1682 | $canon =~ s+_so$++; |
| 1683 | generate_list("${canon}_C_SRCS",1,@$target[$T_SOURCES_C]); |
| 1684 | generate_list("${canon}_CXX_SRCS",1,@$target[$T_SOURCES_CXX]); |
| 1685 | generate_list("${canon}_RC_SRCS",1,@$target[$T_SOURCES_RC]); |
| 1686 | my $basename=@$target[$T_NAME]; |
| 1687 | $basename =~ s+\.so$++; |
| 1688 | if (@$target[$T_FLAGS] & $TF_WRAP) { |
| 1689 | $basename =~ s+^lib++; |
| 1690 | } elsif (@$target[$T_FLAGS] & $TF_WRAPPER) { |
| 1691 | $basename.="_wrapper"; |
| 1692 | } |
| 1693 | generate_list("${canon}_SPEC_SRCS",1,[ "$basename.spec"]); |
| 1694 | generate_list("${canon}_LIBRARY_PATH",1,@$target[$T_LIBRARY_PATH],sub |
| 1695 | { |
| 1696 | return "$_[0]"; |
| 1697 | }); |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1698 | generate_list("${canon}_LIBRARIES",1,@$target[$T_LIBRARIES],sub |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1699 | { |
| 1700 | return "$_[0]"; |
| 1701 | }); |
| 1702 | generate_list("${canon}_DEPENDS",1,@$target[$T_DEPENDS],sub |
| 1703 | { |
| 1704 | return "$_[0]"; |
| 1705 | }); |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1706 | print FILEO "\n"; |
| 1707 | generate_list("${canon}_OBJS",1,["\$(${canon}_C_SRCS:.c=.o)","\$(${canon}_CXX_SRCS:.cpp=.o)","\$(EXTRA_OBJS)"]); |
| 1708 | print FILEO "\n\n\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1709 | } |
| 1710 | print FILEO "### Global source lists\n\n"; |
| 1711 | generate_list("C_SRCS",$no_extra,@$project[$P_TARGETS],sub |
| 1712 | { |
| 1713 | my $canon=canonize(@{$_[0]}[$T_NAME]); |
| 1714 | $canon =~ s+_so$++; |
| 1715 | return "\$(${canon}_C_SRCS)"; |
| 1716 | }); |
| 1717 | if (!$no_extra) { |
| 1718 | generate_list("",1,[ "\$(EXTRA_C_SRCS)" ]); |
| 1719 | } |
| 1720 | generate_list("CXX_SRCS",$no_extra,@$project[$P_TARGETS],sub |
| 1721 | { |
| 1722 | my $canon=canonize(@{$_[0]}[$T_NAME]); |
| 1723 | $canon =~ s+_so$++; |
| 1724 | return "\$(${canon}_CXX_SRCS)"; |
| 1725 | }); |
| 1726 | if (!$no_extra) { |
| 1727 | generate_list("",1,[ "\$(EXTRA_CXX_SRCS)" ]); |
| 1728 | } |
| 1729 | generate_list("RC_SRCS",$no_extra,@$project[$P_TARGETS],sub |
| 1730 | { |
| 1731 | my $canon=canonize(@{$_[0]}[$T_NAME]); |
| 1732 | $canon =~ s+_so$++; |
| 1733 | return "\$(${canon}_RC_SRCS)"; |
| 1734 | }); |
| 1735 | if (!$no_extra) { |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1736 | generate_list("",1,[ "\$(EXTRA_RC_SRCS)" ]); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1737 | } |
| 1738 | generate_list("SPEC_SRCS",1,@$project[$P_TARGETS],sub |
| 1739 | { |
| 1740 | my $canon=canonize(@{$_[0]}[$T_NAME]); |
| 1741 | $canon =~ s+_so$++; |
| 1742 | return "\$(${canon}_SPEC_SRCS)"; |
| 1743 | }); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1744 | } |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1745 | print FILEO "\n\n\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1746 | |
| 1747 | print FILEO "### Generic autoconf targets\n\n"; |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1748 | print FILEO "all: "; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1749 | if (@$project[$P_PATH] eq "") { |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1750 | print FILEO "\$(SUBDIRS)"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1751 | } |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1752 | if (@{@$project[$P_TARGETS]} > 0) { |
Francois Gouget | fb5b590 | 2000-11-30 20:34:39 +0000 | [diff] [blame] | 1753 | print FILEO "\$(DLLS) \$(EXES:%=%.so)"; |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1754 | } |
| 1755 | print FILEO "\n\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1756 | print FILEO "\@MAKE_RULES\@\n"; |
| 1757 | print FILEO "\n"; |
| 1758 | print FILEO "install::\n"; |
| 1759 | if (@$project[$P_PATH] eq "") { |
| 1760 | # This is the main project. It is also responsible for recursively |
| 1761 | # calling the other projects |
| 1762 | print FILEO "\tfor i in \$(SUBDIRS); do (cd \$\$i; \$(MAKE) install) || exit 1; done\n"; |
| 1763 | } |
| 1764 | if (@{@$project[$P_TARGETS]} > 0) { |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1765 | print FILEO "\tfor i in \$(EXES); do \$(INSTALL_PROGRAM) \$\$i \$(bindir); done\n"; |
| 1766 | print FILEO "\tfor i in \$(EXES:%=%.so) \$(DLLS); do \$(INSTALL_LIBRARY) \$\$i \$(libdir); done\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1767 | } |
| 1768 | print FILEO "\n"; |
| 1769 | print FILEO "uninstall::\n"; |
| 1770 | if (@$project[$P_PATH] eq "") { |
| 1771 | # This is the main project. It is also responsible for recursively |
| 1772 | # calling the other projects |
| 1773 | print FILEO "\tfor i in \$(SUBDIRS); do (cd \$\$i; \$(MAKE) uninstall) || exit 1; done\n"; |
| 1774 | } |
| 1775 | if (@{@$project[$P_TARGETS]} > 0) { |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1776 | print FILEO "\tfor i in \$(EXES); do \$(RM) \$(bindir)/\$\$i;done\n"; |
| 1777 | print FILEO "\tfor i in \$(EXES:%=%.so) \$(DLLS); do \$(RM) \$(libdir)/\$\$i;done\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1778 | } |
| 1779 | print FILEO "\n\n\n"; |
| 1780 | |
| 1781 | if (@{@$project[$P_TARGETS]} > 0) { |
| 1782 | print FILEO "### Target specific build rules\n\n"; |
| 1783 | foreach $target (@{@$project[$P_TARGETS]}) { |
| 1784 | my $canon=canonize("@$target[$T_NAME]"); |
| 1785 | $canon =~ s/_so$//; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1786 | print FILEO "\$(${canon}_SPEC_SRCS:.spec=.tmp.o): \$(${canon}_OBJS)\n"; |
| 1787 | print FILEO "\t\$(LDCOMBINE) \$(${canon}_OBJS) -o \$\@\n"; |
| 1788 | print FILEO "\t-\$(STRIP) \$(STRIPFLAGS) \$\@\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1789 | print FILEO "\n"; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1790 | print FILEO "\$(${canon}_SPEC_SRCS:.spec=.spec.c): \$(${canon}_SPEC_SRCS:.spec) \$(${canon}_SPEC_SRCS:.spec=.tmp.o) \$(${canon}_RC_SRCS:.rc=.res)\n"; |
| 1791 | print FILEO "\t\$(WINEBUILD) -fPIC \$(${canon}_LIBRARY_PATH) \$(WINE_LIBRARY_PATH) -sym \$(${canon}_SPEC_SRCS:.spec=.tmp.o) -o \$\@ -spec \$(${canon}_SPEC_SRCS)\n"; |
| 1792 | print FILEO "\n"; |
| 1793 | my $t_name=@$target[$T_NAME]; |
| 1794 | if (@$target[$T_TYPE]!=$TT_DLL) { |
| 1795 | $t_name.=".so"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1796 | } |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1797 | print FILEO "$t_name: \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_OBJS) \$(${canon}_DEPENDS) \n"; |
Francois Gouget | 8d0e1e7 | 2001-03-04 01:03:55 +0000 | [diff] [blame] | 1798 | if (@{@$target[$T_SOURCES_CXX]} > 0 or @{@$project_settings[$T_SOURCES_CXX]} > 0) { |
| 1799 | print FILEO "\t\$(LDXXSHARED)"; |
| 1800 | } else { |
| 1801 | print FILEO "\t\$(LDSHARED)"; |
| 1802 | } |
| 1803 | print FILEO " \$(LDDLLFLAGS) -o \$\@ \$(${canon}_OBJS) \$(${canon}_SPEC_SRCS:.spec=.spec.o) \$(${canon}_LIBRARY_PATH) \$(${canon}_LIBRARIES:%=-l%) \$(DLL_LINK) \$(LIBS)\n"; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 1804 | if (@$target[$T_TYPE] ne $TT_DLL) { |
| 1805 | print FILEO "\ttest -e @$target[$T_NAME] || \$(LN_S) \$(WINE) @$target[$T_NAME]\n"; |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 1806 | } |
| 1807 | print FILEO "\n\n"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1808 | } |
| 1809 | } |
| 1810 | close(FILEO); |
| 1811 | |
| 1812 | foreach $target (@{@$project[$P_TARGETS]}) { |
| 1813 | generate_spec_file(@$project[$P_PATH],$target,$project_settings); |
| 1814 | if (@$target[$T_FLAGS] & $TF_WRAPPER) { |
| 1815 | generate_wrapper_file(@$project[$P_PATH],$target); |
| 1816 | } |
| 1817 | } |
| 1818 | } |
| 1819 | |
| 1820 | ## |
| 1821 | # Perform the replacements in the template configure files |
| 1822 | # Return 1 for success, 0 for failure |
| 1823 | sub generate_configure |
| 1824 | { |
| 1825 | my $filename=$_[0]; |
| 1826 | my $a_source_file=$_[1]; |
| 1827 | |
| 1828 | if (!defined $templates{$filename}) { |
| 1829 | if ($filename ne "configure") { |
| 1830 | print STDERR "winemaker: internal error: No template called '$filename'\n"; |
| 1831 | } |
| 1832 | return 0; |
| 1833 | } |
| 1834 | |
| 1835 | if (!open(FILEO,">$filename")) { |
| 1836 | print STDERR "error: unable to open \"$filename\" for writing:\n"; |
| 1837 | print STDERR " $!\n"; |
| 1838 | return 0; |
| 1839 | } |
| 1840 | foreach $line (@{$templates{$filename}}) { |
| 1841 | if ($line =~ /^\#\#WINEMAKER_PROJECTS\#\#$/) { |
| 1842 | foreach $project (@projects) { |
| 1843 | print FILEO "@$project[$P_PATH]Makefile\n"; |
| 1844 | } |
| 1845 | } else { |
| 1846 | $line =~ s+\#\#WINEMAKER_SOURCE\#\#+$a_source_file+; |
| 1847 | $line =~ s+\#\#WINEMAKER_NEEDS_MFC\#\#+$needs_mfc+; |
| 1848 | print FILEO $line; |
| 1849 | } |
| 1850 | } |
| 1851 | close(FILEO); |
| 1852 | return 1; |
| 1853 | } |
| 1854 | |
| 1855 | sub generate_generic |
| 1856 | { |
| 1857 | my $filename=$_[0]; |
| 1858 | |
| 1859 | if (!defined $templates{$filename}) { |
| 1860 | print STDERR "winemaker: internal error: No template called '$filename'\n"; |
| 1861 | return; |
| 1862 | } |
| 1863 | if (!open(FILEO,">$filename")) { |
| 1864 | print STDERR "error: unable to open \"$filename\" for writing:\n"; |
| 1865 | print STDERR " $!\n"; |
| 1866 | return; |
| 1867 | } |
| 1868 | foreach $line (@{$templates{$filename}}) { |
| 1869 | print FILEO $line; |
| 1870 | } |
| 1871 | close(FILEO); |
| 1872 | } |
| 1873 | |
| 1874 | ## |
| 1875 | # Generates the global files: |
| 1876 | # configure |
| 1877 | # configure.in |
| 1878 | # Make.rules.in |
| 1879 | sub generate_global_files |
| 1880 | { |
| 1881 | generate_generic("Make.rules.in"); |
| 1882 | |
| 1883 | # Get the name of a source file for configure.in |
| 1884 | my $a_source_file; |
| 1885 | search_a_file: foreach $project (@projects) { |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 1886 | foreach $target (@{@$project[$P_TARGETS]}, @$project[$P_SETTINGS]) { |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1887 | $a_source_file=@{@$target[$T_SOURCES_C]}[0]; |
| 1888 | if (!defined $a_source_file) { |
| 1889 | $a_source_file=@{@$target[$T_SOURCES_CXX]}[0]; |
| 1890 | } |
| 1891 | if (!defined $a_source_file) { |
| 1892 | $a_source_file=@{@$target[$T_SOURCES_RC]}[0]; |
| 1893 | } |
| 1894 | if (defined $a_source_file) { |
| 1895 | $a_source_file="@$project[$P_PATH]$a_source_file"; |
| 1896 | last search_a_file; |
| 1897 | } |
| 1898 | } |
| 1899 | } |
François Gouget | c1f016b | 2001-01-10 22:43:21 +0000 | [diff] [blame] | 1900 | if (!defined $a_source_file) { |
| 1901 | $a_source_file="Makefile.in"; |
| 1902 | } |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1903 | |
| 1904 | generate_configure("configure.in",$a_source_file); |
| 1905 | unlink("configure"); |
| 1906 | if (generate_configure("configure",$a_source_file) == 0) { |
| 1907 | system("autoconf"); |
| 1908 | } |
| 1909 | # Add execute permission to configure for whoever has the right to read it |
| 1910 | my @st=stat("configure"); |
François Gouget | 38b3ac5 | 2001-01-11 20:17:42 +0000 | [diff] [blame] | 1911 | if (@st) { |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1912 | my $mode=$st[2]; |
| 1913 | $mode|=($mode & 0444) >>2; |
| 1914 | chmod($mode,"configure"); |
| 1915 | } else { |
| 1916 | print "warning: could not generate the configure script. You need to run autoconf\n"; |
| 1917 | } |
| 1918 | } |
| 1919 | |
| 1920 | ## |
| 1921 | # |
| 1922 | sub generate_read_templates |
| 1923 | { |
| 1924 | my $file; |
| 1925 | |
| 1926 | while (<DATA>) { |
| 1927 | if (/^--- ((\w\.?)+) ---$/) { |
| 1928 | my $filename=$1; |
| 1929 | if (defined $templates{$filename}) { |
| 1930 | print STDERR "winemaker: internal error: There is more than one template for $filename\n"; |
| 1931 | undef $file; |
| 1932 | } else { |
| 1933 | $file=[]; |
| 1934 | $templates{$filename}=$file; |
| 1935 | } |
| 1936 | } elsif (defined $file) { |
| 1937 | push @$file, $_; |
| 1938 | } |
| 1939 | } |
| 1940 | } |
| 1941 | |
| 1942 | ## |
| 1943 | # This is where we finally generate files. In fact this method does not |
| 1944 | # do anything itself but calls the methods that do the actual work. |
| 1945 | sub generate |
| 1946 | { |
| 1947 | print "Generating project files...\n"; |
| 1948 | generate_read_templates(); |
| 1949 | generate_global_files(); |
| 1950 | |
| 1951 | foreach $project (@projects) { |
| 1952 | my $path=@$project[$P_PATH]; |
| 1953 | if ($path eq "") { |
| 1954 | $path="."; |
| 1955 | } else { |
| 1956 | $path =~ s+/$++; |
| 1957 | } |
| 1958 | print " $path\n"; |
| 1959 | generate_project_files($project); |
| 1960 | } |
| 1961 | } |
| 1962 | |
| 1963 | |
| 1964 | |
| 1965 | ##### |
| 1966 | # |
| 1967 | # Option defaults |
| 1968 | # |
| 1969 | ##### |
| 1970 | |
| 1971 | $opt_backup=1; |
| 1972 | $opt_lower=$OPT_LOWER_UPPERCASE; |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 1973 | $opt_lower_include=1; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1974 | |
François Gouget | c1f016b | 2001-01-10 22:43:21 +0000 | [diff] [blame] | 1975 | # $opt_work_dir=<undefined> |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1976 | # $opt_single_target=<undefined> |
| 1977 | $opt_target_type=$TT_GUIEXE; |
| 1978 | $opt_flags=0; |
| 1979 | $opt_is_interactive=$OPT_ASK_NO; |
| 1980 | $opt_ask_project_options=$OPT_ASK_NO; |
| 1981 | $opt_ask_target_options=$OPT_ASK_NO; |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 1982 | $opt_no_generated_files=0; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 1983 | $opt_no_banner=0; |
| 1984 | |
| 1985 | |
| 1986 | |
| 1987 | ##### |
| 1988 | # |
| 1989 | # Main |
| 1990 | # |
| 1991 | ##### |
| 1992 | |
François Gouget | 38b3ac5 | 2001-01-11 20:17:42 +0000 | [diff] [blame] | 1993 | sub print_banner |
| 1994 | { |
| 1995 | print "Winemaker $version\n"; |
| 1996 | print "Copyright 2000 Francois Gouget <fgouget\@codeweavers.com> for CodeWeavers\n"; |
| 1997 | } |
| 1998 | |
| 1999 | sub usage |
| 2000 | { |
| 2001 | print_banner(); |
| 2002 | print STDERR "Usage: winemaker [--nobanner] [--backup|--nobackup]\n"; |
| 2003 | print STDERR " [--lower-none|--lower-all|--lower-uppercase]\n"; |
| 2004 | print STDERR " [--lower-include|--nolower-include]\n"; |
| 2005 | print STDERR " [--guiexe|--windows|--cuiexe|--console|--dll]\n"; |
| 2006 | print STDERR " [--wrap|--nowrap] [--mfc|--nomfc]\n"; |
| 2007 | print STDERR " [-Dmacro[=defn]] [-Idir] [-Ldir] [-idll] [-llibrary]\n"; |
| 2008 | print STDERR " [--interactive] [--single-target name]\n"; |
| 2009 | print STDERR " [--generated-files|--nogenerated-files]\n"; |
| 2010 | print STDERR " work_directory\n"; |
| 2011 | print STDERR "\nWinemaker is designed to recursively convert all the Windows sources found in\n"; |
| 2012 | print STDERR "the specified directory so that they can be compiled with Winelib. During this\n"; |
| 2013 | print STDERR "process it will modify and rename some of the files in that directory.\n"; |
| 2014 | print STDERR "\tPlease read the manual page before use.\n"; |
| 2015 | exit (2); |
| 2016 | } |
| 2017 | |
| 2018 | |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2019 | project_init(\@main_project,""); |
| 2020 | |
| 2021 | while (@ARGV>0) { |
| 2022 | my $arg=shift @ARGV; |
| 2023 | # General options |
| 2024 | if ($arg eq "--nobanner") { |
| 2025 | $opt_no_banner=1; |
| 2026 | } elsif ($arg eq "--backup") { |
| 2027 | $opt_backup=1; |
| 2028 | } elsif ($arg eq "--nobackup") { |
| 2029 | $opt_backup=0; |
| 2030 | } elsif ($arg eq "--single-target") { |
| 2031 | $opt_single_target=shift @ARGV; |
| 2032 | } elsif ($arg eq "--lower-none") { |
| 2033 | $opt_lower=$OPT_LOWER_NONE; |
| 2034 | } elsif ($arg eq "--lower-all") { |
| 2035 | $opt_lower=$OPT_LOWER_ALL; |
| 2036 | } elsif ($arg eq "--lower-uppercase") { |
| 2037 | $opt_lower=$OPT_LOWER_UPPERCASE; |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 2038 | } elsif ($arg eq "--lower-include") { |
| 2039 | $opt_lower_include=1; |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 2040 | } elsif ($arg eq "--nolower-include") { |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 2041 | $opt_lower_include=0; |
| 2042 | } elsif ($arg eq "--generated-files") { |
| 2043 | $opt_no_generated_files=0; |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 2044 | } elsif ($arg eq "--nogenerated-files") { |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 2045 | $opt_no_generated_files=1; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2046 | |
| 2047 | } elsif ($arg =~ /^-D/) { |
| 2048 | push @{$global_settings[$T_DEFINES]},$arg; |
| 2049 | } elsif ($arg =~ /^-I/) { |
| 2050 | push @{$global_settings[$T_INCLUDE_PATH]},$arg; |
| 2051 | } elsif ($arg =~ /^-L/) { |
| 2052 | push @{$global_settings[$T_LIBRARY_PATH]},$arg; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2053 | } elsif ($arg =~ /^-i/) { |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2054 | push @{$global_settings[$T_IMPORTS]},$'; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2055 | } elsif ($arg =~ /^-l/) { |
| 2056 | push @{$global_settings[$T_LIBRARIES]},$'; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2057 | |
| 2058 | # 'Source'-based method options |
| 2059 | } elsif ($arg eq "--dll") { |
| 2060 | $opt_target_type=$TT_DLL; |
| 2061 | } elsif ($arg eq "--guiexe" or $arg eq "--windows") { |
| 2062 | $opt_target_type=$TT_GUIEXE; |
| 2063 | } elsif ($arg eq "--cuiexe" or $arg eq "--console") { |
| 2064 | $opt_target_type=$TT_CUIEXE; |
| 2065 | } elsif ($arg eq "--interactive") { |
| 2066 | $opt_is_interactive=$OPT_ASK_YES; |
| 2067 | $opt_ask_project_options=$OPT_ASK_YES; |
| 2068 | $opt_ask_target_options=$OPT_ASK_YES; |
| 2069 | } elsif ($arg eq "--wrap") { |
Francois Gouget | afa36ce | 2001-03-01 22:11:10 +0000 | [diff] [blame] | 2070 | $opt_flags|=$TF_WRAP; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2071 | } elsif ($arg eq "--nowrap") { |
| 2072 | $opt_flags&=~$TF_WRAP; |
| 2073 | } elsif ($arg eq "--mfc") { |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2074 | $opt_flags|=$TF_MFC; |
Francois Gouget | afa36ce | 2001-03-01 22:11:10 +0000 | [diff] [blame] | 2075 | $opt_flags|=$TF_MFC|$TF_WRAP; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2076 | $needs_mfc=1; |
| 2077 | } elsif ($arg eq "--nomfc") { |
| 2078 | $opt_flags&=~($TF_MFC|$TF_WRAP); |
| 2079 | $needs_mfc=0; |
| 2080 | |
| 2081 | # Catch errors |
| 2082 | } else { |
| 2083 | if ($arg ne "--help" and $arg ne "-h" and $arg ne "-?") { |
François Gouget | c1f016b | 2001-01-10 22:43:21 +0000 | [diff] [blame] | 2084 | if (!defined $opt_work_dir) { |
| 2085 | $opt_work_dir=$arg; |
| 2086 | } else { |
| 2087 | print STDERR "error: the work directory, \"$arg\", has already been specified (was \"$opt_work_dir\")\n"; |
François Gouget | 38b3ac5 | 2001-01-11 20:17:42 +0000 | [diff] [blame] | 2088 | usage(); |
François Gouget | c1f016b | 2001-01-10 22:43:21 +0000 | [diff] [blame] | 2089 | } |
| 2090 | } else { |
François Gouget | 38b3ac5 | 2001-01-11 20:17:42 +0000 | [diff] [blame] | 2091 | usage(); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2092 | } |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2093 | } |
| 2094 | } |
| 2095 | |
François Gouget | c1f016b | 2001-01-10 22:43:21 +0000 | [diff] [blame] | 2096 | if (!defined $opt_work_dir) { |
| 2097 | print STDERR "error: you must specify the directory containing the sources to be converted\n"; |
François Gouget | 38b3ac5 | 2001-01-11 20:17:42 +0000 | [diff] [blame] | 2098 | usage(); |
François Gouget | c1f016b | 2001-01-10 22:43:21 +0000 | [diff] [blame] | 2099 | } elsif (!chdir $opt_work_dir) { |
| 2100 | print STDERR "error: could not chdir to the work directory\n"; |
| 2101 | print STDERR " $!\n"; |
François Gouget | 38b3ac5 | 2001-01-11 20:17:42 +0000 | [diff] [blame] | 2102 | usage(); |
François Gouget | c1f016b | 2001-01-10 22:43:21 +0000 | [diff] [blame] | 2103 | } |
| 2104 | |
François Gouget | 38b3ac5 | 2001-01-11 20:17:42 +0000 | [diff] [blame] | 2105 | if ($opt_no_banner == 0) { |
| 2106 | print_banner(); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2107 | } |
| 2108 | |
| 2109 | # Fix the file and directory names |
| 2110 | fix_file_and_directory_names("."); |
| 2111 | |
| 2112 | # Scan the sources to identify the projects and targets |
| 2113 | source_scan(); |
| 2114 | |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 2115 | # Create targets for wrappers, etc. |
| 2116 | postprocess_targets(); |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2117 | |
| 2118 | # Fix the source files |
| 2119 | fix_source(); |
| 2120 | |
| 2121 | # Generate the Makefile and the spec file |
Francois Gouget | a106edb | 2000-11-10 22:29:11 +0000 | [diff] [blame] | 2122 | if (! $opt_no_generated_files) { |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2123 | generate(); |
| 2124 | } |
| 2125 | |
| 2126 | |
| 2127 | __DATA__ |
| 2128 | --- configure.in --- |
| 2129 | dnl Process this file with autoconf to produce a configure script. |
| 2130 | dnl Author: Michael Patra <micky@marie.physik.tu-berlin.de> |
| 2131 | dnl <patra@itp1.physik.tu-berlin.de> |
| 2132 | dnl Francois Gouget <fgouget@codeweavers.com> for CodeWeavers |
| 2133 | |
| 2134 | AC_REVISION([configure.in 1.00]) |
| 2135 | AC_INIT(##WINEMAKER_SOURCE##) |
| 2136 | |
| 2137 | NEEDS_MFC=##WINEMAKER_NEEDS_MFC## |
| 2138 | |
| 2139 | dnl **** Command-line arguments **** |
| 2140 | |
| 2141 | AC_SUBST(OPTIONS) |
| 2142 | |
| 2143 | dnl **** Check for some programs **** |
| 2144 | |
| 2145 | AC_PROG_MAKE_SET |
| 2146 | AC_PROG_CC |
| 2147 | AC_PROG_CXX |
| 2148 | AC_PROG_CPP |
| 2149 | AC_PATH_XTRA |
| 2150 | AC_PROG_RANLIB |
| 2151 | AC_PROG_LN_S |
| 2152 | AC_PATH_PROG(LDCONFIG, ldconfig, true, /sbin:/usr/sbin:$PATH) |
| 2153 | |
| 2154 | dnl **** Check for some libraries **** |
| 2155 | |
| 2156 | dnl Check for -lm for BeOS |
| 2157 | AC_CHECK_LIB(m,sqrt) |
| 2158 | dnl Check for -li386 for NetBSD and OpenBSD |
| 2159 | AC_CHECK_LIB(i386,i386_set_ldt) |
| 2160 | dnl Check for -lossaudio for NetBSD |
| 2161 | AC_CHECK_LIB(ossaudio,_oss_ioctl) |
| 2162 | dnl Check for -lw for Solaris |
| 2163 | AC_CHECK_LIB(w,iswalnum) |
| 2164 | dnl Check for -lnsl for Solaris |
| 2165 | AC_CHECK_FUNCS(gethostbyname,, AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl", AC_CHECK_LIB(socket, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl", , -lnsl), -lsocket)) |
| 2166 | dnl Check for -lsocket for Solaris |
| 2167 | AC_CHECK_FUNCS(connect,,AC_CHECK_LIB(socket,connect)) |
| 2168 | dnl Check for -lxpg4 for FreeBSD |
| 2169 | AC_CHECK_LIB(xpg4,setrunelocale) |
| 2170 | dnl Check for -lmmap for OS/2 |
| 2171 | AC_CHECK_LIB(mmap,mmap) |
| 2172 | dnl Check for openpty |
| 2173 | AC_CHECK_FUNCS(openpty,, |
| 2174 | AC_CHECK_LIB(util,openpty, |
| 2175 | AC_DEFINE(HAVE_OPENPTY) |
| 2176 | LIBS="$LIBS -lutil" |
| 2177 | )) |
| 2178 | |
| 2179 | AC_CHECK_HEADERS(dlfcn.h, |
| 2180 | AC_CHECK_FUNCS(dlopen, |
| 2181 | AC_DEFINE(HAVE_DL_API), |
| 2182 | AC_CHECK_LIB(dl,dlopen, |
| 2183 | AC_DEFINE(HAVE_DL_API) |
| 2184 | LIBS="$LIBS -ldl", |
| 2185 | ) |
| 2186 | ), |
| 2187 | ) |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2188 | |
| 2189 | dnl **** Check which curses lib to use *** |
| 2190 | if test "$CURSES" = "yes" |
| 2191 | then |
| 2192 | AC_CHECK_HEADERS(ncurses.h) |
| 2193 | if test "$ac_cv_header_ncurses_h" = "yes" |
| 2194 | then |
| 2195 | AC_CHECK_LIB(ncurses,waddch) |
| 2196 | fi |
| 2197 | if test "$ac_cv_lib_ncurses_waddch" = "yes" |
| 2198 | then |
| 2199 | AC_CHECK_LIB(ncurses,resizeterm,AC_DEFINE(HAVE_RESIZETERM)) |
| 2200 | AC_CHECK_LIB(ncurses,getbkgd,AC_DEFINE(HAVE_GETBKGD)) |
| 2201 | else |
| 2202 | AC_CHECK_HEADERS(curses.h) |
| 2203 | if test "$ac_cv_header_curses_h" = "yes" |
| 2204 | then |
| 2205 | AC_CHECK_LIB(curses,waddch) |
| 2206 | if test "$ac_cv_lib_curses_waddch" = "yes" |
| 2207 | then |
| 2208 | AC_CHECK_LIB(curses,resizeterm,AC_DEFINE(HAVE_RESIZETERM)) |
| 2209 | AC_CHECK_LIB(curses,getbkgd,AC_DEFINE(HAVE_GETBKGD)) |
| 2210 | fi |
| 2211 | fi |
| 2212 | fi |
| 2213 | fi |
| 2214 | |
| 2215 | dnl **** If ln -s doesn't work, use cp instead **** |
| 2216 | if test "$ac_cv_prog_LN_S" = "ln -s"; then : ; else LN_S=cp ; fi |
| 2217 | |
| 2218 | dnl **** Check for gcc strength-reduce bug **** |
| 2219 | |
| 2220 | if test "x${GCC}" = "xyes" |
| 2221 | then |
| 2222 | AC_CACHE_CHECK( "for gcc strength-reduce bug", ac_cv_c_gcc_strength_bug, |
| 2223 | AC_TRY_RUN([ |
| 2224 | int main(void) { |
| 2225 | static int Array[[3]]; |
| 2226 | unsigned int B = 3; |
| 2227 | int i; |
| 2228 | for(i=0; i<B; i++) Array[[i]] = i - 3; |
| 2229 | exit( Array[[1]] != -2 ); |
| 2230 | }], |
| 2231 | ac_cv_c_gcc_strength_bug="no", |
| 2232 | ac_cv_c_gcc_strength_bug="yes", |
| 2233 | ac_cv_c_gcc_strength_bug="yes") ) |
| 2234 | if test "$ac_cv_c_gcc_strength_bug" = "yes" |
| 2235 | then |
| 2236 | CFLAGS="$CFLAGS -fno-strength-reduce" |
| 2237 | fi |
| 2238 | fi |
| 2239 | |
| 2240 | dnl **** Check for underscore on external symbols **** |
| 2241 | |
| 2242 | AC_CACHE_CHECK("whether external symbols need an underscore prefix", |
| 2243 | ac_cv_c_extern_prefix, |
| 2244 | [saved_libs=$LIBS |
| 2245 | LIBS="conftest_asm.s $LIBS" |
| 2246 | cat > conftest_asm.s <<EOF |
| 2247 | .globl _ac_test |
| 2248 | _ac_test: |
| 2249 | .long 0 |
| 2250 | EOF |
| 2251 | AC_TRY_LINK([extern int ac_test;],[if (ac_test) return 1], |
| 2252 | ac_cv_c_extern_prefix="yes",ac_cv_c_extern_prefix="no") |
| 2253 | LIBS=$saved_libs]) |
| 2254 | if test "$ac_cv_c_extern_prefix" = "yes" |
| 2255 | then |
| 2256 | AC_DEFINE(NEED_UNDERSCORE_PREFIX) |
| 2257 | fi |
| 2258 | |
| 2259 | dnl **** Check for working dll **** |
| 2260 | |
| 2261 | LDSHARED="" |
Francois Gouget | 8d0e1e7 | 2001-03-04 01:03:55 +0000 | [diff] [blame] | 2262 | LDXXSHARED="" |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2263 | LDDLLFLAGS="" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2264 | AC_CACHE_CHECK("whether we can build a Linux dll", |
| 2265 | ac_cv_c_dll_linux, |
| 2266 | [saved_cflags=$CFLAGS |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2267 | CFLAGS="$CFLAGS -fPIC -shared -Wl,-soname,conftest.so.1.0,-Bsymbolic" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2268 | AC_TRY_LINK(,[return 1],ac_cv_c_dll_linux="yes",ac_cv_c_dll_linux="no") |
| 2269 | CFLAGS=$saved_cflags |
| 2270 | ]) |
| 2271 | if test "$ac_cv_c_dll_linux" = "yes" |
| 2272 | then |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2273 | LDSHARED="\$(CC) -shared -Wl,-rpath,\$(libdir)" |
Francois Gouget | 8d0e1e7 | 2001-03-04 01:03:55 +0000 | [diff] [blame] | 2274 | LDXXSHARED="\$(CXX) -shared -Wl,-rpath,\$(libdir)" |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2275 | LDDLLFLAGS="-Wl,-Bsymbolic" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2276 | else |
| 2277 | AC_CACHE_CHECK(whether we can build a UnixWare (Solaris) dll, |
| 2278 | ac_cv_c_dll_unixware, |
| 2279 | [saved_cflags=$CFLAGS |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2280 | CFLAGS="$CFLAGS -fPIC -Wl,-G,-h,conftest.so.1.0,-B,symbolic" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2281 | AC_TRY_LINK(,[return 1],ac_cv_c_dll_unixware="yes",ac_cv_c_dll_unixware="no") |
| 2282 | CFLAGS=$saved_cflags |
| 2283 | ]) |
| 2284 | if test "$ac_cv_c_dll_unixware" = "yes" |
| 2285 | then |
Francois Gouget | 8d0e1e7 | 2001-03-04 01:03:55 +0000 | [diff] [blame] | 2286 | LDSHARED="\$(CC) -Wl,-G" |
| 2287 | LDXXSHARED="\$(CXX) -Wl,-G" |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2288 | LDDLLFLAGS="-Wl,-B,symbolic" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2289 | else |
| 2290 | AC_CACHE_CHECK("whether we can build a NetBSD dll", |
| 2291 | ac_cv_c_dll_netbsd, |
| 2292 | [saved_cflags=$CFLAGS |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2293 | CFLAGS="$CFLAGS -fPIC -Wl,-Bshareable,-Bforcearchive" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2294 | AC_TRY_LINK(,[return 1],ac_cv_c_dll_netbsd="yes",ac_cv_c_dll_netbsd="no") |
| 2295 | CFLAGS=$saved_cflags |
| 2296 | ]) |
| 2297 | if test "$ac_cv_c_dll_netbsd" = "yes" |
| 2298 | then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2299 | LDSHARED="\$(CC) -Wl,-Bshareable,-Bforcearchive" |
Francois Gouget | 8d0e1e7 | 2001-03-04 01:03:55 +0000 | [diff] [blame] | 2300 | LDXXSHARED="\$(CXX) -Wl,-Bshareable,-Bforcearchive" |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2301 | LDDLLFLAGS="" #FIXME |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2302 | fi |
| 2303 | fi |
| 2304 | fi |
| 2305 | if test "$ac_cv_c_dll_linux" = "no" -a "$ac_cv_c_dll_unixware" = "no" -a "$ac_cv_c_dll_netbsd" = "no" |
| 2306 | then |
| 2307 | AC_MSG_ERROR([Could not find how to build a dynamically linked library]) |
| 2308 | fi |
| 2309 | |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2310 | CFLAGS="$CFLAGS -fPIC" |
Alexandre Julliard | c4d1176 | 2000-12-27 19:06:44 +0000 | [diff] [blame] | 2311 | DLL_LINK="\$(WINE_LIBRARY_PATH) \$(LIBRARY_PATH) \$(LIBRARIES:%=-l%) -lwine -lwine_unicode -lwine_uuid" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2312 | |
| 2313 | AC_SUBST(DLL_LINK) |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2314 | AC_SUBST(LDSHARED) |
Francois Gouget | 8d0e1e7 | 2001-03-04 01:03:55 +0000 | [diff] [blame] | 2315 | AC_SUBST(LDXXSHARED) |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2316 | AC_SUBST(LDDLLFLAGS) |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2317 | |
| 2318 | dnl *** check for the need to define __i386__ |
| 2319 | |
| 2320 | AC_CACHE_CHECK("whether we need to define __i386__",ac_cv_cpp_def_i386, |
| 2321 | AC_EGREP_CPP(yes,[#if (defined(i386) || defined(__i386)) && !defined(__i386__) |
| 2322 | yes |
| 2323 | #endif], |
| 2324 | ac_cv_cpp_def_i386="yes", ac_cv_cpp_def_i386="no")) |
| 2325 | if test "$ac_cv_cpp_def_i386" = "yes" |
| 2326 | then |
| 2327 | CFLAGS="$CFLAGS -D__i386__" |
| 2328 | fi |
| 2329 | |
| 2330 | dnl $GCC is set by autoconf |
| 2331 | GCC_NO_BUILTIN="" |
| 2332 | if test "$GCC" = "yes" |
| 2333 | then |
| 2334 | GCC_NO_BUILTIN="-fno-builtin" |
| 2335 | fi |
| 2336 | AC_SUBST(GCC_NO_BUILTIN) |
| 2337 | |
| 2338 | dnl **** Test Winelib-related features of the C++ compiler |
| 2339 | AC_LANG_CPLUSPLUS() |
| 2340 | if test "x${GCC}" = "xyes" |
| 2341 | then |
| 2342 | OLDCXXFLAGS="$CXXFLAGS"; |
| 2343 | CXXFLAGS="-fpermissive"; |
| 2344 | AC_CACHE_CHECK("for g++ -fpermissive option", has_gxx_permissive, |
| 2345 | AC_TRY_COMPILE(,[ |
| 2346 | for (int i=0;i<2;i++); |
| 2347 | i=0; |
| 2348 | ], |
| 2349 | [has_gxx_permissive="yes"], |
| 2350 | [has_gxx_permissive="no"]) |
| 2351 | ) |
| 2352 | CXXFLAGS="-fno-for-scope"; |
| 2353 | AC_CACHE_CHECK("for g++ -fno-for-scope option", has_gxx_no_for_scope, |
| 2354 | AC_TRY_COMPILE(,[ |
| 2355 | for (int i=0;i<2;i++); |
| 2356 | i=0; |
| 2357 | ], |
| 2358 | [has_gxx_no_for_scope="yes"], |
| 2359 | [has_gxx_no_for_scope="no"]) |
| 2360 | ) |
| 2361 | CXXFLAGS="$OLDCXXFLAGS"; |
| 2362 | if test "$has_gxx_permissive" = "yes" |
| 2363 | then |
| 2364 | CXXFLAGS="$CXXFLAGS -fpermissive" |
| 2365 | fi |
| 2366 | if test "$has_gxx_no_for_scope" = "yes" |
| 2367 | then |
| 2368 | CXXFLAGS="$CXXFLAGS -fno-for-scope" |
| 2369 | fi |
| 2370 | fi |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2371 | AC_LANG_C() |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2372 | |
| 2373 | dnl **** Test Winelib-related features of the C compiler |
| 2374 | dnl none for now |
| 2375 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2376 | dnl **** Macros for finding a headers/libraries in a collection of places |
| 2377 | |
| 2378 | dnl AC_PATH_HEADER(variable,header,action-if-not-found,default-locations) |
| 2379 | dnl Note that the above may set variable to an empty value if the header is |
| 2380 | dnl already in the include path |
| 2381 | AC_DEFUN(AC_PATH_HEADER,[ |
| 2382 | AC_MSG_CHECKING([for $2]) |
| 2383 | AC_CACHE_VAL(ac_cv_path_$1, |
| 2384 | [ |
| 2385 | ac_found= |
| 2386 | ac_dummy="ifelse([$4], , :/usr/local/include, [$4])" |
| 2387 | save_CPPFLAGS="$CPPFLAGS" |
| 2388 | IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" |
| 2389 | for ac_dir in $ac_dummy; do |
| 2390 | IFS="$ac_save_ifs" |
| 2391 | if test -z "$ac_dir" |
| 2392 | then |
| 2393 | CPPFLAGS="$save_CPPFLAGS" |
| 2394 | else |
| 2395 | CPPFLAGS="-I$ac_dir $save_CPPFLAGS" |
| 2396 | fi |
| 2397 | AC_TRY_COMPILE([#include <$2>],,ac_found=1;ac_cv_path_$1="$ac_dir";break) |
| 2398 | done |
| 2399 | CPPFLAGS="$save_CPPFLAGS" |
| 2400 | ifelse([$3],,,[if test -z "$ac_found" |
| 2401 | then |
| 2402 | $3 |
| 2403 | fi |
| 2404 | ]) |
| 2405 | ]) |
| 2406 | $1="$ac_cv_path_$1" |
| 2407 | if test -n "$ac_found" -o -n "[$]$1" |
| 2408 | then |
| 2409 | AC_MSG_RESULT([$]$1) |
| 2410 | else |
| 2411 | AC_MSG_RESULT(no) |
| 2412 | fi |
| 2413 | AC_SUBST($1) |
| 2414 | ]) |
| 2415 | |
| 2416 | dnl AC_PATH_LIBRARY(variable,libraries,extra libs,action-if-not-found,default-locations) |
| 2417 | AC_DEFUN(AC_PATH_LIBRARY,[ |
| 2418 | AC_MSG_CHECKING([for $2]) |
| 2419 | AC_CACHE_VAL(ac_cv_path_$1, |
| 2420 | [ |
| 2421 | ac_found= |
| 2422 | ac_dummy="ifelse([$5], , :/usr/local/lib, [$5])" |
| 2423 | save_LIBS="$LIBS" |
| 2424 | IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" |
| 2425 | for ac_dir in $ac_dummy; do |
| 2426 | IFS="$ac_save_ifs" |
| 2427 | if test -z "$ac_dir" |
| 2428 | then |
| 2429 | LIBS="$2 $3 $save_LIBS" |
| 2430 | else |
| 2431 | LIBS="-L$ac_dir $2 $3 $save_LIBS" |
| 2432 | fi |
| 2433 | AC_TRY_LINK(,,ac_found=1;ac_cv_path_$1="$ac_dir";break) |
| 2434 | done |
| 2435 | LIBS="$save_LIBS" |
| 2436 | ifelse([$4],,,[if test -z "$ac_found" |
| 2437 | then |
| 2438 | $4 |
| 2439 | fi |
| 2440 | ]) |
| 2441 | ]) |
| 2442 | $1="$ac_cv_path_$1" |
| 2443 | if test -n "$ac_found" -o -n "[$]$1" |
| 2444 | then |
| 2445 | AC_MSG_RESULT([$]$1) |
| 2446 | else |
| 2447 | AC_MSG_RESULT(no) |
| 2448 | fi |
| 2449 | AC_SUBST($1) |
| 2450 | ]) |
| 2451 | |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2452 | dnl **** Try to find where winelib is located **** |
| 2453 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2454 | WINE_INCLUDE_ROOT=""; |
| 2455 | WINE_INCLUDE_PATH=""; |
| 2456 | WINE_LIBRARY_ROOT=""; |
| 2457 | WINE_LIBRARY_PATH=""; |
| 2458 | WINE_TOOL_PATH=""; |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2459 | WINE=""; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2460 | WINEBUILD=""; |
| 2461 | WRC=""; |
| 2462 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2463 | AC_ARG_WITH(wine, |
| 2464 | [ --with-wine=DIR the Wine package (or sources) is in DIR], |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2465 | [if test "$withval" != "no"; then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2466 | WINE_ROOT="$withval"; |
| 2467 | WINE_INCLUDES=""; |
| 2468 | WINE_LIBRARIES=""; |
| 2469 | WINE_TOOLS=""; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2470 | else |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2471 | WINE_ROOT=""; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2472 | fi]) |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2473 | if test -n "$WINE_ROOT" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2474 | then |
François Gouget | ba5bb0b | 2001-01-09 20:50:34 +0000 | [diff] [blame] | 2475 | WINE_INCLUDE_ROOT="$WINE_ROOT/include:$WINE_ROOT/include/wine"; |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2476 | WINE_LIBRARY_ROOT="$WINE_ROOT"; |
| 2477 | WINE_TOOL_PATH="$WINE_ROOT:$WINE_ROOT/bin:$WINE_ROOT/tools/wrc:$WINE_ROOT/tools/winebuild:$PATH"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2478 | fi |
| 2479 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2480 | AC_ARG_WITH(wine-includes, |
| 2481 | [ --with-wine-includes=DIR the Wine includes are in DIR], |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2482 | [if test "$withval" != "no"; then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2483 | WINE_INCLUDES="$withval"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2484 | else |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2485 | WINE_INCLUDES=""; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2486 | fi]) |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2487 | if test -n "$WINE_INCLUDES" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2488 | then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2489 | WINE_INCLUDE_ROOT="$WINE_INCLUDES"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2490 | fi |
| 2491 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2492 | AC_ARG_WITH(wine-libraries, |
| 2493 | [ --with-wine-libraries=DIR the Wine libraries are in DIR], |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2494 | [if test "$withval" != "no"; then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2495 | WINE_LIBRARIES="$withval"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2496 | else |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2497 | WINE_LIBRARIES=""; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2498 | fi]) |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2499 | if test -n "$WINE_LIBRARIES" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2500 | then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2501 | WINE_LIBRARY_ROOT="$WINE_LIBRARIES"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2502 | fi |
| 2503 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2504 | AC_ARG_WITH(wine-tools, |
| 2505 | [ --with-wine-tools=DIR the Wine tools are in DIR], |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2506 | [if test "$withval" != "no"; then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2507 | WINE_TOOLS="$withval"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2508 | else |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2509 | WINE_TOOLS=""; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2510 | fi]) |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2511 | if test -n "$WINE_TOOLS" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2512 | then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2513 | WINE_TOOL_PATH="$WINE_TOOLS:$WINE_TOOLS/wrc:$WINE_TOOLS/winebuild"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2514 | fi |
| 2515 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2516 | if test -z "$WINE_INCLUDE_ROOT" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2517 | then |
François Gouget | ba5bb0b | 2001-01-09 20:50:34 +0000 | [diff] [blame] | 2518 | WINE_INCLUDE_ROOT=":/usr/include/wine:/usr/local/include/wine:/opt/wine/include:/opt/wine/include/wine"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2519 | fi |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2520 | AC_PATH_HEADER(WINE_INCLUDE_ROOT,windef.h,[ |
| 2521 | AC_MSG_ERROR([Could not find the Wine includes]) |
| 2522 | ],$WINE_INCLUDE_ROOT) |
| 2523 | if test -n "$WINE_INCLUDE_ROOT" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2524 | then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2525 | WINE_INCLUDE_PATH="-I$WINE_INCLUDE_ROOT" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2526 | else |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2527 | WINE_INCLUDE_PATH="" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2528 | fi |
| 2529 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2530 | if test -z "$WINE_LIBRARY_ROOT" |
| 2531 | then |
| 2532 | WINE_LIBRARY_ROOT=":/usr/lib/wine:/usr/local/lib:/usr/local/lib/wine:/opt/wine/lib"; |
| 2533 | else |
| 2534 | WINE_LIBRARY_ROOT="$WINE_LIBRARY_ROOT:$WINE_LIBRARY_ROOT/lib"; |
| 2535 | fi |
| 2536 | AC_PATH_LIBRARY(WINE_LIBRARY_ROOT,[-lwine],[-lutil],[ |
| 2537 | AC_MSG_ERROR([Could not find the Wine libraries (libwine.so)]) |
| 2538 | ],$WINE_LIBRARY_ROOT) |
| 2539 | if test -n "$WINE_LIBRARY_ROOT" |
| 2540 | then |
| 2541 | WINE_LIBRARY_PATH="-L$WINE_LIBRARY_ROOT" |
| 2542 | else |
| 2543 | WINE_LIBRARY_PATH="" |
| 2544 | fi |
| 2545 | AC_PATH_LIBRARY(LIBNTDLL_PATH,[-lntdll],[$WINE_LIBRARY_PATH -lwine -lwine_unicode -lncurses -ldl -lutil],[ |
| 2546 | AC_MSG_ERROR([Could not find the Wine libraries (libntdll.so)]) |
| 2547 | ],[$WINE_LIBRARY_ROOT:$WINE_LIBRARY_ROOT/dlls]) |
| 2548 | if test -n "$LIBNTDLL_PATH" -a "-L$LIBNTDLL_PATH" != "$WINE_LIBRARY_PATH" |
| 2549 | then |
| 2550 | WINE_LIBRARY_PATH="$WINE_LIBRARY_PATH -L$LIBNTDLL_PATH" |
| 2551 | fi |
| 2552 | |
| 2553 | if test -z "$WINE_TOOL_PATH" |
| 2554 | then |
| 2555 | WINE_TOOL_PATH="$PATH:/usr/local/bin:/opt/wine/bin"; |
| 2556 | fi |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2557 | AC_PATH_PROG(WINE,wine,,$WINE_TOOL_PATH) |
| 2558 | if test -z "$WINE" |
| 2559 | then |
| 2560 | AC_MSG_ERROR([Could not find Wine's wine tool]) |
| 2561 | fi |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2562 | AC_PATH_PROG(WINEBUILD,winebuild,,$WINE_TOOL_PATH) |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2563 | if test -z "$WINEBUILD" |
| 2564 | then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2565 | AC_MSG_ERROR([Could not find Wine's winebuild tool]) |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2566 | fi |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2567 | AC_PATH_PROG(WRC,wrc,,$WINE_TOOL_PATH) |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2568 | if test -z "$WRC" |
| 2569 | then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2570 | AC_MSG_ERROR([Could not find Wine's wrc tool]) |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2571 | fi |
| 2572 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2573 | AC_SUBST(WINE_INCLUDE_PATH) |
| 2574 | AC_SUBST(WINE_LIBRARY_PATH) |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2575 | |
| 2576 | dnl **** Try to find where the MFC are located **** |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2577 | AC_LANG_CPLUSPLUS() |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2578 | |
| 2579 | if test "x$NEEDS_MFC" = "x1" |
| 2580 | then |
| 2581 | ATL_INCLUDE_ROOT=""; |
| 2582 | ATL_INCLUDE_PATH=""; |
| 2583 | MFC_INCLUDE_ROOT=""; |
| 2584 | MFC_INCLUDE_PATH=""; |
| 2585 | MFC_LIBRARY_ROOT=""; |
| 2586 | MFC_LIBRARY_PATH=""; |
| 2587 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2588 | AC_ARG_WITH(mfc, |
| 2589 | [ --with-mfc=DIR the MFC package (or sources) is in DIR], |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2590 | [if test "$withval" != "no"; then |
| 2591 | MFC_ROOT="$withval"; |
| 2592 | ATL_INCLUDES=""; |
| 2593 | MFC_INCLUDES=""; |
| 2594 | MFC_LIBRARIES=""; |
| 2595 | else |
| 2596 | MFC_ROOT=""; |
| 2597 | fi]) |
| 2598 | if test -n "$MFC_ROOT" |
| 2599 | then |
| 2600 | ATL_INCLUDE_ROOT="$MFC_ROOT"; |
| 2601 | MFC_INCLUDE_ROOT="$MFC_ROOT"; |
| 2602 | MFC_LIBRARY_ROOT="$MFC_ROOT"; |
| 2603 | fi |
| 2604 | |
| 2605 | AC_ARG_WITH(atl-includes, |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2606 | [ --with-atl-includes=DIR the ATL includes are in DIR], |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2607 | [if test "$withval" != "no"; then |
| 2608 | ATL_INCLUDES="$withval"; |
| 2609 | else |
| 2610 | ATL_INCLUDES=""; |
| 2611 | fi]) |
| 2612 | if test -n "$ATL_INCLUDES" |
| 2613 | then |
| 2614 | ATL_INCLUDE_ROOT="$ATL_INCLUDES"; |
| 2615 | fi |
| 2616 | |
| 2617 | AC_ARG_WITH(mfc-includes, |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2618 | [ --with-mfc-includes=DIR the MFC includes are in DIR], |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2619 | [if test "$withval" != "no"; then |
| 2620 | MFC_INCLUDES="$withval"; |
| 2621 | else |
| 2622 | MFC_INCLUDES=""; |
| 2623 | fi]) |
| 2624 | if test -n "$MFC_INCLUDES" |
| 2625 | then |
| 2626 | MFC_INCLUDE_ROOT="$MFC_INCLUDES"; |
| 2627 | fi |
| 2628 | |
| 2629 | AC_ARG_WITH(mfc-libraries, |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2630 | [ --with-mfc-libraries=DIR the MFC libraries are in DIR], |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2631 | [if test "$withval" != "no"; then |
| 2632 | MFC_LIBRARIES="$withval"; |
| 2633 | else |
| 2634 | MFC_LIBRARIES=""; |
| 2635 | fi]) |
| 2636 | if test -n "$MFC_LIBRARIES" |
| 2637 | then |
| 2638 | MFC_LIBRARY_ROOT="$MFC_LIBRARIES"; |
| 2639 | fi |
| 2640 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2641 | OLDCPPFLAGS="$CPPFLAGS" |
| 2642 | dnl FIXME: We should not have defines in any of the include paths |
| 2643 | CPPFLAGS="$WINE_INCLUDE_PATH -I$WINE_INCLUDE_ROOT/mixedcrt -D_DLL -D_MT $CPPFLAGS" |
| 2644 | ATL_INCLUDE_PATH="-I\$(WINE_INCLUDE_ROOT)/mixedcrt -D_DLL -D_MT" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2645 | if test -z "$ATL_INCLUDE_ROOT" |
| 2646 | then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2647 | ATL_INCLUDE_ROOT=":$WINE_INCLUDE_ROOT/atl:/usr/include/atl:/usr/local/include/atl:/opt/mfc/include/atl:/opt/atl/include" |
| 2648 | else |
| 2649 | ATL_INCLUDE_ROOT="$ATL_INCLUDE_ROOT:$ATL_INCLUDE_ROOT/atl:$ATL_INCLUDE_ROOT/atl/include" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2650 | fi |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2651 | AC_PATH_HEADER(ATL_INCLUDE_ROOT,atldef.h,[ |
| 2652 | AC_MSG_ERROR([Could not find the ATL includes]) |
| 2653 | ],$ATL_INCLUDE_ROOT) |
| 2654 | if test -n "$ATL_INCLUDE_ROOT" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2655 | then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2656 | ATL_INCLUDE_PATH="$ATL_INCLUDE_PATH -I$ATL_INCLUDE_ROOT" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2657 | fi |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2658 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2659 | MFC_INCLUDE_PATH="$ATL_INCLUDE_PATH" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2660 | if test -z "$MFC_INCLUDE_ROOT" |
| 2661 | then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2662 | MFC_INCLUDE_ROOT=":$WINE_INCLUDE_ROOT/mfc:/usr/include/mfc:/usr/local/include/mfc:/opt/mfc/include/mfc:/opt/mfc/include" |
| 2663 | else |
| 2664 | MFC_INCLUDE_ROOT="$MFC_INCLUDE_ROOT:$MFC_INCLUDE_ROOT/mfc:$MFC_INCLUDE_ROOT/mfc/include" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2665 | fi |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2666 | AC_PATH_HEADER(MFC_INCLUDE_ROOT,afx.h,[ |
| 2667 | AC_MSG_ERROR([Could not find the MFC includes]) |
| 2668 | ],$MFC_INCLUDE_ROOT) |
| 2669 | if test -n "$MFC_INCLUDE_ROOT" -a "$ATL_INCLUDE_ROOT" != "$MFC_INCLUDE_ROOT" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2670 | then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2671 | MFC_INCLUDE_PATH="$MFC_INCLUDE_PATH -I$MFC_INCLUDE_ROOT" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2672 | fi |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2673 | CPPFLAGS="$OLDCPPFLAGS" |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2674 | |
| 2675 | if test -z "$MFC_LIBRARY_ROOT" |
| 2676 | then |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2677 | MFC_LIBRARY_ROOT=":$WINE_LIBRARY_ROOT:/usr/lib/mfc:/usr/local/lib:/usr/local/lib/mfc:/opt/mfc/lib"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2678 | else |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2679 | MFC_LIBRARY_ROOT="$MFC_LIBRARY_ROOT:$MFC_LIBRARY_ROOT/lib:$MFC_LIBRARY_ROOT/mfc/src"; |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2680 | fi |
Francois Gouget | 82747b7 | 2000-11-25 01:38:39 +0000 | [diff] [blame] | 2681 | AC_PATH_LIBRARY(MFC_LIBRARY_ROOT,[-lmfc],[$WINE_LIBRARY_PATH -lwine -lwine_unicode],[ |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2682 | AC_MSG_ERROR([Could not find the MFC library]) |
| 2683 | ],$MFC_LIBRARY_ROOT) |
| 2684 | if test -n "$MFC_LIBRARY_ROOT" -a "$MFC_LIBRARY_ROOT" != "$WINE_LIBRARY_ROOT" |
| 2685 | then |
| 2686 | MFC_LIBRARY_PATH="-L$MFC_LIBRARY_ROOT" |
| 2687 | else |
| 2688 | MFC_LIBRARY_PATH="" |
| 2689 | fi |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2690 | |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2691 | AC_SUBST(ATL_INCLUDE_PATH) |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2692 | AC_SUBST(MFC_INCLUDE_PATH) |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2693 | AC_SUBST(MFC_LIBRARY_PATH) |
| 2694 | fi |
| 2695 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2696 | AC_LANG_C() |
| 2697 | |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2698 | dnl **** Generate output files **** |
| 2699 | |
| 2700 | MAKE_RULES=Make.rules |
| 2701 | AC_SUBST_FILE(MAKE_RULES) |
| 2702 | |
| 2703 | AC_OUTPUT([ |
| 2704 | Make.rules |
| 2705 | ##WINEMAKER_PROJECTS## |
| 2706 | ]) |
| 2707 | |
| 2708 | echo |
| 2709 | echo "Configure finished. Do 'make' to build the project." |
| 2710 | echo |
| 2711 | |
| 2712 | dnl Local Variables: |
| 2713 | dnl comment-start: "dnl " |
| 2714 | dnl comment-end: "" |
| 2715 | dnl comment-start-skip: "\\bdnl\\b\\s *" |
| 2716 | dnl compile-command: "autoconf" |
| 2717 | dnl End: |
| 2718 | --- Make.rules.in --- |
| 2719 | # Copyright 2000 Francois Gouget for CodeWeavers |
| 2720 | # fgouget@codeweavers.com |
| 2721 | # |
| 2722 | # Global rules shared by all makefiles -*-Makefile-*- |
| 2723 | # |
| 2724 | # Each individual makefile must define the following variables: |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2725 | # WINE_INCLUDE_ROOT: Wine's headers location |
| 2726 | # WINE_LIBRARY_ROOT: Wine's libraries location |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2727 | # TOPOBJDIR : top-level object directory |
| 2728 | # SRCDIR : source directory for this module |
| 2729 | # |
| 2730 | # Each individual makefile may define the following additional variables: |
| 2731 | # |
| 2732 | # SUBDIRS : subdirectories that contain a Makefile |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2733 | # DLLS : WineLib libraries to be built |
| 2734 | # EXES : WineLib executables to be built |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2735 | # |
| 2736 | # CEXTRA : extra c flags (e.g. '-Wall') |
| 2737 | # CXXEXTRA : extra c++ flags (e.g. '-Wall') |
| 2738 | # WRCEXTRA : extra wrc flags (e.g. '-p _SysRes') |
| 2739 | # DEFINES : defines (e.g. -DSTRICT) |
| 2740 | # INCLUDE_PATH : additional include path |
| 2741 | # LIBRARY_PATH : additional library path |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2742 | # LIBRARIES : additional Unix libraries to link with |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2743 | # |
| 2744 | # C_SRCS : C sources for the module |
| 2745 | # CXX_SRCS : C++ sources for the module |
| 2746 | # RC_SRCS : resource source files |
| 2747 | # SPEC_SRCS : interface definition files |
| 2748 | |
| 2749 | |
| 2750 | # Where is Winelib |
| 2751 | |
Francois Gouget | 7f1ab7a | 2000-11-13 04:13:22 +0000 | [diff] [blame] | 2752 | WINE_INCLUDE_ROOT = @WINE_INCLUDE_ROOT@ |
| 2753 | WINE_INCLUDE_PATH = @WINE_INCLUDE_PATH@ |
| 2754 | WINE_LIBRARY_ROOT = @WINE_LIBRARY_ROOT@ |
| 2755 | WINE_LIBRARY_PATH = @WINE_LIBRARY_PATH@ |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2756 | |
| 2757 | # Where are the MFC |
| 2758 | |
| 2759 | ATL_INCLUDE_ROOT = @ATL_INCLUDE_ROOT@ |
| 2760 | ATL_INCLUDE_PATH = @ATL_INCLUDE_PATH@ |
| 2761 | MFC_INCLUDE_ROOT = @MFC_INCLUDE_ROOT@ |
| 2762 | MFC_INCLUDE_PATH = @MFC_INCLUDE_PATH@ |
| 2763 | MFC_LIBRARY_ROOT = @MFC_LIBRARY_ROOT@ |
| 2764 | MFC_LIBRARY_PATH = @MFC_LIBRARY_PATH@ |
| 2765 | |
| 2766 | # First some useful definitions |
| 2767 | |
| 2768 | SHELL = /bin/sh |
| 2769 | CC = @CC@ |
| 2770 | CPP = @CPP@ |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 2771 | WRC = @WRC@ |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2772 | CFLAGS = @CFLAGS@ |
| 2773 | CXXFLAGS = @CXXFLAGS@ |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 2774 | WRCFLAGS = -r -L |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2775 | OPTIONS = @OPTIONS@ -D_REENTRANT -DWINELIB |
| 2776 | X_CFLAGS = @X_CFLAGS@ |
| 2777 | X_LIBS = @X_LIBS@ |
| 2778 | XLIB = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ |
| 2779 | DLL_LINK = @DLL_LINK@ |
| 2780 | LIBS = @LIBS@ $(LIBRARY_PATH) |
| 2781 | YACC = @YACC@ |
| 2782 | LEX = @LEX@ |
| 2783 | LEXLIB = @LEXLIB@ |
| 2784 | LN_S = @LN_S@ |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 2785 | ALLFLAGS = $(DEFINES) -I$(SRCDIR) $(WINE_INCLUDE_PATH) $(INCLUDE_PATH) |
| 2786 | ALLCFLAGS = $(CFLAGS) $(CEXTRA) $(OPTIONS) $(X_CFLAGS) $(ALLFLAGS) |
| 2787 | ALLCXXFLAGS=$(CXXFLAGS) $(CXXEXTRA) $(OPTIONS) $(X_CFLAGS) $(ALLFLAGS) |
| 2788 | ALLWRCFLAGS=$(WRCFLAGS) $(WRCEXTRA) $(OPTIONS) $(ALLFLAGS) |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2789 | LDCOMBINE = ld -r |
| 2790 | LDSHARED = @LDSHARED@ |
Francois Gouget | 8d0e1e7 | 2001-03-04 01:03:55 +0000 | [diff] [blame] | 2791 | LDXXSHARED = @LDXXSHARED@ |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2792 | LDDLLFLAGS= @LDDLLFLAGS@ |
| 2793 | STRIP = strip |
| 2794 | STRIPFLAGS= --strip-unneeded |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2795 | RM = rm -f |
| 2796 | MV = mv |
| 2797 | MKDIR = mkdir -p |
Francois Gouget | be85959 | 2000-11-15 22:12:20 +0000 | [diff] [blame] | 2798 | WINE = @WINE@ |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2799 | WINEBUILD = @WINEBUILD@ |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2800 | @SET_MAKE@ |
| 2801 | |
| 2802 | # Installation infos |
| 2803 | |
| 2804 | INSTALL = @INSTALL@ |
| 2805 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ |
| 2806 | INSTALL_DATA = @INSTALL_DATA@ |
| 2807 | prefix = @prefix@ |
| 2808 | exec_prefix = @exec_prefix@ |
| 2809 | bindir = @bindir@ |
| 2810 | libdir = @libdir@ |
| 2811 | infodir = @infodir@ |
| 2812 | mandir = @mandir@ |
| 2813 | prog_manext = 1 |
| 2814 | conf_manext = 5 |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2815 | |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 2816 | OBJS = $(C_SRCS:.c=.o) $(CXX_SRCS:.cpp=.o) \ |
| 2817 | $(SPEC_SRCS:.spec=.spec.o) |
| 2818 | CLEAN_FILES = *.spec.c y.tab.c y.tab.h lex.yy.c \ |
| 2819 | core *.orig *.rej \ |
| 2820 | \\\#*\\\# *~ *% .\\\#* |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2821 | |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2822 | # Implicit rules |
| 2823 | |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 2824 | .SUFFIXES: .cpp .rc .res .tmp.o .spec .spec.c .spec.o |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2825 | |
| 2826 | .c.o: |
| 2827 | $(CC) -c $(ALLCFLAGS) -o $@ $< |
| 2828 | |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2829 | .cpp.o: |
| 2830 | $(CXX) -c $(ALLCXXFLAGS) -o $@ $< |
| 2831 | |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2832 | .cxx.o: |
| 2833 | $(CXX) -c $(ALLCXXFLAGS) -o $@ $< |
| 2834 | |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2835 | .rc.res: |
Francois Gouget | 3af251e | 2000-11-30 20:36:04 +0000 | [diff] [blame] | 2836 | $(WRC) $(ALLWRCFLAGS) -o $@ $< |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2837 | |
| 2838 | .PHONY: all install uninstall clean distclean depend dummy |
| 2839 | |
| 2840 | # 'all' target first in case the enclosing Makefile didn't define any target |
| 2841 | |
| 2842 | all: Makefile |
| 2843 | |
| 2844 | # Rules for makefile |
| 2845 | |
| 2846 | Makefile: Makefile.in $(TOPSRCDIR)/configure |
| 2847 | @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure |
| 2848 | @exit 1 |
| 2849 | |
| 2850 | # Rules for cleaning |
| 2851 | |
| 2852 | $(SUBDIRS:%=%/__clean__): dummy |
| 2853 | cd `dirname $@` && $(MAKE) clean |
| 2854 | |
| 2855 | $(EXTRASUBDIRS:%=%/__clean__): dummy |
| 2856 | -cd `dirname $@` && $(RM) $(CLEAN_FILES) |
| 2857 | |
| 2858 | clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__) |
Francois Gouget | a11664c | 2000-12-07 23:13:23 +0000 | [diff] [blame] | 2859 | $(RM) $(CLEAN_FILES) $(RC_SRCS:.rc=.res) $(OBJS) $(SPEC_SRCS:.spec=.tmp.o) $(EXES) $(EXES:%=%.so) $(DLLS) |
Francois Gouget | 755bb92 | 2000-11-05 05:23:39 +0000 | [diff] [blame] | 2860 | |
| 2861 | # Rules for installing |
| 2862 | |
| 2863 | $(SUBDIRS:%=%/__install__): dummy |
| 2864 | cd `dirname $@` && $(MAKE) install |
| 2865 | |
| 2866 | $(SUBDIRS:%=%/__uninstall__): dummy |
| 2867 | cd `dirname $@` && $(MAKE) uninstall |
| 2868 | |
| 2869 | # Misc. rules |
| 2870 | |
| 2871 | $(SUBDIRS): dummy |
| 2872 | @cd $@ && $(MAKE) |
| 2873 | |
| 2874 | dummy: |
| 2875 | |
| 2876 | # End of global rules |
| 2877 | --- wrapper.c --- |
| 2878 | /* |
| 2879 | * Copyright 2000 Francois Gouget <fgouget@codeweavers.com> for CodeWeavers |
| 2880 | */ |
| 2881 | |
| 2882 | #include <dlfcn.h> |
| 2883 | #include <windows.h> |
| 2884 | |
| 2885 | |
| 2886 | |
| 2887 | /* |
| 2888 | * Describe the wrapped application |
| 2889 | */ |
| 2890 | |
| 2891 | /** |
| 2892 | * This is either CUIEXE for a console based application or |
| 2893 | * GUIEXE for a regular windows application. |
| 2894 | */ |
| 2895 | #define APP_TYPE ##WINEMAKER_APP_TYPE## |
| 2896 | |
| 2897 | /** |
| 2898 | * This is the application library's base name, i.e. 'hello' if the |
| 2899 | * library is called 'libhello.so'. |
| 2900 | */ |
| 2901 | static char* appName = ##WINEMAKER_APP_NAME##; |
| 2902 | |
| 2903 | /** |
| 2904 | * This is the name of the application's Windows module. If left NULL |
| 2905 | * then appName is used. |
| 2906 | */ |
| 2907 | static char* appModule = NULL; |
| 2908 | |
| 2909 | /** |
| 2910 | * This is the application's entry point. This is usually "WinMain" for a |
| 2911 | * GUIEXE and 'main' for a CUIEXE application. |
| 2912 | */ |
| 2913 | static char* appInit = ##WINEMAKER_APP_INIT##; |
| 2914 | |
| 2915 | /** |
| 2916 | * This is either non-NULL for MFC-based applications and is the name of the |
| 2917 | * MFC's module. This is the module in which we will take the 'WinMain' |
| 2918 | * function. |
| 2919 | */ |
| 2920 | static char* mfcModule = ##WINEMAKER_APP_MFC##; |
| 2921 | |
| 2922 | |
| 2923 | |
| 2924 | /* |
| 2925 | * Implement the main. |
| 2926 | */ |
| 2927 | |
| 2928 | #if APP_TYPE == GUIEXE |
| 2929 | typedef int WINAPI (*WinMainFunc)(HINSTANCE hInstance, HINSTANCE hPrevInstance, |
| 2930 | PSTR szCmdLine, int iCmdShow); |
| 2931 | #else |
| 2932 | typedef int WINAPI (*MainFunc)(int argc, char** argv, char** envp); |
| 2933 | #endif |
| 2934 | |
| 2935 | #if APP_TYPE == GUIEXE |
| 2936 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, |
| 2937 | PSTR szCmdLine, int iCmdShow) |
| 2938 | #else |
| 2939 | int WINAPI Main(int argc, char** argv, char** envp) |
| 2940 | #endif |
| 2941 | { |
| 2942 | void* appLibrary; |
| 2943 | HINSTANCE hApp,hMFC,hMain; |
| 2944 | void* appMain; |
| 2945 | char* libName; |
| 2946 | int retcode; |
| 2947 | |
| 2948 | /* Load the application's library */ |
| 2949 | libName=(char*)malloc(strlen(appName)+5+3+1); |
| 2950 | /* FIXME: we should get the wrapper's path and use that as the base for |
| 2951 | * the library |
| 2952 | */ |
| 2953 | sprintf(libName,"./lib%s.so",appName); |
| 2954 | appLibrary=dlopen(libName,RTLD_NOW); |
| 2955 | if (appLibrary==NULL) { |
| 2956 | sprintf(libName,"lib%s.so",appName); |
| 2957 | appLibrary=dlopen(libName,RTLD_NOW); |
| 2958 | } |
| 2959 | if (appLibrary==NULL) { |
| 2960 | char format[]="Could not load the %s library:\r\n%s"; |
| 2961 | char* error; |
| 2962 | char* msg; |
| 2963 | |
| 2964 | error=dlerror(); |
| 2965 | msg=(char*)malloc(strlen(format)+strlen(libName)+strlen(error)); |
| 2966 | sprintf(msg,format,libName,error); |
| 2967 | MessageBox(NULL,msg,"dlopen error",MB_OK); |
| 2968 | free(msg); |
| 2969 | return 1; |
| 2970 | } |
| 2971 | |
| 2972 | /* Then if this application is MFC based, load the MFC module */ |
| 2973 | /* FIXME: I'm not sure this is really necessary */ |
| 2974 | if (mfcModule!=NULL) { |
| 2975 | hMFC=LoadLibrary(mfcModule); |
| 2976 | if (hMFC==NULL) { |
| 2977 | char format[]="Could not load the MFC module %s (%d)"; |
| 2978 | char* msg; |
| 2979 | |
| 2980 | msg=(char*)malloc(strlen(format)+strlen(mfcModule)+11); |
| 2981 | sprintf(msg,format,mfcModule,GetLastError()); |
| 2982 | MessageBox(NULL,msg,"LoadLibrary error",MB_OK); |
| 2983 | free(msg); |
| 2984 | return 1; |
| 2985 | } |
| 2986 | /* MFC is a special case: the WinMain is in the MFC library, |
| 2987 | * instead of the application's library. |
| 2988 | */ |
| 2989 | hMain=hMFC; |
| 2990 | } else { |
| 2991 | hMFC=NULL; |
| 2992 | } |
| 2993 | |
| 2994 | /* Load the application's module */ |
| 2995 | if (appModule==NULL) { |
| 2996 | appModule=appName; |
| 2997 | } |
| 2998 | hApp=LoadLibrary(appModule); |
| 2999 | if (hApp==NULL) { |
| 3000 | char format[]="Could not load the application's module %s (%d)"; |
| 3001 | char* msg; |
| 3002 | |
| 3003 | msg=(char*)malloc(strlen(format)+strlen(appModule)+11); |
| 3004 | sprintf(msg,format,appModule,GetLastError()); |
| 3005 | MessageBox(NULL,msg,"LoadLibrary error",MB_OK); |
| 3006 | free(msg); |
| 3007 | return 1; |
| 3008 | } else if (hMain==NULL) { |
| 3009 | hMain=hApp; |
| 3010 | } |
| 3011 | |
| 3012 | /* Get the address of the application's entry point */ |
| 3013 | appMain=(WinMainFunc*)GetProcAddress(hMain, appInit); |
| 3014 | if (appMain==NULL) { |
| 3015 | char format[]="Could not get the address of %s (%d)"; |
| 3016 | char* msg; |
| 3017 | |
| 3018 | msg=(char*)malloc(strlen(format)+strlen(appInit)+11); |
| 3019 | sprintf(msg,format,appInit,GetLastError()); |
| 3020 | MessageBox(NULL,msg,"GetProcAddress error",MB_OK); |
| 3021 | free(msg); |
| 3022 | return 1; |
| 3023 | } |
| 3024 | |
| 3025 | /* And finally invoke the application's entry point */ |
| 3026 | #if APP_TYPE == GUIEXE |
| 3027 | retcode=(*((WinMainFunc)appMain))(hApp,hPrevInstance,szCmdLine,iCmdShow); |
| 3028 | #else |
| 3029 | retcode=(*((MainFunc)appMain))(argc,argv,envp); |
| 3030 | #endif |
| 3031 | |
| 3032 | /* Cleanup and done */ |
| 3033 | FreeLibrary(hApp); |
| 3034 | if (hMFC!=NULL) { |
| 3035 | FreeLibrary(hMFC); |
| 3036 | } |
| 3037 | dlclose(appLibrary); |
| 3038 | free(libName); |
| 3039 | |
| 3040 | return retcode; |
| 3041 | } |