Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

608 lines
23 KiB

  1. @perl -x %0 %*
  2. @goto :eof
  3. #!perl
  4. # Copyright 1999 Microsoft Corporation
  5. ################################################################################
  6. #
  7. # Script begins here. Above is overhead to make a happy batch file.
  8. #
  9. # Revision history:
  10. # 5/18/00 - Use binplace instead of copy for all 'COPY*' ops. except when
  11. # renaming the file.
  12. # 11/10/00 - CopyLIB no longer uses lib[fre|chk]. Now just goes to lib in
  13. # order to match razzle more closely
  14. # 06/04/02 - add support for legacy headers/libs and don't error if they're
  15. # missing since the legacy content is not required
  16. ################################################################################
  17. use strict;
  18. #use File::Temp qw(tempfile);
  19. my($WarnLevel);
  20. my $OS_SUBDIR = "wnet";
  21. #if (@ARGV != 3 ) {
  22. # print(STDERR "Usage: $0 <ini_file> <kit_name> [ProjectRoot value]\n");
  23. # exit(0);
  24. #}
  25. die ("nmake : $0: DDK_ERROR_FATAL: ProjectRoot is not defined. Aborting DDK scripts.\n") unless defined($ARGV[2]);
  26. die ("nmake : $0: DDK_ERROR_FATAL: Kit is not defined. Aborting DDK scripts.\n") unless defined($ARGV[1]);
  27. # ---------------------------------------------------------
  28. # Make sure our dependent variables are defined.
  29. # ---------------------------------------------------------
  30. if (! defined $ENV{_NTTREE}) {
  31. print(STDERR "$0 \%_NTTREE\% not defined - assuming a 'no_binaries' build. Script aborted.\n");
  32. exit(0);
  33. }
  34. # ---------------------------------------------------------
  35. # The default is to build samples on X86Fre machines only.
  36. # Set _DDK_SAMPLES = FALSE to disable
  37. # ---------------------------------------------------------
  38. if (defined $ENV{_NO_DDK}) {
  39. print("BUILDMSG: $0: Not building the DDK because \%_NO_DDK\% is set.\n");
  40. exit(0);
  41. }
  42. my $FileNameCheck = 0;
  43. if ( defined $ENV{_DDK_FILENAME_CHECKING} || ($WarnLevel >= 2) ) {
  44. $FileNameCheck = 1;
  45. }
  46. #
  47. # Setting the warning level based on %_DDK_WARN_LEVEL%, else default to
  48. # 0. Valid values are 0-4 with increasingly restrictive checking.
  49. #
  50. # All level 0 errors and warnings are DDK requirements.
  51. #
  52. if (defined($ENV{_DDK_WARN_LEVEL})) {
  53. if ($ENV{_DDK_WARN_LEVEL} =~ /^\d*$/) {
  54. if (($ENV{_DDK_WARN_LEVEL} >= 0) && ($ENV{_DDK_WARN_LEVEL} <= 4)) {
  55. $WarnLevel = $ENV{_DDK_WARN_LEVEL};
  56. } else {
  57. warn("\%_DDK_WARN_LEVEL\% out of range. (Expected 0-4). Using default value.\n");
  58. }
  59. } else {
  60. warn("\%_DDK_WARN_LEVEL\% is not numeric. Using default value.\n");
  61. }
  62. } else {
  63. $WarnLevel = 0;
  64. }
  65. $0 =~ /.*\\(.*)$/;
  66. $0=$1 if (defined($1));
  67. sub FALSE {return(0);} # BOOLEAN FALSE
  68. sub TRUE {return(1);} # BOOLEAN TRUE
  69. #
  70. # Global variables
  71. #
  72. my($Version) = "2000.02.29.1"; # Version of this file (YYYY.MM.DD.#)
  73. my($DEBUG) = FALSE; # Set to TRUE for testing
  74. my($ini_file)=$ARGV[0]; # File we're processing
  75. my($hFILE, $hDIR); # File handle, Directory handle
  76. my($kit) =$ARGV[1]; # Kit file is for
  77. my(@lines_to_process); # Array to hold file contents
  78. my($current_line); # Hold ini line to be processed
  79. my($cur_line_num)=0; # Count which line we're on
  80. my($token,@dirs); # Temp Var
  81. my($dest_root); # Root to base destination on
  82. my($cd_root); # Root to CD image of kit
  83. my($hsplit);
  84. my(@files); # Array for directory-level ops
  85. my($ProjectRoot)=$ARGV[2]; # Root of the project use
  86. $dest_root="$ENV{_NTTREE}\\${kit}_flat";
  87. $cd_root ="$ENV{_NTTREE}\\${kit}_cd";
  88. my($source_dir, $source_file); # Contents of the current line
  89. my($dest_dir, $dest_file, $operation);
  90. my $Arch;
  91. if ($ENV{_BuildArch} eq "x86") {
  92. $Arch = "i386";
  93. } else {
  94. $Arch = $ENV{_BuildArch};
  95. }
  96. system("mkdir .\\obj\\${Arch}\\${kit}tmp 2> NUL");
  97. my $tmpdir = ".\\obj\\${Arch}\\${kit}tmp";
  98. # Make sure our tree exists
  99. #system("mkdir $dest_root 2> NUL");
  100. #system("mkdir $cd_root 2> NUL");
  101. #
  102. # Open the ini, slurp the contents to an array, close the ini
  103. #
  104. open(hFILE, $ini_file) || die("nmake : $0: DDK_ERROR_FATAL: $ini_file could not be opened!\n");
  105. print("Processing $ini_file...\n");
  106. @lines_to_process = <hFILE>;
  107. close(hFILE);
  108. #
  109. # Loop through the contents
  110. #
  111. foreach $current_line (@lines_to_process) {
  112. chomp $current_line;
  113. $cur_line_num++;
  114. # If the first character on the line is a ';' or is blank, skip it
  115. next if ($current_line =~ /^[\s\t]*\;/);
  116. next if (($current_line =~ /^[\s\t]*$/) or ($current_line =~ /^$/));
  117. # Swap out environment variables
  118. while ($current_line =~ /\%(.+?)\%/) {
  119. $token=$1;
  120. $current_line =~ s/\%$token\%/$ENV{$token}/;
  121. }
  122. if ($current_line =~ /\%PROJECT_ROOT\%/i) {
  123. warn("BUILDMSG: Warning $0: DDK_WARNING: Correct reference to \%_DDK_CONTENT\% ($ini_file: $cur_line_num) \n");
  124. next;
  125. }
  126. ($source_dir, $source_file, $dest_dir, $dest_file, $operation) =
  127. split(/,/,$current_line);
  128. #
  129. # Break on undefined op!
  130. #
  131. if (not defined $operation) {
  132. warn("BUILDMSG: Warning $0: DDK_WARNING: Line is malformed ($ini_file: $cur_line_num) \n");
  133. next;
  134. }
  135. $source_dir =~ s/^[\s\t]*//; # Kill leading and trailing spaces
  136. $source_dir =~ s/[\s\t]*$//;
  137. $source_dir =~ s/^/$ProjectRoot\\/;
  138. $source_file=~ s/^[\s\t]*//; # Kill leading and trailing spaces
  139. $source_file=~ s/[\s\t]*$//;
  140. $dest_dir =~ s/^[\s\t]*//; # Kill leading and trailing spaces
  141. $dest_dir =~ s/[\s\t]*$//;
  142. $dest_file =~ s/^[\s\t]*//; # Kill leading and trailing spaces
  143. $dest_file =~ s/[\s\t]*$//;
  144. $operation =~ s/^[\s\t]*//; # Kill leading and trailing spaces
  145. $operation =~ s/[\s\t]*$//;
  146. my $tmpfile;
  147. ###############################################
  148. #+-------------------------------------------+#
  149. #| DDK ERROR REPORTING RULES SHOULD GO HERE! |#
  150. #+-------------------------------------------+#
  151. ###############################################
  152. # This variable was only valid during porting/testing.
  153. if ($current_line =~ /\%_DDK_CONTENT\%/i) {
  154. warn("BUILDMSG: Warning $0: DDK_WARNING: Correct reference to \%_DDK_CONTENT\% ($ini_file: $cur_line_num) \n");
  155. next;
  156. }
  157. # Don't allow files that have 'internal' in the source path
  158. if ($source_dir =~ /internal/i) {
  159. # except termsrv.
  160. if ($kit eq "termsrv") {
  161. # termsrv ddk is exception to above rule, this ddk goes only to citrix.
  162. }
  163. else {
  164. warn("nmake : $0: DDK_ERROR: Attempting to copy a file from path with 'internal' ($ini_file: $cur_line_num)\n");
  165. next;
  166. }
  167. }
  168. # Watch what gets copied to %NTDDK%\inc
  169. if (($dest_dir =~ /^inc$/i) and
  170. (($source_dir !~ /public.*inc?/) and ($source_dir !~ /legacy_files/i) and ($source_dir !~ /sdktools\\ddk\\inc$/i)))
  171. {
  172. warn("nmake : $0: DDK_ERROR: Only files from the public depot can be copied into the \%DDK_ROOT\%\\incs directory. ($ini_file: $cur_line_num)\n");
  173. next;
  174. }
  175. # Look for files marked with MS Confidential
  176. (CheckForMSConfidential("${source_dir}","${source_file}")||next) unless ($operation =~ /^COPYLIB/i);
  177. #####################################################################
  178. #+-----------------------------------------------------------------+#
  179. #| |#
  180. #| Remainder of script 'does the right thing' based on $operation. |#
  181. #| |#
  182. #+-----------------------------------------------------------------+#
  183. #####################################################################
  184. #
  185. # COPYX86CHK - Use COPYX86 if platform is CHK
  186. #
  187. if (uc($operation) eq "COPYX86CHK") {
  188. if (uc($ENV{_BUILDTYPE}) eq "CHK") {
  189. $operation = "COPYX86";
  190. } else {
  191. next;
  192. }
  193. }
  194. #
  195. # COPYX86FRE - Use COPYX86 if platform is FRE
  196. #
  197. if (uc($operation) eq "COPYX86FRE") {
  198. if (uc($ENV{_BUILDTYPE}) eq "FRE") {
  199. $operation = "COPYX86";
  200. } else {
  201. next;
  202. }
  203. }
  204. #
  205. # COPYAMD64CHK - Use COPYAMD64 if platform is CHK
  206. #
  207. if (uc($operation) eq "COPYAMD64CHK") {
  208. if (uc($ENV{_BUILDTYPE}) eq "CHK") {
  209. $operation = "COPYAMD64";
  210. } else {
  211. next;
  212. }
  213. }
  214. #
  215. # COPYAMD64FRE - Use COPYAMD64 if platform is FRE
  216. #
  217. if (uc($operation) eq "COPYAMD64FRE") {
  218. if (uc($ENV{_BUILDTYPE}) eq "FRE") {
  219. $operation = "COPYAMD64";
  220. } else {
  221. next;
  222. }
  223. }
  224. #
  225. # COPYIA64CHK - Use COPYIA64 if platform is CHK
  226. #
  227. if (uc($operation) eq "COPYIA64CHK") {
  228. if (uc($ENV{_BUILDTYPE}) eq "CHK") {
  229. $operation = "COPYIA64";
  230. } else {
  231. next;
  232. }
  233. }
  234. #
  235. # COPYIA64FRE - Use COPYIA64 if platform is FRE
  236. #
  237. if (uc($operation) eq "COPYIA64FRE") {
  238. if (uc($ENV{_BUILDTYPE}) eq "FRE") {
  239. $operation = "COPYIA64";
  240. } else {
  241. next;
  242. }
  243. }
  244. #
  245. # COPYX86 - Use COPY if platform is x86
  246. #
  247. if (uc($operation) eq "COPYX86") {
  248. if (uc($ENV{_BUILDARCH}) eq "X86") {
  249. $operation = "COPY";
  250. } else {
  251. next;
  252. }
  253. }
  254. #
  255. # COPYAMD64 - Use COPY if platform is AMD64
  256. #
  257. if (uc($operation) eq "COPYAMD64") {
  258. if (uc($ENV{_BUILDARCH}) eq "AMD64") {
  259. $operation = "COPY";
  260. } else {
  261. next;
  262. }
  263. }
  264. #
  265. # COPYIA64 - Use COPY if platform is IA64
  266. #
  267. if (uc($operation) eq "COPYIA64") {
  268. if (uc($ENV{_BUILDARCH}) eq "IA64") {
  269. $operation = "COPY";
  270. } else {
  271. next;
  272. }
  273. }
  274. #
  275. # COPYLIB32 - Do the right thing with libs on 32-bit platforms
  276. #
  277. if (uc($operation) eq "COPYLIB32") {
  278. if (uc($ENV{_BUILDARCH}) eq "X86") {
  279. $operation = "COPYLIB";
  280. } else {
  281. next;
  282. }
  283. }
  284. #
  285. # COPYLIB64 - Do the right thing with libs on 64-bit platforms
  286. #
  287. if (uc($operation) eq "COPYLIB64") {
  288. if (uc($ENV{_BUILDARCH}) eq "IA64") {
  289. $operation = "COPYLIB";
  290. } elsif (uc($ENV{_BUILDARCH}) eq "AMD64") {
  291. $operation = "COPYLIB";
  292. } else {
  293. next;
  294. }
  295. }
  296. #
  297. # COPYLIBAMD64 - Do the right thing with libs on AMD64 64-bit platforms
  298. #
  299. if (uc($operation) eq "COPYLIBAMD64") {
  300. if (uc($ENV{_BUILDARCH}) eq "AMD64") {
  301. $operation = "COPYLIB";
  302. } else {
  303. next;
  304. }
  305. }
  306. #
  307. # COPYLIBIA64 - Do the right thing with libs on IA64 64-bit platforms
  308. #
  309. if (uc($operation) eq "COPYLIBIA64") {
  310. if (uc($ENV{_BUILDARCH}) eq "IA64") {
  311. $operation = "COPYLIB";
  312. } else {
  313. next;
  314. }
  315. }
  316. #
  317. # COPYLIB - Do the right thing with libs
  318. #
  319. if (uc($operation) eq "COPYLIB") {
  320. # Determine base dest_dir
  321. $dest_dir = "lib\\$OS_SUBDIR";
  322. # Determine subdir for both dest and source
  323. if (uc($ENV{_BUILDARCH}) eq "X86") {
  324. $source_dir .= "\\i386";
  325. $dest_dir .= "\\i386";
  326. } elsif (uc($ENV{_BUILDARCH}) eq "AMD64") {
  327. $source_dir .= "\\amd64";
  328. $dest_dir .= "\\amd64";
  329. } elsif (uc($ENV{_BUILDARCH}) eq "IA64") {
  330. $source_dir .= "\\ia64";
  331. $dest_dir .= "\\ia64";
  332. }
  333. $operation = "COPY";
  334. }
  335. ## Uncomment the following line to turn off HSPLITting
  336. ##$operation = "COPY" if (uc($operation) eq "HSPLIT");
  337. # Always make sure the destination dir exists. A little wastefull, but worthwhile
  338. if (uc($operation) eq "COPYCDFILE") {
  339. $token="$cd_root";
  340. } else {
  341. $token="$dest_root";
  342. }
  343. @dirs=split(/\\/,$dest_dir);
  344. #
  345. # COPY
  346. #
  347. if (uc($operation) eq "COPY") {
  348. if ($dest_file eq "*") {
  349. if ($source_file =~ "[\*|\?]+") {
  350. if (-e("${source_dir}")) {
  351. system("binplace -xa -s obj -n obj -e -:DEST $dest_dir -r ${dest_root} ${source_dir}\\${source_file}");
  352. } else {
  353. # Don't error on optional legacy support directories
  354. if ( $source_dir !~ /.*\\public\\.*\\(wxp|w2k|legacy)$/ ) {
  355. warn("nmake : $0: DDK_ERROR: ${source_dir} not found. ($ini_file: $cur_line_num) \n");
  356. }
  357. next;
  358. }
  359. } else {
  360. if (-e("${source_dir}\\${source_file}")) {
  361. system("binplace -xa -s obj -n obj -e -:DEST $dest_dir -r ${dest_root} ${source_dir}\\${source_file}");
  362. } else {
  363. # Don't error on optional legacy support directories
  364. if ( $source_dir !~ /.*\\public\\.*\\(wxp|w2k|legacy)$/ ) {
  365. warn("nmake : $0: DDK_ERROR: ${source_file} not found. ($ini_file: $cur_line_num) \n");
  366. }
  367. next;
  368. }
  369. }
  370. } else {
  371. warn("nmake : $0: DDK_ERROR: ${source_file} not found. ($ini_file: $cur_line_num) \n"), next unless (-e("${source_dir}\\${source_file}"));
  372. system("binplace -xa -s obj -n obj -f -e -:DEST $dest_dir -:REN ${dest_file} -r ${dest_root} ${source_dir}\\${source_file}");
  373. }
  374. #
  375. # COPYCDFILE
  376. # use binplace -f to force the updates.
  377. } elsif (uc($operation) eq "COPYCDFILE") {
  378. if ($dest_file eq "*") {
  379. if ($source_file =~ "[\*|\?]+") {
  380. warn("nmake : $0: DDK_ERROR: ${source_dir} not found. ($ini_file: $cur_line_num) \n"), next unless (-e("${source_dir}"));
  381. system("binplace -xa -s obj -n obj -f -e -:DEST ${dest_dir} -r ${cd_root} ${source_dir}\\${source_file}");
  382. } else {
  383. warn("nmake : $0: DDK_ERROR: ${source_file} not found. ($ini_file: $cur_line_num) \n"), next unless (-e("${source_dir}\\${source_file}"));
  384. system("binplace -xa -s obj -n obj -f -e -:DEST ${dest_dir} -r ${cd_root} ${source_dir}\\${source_file}");
  385. }
  386. } else {
  387. warn("nmake : $0: DDK_ERROR: ${source_file} not found. ($ini_file: $cur_line_num) \n"), next unless (-e("${source_dir}\\${source_file}"));
  388. system("binplace -xa -s obj -n obj -f -e -:DEST ${dest_dir} -r ${cd_root} -:REN ${dest_file} ${source_dir}\\${source_file}");
  389. }
  390. #
  391. # APPENDCDFILE
  392. # ugly hack, but should only be used for cabs.ini. If it gets more use, this should be
  393. # made more efficent.
  394. } elsif (uc($operation) eq "APPENDCDFILE") {
  395. if ($dest_file eq "*") {
  396. if ($source_file =~ "[\*|\?]+") {
  397. warn("nmake : $0: DDK_ERROR: APPENDCDFILE cannot be used on wildcards.");
  398. next;
  399. } else {
  400. $tmpfile = "${dest_dir}_${source_file}";
  401. $tmpfile =~ s/\\/_/g;
  402. warn("nmake : $0: DDK_ERROR: ${source_file} not found. ($ini_file: $cur_line_num) \n"), next unless (-e("${source_dir}\\${source_file}"));
  403. system("copy ${cd_root}\\${dest_dir}\\${dest_file} ${tmpdir}\\${tmpfile} >NUL");
  404. system("cat -o ${source_dir}\\${source_file} >> ${tmpdir}\\${tmpfile} 2>NUL");
  405. system("binplace -xa -s obj -n obj -r ${cd_root} -:REN ${dest_file} -:DEST ${dest_dir} ${tmpdir}\\${tmpfile}");
  406. }
  407. } else {
  408. $tmpfile = "${dest_dir}_${dest_file}";
  409. $tmpfile =~ s/\\/_/g;
  410. warn("nmake : $0: DDK_ERROR: ${source_file} not found. ($ini_file: $cur_line_num) \n"), next unless (-e("${source_dir}\\${source_file}"));
  411. system("copy ${cd_root}\\${dest_dir}\\${dest_file} ${tmpdir}\\${tmpfile} >NUL");
  412. system("cat -o ${source_dir}\\${source_file} >> ${tmpdir}\\${tmpfile} 2>NUL");
  413. system("binplace -xa -s obj -n obj -r ${cd_root} -:REN ${dest_file} -:DEST ${dest_dir} ${tmpdir}\\${tmpfile}");
  414. }
  415. #
  416. # HSPLIT
  417. #
  418. } elsif (uc($operation) eq "HSPLIT") {
  419. # Look to see if we're using a wildcard
  420. if (($source_file =~ /\*/) || ($source_file =~ /\?/)) {
  421. # CMD Wildcard to RegExp Wildcard
  422. $source_file =~ s/\./\\\./g;
  423. $source_file =~ s/\?/\./g;
  424. $source_file =~ s/\*/\.\*/g;
  425. $source_file .= "\$";
  426. opendir(hDIR, ${source_dir});
  427. @files=readdir(hDIR);
  428. closedir(hDIR);
  429. foreach $token (@files) {
  430. next unless -e("${source_dir}\\${token}");
  431. next if -d("${source_dir}\\${token}");
  432. if ($token =~ /$source_file/i) {
  433. $tmpfile = "${dest_dir}_${token}";
  434. $tmpfile =~ s/\\/_/g;
  435. # Don't try to HSPLIT not text files
  436. # GIF files not correctly detected as binary.
  437. if (( -B "${source_dir}\\${token}") || ($token =~ /\.gif$/i)) {
  438. if ($WarnLevel > 1) { # This is an info message, require a higher warning level
  439. warn("BUILDMSG: $0: DDK_INFO: Not HSPLITTING ${token} - Detected as binary. ($ini_file: $cur_line_num) \n");
  440. }
  441. system("binplace -xa -s obj -n obj -r ${dest_root} -:DEST ${dest_dir} ${source_dir}\\${token}");
  442. } else {
  443. if ( $FileNameCheck ) {
  444. if (-e "${tmpdir}\\${tmpfile}" ) {
  445. warn("nmake : $0: DDK_ERROR: ${tmpfile} already exists in $tmpdir. ($ini_file: $cur_line_num) \n");
  446. }
  447. }
  448. system("hsplit -o ${tmpdir}\\${tmpfile} nul -bt2 BEGIN_DDKSPLIT END_DDKSPLIT -c \@\@ -i ${source_dir}\\${token} ");
  449. system("binplace -xa -s obj -n obj -r ${dest_root} -:REN ${token} -:DEST ${dest_dir} ${tmpdir}\\${tmpfile}");
  450. ## This was a bad mistake- we need to split to a temp file, then split the temp file again to get cumlative hsplits. Pulling thi
  451. ## extra split for a quick fix so we can RI. A proper fix that uses both hsplits will be test and checked in for the next RI.
  452. ##system("hsplit -o ${dest_root}\\${dest_dir}\\${token} nul -bt2 BEGIN_MSINTERNAL END_MSINTERNAL -c \@\@ -i ${source_dir}\\${token} ");
  453. }
  454. }
  455. }
  456. } else {
  457. # No wildcard- just do the split
  458. $dest_file=$source_file if ($dest_file eq "*");
  459. $tmpfile = "${dest_dir}_${dest_file}";
  460. $tmpfile =~ s/\\/_/g;
  461. warn("nmake : $0: DDK_ERROR: ${source_file} not found ($ini_file: $cur_line_num) \n"), next unless (-e("${source_dir}\\${source_file}"));
  462. # Don't try to HSPLIT not text files.
  463. # GIF files not correctly detected as binary.
  464. if (( -B "${source_dir}\\${source_file}") || ($token =~ /\.gif$/i)){
  465. if ($WarnLevel > 0) { # This is an explicit HSPLIT of a binary file. Warn at a low warning level.
  466. warn("BUILDMSG: Warning $0: DDK_WARNING: Binary files cannot be HSPLIT- ${source_file} ($ini_file: $cur_line_num)\n");
  467. }
  468. system("binplace -xa -s obj -n obj -r ${dest_root} -:REN ${dest_file} -:DEST ${dest_dir} ${source_dir}\\${source_file}");
  469. } else {
  470. if ( $FileNameCheck ) {
  471. if (-e "${tmpdir}\\${tmpfile}" ) {
  472. warn("nmake : $0: DDK_ERROR: ${tmpfile} already exists in $tmpdir. ($ini_file: $cur_line_num) \n");
  473. }
  474. }
  475. system("hsplit -o ${tmpdir}\\${tmpfile} nul -bt2 BEGIN_DDKSPLIT END_DDKSPLIT -c \@\@ -i ${source_dir}\\${source_file} ");
  476. system("binplace -xa -s obj -n obj -r ${dest_root} -:REN ${dest_file} -:DEST ${dest_dir} ${tmpdir}\\${tmpfile}");
  477. ## This was a bad mistake- we need to split to a temp file, then split the temp file again to get cumlative hsplits. Pulling thi
  478. ## extra split for a quick fix so we can RI. A proper fix that uses both hsplits will be test and checked in for the next RI.
  479. ##system("hsplit -o ${dest_root}\\${dest_dir}\\${dest_file} nul -bt2 BEGIN_MSINTERNAL END_MSINTERNAL -c \@\@ -i ${source_dir}\\${source_file} ");
  480. }
  481. }
  482. } else {
  483. warn("nmake : $0: DDK_ERROR: Unknown operation ($operation) ($ini_file: $cur_line_num)\n");
  484. }
  485. }
  486. #
  487. # Check file or glob for " Confidential"
  488. #
  489. sub CheckForMSConfidential {
  490. my($dir) = shift;
  491. my($source) = shift;
  492. my($return) = 1;
  493. my($file, @files);
  494. my($hDIR, $hFILE);
  495. my(@lines);
  496. # Files that have the string 'Confidential' but are shippable
  497. my(%exclusions) = ( "LICENSE.RTF" => TRUE,
  498. "NTLMSP.H" => TRUE,
  499. "MMREG.H" => TRUE );
  500. if (($source =~ /\*/) || ($source =~ /\?/)) {
  501. # CMD Wildcard to RegExp Wildcard
  502. $source =~ s/\?/\./g;
  503. $source =~ s/\*/\.\*/g;
  504. opendir(hDIR, ${dir});
  505. @files=readdir(hDIR);
  506. closedir(hDIR);
  507. foreach $file (@files) {
  508. next unless -e("${dir}\\${file}");
  509. next if -d("${dir}\\${file}");
  510. next if (( -B "${dir}\\${file}") || ($file =~ /\.gif$/));
  511. if ($file =~ /$source/i) {
  512. return(11) unless (-e "$dir\\$file");
  513. return(12) if (( -B "${dir}\\${file}") || ($file =~ /\.gif$/i));
  514. open(hFILE, "${dir}\\${file}") || die("nmake : $0: DDK_ERROR_FATAL: $dir\\$file could not be opened!\n");
  515. @lines=<hFILE>;
  516. close(hFILE);
  517. if (grep(/\ Confidential/i,@lines) > 0) {
  518. warn("nmake : $0: DDK_ERROR: $file contains \"Confidential\". ($ini_file: $cur_line_num)\n"),
  519. $return=0 unless(defined($exclusions{uc($file)}));
  520. }
  521. }
  522. }
  523. } else {
  524. # No wildcard
  525. return(21) unless (-e "$dir\\$source");
  526. return(22) if (( -B "${dir}\\${source}") || ($source =~ /\.gif$/i));
  527. open(hFILE, "$dir\\$source") || die("nmake : $0: DDK_ERROR_FATAL: $dir\\$source could not be opened!\n");
  528. @lines=<hFILE>;
  529. close(hFILE);
  530. if (grep(/\ Confidential/i,@lines) > 0) {
  531. warn("nmake : $0: DDK_ERROR: $source contains \"Confidential\". ($ini_file: $cur_line_num)\n"),
  532. $return=0 unless(defined($exclusions{uc($source)}));
  533. }
  534. }
  535. return($return);
  536. }
  537. __END__
  538. :endofperl