aboutsummaryrefslogtreecommitdiff
path: root/make/common/shared/Sanity.gmk
blob: 3048281df91de647b1b69dfeefb645ae050014bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
#
# Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#

#
# WARNING: This file is shared with other workspaces.
#

#
# Shared sanity rules for the JDK builds.
#

.SUFFIXES: .hdiffs

# All files created during sanity checking

SANITY_FILES =  $(ERROR_FILE) $(WARNING_FILE) $(MESSAGE_FILE)

# How to say "The Release Engineering people use this"
THE_OFFICIAL_USES=The official $(PLATFORM) builds use

# How to say "You are using:"
YOU_ARE_USING=You appear to be using

# Settings and rules to validate the JDK build environment.

ifeq ($(PLATFORM), solaris)
  FREE_SPACE := $(shell $(DF) -b $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$2;}')
  TEMP_FREE_SPACE := $(shell $(DF) -b $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$2;}')
  REQ_PATCH_LIST = $(JDK_TOPDIR)/make/PatchList.solaris
  ifeq ($(ARCH_FAMILY), sparc)
    PATCH_POSITION = $$4
  else
    PATCH_POSITION = $$6
  endif
endif

ifeq ($(PLATFORM), linux)
  FREE_SPACE := $(shell $(DF) --sync -kP $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
  TEMP_FREE_SPACE := $(shell $(DF) --sync -kP $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
  ifeq ($(ARCH), amd64)
    LINUX_VERSION := $(shell \
        if [ -r "$(LINUX_VERSION_INFO)" ] ; then \
          $(CAT) $(LINUX_VERSION_INFO) | $(TAIL) -1 | $(NAWK) '{ print $$3; }';\
        else \
          $(ECHO) "Unknown linux"; \
        fi )
  else
    LINUX_VERSION := $(shell \
        if [ -r "$(LINUX_VERSION_INFO)" ] ; then \
          $(NAWK) '{ print $$4" "$$5; }' $(LINUX_VERSION_INFO) ; \
        else \
          $(ECHO) "Unknown linux"; \
        fi )
  endif
  ifneq ($(ARCH), ia64)
    # dummy program that outputs ALSA's version (created in target sane-alsa-versioncheck)
    ALSA_VERSION_CHECK = $(TEMPDIR)/alsaversioncheck
    ALSA_VERSION = `if [ -f "$(ALSA_VERSION_CHECK)" ] ; then $(ALSA_VERSION_CHECK) ; fi`
  endif
endif

ifeq ($(PLATFORM), windows)
  FREE_SPACE := $(shell $(DF) -kP $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
  TEMP_FREE_SPACE := $(shell $(DF) -kP $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
  # Localized systeminfo has localized labels, but not localized values.
  _WINDOWS_VERSION := \
    $(shell systeminfo 2> $(DEV_NULL) | grep 'Microsoft' | grep 'Windows' | \
	 cut -d':' -f2)
  ifeq ($(_WINDOWS_VERSION),)
    _WINDOWS_VERSION := Windows 2000 or Unknown (no systeminfo utility)
  endif
  WINDOWS_VERSION := $(strip $(_WINDOWS_VERSION))
  DXSDK_VER := $(shell $(EGREP) DIRECT3D_VERSION $(DXSDK_INCLUDE_PATH)/d3d9.h 2>&1 | \
    $(EGREP) "\#define" | $(NAWK) '{print $$3}')
endif

# Get the version numbers of what we are using
_MAKE_VER  :=$(shell $(MAKE) --version 2>&1 | $(HEAD) -n 1)
_ZIP_VER   :=$(shell $(ZIPEXE) -help 2>&1 | $(HEAD) -n 4 | $(EGREP) '^Zip')
_UNZIP_VER :=$(shell $(UNZIP)  -help 2>&1 | $(HEAD) -n 4 | $(EGREP) '^UnZip')
_BOOT_VER  :=$(shell $(BOOTDIR)/bin/java -version 2>&1 | $(HEAD) -n 1)
MAKE_VER   :=$(call GetVersion,"$(_MAKE_VER)")
ZIP_VER    :=$(call GetVersion,"$(_ZIP_VER)")
UNZIP_VER  :=$(call GetVersion,"$(_UNZIP_VER)")
BOOT_VER   :=$(call GetVersion,"$(_BOOT_VER)")

REQUIRED_ANT_VER := 1.6.3
ifeq ($(ANT_HOME),)
  _ANT_VER:=$(shell JAVACMD="$(BOOTDIR)/bin/java" $(ANT) -version 2>&1 )
else
  _ANT_VER:=$(shell JAVACMD="$(BOOTDIR)/bin/java" ANT_HOME="$(ANT_HOME)" $(ANT) -version 2>&1 )
endif
ANT_VER:=$(call GetVersion,"$(_ANT_VER)")

REQUIRED_FINDBUGS_VER := 1.2
ifeq ($(FINDBUGS_HOME),)
  _FINDBUGS_VER:=$(shell $(FINDBUGS) -javahome "$(BOOTDIR)" -textui -version 2>&1 )
else
  _FINDBUGS_VER:=$(shell FINDBUGS_HOME="$(FINDBUGS_HOME)" $(FINDBUGS) -javahome "$(BOOTDIR)" -textui -version 2>&1 )
endif
FINDBUGS_VER:=$(call GetVersion,"$(_FINDBUGS_VER)")

ifdef ALT_BINDIR
  ALT_BINDIR_VERSION := $(shell $(ALT_BINDIR)/java$(EXE_SUFFIX) -version 2>&1  | $(NAWK) -F'"' '{ print $$2 }')
  ALT_BINDIR_OK := $(shell $(ECHO) $(ALT_BINDIR_VERSION) | $(EGREP) -c '^$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION)')
endif

INSTALL_PATCHES_FILE = $(TEMPDIR)/installed.patches

# Get ALL_SETTINGS defined
include $(JDK_MAKE_SHARED_DIR)/Sanity-Settings.gmk

.PHONY: \
	sane-copyrightyear\
	sane-settings \
	sane-insane \
	sane-build_number \
	sane-os_version \
	sane-memory_check \
	sane-windows \
	sane-locale \
	sane-linux \
	sane-cygwin \
	sane-cygwin-shell \
	sane-mks \
	sane-arch_data_model \
	sane-os_patch_level \
	sane-classpath \
	sane-java_home \
	sane-fonts \
	sane-binary-plugs \
	sane-variant \
	sane-ld_library_path \
	sane-ld_library_path_64 \
	sane-ld_options \
	sane-ld_run_path \
	sane-makeflags \
	sane-alt_outputdir \
	sane-outputdir \
	sane-alt_bootdir \
	sane-bootdir \
        sane-cups \
	sane-devtools_path \
	sane-compiler_path \
	sane-unixcommand_path \
	sane-usrbin_path \
	sane-unixccs_path \
	sane-docs_import \
	sane-math_iso \
	sane-libCrun \
	sane-odbcdir \
	sane-msdevtools_path \
	sane-hotspot_binaries \
	sane-hotspot_import \
	sane-hotspot_import_dir \
	sane-hotspot_import_include \
	sane-compiler \
	sane-link \
	sane-cacerts \
	sane-alsa-versioncheck \
	sane-alsa-headers \
	sane-ant_version \
	sane-findbugs_version \
	sane-zip_version \
	sane-unzip_version \
 	sane-msvcrt_path \
        sane-freetype

######################################################
# check for COPYRIGHT_YEAR variable
######################################################
sane-copyrightyear:
ifdef ALT_COPYRIGHT_YEAR
	@$(ECHO) "WARNING: ALT_COPYRIGHT_YEAR but not the current year\n" \
			 	 " will be used for copyright year.\n " \
		"" >>$(WARNING_FILE)
endif

######################################################
# check for INSANE variable
######################################################
sane-insane:
ifdef INSANE
	@$(ECHO) "WARNING: You are building in 'INSANE' mode. You \n" \
	   "        should not use this mode, and in fact, \n" \
	   "        it may be removed at any time. If you \n" \
	   "        have build problems as a result of using \n" \
	   "        INSANE mode, then you should not expect \n" \
	   "        assistance from anyone with the problems \n" \
	   "        or consequences you experience. \n" \
	   "" >> $(WARNING_FILE)
endif

######################################################
# check for GNU Make version
######################################################
MAKE_CHECK :=$(call CheckVersions,$(MAKE_VER),$(REQUIRED_MAKE_VER))
sane-make:
	@if [ "$(MAKE_CHECK)" != "same" -a "$(MAKE_CHECK)" != "newer" ]; then \
	  $(ECHO) "WARNING: The version of make being used is older than \n" \
	    "      the required version of '$(REQUIRED_MAKE_VER)'. \n" \
	    "      The version of make found was '$(MAKE_VER)'. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check the BUILD_NUMBER to make sure it contains bNN
######################################################
sane-build_number: 
	@if [ "`$(ECHO) $(BUILD_NUMBER) | $(SED) 's@.*b[0-9][0-9]*.*@bNN@'`" != "bNN" ] ; then \
	    $(ECHO) "WARNING: The BUILD_NUMBER needs to contain b[0-9][0-9]*. Currently BUILD_NUMBER=$(BUILD_NUMBER). \n" \
	      "        This has been known to cause build failures. \n" \
	      "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check the ARCH_DATA_MODEL setting
######################################################
sane-arch_data_model:
	@if [ "$(ARCH_DATA_MODEL)" != 32 -a "$(ARCH_DATA_MODEL)" != 64 ]; then \
	    $(ECHO) "ERROR: The setting of ARCH_DATA_MODEL must be 32 or 64.\n" \
	      "      $(YOU_ARE_USING) ARCH_DATA_MODEL=$(ARCH_DATA_MODEL). \n" \
	      "" >> $(ERROR_FILE) ; \
	fi

######################################################
# Check the OS version (windows and linus have release name checks)
#   NOTE: OPENJDK explicitly does not check for OS release information.
#         Unless we know for sure that it will not build somewhere, we cannot
#         generate a fatal sanity error, and a warning about the official
#         build platform just becomes clutter.
######################################################
OS_CHECK :=$(call CheckVersions,$(OS_VERSION),$(REQUIRED_OS_VERSION))
sane-os_version:: sane-arch_data_model sane-memory_check sane-locale sane-os_patch_level
ifndef OPENJDK
	@if [ "$(OS_CHECK)" = "missing" ]; then \
	  $(ECHO) "ERROR: The $(PLATFORM) OS version is undefined (Try: uname -r). \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@if [ "$(OS_CHECK)" != "same" ]; then \
	  $(ECHO) "WARNING: $(THE_OFFICIAL_USES) OS version $(REQUIRED_OS_VERSION). \n" \
	    "        $(YOU_ARE_USING) OS version $(OS_VERSION). \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
  ifeq ($(PLATFORM), windows)
	@if [ "$(findstring $(REQUIRED_WINDOWS_VERSION),$(WINDOWS_VERSION))" = "" ]; then \
	    $(ECHO) "WARNING: $(YOU_ARE_USING) an unknown version of Windows. \n" \
	      "        The required version is $(REQUIRED_WINDOWS_VERSION). \n" \
	      "        $(YOU_ARE_USING) $(WINDOWS_VERSION) \n" \
	      "" >> $(WARNING_FILE) ; \
	fi
  endif # windows
  ifeq ($(PLATFORM), linux)
	@if [ `$(ECHO) "$(LINUX_VERSION)" | $(EGREP) -c '$(REQUIRED_LINUX_VER)'` -ne 1 ]; then \
	  $(ECHO) "WARNING: The build is being done on Linux $(LINUX_VERSION). \n" \
	    "        $(THE_OFFICIAL_USES) Linux $(REQUIRED_LINUX_VER), \n" \
	    "        specifically Linux $(REQUIRED_LINUX_FULLVER). \n" \
	    "        The version found was '$(OS_VERSION)'. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
  endif # linux
endif # OPENJDK

ifeq ($(PLATFORM), windows)
  sane-os_version:: sane-cygwin sane-mks sane-cygwin-shell
endif

######################################################
# Check the memory available on this machine
######################################################
sane-memory_check:
	@if [ "$(LOW_MEMORY_MACHINE)" = "true" ]; then \
	  $(ECHO) "WARNING: This machine appears to only have $(MB_OF_MEMORY)Mb of physical memory, \n" \
	    "        builds on this machine could be slow. \n" \
	    "" >> $(WARNING_FILE) ; \
        fi

######################################################
# Check the locale (value of LC_ALL, not being empty or ==C can be a problem)
######################################################
sane-locale:
ifneq ($(PLATFORM), windows)
	@if [ "$(LC_ALL)" != "" -a "$(LC_ALL)" != "C" ]; then \
	  $(ECHO) "WARNING: LC_ALL has been set to $(LC_ALL), this can cause build failures. \n" \
	    "        Try setting LC_ALL to \"C\". \n" \
	    "" >> $(WARNING_FILE) ; \
        fi
	@if [ "$(LANG)" != "" -a "$(LANG)" != "C" ]; then \
	  $(ECHO) "WARNING: LANG has been set to $(LANG), this can cause build failures. \n" \
	    "        Try setting LANG to \"C\". \n" \
	    "" >> $(WARNING_FILE) ; \
        fi
endif

######################################################
# Check the Windows cygwin version
######################################################
ifeq ($(PLATFORM), windows)
  CYGWIN_CHECK :=$(call CheckVersions,$(CYGWIN_VER),$(REQUIRED_CYGWIN_VER))
sane-cygwin:
  ifdef USING_CYGWIN
	@if [ "$(CYGWIN_CHECK)" = "missing" ]; then \
	  $(ECHO) "ERROR: The CYGWIN version is undefined. \n" \
	    "      $(THE_OFFICIAL_USES) CYGWIN $(REQUIRED_CYGWIN_VER). \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@if [ "$(CYGWIN_CHECK)" = "older" ]; then \
	  $(ECHO) "ERROR: The build cannot be done on CYGWIN $(CYGWIN_VER). \n" \
	    "      Use CYGWIN $(REQUIRED_CYGWIN_VER) or higher. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
endif

######################################################
# Check the cygwin shell is used, not cmd.exe
######################################################
ifeq ($(PLATFORM), windows)
sane-cygwin-shell:
  ifdef USING_CYGWIN
	@if [ "$(SHLVL)" = "" -a "$(_)" = "" ]; then \
	  $(ECHO) "ERROR: You are using an unsupported shell. \n" \
	    "      Use either sh, bash, ksh, zsh, or tcsh. \n" \
	    "      Using the cmd.exe utility is not supported. \n" \
	    "      If you still want to try your current shell, \n" \
	    "      please export SHLVL=1 when running $(MAKE).  \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
endif

######################################################
# Check the Windows mks version
######################################################
ifeq ($(PLATFORM), windows)
    MKS_CHECK :=$(call CheckVersions,$(MKS_VER),$(REQUIRED_MKS_VER))
sane-mks:
  ifndef USING_CYGWIN
	@if [ "$(MKS_CHECK)" = "missing" ]; then \
	  $(ECHO) "ERROR: The MKS version is undefined. \n" \
	    "      $(THE_OFFICIAL_USES) MKS $(REQUIRED_MKS_VER). \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@if [ "$(MKS_CHECK)" = "older" ]; then \
	  $(ECHO) "ERROR: The build cannot be done on MKS $(MKS_VER). \n" \
	    "      Use MKS $(REQUIRED_MKS_VER) or higher. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
endif

######################################################
# Get list of installed patches (this file has a particular format)
######################################################
$(INSTALL_PATCHES_FILE):
	@$(prep-target)
ifeq ($(PLATFORM), solaris)
  ifeq ($(OS_VERSION),$(REQUIRED_OS_VERSION))
	$(SHOWREV) -p > $@ 2>&1
  endif
endif
	@$(ECHO) "" >> $@

######################################################
# Check list of Solaris patches
######################################################
sane-os_patch_level: $(INSTALL_PATCHES_FILE)
ifeq ($(PLATFORM), solaris)
  ifeq ($(OS_VERSION),$(REQUIRED_OS_VERSION))
	@$(NAWK) 'BEGIN { \
    readingInstallPatches = 0; \
    requiredCount = 0; \
    installCount = 0; \
} \
{ \
    if (readingInstallPatches) { \
        if ($$1=="Patch:") { \
            ns = split($$2,parts,"-");  \
            installPatchNo[installCount]=parts[1]; \
            installPatchRev[installCount]=parts[2]; \
            installCount++; \
        } \
    } \
     \
    if (!readingInstallPatches) { \
        if (index($$1,"#") != 0) continue; \
        if (match($$1,"BUILD") > 0 \
        && $$2 == $(OS_VERSION) \
        && ($$7 == "REQ" || $$7 == "req") \
        && $(PATCH_POSITION) != "none" \
        && $(PATCH_POSITION) != "NONE") { \
            ns = split($(PATCH_POSITION),parts,"-");  \
            requiredPatchNo[requiredCount]=parts[1]; \
            requiredPatchRev[requiredCount]=parts[2]; \
            requiredCount++; \
       } \
    } \
} \
END { \
    errorCount=0; \
    for (i=0; i<requiredCount; i++) { \
        foundMatch = 0; \
        for (j=0; j<installCount; j++) { \
            if (installPatchNo[j] == requiredPatchNo[i] \
            && installPatchRev[j] >= requiredPatchRev[i]) { \
                foundMatch = 1; \
                break; \
            } \
        } \
        if ( foundMatch == 0) { \
            printf("WARNING: Your solaris install is missing the required patch %s-%s\n", requiredPatchNo[i], requiredPatchRev[i] ); \
            printf("         Please update your your system patches or build on a different machine.\n\n" ); \
            errorCount++; \
        } \
    } \
}' $(REQ_PATCH_LIST) readingInstallPatches=1 $(INSTALL_PATCHES_FILE) >> $(WARNING_FILE)
  endif
endif # PLATFORM

######################################################
# CLASSPATH cannot be set, unless you are insane.
######################################################
sane-classpath:
ifdef CLASSPATH
	@$(ECHO) "ERROR: Your CLASSPATH environment variable is set.  This will \n" \
	   "      most likely cause the build to fail.  Please unset it \n" \
	   "      and start your build again. \n" \
	   "" >> $(ERROR_FILE)
endif

######################################################
# JAVA_HOME cannot be set, unless you are insane.
######################################################
sane-java_home:
ifdef JAVA_HOME
	@$(ECHO) "ERROR: Your JAVA_HOME environment variable is set.  This will \n" \
	   "      most likely cause the build to fail.  Please unset it \n" \
	   "      and start your build again. \n" \
	   "" >> $(ERROR_FILE)
endif

######################################################
# Make sure the fonts are there
# Exceptions are when explicitly building OPENJDK, or
# when the entire CLOSED_SRC dir is excluded, so we are
# implicitly building OPENJDK
######################################################
FONT_FILE=$(CLOSED_SRC)/share/lib/fonts/LucidaTypewriterRegular.ttf
sane-fonts:
ifndef OPENJDK
	@if [ -d $(CLOSED_SRC) ] ; then \
	 if [ ! -f $(FONT_FILE) ] ; then \
	  $(ECHO) "ERROR: Missing $(FONT_FILE). \n" \
	   "      Verify you have downloaded and overlayed on the source area all the binary files. \n" \
	   "" >> $(ERROR_FILE); \
	fi \
	fi
endif

######################################################
# If building OPENJDK check pre-built binaries are
# available for binary plug source components.
######################################################
ifdef OPENJDK
sane-binary-plugs:
	@if [ ! -d "$(BINARY_PLUGS_PATH)" ]; then \
	  $(ECHO) "ERROR: Can't locate pre-built libraries. \n" \
	    "      Please check your access to \n" \
	    "          $(BINARY_PLUGS_PATH) \n" \
	    "      and/or check your value of ALT_BINARY_PLUGS_PATH. \n" \
	   "" >> $(ERROR_FILE); \
	fi
endif

######################################################
# VARIANT must be set to DBG or OPT
######################################################
sane-variant:
	@if [ "$(VARIANT)" != DBG -a "$(VARIANT)" != OPT ] ; then \
	  $(ECHO) "ERROR: Your VARIANT environment variable is set to $(VARIANT). \n" \
	   "      Needs to be set to DBG or OPT \n" \
	   "" >> $(ERROR_FILE); \
	fi

######################################################
# LD_LIBRARY_PATH should not be set, unless you are insane.
######################################################
sane-ld_library_path:
ifdef LD_LIBRARY_PATH
	@$(ECHO) "ERROR: Your LD_LIBRARY_PATH environment variable is set.  This may \n" \
	   "      produce binaries binaries incorrectly.  Please unset it \n" \
	   "      and start your build again. \n" \
	   "" >> $(ERROR_FILE)
endif

######################################################
# LD_LIBRARY_PATH_64 should not be set, unless you are insane.
######################################################
sane-ld_library_path_64:
ifdef LD_LIBRARY_PATH_64
	@$(ECHO) "ERROR: Your LD_LIBRARY_PATH_64 environment variable is set.  This may \n" \
	   "      produce binaries binaries incorrectly.  Please unset it \n" \
	   "      and start your build again. \n" \
	   "" >> $(ERROR_FILE)
endif

######################################################
# LD_OPTIONS should not be set, unless you are insane.
######################################################
sane-ld_options:
ifdef LD_OPTIONS
	@$(ECHO) "ERROR: Your LD_OPTIONS environment variable is set.  This may \n" \
	   "      produce binaries binaries incorrectly.  Please unset it \n" \
	   "      and start your build again. \n" \
	   "" >> $(ERROR_FILE)
endif

######################################################
# LD_RUN_PATH should not be set, unless you are insane.
######################################################
sane-ld_run_path:
ifdef LD_RUN_PATH
	@$(ECHO) "ERROR: Your LD_RUN_PATH environment variable is set.  This may \n" \
	   "      produce binaries binaries incorrectly.  Please unset it \n" \
	   "      produce binaries binaries incorrectly.  Please unset it \n" \
	   "      and start your build again. \n" \
	   "" >> $(ERROR_FILE)
endif

######################################################
# MAKEFLAGS cannot be set, unless you are insane.
######################################################
ifeq ($(PLATFORM), windows)
ifdef USING_CYGWIN
REAL_MAKEFLAGS:=$(subst --unix,,$(MAKEFLAGS))
else
REAL_MAKEFLAGS:=$(MAKEFLAGS)
endif
else
REAL_MAKEFLAGS:=$(MAKEFLAGS)
endif
sane-makeflags:
# ifneq ($(strip $(REAL_MAKEFLAGS)),)
ifeq ($(origin MAKEFLAGS),environment)
	@#
	@# it is unacceptable to have the-e or --environment-overrides value in MAKEFLAGS
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(e|--environment-overrides)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -e or \n" \
	    "      --environment-overrides, or the MAKEFLAGS environment \n" \
	    "      variable has this value set.  This will cause any \n" \
	    "      environment variables you have defined to override \n" \
	    "      the values defined by the makefiles. This practice is \n" \
	    "      not recommemded by the authors of GNU Make, and \n" \
	    "      will lead to an improper build. \n" \
	    "      Please fix and restart the build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# it is unacceptable to havethe -i or --ignore-errors value in MAKEFLAGS
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(i|--ignore-errors)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -i or \n" \
	    "      --ignore-errors, or the MAKEFLAGS environment \n" \
	    "      variable has this value set. 1111 You will be unable \n" \
	    "      to determine if the build is broken or not. \n" \
	    "      Please fix and restart the build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# it is unacceptable to have the -I or --include-dir value in MAKEFLAGS
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(I|--include-dir)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -I or \n" \
	    "      --include-dir, or the MAKEFLAGS environment \n" \
	    "      variable has this value set.  This will render your \n" \
	    "      build questionable as not all the rules and depenencies \n" \
	    "      are captured by the build. \n" \
	    "      Please fix and restart the build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# it is unacceptable to have the -k or --keep-going value in MAKEFLAGS:
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(k|--keep-going)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -k or \n" \
	    "      --keep-going, or the MAKEFLAGS environment \n" \
	    "      variable has this value set. 222 You will be unable \n" \
	    "      to determine if the build is broken or not. \n" \
	    "      Please fix and restart the build.  \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# it is unacceptable to have the -o or --assume-old or --old-filevalue in MAKEFLAGS:
	@# Note - this rule never gets invoked because it is processed out
	@#        in GNU Make startup
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(o|--assume-old|--old-file)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -o or \n" \
	    "      --assume-old or --old-file, or the MAKEFLAGS environment \n" \
	    "      variable has this value set.  This could prevent the \n" \
	    "      build from executing rules it should, thus rendering a \n" \
	    "      questionable result. \n" \
	    "      Please fix and restart the build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# it is unacceptable to have the -r or --nobuiltin-rules value in MAKEFLAGS
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(r|--no-builtin-rules)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -r or \n" \
	    "      --no-builtin-rules, or the MAKEFLAGS environment \n" \
	    "      variable has this value set.  This may break the build \n" \
	    "      by not allowing builtin rules that may be required. \n" \
	    "      Please fix and restart the build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# it is unacceptable to have the -t or --touch value in MAKEFLAGS
	@# Note - this rule never gets invoked because it is processed out
	@#        in GNU Make startup
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(t|--touch)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -t or \n" \
	    "      --touch, or the MAKEFLAGS environment \n" \
	    "      variable has this value set.  This will leave the \n" \
	    "      build in a unclear state and could lead to not executing \n" \
	    "      rules which should be executed. \n" \
	    "      Please fix and restart the build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# show what is in MAKEFLAGS so the user is aware...
	@#
	@$(ECHO) "WARNING: Your MAKEFLAGS environment variable is set. \n" \
	   "        You should be very careful about the values set here. \n" \
	   "\n" \
	   "        MAKEFLAGS is set to =>$(MAKEFLAGS)<= \n" \
	   "" >> $(WARNING_FILE)
endif

######################################################
# if specified, ALT_OUTPUTDIR must point to non-relative path if set
######################################################
sane-alt_outputdir:
ifdef ALT_OUTPUTDIR
	@if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -ci '^([a-z]:)?/'` -ne 1 ]; then \
	  $(ECHO) "ERROR: ALT_OUTPUTDIR must be an Absolute Path Name, \n" \
	    "      not a Relative Path Name. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  ifeq ($(PLATFORM), windows)
	@if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -ci '^([a-z]:)'` -ne 1 ]; then \
	  $(ECHO) "ERROR: On windows, ALT_OUTPUTDIR must contain the drive letter. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
endif

######################################################
# OUTPUTDIR tests
######################################################
sane-outputdir:
	@#
	@# OUTPUTDIR must be a directory...
	@#
	@if [ ! -d "$(OUTPUTDIR)" ]; then \
	  $(ECHO) "ERROR: OUTPUTDIR must be an existing directory. The current \n" \
	    "      value of OUTPUTDIR is \n" \
	    "          $(OUTPUTDIR) \n" \
	    "      Please check your value of ALT_OUTPUTDIR. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# OUTPUTDIR must be writeable by user...
	@#
	@if [ ! -w "$(OUTPUTDIR)" ]; then \
	  $(ECHO) "ERROR: You must have write permissions to OUTPUTDIR. The \n" \
	    "      current value of OUTPUTDIR is \n" \
	    "          $(OUTPUTDIR) \n" \
	    "      Either obtain these permissions or set ALT_OUTPUTDIR. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# OUTPUTDIR must have enough free space...
	@#
	@if [ $(FREE_SPACE) -lt $(REQUIRED_FREE_SPACE) ]; then \
	  $(ECHO) "WARNING: You may not have enough free space in your OUTPUTDIR. The \n" \
	    "        current value of OUTPUTDIR is \n" \
	    "            $(OUTPUTDIR) \n" \
	    "        You need "$(REQUIRED_FREE_SPACE)" Kbytes free on this device to build \n" \
	    "        and it appears that only "$(FREE_SPACE)" Kbytes are free. \n" \
	    "        Either obtain more space or set ALT_OUTPUTDIR to a larger disk. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi

######################################################
# if specified, ALT_BOOTDIR must point to non-relative path if set
######################################################
sane-alt_bootdir:
ifdef ALT_BOOTDIR
	@if [ `$(ECHO) $(subst \,/,$(ALT_BOOTDIR)) | $(EGREP) -ci '^([a-z]:)?/'` -ne 1 ]; then \
	  $(ECHO) "ERROR: ALT_BOOTDIR must be an Absolute Path Name, \n" \
	    "      not a Relative Path Name. \n" \
	    "      The current value of ALT_BOOTDIR is \n" \
	    "          $(ALT_BOOTDIR) \n" \
	    "      Please fix this and continue your build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif

######################################################
# BOOTDIR must point to a valid JDK.
######################################################
BOOT_CHECK :=$(call CheckVersions,$(BOOT_VER),$(REQUIRED_BOOT_VER))
sane-bootdir:
	@if [ "$(BOOT_CHECK)" != "same" -a "$(BOOT_CHECK)" != "newer" ]; then \
	  $(ECHO) "ERROR: Your BOOTDIR environment variable does not point \n" \
	    "      to a valid JDK for bootstrapping this build. \n" \
	    "      A JDK $(JDK_MINOR_VERSION) $(MARKET_NAME) build must be bootstrapped using  \n" \
	    "      JDK $(PREVIOUS_JDK_VERSION) fcs (or later). \n" \
	    "      Apparently, your bootstrap JDK is version $(BOOT_VER) \n" \
	    "      Please update your ALT_BOOTDIR setting and start your build again. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi

######################################################
# CACERTS_FILE must be absoulte path and readable
######################################################
sane-cacerts:
  ifdef ALT_CACERTS_FILE
	@if [ `$(ECHO) $(subst \,/,$(ALT_CACERTS_FILE)) | $(EGREP) -ci '^([a-z]:)?/'` -ne 1 ]; then \
	  $(ECHO) "ERROR: ALT_CACERTS_FILE must be an Absolute Path Name, \n" \
	    "      not a Relative Path Name. \n" \
	    "      The current value of ALT_CACERTS_FILE is \n" \
	    "          $(ALT_CACERTS_FILE) \n" \
	    "      Please fix this and continue your build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
	@#
	@# CACERTS_FILE must be readable
	@#
	@if [ ! -r "$(subst \,/,$(CACERTS_FILE))" ]; then \
	  $(ECHO) "ERROR: You do not have access to a valid cacerts file. \n" \
	    "      Please check your access to \n" \
	    "          $(subst \,/,$(CACERTS_FILE)) \n" \
	    "      and/or check your value of ALT_CACERTS_FILE. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# CACERTS_FILE must be a file
	@#
	@if [ -d "$(subst \,/,$(CACERTS_FILE))" ]; then \
	  $(ECHO) "ERROR: You do not have access to a valid cacerts file.\n" \
	    "      The value of CACERTS_FILE must point to a normal file.\n" \
	    "      Please check your access to \n" \
	    "          $(subst \,/,$(CACERTS_FILE)) \n" \
	    "      and/or check your value of ALT_CACERTS_FILE. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi


######################################################
# Check for availability of FreeType (OpenJDK specific)
######################################################

ifdef OPENJDK

# The freetypecheck Makefile prints out "Failed" if not good enough
$(TEMPDIR)/freetypeinfo: FRC
	@$(prep-target)
	@(($(CD) $(BUILDDIR)/tools/freetypecheck && $(MAKE)) || \
	    $(ECHO) "Failed to build freetypecheck." ) > $@

sane-freetype: $(TEMPDIR)/freetypeinfo
	@if [ "`$(CAT) $< | $(GREP) Fail`" != "" ]; then \
	  $(ECHO) "ERROR: FreeType version " $(REQUIRED_FREETYPE_VERSION) \
	          " or higher is required. \n" \
		  "`$(CAT) $<`  \n" >> $(ERROR_FILE) ; \
	fi

else
#do nothing  (not OpenJDK)
sane-freetype: 
endif

######################################################
# CUPS_HEADERS_PATH must be valid
######################################################
sane-cups:
ifneq ($(PLATFORM), windows)
	@if [ ! -r $(CUPS_HEADERS_PATH)/cups/cups.h ]; then \
	  $(ECHO) "ERROR: You do not have access to valid Cups header files. \n" \
	    "      Please check your access to \n" \
	    "          $(CUPS_HEADERS_PATH)/cups/cups.h \n" \
	    "      and/or check your value of ALT_CUPS_HEADERS_PATH, \n" \
	    "      CUPS is frequently pre-installed on many systems, \n" \
            "      or may be downloaded from http://www.cups.org \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif

######################################################
# Check for existence of DEVTOOLS_PATH
######################################################
sane-devtools_path:
	@if [ "$(DEVTOOLS_PATH)" != "" -a ! -r "$(DEVTOOLS_PATH)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid DEVTOOLS_PATH setting. \n" \
	    "      Please check your access to \n" \
	    "          $(DEVTOOLS_PATH) \n" \
	    "      and/or check your value of ALT_DEVTOOLS_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi

######################################################
# Check for existence of MS_RUNTIME_LIBRARIES
######################################################
sane-msvcrt_path:
ifeq ($(PLATFORM), windows)
	@if [ ! -r "$(MSVCRT_DLL_PATH)/msvcrt.dll" ]; then \
	  $(ECHO) "ERROR: You do not have access to msvcrt.dll. \n" \
	    "      Please check your access to \n" \
	    "          $(MSVCRT_DLL_PATH) \n" \
	    "      and/or check your value of ALT_MSVCRT_DLL_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  ifeq ($(ARCH_DATA_MODEL), 32)
    ifeq ($(COMPILER_VERSION), VS2003)
	@if [ ! -r "$(MSVCR71_DLL_PATH)/msvcr71.dll" ]; then \
	  $(ECHO) "ERROR: You do not have access to msvcr71.dll. \n" \
	    "      Please check your access to \n" \
	    "          $(MSVCR71_DLL_PATH) \n" \
	    "      and/or check your value of ALT_MSVCR71_DLL_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
    endif
  endif
endif

######################################################
# Check for existence of COMPILER_PATH
######################################################
sane-compiler_path:
	@if [ "$(COMPILER_PATH)" != "" -a ! -r "$(COMPILER_PATH)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid COMPILER_PATH setting. \n" \
	    "      Please check your access to \n" \
	    "          $(COMPILER_PATH) \n" \
	    "      and/or check your value of ALT_COMPILER_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi

######################################################
# Check for existence of UNIXCOMMAND_PATH
######################################################
sane-unixcommand_path:
	@if [ "$(UNIXCOMMAND_PATH)" != "" -a ! -r "$(UNIXCOMMAND_PATH)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid UNIXCOMMAND_PATH setting. \n" \
	    "      Please check your access to \n" \
	    "          $(UNIXCOMMAND_PATH) \n" \
	    "      and/or check your value of ALT_UNIXCOMMAND_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
ifeq ($(PLATFORM), windows)
	@for utility in cpio ar file m4 ; do \
	  if [ ! -r "`$(WHICH) $${utility}`" ]; then \
	    $(ECHO) "WARNING: You do not have the utility $${utility} in the \n" \
	      "      directory $(UNIXCOMMAND_PATH). \n" \
	      "      The utilities cpio, ar, file, and m4 are required. \n" \
	      "" >> $(WARNING_FILE) ; \
	  fi; \
	done
endif

######################################################
# Check for existence of USRBIN_PATH on linux
######################################################
sane-usrbin_path:
ifeq ($(PLATFORM), linux)
	@if [ "$(USRBIN_PATH)" != "" -a ! -r "$(USRBIN_PATH)" ]; then \
	    $(ECHO) "ERROR: You do not have a valid USRBIN_PATH setting. \n" \
	      "      Please check your access to \n" \
	      "          $(USRBIN_PATH)  \n" \
	      "      and/or check your value of ALT_USRBIN_PATH. \n" \
	      "" >> $(ERROR_FILE) ; \
	  fi
endif

######################################################
# Check for existence of UNIXCCS_PATH on solaris
######################################################
sane-unixccs_path:
ifeq ($(PLATFORM), solaris)
	@if [ "$(UNIXCCS_PATH)" != "" -a ! -r "$(UNIXCCS_PATH)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid UNIXCCS_PATH setting. \n" \
	    "      Please check your access to \n" \
	    "          $(UNIXCCS_PATH) \n" \
	    "      and/or check your value of ALT_UNIXCCS_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	  fi
endif

######################################################
# Verify the docs directory exists
######################################################
sane-docs_import:
	@if [ ! -d "$(HOTSPOT_DOCS_IMPORT_PATH)" ]; then \
	    $(ECHO) "WARNING: The directory HOTSPOT_DOCS_IMPORT_PATH=$(HOTSPOT_DOCS_IMPORT_PATH) \n" \
	      "      does not exist, check your value of ALT_HOTSPOT_DOCS_IMPORT_PATH. \n" \
	      "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check for possible problem regarding __fabsf,  math_iso.h and the libm patch.
#    Hotspot should have been changed in Mustang 6.0 Build 47 to not depend
#    on __fabsf, this is just checking that fact now.
######################################################
sane-math_iso:
ifeq ($(PLATFORM), solaris)
	@if [ -f $(HOTSPOT_SERVER_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) ]; then \
	  if [ "`$(NM) $(HOTSPOT_SERVER_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) | $(GREP) __fabsf`" != "" ]; then \
	    $(ECHO) "WARNING: This version of hotspot relies on __fabsf \n" \
	      "        which is not always available on Solaris 8 and 9 machines \n" \
	      "        unless they have the latest libm patch and the file \n" \
	      "        /usr/include/iso/math_iso.h which can trigger this dependency.\n" \
	      "        Hotspot should NOT be dependent on this extern, check the \n" \
	      "        version of the hotspot library you are using. \n" \
	      "" >> $(WARNING_FILE) ; \
	    fi; \
	fi
endif

######################################################
# Check for possible patch problem regarding /usr/lib/libCrun.so
######################################################
sane-libCrun:
ifeq ($(PLATFORM), solaris)
	@if [ "`$(NM) /usr/lib/libCrun.so.1 | $(GREP) __1c2n6FIpv_0_`" = "" ]; then \
	  $(ECHO) "WARNING: The file /usr/lib/libCrun.so.1 is missing the extern \n" \
	    "        __1c2n6FIpv_0_ which indicates that the system is missing \n" \
	    "        a required Solaris patch, or you are using a pre-FCS release \n" \
	    "        of Solaris 10. You need the latest /usr/lib/libCrun.so.1 \n" \
	    "        which comes with the FCS release of Solaris 10 and available \n" \
	    "        through the latest Solaris 8 or 9 C++ runtime patches. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
endif

######################################################
# Check for existence of MSDEVTOOLS_PATH on windows
######################################################
sane-msdevtools_path:
ifeq ($(PLATFORM), windows)
	@if [ "$(MSDEVTOOLS_PATH)" != "" -a ! -r "$(MSDEVTOOLS_PATH)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid MSDEVTOOLS_PATH setting. \n" \
	    "      Please check your access to \n" \
	    "          $(MSDEVTOOLS_PATH) \n" \
	    "      and/or check your value of ALT_MSDEVTOOLS_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif

######################################################
# Check for existence of Hotspot binaries
######################################################
sane-hotspot_binaries:
ifeq ($(ARCH_DATA_MODEL), 32)
	@if [ ! -r $(HOTSPOT_CLIENT_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) ]; then \
	  $(ECHO) "ERROR: HOTSPOT_CLIENT_PATH does not point to a valid HotSpot VM. \n" \
	    "      Please check your access to \n" \
	    "          $(HOTSPOT_CLIENT_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) \n" \
	    "      and/or check your value of ALT_HOTSPOT_CLIENT_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif
	@if [ ! -r $(HOTSPOT_SERVER_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) ]; then \
	  $(ECHO) "ERROR: HOTSPOT_SERVER_PATH does not point to a valid HotSpot VM. \n" \
	    "      Please check your access to \n" \
	    "          $(HOTSPOT_SERVER_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) \n" \
	    "      and/or check your value of ALT_HOTSPOT_SERVER_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# Check value of HOTSPOT_LIB_PATH
	@#
ifeq ($(PLATFORM), windows)
	@if [ ! -r $(HOTSPOT_LIB_PATH)/jvm.lib ]; then \
	  $(ECHO) "ERROR: HOTSPOT_LIB_PATH does not point to a valid HotSpot library. \n" \
	    "      Please check your access to \n" \
	    "          $(HOTSPOT_LIB_PATH)/jvm.lib \n" \
	    "      and/or check your value of ALT_HOTSPOT_LIB_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# Check for the .map files - its OK if they are not there..
	@#
  ifeq ($(ARCH_DATA_MODEL), 32)
	@# There is no 64-bit HotSpot client VM
	@if [ ! -r $(HOTSPOT_CLIENT_PATH)/jvm.map ]; then \
	  $(ECHO) "WARNING: HOTSPOT_CLIENT_PATH does not point to valid HotSpot .map files. \n" \
	    "        These files are optional and aid in the debugging of the JVM. \n" \
	    "        Please check your access to \n" \
	    "          $(HOTSPOT_CLIENT_PATH)/jvm.map \n" \
	    "        and/or check your value of ALT_HOTSPOT_CLIENT_PATH. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
	@if [ ! -r $(HOTSPOT_CLIENT_PATH)/jvm.pdb ]; then \
	  $(ECHO) "WARNING: HOTSPOT_CLIENT_PATH does not point to valid HotSpot .pdb files. \n" \
	    "        These files are optional and aid in the debugging of the JVM. \n" \
	    "        Please check your access to \n" \
	    "          $(HOTSPOT_CLIENT_PATH)/jvm.pdb \n" \
	    "        and/or check your value of ALT_HOTSPOT_CLIENT_PATH. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
  endif
	@if [ ! -r $(HOTSPOT_SERVER_PATH)/jvm.map ]; then \
	  $(ECHO) "WARNING: HOTSPOT_SERVER_PATH does not point to valid HotSpot .map files. \n" \
	    "        These files are optional and aid in the debugging of the JVM. \n" \
	    "        Please check your access to \n" \
	    "          $(HOTSPOT_SERVER_PATH)/jvm.map \n" \
	    "        and/or check your value of ALT_HOTSPOT_SERVER_PATH. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
	@if [ ! -r $(HOTSPOT_SERVER_PATH)/jvm.pdb ]; then \
	  $(ECHO) "WARNING: HOTSPOT_SERVER_PATH does not point to valid HotSpot .pdb files. \n" \
	    "        These files are optional and aid in the debugging of the JVM. \n" \
	    "        Please check your access to \n" \
	    "          $(HOTSPOT_SERVER_PATH)/jvm.pdb \n" \
	    "        and/or check your value of ALT_HOTSPOT_SERVER_PATH. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
endif	


######################################################
# Check for existence of misc Hotspot imported files
######################################################
HOTSPOT_INCLUDE_FILE_LIST  = jvmti.h
#HOTSPOT_INCLUDE_FILE_LIST += jni.h jni_md.h
#HOTSPOT_INCLUDE_FILE_LIST += jvm.h jvm_md.h
#HOTSPOT_INCLUDE_FILE_LIST += jmm.h
TMP_SDK_INCLUDE_FILE_LIST=$(HOTSPOT_INCLUDE_FILE_LIST:%.h=$(TEMPDIR)/%.h)
TMP_SDK_INCLUDE_FILE_DIFFS=$(HOTSPOT_INCLUDE_FILE_LIST:%.h=$(TEMPDIR)/%.hdiffs)

# These include files must have a pattern: 'version: MAJOR.MINOR.MICRO'
#    where MACRO, MINOR, and MICRO are numbers, e.g. 1.0.1, 0.2.90, etc.
#    The critical version we are checking is MAJOR.MINOR, we print all three
#    when we detect an error.

TMP_SDK_INCLUDE_FIND_VERSION= $(EGREP) 'version:'
TMP_SDK_INCLUDE_GET_VERSION= $(TMP_SDK_INCLUDE_FIND_VERSION) | \
		$(SED) -e 's@.*\([0-9][0-9]*\.[0-9][0-9]*\)\.[0-9].*@\1@'
TMP_SDK_INCLUDE_GET_FULL_VERSION= $(TMP_SDK_INCLUDE_FIND_VERSION) | \
		$(SED) -e 's@.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*@\1@'

# Compare an interface file (Rule creates 2 temp files: %.h and %.h.IMPORT)
#    Files jvm.h, jvm_md.h and jmm.h are special in that they are not publicly 
#    exported but do represent VM interfaces used by the rest of the jdk.
#    So these 3 will not be found in a promoted build and can only
#    be checked when this represents a full control build (i.e. the
#    HOTSPOT_IMPORT_PATH includes these files in it's 'include' directory).
$(TEMPDIR)/%.h: $(SHARE_SRC)/javavm/export/%.h
	@$(install-file)
	@$(RM) $@.IMPORT
	@if [ -r $(HOTSPOT_IMPORT_PATH)/include/$(@F) ]; then \
	  $(CP) $(HOTSPOT_IMPORT_PATH)/include/$(@F) $@.IMPORT ; \
	elif [ "$(@F)" != "jvm.h" -a "$(@F)" != "jmm.h" ] ; then \
	  $(ECHO) "WARNING: HOTSPOT_IMPORT_PATH does not contain the interface file $(@F). \n" \
	    "        Check your value of ALT_HOTSPOT_IMPORT_PATH. \n" \
	    "" >> $(WARNING_FILE) ; \
	  $(CP) $< $@.IMPORT; \
	else \
	  $(CP) $< $@.IMPORT; \
	fi

$(TEMPDIR)/%.h: $(PLATFORM_SRC)/javavm/export/%.h
	@$(install-file)
	@$(RM) $@.IMPORT
	@if [ -r $(HOTSPOT_IMPORT_PATH)/include/$(PLATFORM_INCLUDE_NAME)/$(@F) ]; then \
	  $(CP) $(HOTSPOT_IMPORT_PATH)/include/$(PLATFORM_INCLUDE_NAME)/$(@F) $@.IMPORT ; \
	elif [ "$(@F)" != "jvm_md.h" ] ; then \
	  $(ECHO) "WARNING: HOTSPOT_IMPORT_PATH does not contain the interface file $(@F). \n" \
	    "        Check your value of ALT_HOTSPOT_IMPORT_PATH. \n" \
	    "" >> $(WARNING_FILE) ; \
	  $(CP) $< $@.IMPORT; \
	else \
	  $(CP) $< $@.IMPORT; \
	fi

# Compares the two tempfiles: %.h and %.h.IMPORT, answer in %.hdiffs
#   Note: Putting anything into the hdiffs file will trigger generic IMPORT
#         warning message in hotspot_import_include.
#   First checks the major.minor versions, the micro number can differ.
#   Second checks the full version.
#   Lastly does a full diff if the full version differs or it has no version
$(TEMPDIR)/%.hdiffs: $(TEMPDIR)/%.h
	@$(prep-target)
	@$(TOUCH) $@
	@if [ "`$(CAT) $<        | $(TMP_SDK_INCLUDE_GET_VERSION)`" != \
	      "`$(CAT) $<.IMPORT | $(TMP_SDK_INCLUDE_GET_VERSION)`" ] ; then \
	    $(ECHO) "WARNING: The file $(<F) is not the same interface as the VM version.\n " \
	      "        this workspace has $(<F) `$(CAT) $< | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)` and \n " \
	      "        HOTSPOT_IMPORT_PATH contains $(<F) `$(CAT) $<.IMPORT | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)` \n" \
	    "" >> $(WARNING_FILE) ; \
	     $(ECHO) "Version mis-match" > $@ ; \
	fi
	@if [ "`$(CAT) $<        | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)`" != \
               "`$(CAT) $<.IMPORT | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)`" ] ; then \
          $(RM) $<.filtered  $<.IMPORT.filtered; \
          $(EGREP) -v 'VERSION' $< > $<.filtered; \
          $(EGREP) -v 'VERSION' $<.IMPORT > $<.IMPORT.filtered; \
          ($(DIFF) -w $<.filtered $<.IMPORT.filtered || exit 0) >> $@ ; \
        elif [ "`$(CAT) $< | $(TMP_SDK_INCLUDE_FIND_VERSION)`" = "" ] ; then \
          $(RM) $<.filtered  $<.IMPORT.filtered; \
          $(EGREP) -v '@\(#\)' $< > $<.filtered; \
          $(EGREP) -v '@\(#\)' $<.IMPORT > $<.IMPORT.filtered; \
          ($(DIFF) -w $<.filtered $<.IMPORT.filtered || exit 0) >> $@ ; \
	fi

# Verify all imported hotspot files
sane-hotspot_import:: sane-hotspot_import_dir sane-hotspot_import_include

# Verify the base directory exists
sane-hotspot_import_dir:
	@$(RM) $(TMP_SDK_INCLUDE_FILE_DIFFS)
	@$(RM) $(TMP_SDK_INCLUDE_FILE_LIST)
	@if [ ! -d "$(HOTSPOT_IMPORT_PATH)" ]; then \
	    $(ECHO) "WARNING: The directory HOTSPOT_IMPORT_PATH=$(HOTSPOT_IMPORT_PATH) \n" \
	      "      does not exist, check your value of ALT_HOTSPOT_IMPORT_PATH. \n" \
	      "" >> $(WARNING_FILE) ; \
	fi

# Verify hotspot include files
sane-hotspot_import_include: $(TMP_SDK_INCLUDE_FILE_LIST) $(TMP_SDK_INCLUDE_FILE_DIFFS)
	@if [ "`$(CAT) $(TMP_SDK_INCLUDE_FILE_DIFFS)`" != "" ] ; then \
	  $(ECHO) "WARNING: Possible HotSpot VM interface conflict. \n" \
	    "        HOTSPOT_IMPORT_PATH is used to import files from the VM build. \n" \
	    "        It is also used to verify that any copied files are consistent between \n" \
	    "        these two components. It has been detected that one or more of the \n" \
	    "        VM interface files inside this workspace may not match the interfaces \n" \
	    "        exported by the VM, or the VM versions could not be found. \n" \
	    "        The list of VM interface files is: \n" \
	    "            $(HOTSPOT_INCLUDE_FILE_LIST). \n" \
	    "        This workspace has copies of these files at: \n" \
	    "          $(SHARE_SRC)/javavm/export and $(PLATFORM_SRC)/javavm/export \n" \
	    "        for build purposes, and they should contain the same interfaces \n" \
	    "        as the VM versions imported from: \n" \
	    "          \$$(HOTSPOT_IMPORT_PATH)/include \n" \
	    "               (i.e. $(HOTSPOT_IMPORT_PATH)/include) \n" \
	    "        If an interface indeed doesn't match, then the use of this interface \n" \
	    "        at JDK runtime could cause serious errors. \n" \
	    "" >> $(WARNING_FILE) ; \
	    for i in $(TMP_SDK_INCLUDE_FILE_DIFFS); do \
		if [ -s $$i ] ; then \
		  $(ECHO) " " >> $(WARNING_FILE); \
		  $(ECHO) "VM Interface Differences: $$i" >> $(WARNING_FILE); \
		  $(CAT) $$i >> $(WARNING_FILE); \
		  $(ECHO) " " >> $(WARNING_FILE); \
		fi; \
	    done; \
	fi
	@$(RM) $(TMP_SDK_INCLUDE_FILE_DIFFS)
	@$(RM) $(TMP_SDK_INCLUDE_FILE_LIST)

# The JDI-SA feature is not currently released on some platforms.
# See the Defs-<arch>.gmk files.

ifeq ($(INCLUDE_SA), true)
# Verify that hotspot Serviceability Agent files are present.  To keep 
# it simple, we will just check for one of them.  The others have arch 
# dependent paths.

sane-hotspot_import::
	@if [ ! -r  $(HOTSPOT_IMPORT_PATH)/lib/sa-jdi.jar ] ; then \
	  $(ECHO) "WARNING: File $(HOTSPOT_IMPORT_PATH)/lib/sa-jdi.jar does not exist.\n" \
	    "        The JDI binding for the Serviceability Agent will not be included in the build.\n" \
	    "        Please check your access to\n" \
	    "          $(HOTSPOT_IMPORT_PATH)/lib/sa-jdi.jar\n" \
	    "        and/or check your value of ALT_HOTSPOT_IMPORT_PATH.\n" \
	    "" >> $(WARNING_FILE) ; \
	 fi
endif

######################################################
# Check the ant version
######################################################
ANT_CHECK :=$(call CheckVersions,$(ANT_VER),$(REQUIRED_ANT_VER))
sane-ant_version:
	@if [ "$(ANT_CHECK)" != "same" \
	      -a "$(ANT_CHECK)" != "newer" ]; then \
	  $(ECHO) "WARNING: The version of ant being used is older than \n" \
	    "      the required version of '$(REQUIRED_ANT_VER)'. \n" \
	    "      The version of ant found was '$(ANT_VER)'. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check the findbugs version
######################################################
FINDBUGS_CHECK :=$(call CheckVersions,$(FINDBUGS_VER),$(REQUIRED_FINDBUGS_VER))
sane-findbugs_version:
	@if [ "$(FINDBUGS_CHECK)" != "same" \
	      -a "$(FINDBUGS_CHECK)" != "newer" ]; then \
	  $(ECHO) "WARNING: The version of findbugs being used is older than \n" \
	    "      the required version of '$(REQUIRED_FINDBUGS_VER)'. \n" \
	    "      The version of findbugs found was '$(FINDBUGS_VER)'. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check the zip file version
######################################################
ZIP_CHECK :=$(call CheckVersions,$(ZIP_VER),$(REQUIRED_ZIP_VER))
sane-zip_version: sane-unzip_version
	@if [ "$(ZIP_CHECK)" != "same" -a "$(ZIP_CHECK)" != "newer" ]; then \
	  $(ECHO) "WARNING: The version of zip being used is older than \n" \
	    "      the required version of '$(REQUIRED_ZIP_VER)'. \n" \
	    "      The version of zip found was '$(ZIP_VER)'. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check the unzip file version
######################################################
UNZIP_CHECK :=$(call CheckVersions,$(UNZIP_VER),$(REQUIRED_UNZIP_VER))
sane-unzip_version:
	@if [ "$(UNZIP_CHECK)" != "same" -a "$(UNZIP_CHECK)" != "newer" ]; then \
	  $(ECHO) "WARNING: The version of unzip being used is older than \n" \
	    "      the required version of '$(REQUIRED_UNZIP_VER)'. \n" \
	    "      The version of unzip found was '$(UNZIP_VER)'. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check for windows DirectX sdk directory
######################################################
sane-dxsdk:
ifeq ($(PLATFORM), windows)
	@if [ ! -r $(DXSDK_INCLUDE_PATH)/d3d9.h  ]; then \
	$(ECHO) "ERROR: You do not have access to a valid DirectX SDK Include dir.\n" \
	  "      The value of DXSDK_INCLUDE_PATH must point a valid DX SDK dir.\n" \
	  "      Please check your access to \n" \
	  "          $(DXSDK_INCLUDE_PATH) \n" \
	  "      and/or check your value of ALT_DXSDK_PATH or ALT_DXSDK_INCLUDE_PATH.\n" \
	  "      Microsoft DirectX 9 SDK (Summer 2004 Update or newer) can be downloaded from the following location:\n" \
	  "          http://msdn.microsoft.com/library/default.asp?url=/downloads/list/directx.asp\n" \
	  "      Or  http://www.microsoft.com/directx\n" \
	  "" >> $(ERROR_FILE) ; \
	else \
	  if [ ! "$(DXSDK_VER)" = "$(REQUIRED_DXSDK_VER)" ]; then \
	  $(ECHO) "ERROR: The DirectX SDK must be version $(REQUIRED_DXSDK_VER).\n" \
	    "      $(YOU_ARE_USING) DirectX SDK version: $(DXSDK_VER)\n" \
	    "      The DirectX SDK was obtained from the following location: \n" \
	    "          $(DXSDK_PATH) \n" \
	    "      Please change your DirectX SDK. \n" \
	    "      Microsoft DirectX 9 SDK (Summer 2004 Update or newer) can be downloaded from the following location:\n" \
	    "          http://msdn.microsoft.com/library/default.asp?url=/downloads/list/directx.asp\n" \
	    "      Or  http://www.microsoft.com/directx\n" \
	    "" >> $(ERROR_FILE) ; \
	  else \
	    if [ -r $(DXSDK_INCLUDE_PATH)/basetsd.h ]; then \
              if [ `$(EGREP) -c __int3264 $(DXSDK_INCLUDE_PATH)/basetsd.h` -ne 0 ]; then \
	      $(ECHO) "WARNING: The DirectX SDK Include directory contains a newer basetsd.h,\n" \
		"      which may indicate that you're using an incorrect version of DirectX SDK.\n" \
		"      This may result in a build failure.\n" \
		"      The DirectX SDK Include dir was obtained from the following location:\n" \
		" 	  $(DXSDK_INCLUDE_PATH) \n" \
		"      Please change your DirectX SDK to version 9 (Summer 2004 Update or newer).\n" \
	        "      Microsoft DirectX 9 SDK can be downloaded from the following location:\n" \
	        "          http://msdn.microsoft.com/library/default.asp?url=/downloads/list/directx.asp\n" \
		"      Or  http://www.microsoft.com/directx\n" \
  		"" >> $(WARNING_FILE) ; \
	      fi \
	    fi \
	  fi \
	fi
endif

######################################################
# Check the linker version(s)
######################################################
ifeq ($(PLATFORM), windows)
  LINK_CHECK  :=$(call CheckVersions,$(LINK_VER),$(REQUIRED_LINK_VER))
endif
sane-link:
ifdef LINK_VER
	@if [ "$(LINK_CHECK)" = "missing" ]; then \
	  $(ECHO) "ERROR: The Linker version is undefined. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@if [ "$(LINK_CHECK)" != "same" ]; then \
	  $(ECHO) "WARNING: To build Java 2 SDK $(JDK_VERSION) you need : \n" \
	    "      $(COMPILER_VERSION) - link.exe version \"$(REQUIRED_LINK_VER)\" \n" \
	      "      Specifically the $(COMPILER_NAME) link.exe. \n " \
	    "      $(YOU_ARE_USING) Linker version \"$(LINK_VER)\" \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
endif

######################################################
# Check the compiler version(s)
######################################################
CC_CHECK  :=$(call CheckVersions,$(CC_VER),$(REQUIRED_CC_VER))
ifeq ($(PLATFORM), solaris)
  ifeq ($(ARCH_DATA_MODEL), 32)
    GCC_CHECK :=$(call CheckVersions,$(GCC_VER),$(REQUIRED_GCC_VER))
  endif
endif
sane-compiler: sane-link
	@if [ "$(CC_CHECK)" = "missing" ]; then \
	  $(ECHO) "ERROR: The Compiler version is undefined. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
ifndef OPENJDK
	@if [ "$(CC_CHECK)" != "same" ]; then \
	      $(ECHO) "WARNING: The $(PLATFORM) compiler is not version $(COMPILER_VERSION) $(REQUIRED_CC_VER) \n" \
	      "      Specifically the $(COMPILER_NAME) compiler. \n " \
	      "      $(YOU_ARE_USING) compiler version: $(CC_VER) \n" \
	      "      The compiler was obtained from the following location: \n" \
	      "          $(COMPILER_PATH) \n" \
	      "" >> $(WARNING_FILE) ; \
         fi
  ifdef GCC_CHECK
	  @if [ "$(GCC_CHECK)" != "same" ]; then \
	      $(ECHO) "WARNING: The $(PLATFORM) GCC compiler must be version $(REQUIRED_GCC_VER) \n" \
	      "      $(YOU_ARE_USING) compiler version: $(GCC_VER) \n" \
	      "      The compiler was obtained from the following location: \n" \
	      "          $(GCC_COMPILER_PATH) \n" \
	      "      Please change your compiler. \n" \
	      "" >> $(WARNING_FILE) ; \
	  fi
  endif
  ifeq ($(PLATFORM), windows)
    ifeq ($(ARCH_DATA_MODEL), 64)
      ifneq ($(COMPILER_VERSION), VS2005)
	@$(ECHO) "WARNING: Should be using VS2005 compiler on 64bit platform. \n" \
	    "" >> $(WARNING_FILE)
      endif
    endif
  endif
endif

######################################################
# Check that ALSA headers and libs are installed and 
# that the header has the right version. We only
# need /usr/include/alsa/*.h and /usr/lib/libasound.so
######################################################

ifdef ALSA_VERSION_CHECK
$(ALSA_VERSION_CHECK): $(ALSA_VERSION_CHECK).c
	@$(prep-target)
	@$(CC) -lasound -o $@ $<

$(ALSA_VERSION_CHECK).c:
	@$(prep-target)
	@$(ECHO) "#include <alsa/asoundlib.h>\n" \
                  "int main(char** argv, int argc) {\n" \
                   "  printf(\"%s\", SND_LIB_VERSION_STR);\n" \
                    "  return 0;\n" \
                    "}\n" \
                    > $@
endif

sane-alsa-versioncheck: $(ALSA_VERSION_CHECK)
sane-alsa-headers: sane-alsa-versioncheck
ifdef ALSA_VERSION_CHECK
	@if [ -f "$(ALSA_VERSION_CHECK)" ]; then \
	  if [ `$(ALSA_VERSION_CHECK) | $(EGREP) -c '$(REQUIRED_ALSA_VERSION)'` -ne 1 ] ; then \
	    $(ECHO) "ERROR: The ALSA version must be 0.9.1 or higher. \n" \
	      "      You have the following ALSA version installed: $(ALSA_VERSION) \n" \
	      "      Please reinstall ALSA (drivers and lib). You can download \n" \
	      "      the source distribution from http://www.alsa-project.org \n" \
	      "      or go to http://www.freshrpms.net/docs/alsa/ for precompiled RPM packages. \n" \
	      "" >> $(ERROR_FILE) ; \
	  fi \
	else \
	  $(ECHO) "ERROR: You seem to not have installed ALSA 0.9.1 or higher. \n" \
	  "      Please install ALSA (drivers and lib). You can download the \n" \
	  "      source distribution from http://www.alsa-project.org or go to \n" \
	  "      http://www.freshrpms.net/docs/alsa/ for precompiled RPM packages. \n" \
	  "" >> $(ERROR_FILE) ; \
	fi
endif

# If a sanity file doesn't exist, just make sure it's dir exists
$(SANITY_FILES):
	-@$(prep-target)

######################################################
# dump out the variable settings...
######################################################
sane-settings:: sane-alsa-versioncheck
	@$(ECHO)  >> $(MESSAGE_FILE)
	@$(ECHO) $(ALL_SETTINGS)  >> $(MESSAGE_FILE)
	@$(ECHO)  >> $(MESSAGE_FILE)

######################################################
# Check for existence of DEPLOY_MSSDK on windows
######################################################
sane-mssdk_path:
ifeq ($(PLATFORM), windows)
	@if [ -z "$(DEPLOY_MSSDK)" ]; then \
	  $(ECHO) "WARNING: Your DEPLOY_MSSDK setting is empty.\n" \
	    "        It is recommended to set ALT_DEPLOY_MSSDK.\n" \
	    "" >> $(WARNING_FILE) ; \
	fi
	@if [ ! -r "$(DEPLOY_MSSDK)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid DEPLOY_MSSDK setting. \n" \
	    "      Please check your access to \n" \
	    "          $(DEPLOY_MSSDK) \n" \
	    "      and/or check your value of ALT_DEPLOY_MSSDK. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif

######################################################
# Check for existence of INSTALL_MSSDK on windows
######################################################
sane-install-mssdk_path:
ifeq ($(PLATFORM), windows)
	@if [ -z "$(INSTALL_MSSDK)" ]; then \
	  $(ECHO) "WARNING: Your INSTALL_MSSDK setting is empty.\n" \
	    "        It is recommended to set ALT_INSTALL_MSSDK.\n" \
	    "" >> $(WARNING_FILE) ; \
	fi
	@if [ ! -r "$(INSTALL_MSSDK)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid INSTALL_MSSDK setting. \n" \
	    "      Please check your access to \n" \
	    "          $(INSTALL_MSSDK) \n" \
	    "      and/or check your value of ALT_INSTALL_MSSDK. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif

######################################################
# Check for existence of INSTALL_MSIVAL2 on windows
######################################################
sane-install-msival2_path:
ifeq ($(PLATFORM), windows)
	@if [ -z "$(INSTALL_MSIVAL2)" ]; then \
	  $(ECHO) "WARNING: Your INSTALL_MSIVAL2 setting is empty.\n" \
	    "        It is recommended to set ALT_INSTALL_MSIVAL2.\n" \
	    "" >> $(WARNING_FILE) ; \
	fi
	@if [ ! -r "$(INSTALL_MSIVAL2)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid INSTALL_MSIVAL2 setting. \n" \
	    "      Please check your access to \n" \
	    "          $(INSTALL_MSIVAL2) \n" \
	    "      and/or check your value of ALT_INSTALL_MSIVAL2. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif

######################################################
# Check the Solaris GNU c++ compiler for solaris plugin
######################################################
sane-gcc-compiler:
ifeq ($(PLATFORM), solaris)
  ifndef OPENJDK
    @if [ -r $(GCC_COMPILER_PATH) ]; then \
	  if [ ! "$(GCC_VER)" = 2.95.2 ]; then \
	    $(ECHO) "ERROR: The Solaris GCC compiler version must be 2.95.2. \n" \
	      "      You are using the following compiler version: $(GCC_VER) \n" \
	      "      The compiler was obtained from the following location: \n" \
	      "          $(GCC_COMPILER_PATH) \n" \
	      "      Please change your compiler. \n" \
	      "" >> $(ERROR_FILE) ; \
    fi \
	else \
	  $(ECHO) "ERROR: You do not have a valid GCC_COMPILER_PATH setting. \n" \
	    "      Please check your access to \n" \
	    "          $(GCC_COMPILER_PATH) \n" \
	    "      and/or check your value of ALT_GCC_COMPILER_PATH. \n" \
	    "      This will affect you if you build the plugin target. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif

  ifeq ($(PLATFORM), linux)
    ifdef ALT_GCC29_COMPILER_PATH
	@if [ ! -x $(ALT_GCC29_COMPILER_PATH)/bin/gcc ]; then \
 	    $(ECHO) "ERROR: You do not have a valid ALT_GCC29_COMPILER_PATH setting. \n" \
	         "      Please check your access to \n" \
	         "      $(ALT_GCC29_COMPILER_PATH)/bin/gcc \n" \
	         "      This will affect you if you build the plugin target. \n" \
	         "" >> $(ERROR_FILE) ; \
    fi
    endif
    ifdef ALT_GCC29_PLUGIN_LIB_PATH
	@if [ ! -r $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so ]; then \
	    $(ECHO) "Error: You do not have a valid ALT_GCC29_PLUGIN_LIB_PATH setting. \n" \
		        " Please check your access to \n" \
		        " $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so \n" \
		        " This will affect you if you build the plugin target, specifically for gcc 2.9 version of OJI plugin library. \n" \
		        "" >> $(ERROR_FILE) ; \
	fi
    else
	@if [ ! -r $(GCC29_COMPILER_PATH) ]; then \
	    $(ECHO) "ERROR: You do not have a valid GCC29_COMPILER_PATH setting. \n" \
	    	    " Please check your access to \n" \
	    	    " $(GCC29_COMPILER_PATH) \n" \
	    	    " and/or check your value of ALT_GCC29_COMPILER_PATH. \n" \
	    	    " This will affect you if you build the plugin target. \n" \
	    	    "" >> $(ERROR_FILE) ; \
	fi
    endif
  endif
endif


######################################################
# MOZILLA_HEADERS_PATH must be valid
######################################################
sane-mozilla:
ifeq ($(ARCH_DATA_MODEL), 32)
  ifdef ALT_MOZILLA_HEADERS_PATH
	@if [ `$(ECHO) $(subst \,/,$(ALT_MOZILLA_HEADERS_PATH)) | $(EGREP) -ci '^([a-z]:)?/'` -ne 1 ]; then \
	  $(ECHO) "ERROR: ALT_MOZILLA_HEADERS_PATH must be an Absolute Path Name, \n" \
	    "      not a Relative Path Name. \n" \
	    "      The current value of ALT_MOZILLA_HEADERS_PATH is \n" \
	    "          $(ALT_MOZILLA_HEADERS_PATH) \n" \
	    "      Please fix this and continue your build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
	@#
	@# MOZILLA_HEADERS_PATH must be valid....
	@#
  ifeq ($(PLATFORM), windows)
	@if [ ! -r $(subst \,/,$(MOZILLA_HEADERS_PATH))/mozilla_headers_18.win32/java/bool.h ]; then \
	  $(ECHO) "ERROR: You do not have access to valid Mozilla header files. \n" \
	    "      Please check your access to \n" \
	    "          $(subst \,/,$(MOZILLA_HEADERS_PATH))/mozilla_headers_18.win32/java/bool.h \n" \
	    "      and/or check your value of ALT_JDK_DEVTOOLS_DIR, ALT_MOZILLA_HEADERS_PATH, \n" \
	    "	   and on Windows, ALT_JDK_JAVA_DRIVE. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  else
	@if [ ! -r $(subst \,/,$(MOZILLA_HEADERS_PATH))/mozilla_headers_18/java/bool.h ]; then \
	  $(ECHO) "ERROR: You do not have access to valid Mozilla header files. \n" \
	    "      Please check your access to \n" \
	    "          $(subst \,/,$(MOZILLA_HEADERS_PATH))/mozilla_headers_18/java/bool.h \n" \
	    "      and/or check your value of ALT_JDK_DEVTOOLS_DIR, ALT_MOZILLA_HEADERS_PATH, \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
endif


######################################################
# SECURITY_BASELINE_142 test
######################################################
security_baseline_142:
ifeq ($(PLATFORM), windows)
	@if [ -z "$(SECURITY_BASELINE_142)" ]; then \
	    $(ECHO) "WARNING: Your SECURITY_BASELINE_142 setting is empty.\n" \
		"        Setting it to the default value of 1.4.2_10.\n" \
		"        It is recommended to set SECURITY_BASELINE_142.\n" \
		"" >> $(WARNING_FILE) ; \
	fi
endif

######################################################
# SECURITY_BASELINE_150 test
######################################################
security_baseline_150:
ifeq ($(PLATFORM), windows)
	@if [ -z "$(SECURITY_BASELINE_150)" ]; then \
	    $(ECHO) "WARNING: Your SECURITY_BASELINE_150 setting is empty.\n" \
		"        Setting it to the default value of 1.5.0_07.\n" \
		"        It is recommended to set SECURITY_BASELINE_150.\n" \
		"" >> $(WARNING_FILE) ; \
	fi
endif


######################################################
# this should be the last rule in any target's sanity rule.
######################################################
sane-lastrule:
ifndef EXTERNALSANITYCONTROL
	@if [ -r $(MESSAGE_FILE) ]; then \
	  $(CAT) $(MESSAGE_FILE) ; \
	fi
	@if [ -r $(WARNING_FILE) ]; then \
	  $(CAT) $(WARNING_FILE) ; \
	fi
	@if [ "x$(INSANE)" != x ]; then \
	  $(ECHO) "INSANE mode requested. \n" \
	    "Sanity will not force a build termination, even with errors.\n" \
	    "" >> $(ERROR_FILE); \
	fi
	@if [ -r $(ERROR_FILE) ]; then \
	  if [ "x$(INSANE)" = x ]; then \
	    $(ECHO) "Exiting because of the above error(s). \n" \
	      "">> $(ERROR_FILE); \
	  fi ; \
	  $(CAT) $(ERROR_FILE) ; \
	  if [ "x$(INSANE)" = x ]; then \
	    exit 1 ; \
	  fi ; \
	fi
ifdef PEDANTIC
	@if [ -r $(WARNING_FILE) ]; then \
	  $(ECHO) "PEDANTIC mode requested. \n" \
	    "Exiting because of the above warning(s). \n" \
	    "" >> $(ERROR_FILE); \
	  $(CAT) $(ERROR_FILE) ; \
	  exit 1 ; \
	fi
endif # PEDANTIC
	@if [ ! -r $(ERROR_FILE) ]; then \
	  $(ECHO) "Sanity check passed." ; \
	fi
endif #  EXTERNALSANITYCONTROL