head	1.195;
access;
symbols
	gcc-2_8_1-990325:1.195
	gcc-2_8_1-990319:1.195
	gcc-2_8_1-990302:1.195
	gcc_2_8_1-990302:1.195
	gcc_2_8_1-990222:1.195
	gcc-2_8_1-990109:1.195
	gcc-2_8_1-981210:1.195
	gcc-2_8_1-981208:1.195
	gcc-2_8_1-980929:1.195
	gcc_2_8_1-980929:1.195
	gcc-2_8_1-980928:1.195
	gcc-2_8_1-980813:1.195
	gcc-2_8_1-980811:1.195
	gcc-2_8_1-980718:1.195
	gcc-2_8_1-980705:1.195
	gcc-2_8_1-980627:1.195
	gcc-2_8_1-980609:1.195
	gcc-2_8_1-980608:1.195
	gcc-2_8_1-980529:1.195
	gcc-2_8_1-980525:1.195
	gcc-2_8_1-980513:1.195
	gcc-2_8_1-980502:1.195
	gcc-2_8_1-980402:1.195
	gcc-2_8_1-980426:1.195
	gcc-2_8_1-980419:1.193
	gcc-2_8_1-980413:1.193
	gcc-2_8_1-980412:1.192
	gcc-2_8_1-980407:1.192
	gcc-2_8_1-980401:1.192
	gcc_2_8_1-980315:1.192
	gcc-2_8_1-RELEASE:1.192;
locks; strict;
comment	@# @;


1.195
date	98.04.19.23.01.45;	author kenner;	state Exp;
branches;
next	1.194;

1.194
date	98.04.19.22.46.54;	author kenner;	state Exp;
branches;
next	1.193;

1.193
date	98.04.12.14.02.39;	author kenner;	state Exp;
branches;
next	1.192;

1.192
date	98.02.26.20.02.28;	author kenner;	state Exp;
branches;
next	1.191;

1.191
date	98.02.26.10.49.26;	author kenner;	state Exp;
branches;
next	1.190;

1.190
date	98.02.18.14.37.16;	author kenner;	state Exp;
branches;
next	1.189;

1.189
date	98.02.03.18.54.29;	author kenner;	state Exp;
branches;
next	1.188;

1.188
date	97.12.23.00.16.50;	author kenner;	state Exp;
branches;
next	1.187;

1.187
date	97.10.01.20.13.46;	author bkoz;	state Exp;
branches;
next	1.186;

1.186
date	97.09.02.17.43.57;	author ian;	state Exp;
branches;
next	1.185;

1.185
date	97.06.13.23.35.55;	author brendan;	state Exp;
branches;
next	1.184;

1.184
date	97.06.03.23.19.01;	author brendan;	state Exp;
branches;
next	1.183;

1.183
date	97.04.18.22.25.17;	author wilson;	state Exp;
branches;
next	1.182;

1.182
date	97.02.27.17.12.40;	author ian;	state Exp;
branches;
next	1.181;

1.181
date	97.02.24.23.29.09;	author brendan;	state Exp;
branches;
next	1.180;

1.180
date	97.01.27.15.59.05;	author law;	state Exp;
branches;
next	1.179;

1.179
date	96.11.21.19.29.37;	author ian;	state Exp;
branches;
next	1.178;

1.178
date	96.10.02.21.30.23;	author ian;	state Exp;
branches;
next	1.177;

1.177
date	96.09.30.21.19.11;	author ian;	state Exp;
branches;
next	1.176;

1.176
date	96.09.30.17.21.03;	author ian;	state Exp;
branches;
next	1.175;

1.175
date	96.09.24.12.00.06;	author kenner;	state Exp;
branches;
next	1.174;

1.174
date	96.08.13.22.30.02;	author ian;	state Exp;
branches;
next	1.173;

1.173
date	96.06.07.07.32.54;	author bothner;	state Exp;
branches;
next	1.172;

1.172
date	96.05.22.21.49.25;	author wilson;	state Exp;
branches;
next	1.171;

1.171
date	96.04.15.21.39.45;	author ian;	state Exp;
branches;
next	1.170;

1.170
date	96.04.01.22.00.44;	author ian;	state Exp;
branches;
next	1.169;

1.169
date	96.03.05.23.37.33;	author kenner;	state Exp;
branches;
next	1.168;

1.168
date	96.02.15.13.27.48;	author kenner;	state Exp;
branches;
next	1.167;

1.167
date	96.02.13.23.26.57;	author kenner;	state Exp;
branches;
next	1.166;

1.166
date	96.01.11.16.28.49;	author dje;	state Exp;
branches;
next	1.165;

1.165
date	95.12.16.12.03.25;	author kenner;	state Exp;
branches;
next	1.164;

1.164
date	95.12.15.23.41.43;	author kenner;	state Exp;
branches;
next	1.163;

1.163
date	95.11.26.19.22.56;	author kenner;	state Exp;
branches;
next	1.162;

1.162
date	95.11.05.16.05.35;	author kenner;	state Exp;
branches;
next	1.161;

1.161
date	95.10.19.22.56.08;	author kenner;	state Exp;
branches;
next	1.160;

1.160
date	95.09.12.17.55.04;	author kenner;	state Exp;
branches;
next	1.159;

1.159
date	95.09.12.16.42.15;	author kenner;	state Exp;
branches;
next	1.158;

1.158
date	95.07.31.18.33.04;	author ian;	state Exp;
branches;
next	1.157;

1.157
date	95.06.26.22.52.27;	author kenner;	state Exp;
branches;
next	1.156;

1.156
date	95.06.19.22.34.46;	author kenner;	state Exp;
branches;
next	1.155;

1.155
date	95.06.11.17.38.42;	author kenner;	state Exp;
branches;
next	1.154;

1.154
date	95.05.26.21.01.15;	author kenner;	state Exp;
branches;
next	1.153;

1.153
date	95.05.25.21.37.38;	author kenner;	state Exp;
branches;
next	1.152;

1.152
date	95.05.25.21.35.55;	author kenner;	state Exp;
branches;
next	1.151;

1.151
date	95.04.02.12.22.56;	author kenner;	state Exp;
branches;
next	1.150;

1.150
date	95.03.10.17.02.02;	author ian;	state Exp;
branches;
next	1.149;

1.149
date	95.03.03.17.10.48;	author ian;	state Exp;
branches;
next	1.148;

1.148
date	95.02.06.16.51.48;	author ian;	state Exp;
branches;
next	1.147;

1.147
date	95.02.02.20.49.40;	author ian;	state Exp;
branches;
next	1.146;

1.146
date	95.01.25.23.17.02;	author wilson;	state Exp;
branches;
next	1.145;

1.145
date	94.12.14.16.42.18;	author ian;	state Exp;
branches;
next	1.144;

1.144
date	94.11.15.00.14.54;	author kenner;	state Exp;
branches;
next	1.143;

1.143
date	94.11.10.23.37.50;	author kenner;	state Exp;
branches;
next	1.142;

1.142
date	94.10.14.15.56.20;	author ian;	state Exp;
branches;
next	1.141;

1.141
date	94.09.28.18.31.04;	author ian;	state Exp;
branches;
next	1.140;

1.140
date	94.09.22.15.38.17;	author ian;	state Exp;
branches;
next	1.139;

1.139
date	94.09.21.15.33.52;	author ian;	state Exp;
branches;
next	1.138;

1.138
date	94.09.20.16.22.36;	author ian;	state Exp;
branches;
next	1.137;

1.137
date	94.08.19.16.01.48;	author ian;	state Exp;
branches;
next	1.136;

1.136
date	94.08.03.15.13.59;	author ian;	state Exp;
branches;
next	1.135;

1.135
date	94.07.19.00.54.49;	author ian;	state Exp;
branches;
next	1.134;

1.134
date	94.06.30.20.08.45;	author ian;	state Exp;
branches;
next	1.133;

1.133
date	94.06.23.17.48.38;	author ian;	state Exp;
branches;
next	1.132;

1.132
date	94.06.18.21.51.42;	author merrill;	state Exp;
branches;
next	1.131;

1.131
date	94.06.17.19.06.33;	author ian;	state Exp;
branches;
next	1.130;

1.130
date	94.06.16.14.59.50;	author ian;	state Exp;
branches;
next	1.129;

1.129
date	94.06.14.20.01.08;	author ian;	state Exp;
branches;
next	1.128;

1.128
date	94.05.26.22.37.59;	author ian;	state Exp;
branches;
next	1.127;

1.127
date	94.05.26.15.50.35;	author ian;	state Exp;
branches;
next	1.126;

1.126
date	94.05.19.19.09.56;	author ian;	state Exp;
branches;
next	1.125;

1.125
date	94.05.18.22.33.40;	author merrill;	state Exp;
branches;
next	1.124;

1.124
date	94.05.12.22.51.00;	author bill;	state Exp;
branches;
next	1.123;

1.123
date	94.05.11.16.12.15;	author ian;	state Exp;
branches;
next	1.122;

1.122
date	94.04.04.21.21.02;	author merrill;	state Exp;
branches;
next	1.121;

1.121
date	94.04.01.05.58.23;	author wilson;	state Exp;
branches;
next	1.120;

1.120
date	94.03.14.21.55.07;	author ian;	state Exp;
branches;
next	1.119;

1.119
date	94.02.26.18.07.52;	author dje;	state Exp;
branches;
next	1.118;

1.118
date	94.02.22.16.03.44;	author ian;	state Exp;
branches;
next	1.117;

1.117
date	94.02.19.19.26.35;	author ian;	state Exp;
branches;
next	1.116;

1.116
date	94.02.16.05.55.34;	author ian;	state Exp;
branches;
next	1.115;

1.115
date	94.02.15.22.03.40;	author ian;	state Exp;
branches;
next	1.114;

1.114
date	94.02.13.22.08.06;	author ian;	state Exp;
branches;
next	1.113;

1.113
date	94.02.09.00.10.31;	author wilson;	state Exp;
branches;
next	1.112;

1.112
date	93.12.28.03.15.25;	author ian;	state Exp;
branches;
next	1.111;

1.111
date	93.12.23.23.50.50;	author wilson;	state Exp;
branches;
next	1.110;

1.110
date	93.12.22.02.09.32;	author kenner;	state Exp;
branches;
next	1.109;

1.109
date	93.12.16.16.36.22;	author ian;	state Exp;
branches;
next	1.108;

1.108
date	93.12.03.11.41.47;	author kenner;	state Exp;
branches;
next	1.107;

1.107
date	93.12.02.12.06.58;	author kenner;	state Exp;
branches;
next	1.106;

1.106
date	93.11.21.06.54.47;	author rms;	state Exp;
branches;
next	1.105;

1.105
date	93.11.19.20.18.50;	author rms;	state Exp;
branches;
next	1.104;

1.104
date	93.11.18.00.15.24;	author kenner;	state Exp;
branches;
next	1.103;

1.103
date	93.11.11.08.20.12;	author rms;	state Exp;
branches;
next	1.102;

1.102
date	93.11.10.06.29.05;	author rms;	state Exp;
branches;
next	1.101;

1.101
date	93.11.09.23.53.36;	author rms;	state Exp;
branches;
next	1.100;

1.100
date	93.11.02.19.33.52;	author ian;	state Exp;
branches;
next	1.99;

1.99
date	93.11.02.19.26.16;	author rms;	state Exp;
branches;
next	1.98;

1.98
date	93.11.02.04.15.40;	author rms;	state Exp;
branches;
next	1.97;

1.97
date	93.11.01.20.19.12;	author ian;	state Exp;
branches;
next	1.96;

1.96
date	93.10.27.18.15.53;	author rms;	state Exp;
branches;
next	1.95;

1.95
date	93.10.26.17.03.37;	author rms;	state Exp;
branches;
next	1.94;

1.94
date	93.10.25.21.05.29;	author rms;	state Exp;
branches;
next	1.93;

1.93
date	93.10.25.17.57.20;	author rms;	state Exp;
branches;
next	1.92;

1.92
date	93.10.21.15.13.39;	author ian;	state Exp;
branches;
next	1.91;

1.91
date	93.10.21.08.36.14;	author rms;	state Exp;
branches;
next	1.90;

1.90
date	93.10.14.01.47.52;	author kenner;	state Exp;
branches;
next	1.89;

1.89
date	93.10.12.19.51.26;	author rms;	state Exp;
branches;
next	1.88;

1.88
date	93.10.12.18.02.38;	author kenner;	state Exp;
branches;
next	1.87;

1.87
date	93.10.11.19.36.17;	author ian;	state Exp;
branches;
next	1.86;

1.86
date	93.10.11.19.20.40;	author ian;	state Exp;
branches;
next	1.85;

1.85
date	93.10.10.02.50.18;	author rms;	state Exp;
branches;
next	1.84;

1.84
date	93.10.10.02.46.12;	author rms;	state Exp;
branches;
next	1.83;

1.83
date	93.09.29.21.25.02;	author dje;	state Exp;
branches;
next	1.82;

1.82
date	93.09.28.22.54.25;	author wilson;	state Exp;
branches;
next	1.81;

1.81
date	93.09.28.22.41.21;	author wilson;	state Exp;
branches;
next	1.80;

1.80
date	93.09.08.19.10.46;	author wilson;	state Exp;
branches;
next	1.79;

1.79
date	93.08.11.13.22.45;	author ian;	state Exp;
branches;
next	1.78;

1.78
date	93.07.24.22.03.22;	author bothner;	state Exp;
branches;
next	1.77;

1.77
date	93.07.21.21.04.54;	author wilson;	state Exp;
branches;
next	1.76;

1.76
date	93.07.15.17.05.38;	author rms;	state Exp;
branches;
next	1.75;

1.75
date	93.07.14.23.23.58;	author rms;	state Exp;
branches;
next	1.74;

1.74
date	93.07.14.23.15.19;	author rms;	state Exp;
branches;
next	1.73;

1.73
date	93.07.10.19.06.09;	author rms;	state Exp;
branches;
next	1.72;

1.72
date	93.07.01.19.06.50;	author eggert;	state Exp;
branches;
next	1.71;

1.71
date	93.07.01.18.15.17;	author eggert;	state Exp;
branches;
next	1.70;

1.70
date	93.07.01.07.46.15;	author eggert;	state Exp;
branches;
next	1.69;

1.69
date	93.06.30.17.13.09;	author rms;	state Exp;
branches;
next	1.68;

1.68
date	93.06.28.18.58.14;	author rms;	state Exp;
branches;
next	1.67;

1.67
date	93.06.14.21.48.40;	author rms;	state Exp;
branches;
next	1.66;

1.66
date	93.06.01.08.14.22;	author rms;	state Exp;
branches;
next	1.65;

1.65
date	93.05.20.19.06.46;	author rms;	state Exp;
branches;
next	1.64;

1.64
date	93.05.18.19.32.56;	author rms;	state Exp;
branches;
next	1.63;

1.63
date	93.05.11.04.40.17;	author rms;	state Exp;
branches;
next	1.62;

1.62
date	93.05.09.21.55.04;	author rms;	state Exp;
branches;
next	1.61;

1.61
date	93.05.06.19.59.56;	author ian;	state Exp;
branches;
next	1.60;

1.60
date	93.05.05.18.12.35;	author ian;	state Exp;
branches;
next	1.59;

1.59
date	93.04.30.16.00.15;	author ian;	state Exp;
branches;
next	1.58;

1.58
date	93.04.09.19.12.20;	author ian;	state Exp;
branches;
next	1.57;

1.57
date	93.03.28.07.46.33;	author rms;	state Exp;
branches;
next	1.56;

1.56
date	93.03.24.21.10.11;	author rms;	state Exp;
branches;
next	1.55;

1.55
date	93.03.22.23.30.13;	author ian;	state Exp;
branches;
next	1.54;

1.54
date	93.03.11.04.53.06;	author rms;	state Exp;
branches;
next	1.53;

1.53
date	93.02.21.00.14.46;	author rms;	state Exp;
branches;
next	1.52;

1.52
date	93.02.20.15.39.27;	author hassey;	state Exp;
branches;
next	1.51;

1.51
date	93.02.20.08.17.28;	author dje;	state Exp;
branches;
next	1.50;

1.50
date	93.02.17.23.21.42;	author rms;	state Exp;
branches;
next	1.49;

1.49
date	93.02.11.18.49.37;	author kenner;	state Exp;
branches;
next	1.48;

1.48
date	93.02.09.19.05.03;	author brendan;	state Exp;
branches;
next	1.47;

1.47
date	93.01.26.23.26.23;	author wilson;	state Exp;
branches;
next	1.46;

1.46
date	93.01.26.23.19.35;	author wilson;	state Exp;
branches;
next	1.45;

1.45
date	93.01.12.07.53.32;	author rms;	state Exp;
branches;
next	1.44;

1.44
date	93.01.11.22.21.52;	author wilson;	state Exp;
branches;
next	1.43;

1.43
date	93.01.07.22.35.20;	author wilson;	state Exp;
branches;
next	1.42;

1.42
date	93.01.06.10.54.53;	author rms;	state Exp;
branches;
next	1.41;

1.41
date	93.01.06.10.11.52;	author rms;	state Exp;
branches;
next	1.40;

1.40
date	93.01.06.03.01.33;	author wilson;	state Exp;
branches;
next	1.39;

1.39
date	93.01.05.02.11.29;	author rms;	state Exp;
branches;
next	1.38;

1.38
date	93.01.04.21.55.03;	author wilson;	state Exp;
branches;
next	1.37;

1.37
date	93.01.02.00.48.41;	author wilson;	state Exp;
branches;
next	1.36;

1.36
date	92.12.30.07.14.58;	author rms;	state Exp;
branches;
next	1.35;

1.35
date	92.12.05.00.49.52;	author wood;	state Exp;
branches;
next	1.34;

1.34
date	92.12.03.06.40.00;	author wilson;	state Exp;
branches;
next	1.33;

1.33
date	92.11.27.04.27.21;	author rms;	state Exp;
branches;
next	1.32;

1.32
date	92.11.26.17.27.01;	author rms;	state Exp;
branches;
next	1.31;

1.31
date	92.11.20.23.26.34;	author rms;	state Exp;
branches;
next	1.30;

1.30
date	92.11.08.19.54.50;	author rms;	state Exp;
branches;
next	1.29;

1.29
date	92.11.08.18.57.20;	author rms;	state Exp;
branches;
next	1.28;

1.28
date	92.10.23.07.30.01;	author rms;	state Exp;
branches;
next	1.27;

1.27
date	92.10.13.20.53.10;	author rms;	state Exp;
branches;
next	1.26;

1.26
date	92.09.19.04.43.29;	author rms;	state Exp;
branches;
next	1.25;

1.25
date	92.09.16.01.16.41;	author wilson;	state Exp;
branches;
next	1.24;

1.24
date	92.09.03.08.55.41;	author rms;	state Exp;
branches;
next	1.23;

1.23
date	92.08.18.04.19.17;	author rms;	state Exp;
branches;
next	1.22;

1.22
date	92.08.14.05.12.31;	author rms;	state Exp;
branches;
next	1.21;

1.21
date	92.08.01.18.11.28;	author rms;	state Exp;
branches;
next	1.20;

1.20
date	92.07.29.04.46.29;	author rms;	state Exp;
branches;
next	1.19;

1.19
date	92.07.29.04.44.02;	author rms;	state Exp;
branches;
next	1.18;

1.18
date	92.07.25.08.34.46;	author rms;	state Exp;
branches;
next	1.17;

1.17
date	92.07.21.17.47.35;	author rms;	state Exp;
branches;
next	1.16;

1.16
date	92.07.12.21.33.47;	author rms;	state Exp;
branches;
next	1.15;

1.15
date	92.07.09.06.20.53;	author rms;	state Exp;
branches;
next	1.14;

1.14
date	92.07.04.17.16.10;	author mycroft;	state Exp;
branches;
next	1.13;

1.13
date	92.06.25.04.03.11;	author rms;	state Exp;
branches;
next	1.12;

1.12
date	92.06.24.20.21.08;	author rms;	state Exp;
branches;
next	1.11;

1.11
date	92.06.11.23.15.09;	author rms;	state Exp;
branches;
next	1.10;

1.10
date	92.06.11.21.05.39;	author rms;	state Exp;
branches;
next	1.9;

1.9
date	92.05.28.22.48.16;	author rms;	state Exp;
branches;
next	1.8;

1.8
date	92.05.27.21.31.00;	author wilson;	state Exp;
branches;
next	1.7;

1.7
date	92.05.20.00.10.41;	author wilson;	state Exp;
branches;
next	1.6;

1.6
date	92.05.19.19.28.45;	author tege;	state Exp;
branches;
next	1.5;

1.5
date	92.05.07.06.35.35;	author rms;	state Exp;
branches;
next	1.4;

1.4
date	92.03.30.01.50.51;	author rms;	state Exp;
branches;
next	1.3;

1.3
date	92.03.18.05.21.50;	author rms;	state Exp;
branches;
next	1.2;

1.2
date	92.03.07.20.39.54;	author djm;	state Exp;
branches;
next	1.1;

1.1
date	92.02.29.18.29.37;	author djm;	state Exp;
branches;
next	;


desc
@#! /bin/sh
@


1.195
log
@Special case more files which have C++ comments nested inside standard
C comments.
@
text
@#! /bin/sh
# Install modified versions of certain ANSI-incompatible system header files
# which are fixed to work correctly with ANSI C
# and placed in a directory that GNU C will search.

# See README-fixinc for more information.

# Directory containing the original header files.
# (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
INPUT=${2-${INPUT-/usr/include}}

# Directory in which to store the results.
LIB=${1?"fixincludes: output directory not specified"}

# Define what target system we're fixing.
if test -r ./Makefile; then
	target_canonical="`sed -n -e 's,^target[ 	]*=[ 	]*\(.*\)$,\1,p' < Makefile`"
	test -z "${target_canonical}" && target_canonical=unknown
else
	target_canonical=unknown
fi

# Define PWDCMD as a command to use to get the working dir
# in the form that we want.
PWDCMD=pwd
case "`pwd`" in
//*)
	# On an Apollo, discard everything before `/usr'.
	PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
	;;
esac

# Original directory.
ORIGDIR=`${PWDCMD}`

# Make sure it exists.
if [ ! -d $LIB ]; then
  mkdir $LIB || exit 1
fi

# Make LIB absolute only if needed to avoid problems with the amd.
case $LIB in
/*)
	;;
*)
	cd $LIB; LIB=`${PWDCMD}`
	;;
esac

# Fail if no arg to specify a directory for the output.
if [ x$1 = x ]
then echo fixincludes: no output directory specified
exit 1
fi

echo Building fixed headers in ${LIB}

# Determine whether this system has symbolic links.
if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
  rm -f $LIB/ShouldNotExist
  LINKS=true
elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
  rm -f /tmp/ShouldNotExist
  LINKS=true
else
  LINKS=false
fi

echo Finding directories and links to directories
cd ${INPUT}
# Find all directories and all symlinks that point to directories.
# Put the list in $files.
# Each time we find a symlink, add it to newdirs
# so that we do another find within the dir the link points to.
# Note that $files may have duplicates in it;
# later parts of this file are supposed to ignore them.
dirs="."
levels=2
while [ -n "$dirs" ] && [ $levels -gt 0 ]
do
    levels=`expr $levels - 1`
    newdirs=
    for d in $dirs
    do
	echo " Searching $INPUT/$d"

	# Find all directories under $d, relative to $d, excluding $d itself.
	# (The /. is needed after $d in case $d is a symlink.)
        files="$files `find $d/. -type d -print | \
		       sed -e '/\/\.$/d' -e 's@@/./@@/@@g'`"
	# Find all links to directories.
	# Using `-exec test -d' in find fails on some systems,
	# and trying to run test via sh fails on others,
	# so this is the simplest alternative left.
	# First find all the links, then test each one.
	theselinks=
	$LINKS && \
	  theselinks=`find $d/. -type l -print | sed -e 's@@/./@@/@@g'`
	for d1 in $theselinks --dummy--
	do
	    # If the link points to a directory,
	    # add that dir to $newdirs
	    if [ -d $d1 ]
	    then
		files="$files $d1"
		if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
		then
		    newdirs="$newdirs $d1"
		fi
	    fi
	done
    done

    dirs="$newdirs"
done

dirs=
echo "All directories (including links to directories):"
echo $files

for file in $files; do
  rm -rf $LIB/$file
  if [ ! -d $LIB/$file ]
  then mkdir $LIB/$file
  fi
done
mkdir $LIB/root

# treetops gets an alternating list
# of old directories to copy
# and the new directories to copy to.
treetops="${INPUT} ${LIB}"

if $LINKS; then
  echo 'Making symbolic directory links'
  for file in $files; do
    dest=`ls -ld $file | sed -n 's/.*-> //p'`
    if [ "$dest" ]; then    
      cwd=`${PWDCMD}`
      # In case $dest is relative, get to $file's dir first.
      cd ${INPUT}
      cd `echo ./$file | sed -n 's&[^/]*$&&p'`
      # Check that the target directory exists.
      # Redirections changed to avoid bug in sh on Ultrix.
      (cd $dest) > /dev/null 2>&1
      if [ $? = 0 ]; then
	cd $dest
	# X gets the dir that the link actually leads to.
	x=`${PWDCMD}`
	# Canonicalize ${INPUT} now to minimize the time an
	# automounter has to change the result of ${PWDCMD}.
	cinput=`cd ${INPUT}; ${PWDCMD}`
	# If a link points to ., make a similar link to .
	if [ $x = ${cinput} ]; then
	  echo $file '->' . ': Making link'
	  rm -fr ${LIB}/$file > /dev/null 2>&1
	  ln -s . ${LIB}/$file > /dev/null 2>&1
	# If link leads back into ${INPUT},
	# make a similar link here.
	elif expr $x : "${cinput}/.*" > /dev/null; then
	  # Y gets the actual target dir name, relative to ${INPUT}.
	  y=`echo $x | sed -n "s&${cinput}/&&p"`
	  # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
	  dots=`echo "$file" |
	    sed -e 's@@^./@@@@' -e 's@@/./@@/@@g' -e 's@@[^/][^/]*@@..@@g' -e 's@@..$@@@@'`
	  echo $file '->' $dots$y ': Making link'
	  rm -fr ${LIB}/$file > /dev/null 2>&1
	  ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
	else
	  # If the link is to a dir $target outside ${INPUT},
	  # repoint the link at ${INPUT}/root$target
	  # and process $target into ${INPUT}/root$target
	  # treat this directory as if it actually contained the files.
	  echo $file '->' root$x ': Making link'
	  if [ -d $LIB/root$x ]
	  then true
	  else
	    dirname=root$x/
	    dirmade=.
	    cd $LIB
	    while [ x$dirname != x ]; do
	      component=`echo $dirname | sed -e 's|/.*$||'`
	      mkdir $component >/dev/null 2>&1
	      cd $component
	      dirmade=$dirmade/$component
	      dirname=`echo $dirname | sed -e 's|[^/]*/||'`
	    done
	  fi
	  # Duplicate directory structure created in ${LIB}/$file in new
	  # root area.
	  for file2 in $files; do
	    case $file2 in
	      $file/*)
		dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
		echo "Duplicating ${file}'s ${dupdir}"
		if [ -d ${dupdir} ]
		then true
		else
		  mkdir ${dupdir}
		fi
		;;
	      *)
		;;
	    esac
          done
	  # Get the path from ${LIB} to $file, accounting for symlinks.
	  parent=`echo "$file" | sed -e 's@@/[^/]*$@@@@'`
	  libabs=`cd ${LIB}; ${PWDCMD}`
	  file2=`cd ${LIB}; cd $parent; ${PWDCMD} | sed -e "s@@^${libabs}@@@@"`
	  # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
	  dots=`echo "$file2" | sed -e 's@@/[^/]*@@../@@g'`
	  rm -fr ${LIB}/$file > /dev/null 2>&1
	  ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
	  treetops="$treetops $x ${LIB}/root$x"
	fi
      fi
      cd $cwd
    fi
  done
fi

required=
set x $treetops
shift
while [ $# != 0 ]; do
  # $1 is an old directory to copy, and $2 is the new directory to copy to.
  cd ${INPUT}
  cd $1
# The same dir can appear more than once in treetops.
# There's no need to scan it more than once.
  if [ -f $2/DONE ]
  then
    files=
  else
    touch $2/DONE
    echo Fixing directory $1 into $2
# Check .h files which are symlinks as well as those which are files.
# A link to a header file will not be processed by anything but this.
    if $LINKS; then
      files=`find . -name '*.h' \( -type f -o -type l \) -print`
    else
      files=`find . -name '*.h' -type f -print`
    fi
    echo Checking header files
  fi
# Note that BSD43_* are used on recent MIPS systems.
  for file in $files; do
# This call to egrep is essential, since checking a file with egrep
# is much faster than actually trying to fix it.
# It is also essential that most files *not* match!
# Thus, matching every #endif is unacceptable.
# But the argument to egrep must be kept small, or many versions of egrep
# won't be able to handle it.
#
# We use the pattern [!-.0-z{|}~] instead of [^/ 	] to match a noncomment
# following #else or #endif because some buggy egreps think [^/] matches
# newline, and they thus think `#else ' matches `#e[ndiflse]*[ 	]+[^/ 	]'.
# [!-.0-~] does not work properly on AIX 4.1.
#
# We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
# following #if or #elif that is not surrounded by __.  The `a-ce-km-z'
# in this pattern lacks `d' and `l'; this means we don't worry about
# identifiers starting with `d' or `l'.  This is OK, since none of the
# identifiers below start with `d' or `l'.  It also greatly improves
# performance, since many files contain lines of the form `#if ... defined ...'
# or `#if lint'.
    if egrep '//|[ 	_]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ 	]+[!-.0-z\{\|\}\~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-zA-Z][a-zA-Z0-9]' $file >/dev/null; then
      if [ -r $file ]; then
	cp $file $2/$file >/dev/null 2>&1	\
	|| echo "Can't copy $file"
	chmod +w $2/$file
	chmod a+r $2/$file
	# The fixinc_eol stuff is to work around a bug in the sed
	# program on HP/UX 10.20.
	# Here is how the sed commands in braces work.
	# (It doesn't work to put the comments inside the sed commands.)
		# Surround each word with spaces, to simplify matching below.
		# ANSIfy each pre-ANSI machine-dependent symbol
		# by surrounding it with __ __.
		# Remove the spaces that we inserted around each word.
	sed -e '
				   :loop
	  /\\$/			N
 	  s/\\$/\\*fixinc_eol*/
	  /\\$/			b loop
	  s/\\\*fixinc_eol\*/\\/g
	  s%^\([ 	]*#[ 	]*else\)[ 	]*/[^*].*%\1%
	  s%^\([ 	]*#[ 	]*else\)[ 	]*[^/ 	].*%\1%
	  s%^\([ 	]*#[ 	]*endif\)[ 	]*/[^*].*%\1%
	  s%^\([ 	]*#[ 	]*endif\)[ 	]*\*[^/].*%\1%
	  s%^\([ 	]*#[ 	]*endif\)[ 	]*[^/* 	].*%\1%
	  /\/\/[^*]/			s|//\(.*\)$|/*\1*/|
	  /^[ 	]*\/\/[ 	]*/s///
	  /[ 	]_IO[A-Z]*[ 	]*(/	s/\(_IO[A-Z]*[ 	]*(\)\(.\),/\1'\''\2'\'',/
	  /[ 	]BSD43__IO[A-Z]*[ 	]*(/	s/(\(.\),/('\''\1'\'',/
	  /#[ 	]*define[ 	]*[ 	]_IO/			s/'\''\([cgxtf]\)'\''/\1/g
	  /#[ 	]*define[ 	]*[ 	]BSD43__IO/		s/'\''\([cgx]\)'\''/\1/g
	  /#[ 	]*define[ 	]*[ 	]DESIOC/		s/'\''\([cdgx]\)'\''/\1/g
	  /[^A-Z0-9_]CTRL[ 	]*(/		s/\([^'\'']\))/'\''\1'\'')/
	  /[^A-Z0-9]_CTRL[ 	]*(/		s/\([^'\'']\))/'\''\1'\'')/
	  /#[ 	]*define[ 	]*[ 	]CTRL/		s/'\''\([cgx]\)'\''/\1/g
	  /#[ 	]*define[ 	]*[ 	]_CTRL/		s/'\''\([cgx]\)'\''/\1/g
	  /#[ 	]*define.BSD43_CTRL/		s/'\''\([cgx]\)'\''/\1/g
	  /#[	 ]*[el]*if/{
		s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g

		s/ bsd4\([0-9]\) / __bsd4\1__ /g
		s/ _*host_mips / __host_mips__ /g
		s/ _*i386 / __i386__ /g
		s/ M32 / __M32__ /g
		s/ is68k / __is68k__ /g
		s/ m68k / __m68k__ /g
		s/ mc680\([0-9]\)0 / __mc680\10__ /g
		s/ m88k / __m88k__ /g
		s/ _*mips / __mips__ /g
		s/ news\([0-9]*\) / __news\1__ /g
		s/ ns32000 / __ns32000__ /g
		s/ pdp11 / __pdp11__ /g
		s/ pyr / __pyr__ /g
		s/ sel / __sel__ /g
		s/ sony_news / __sony_news__ /g
		s/ sparc / __sparc__ /g
		s/ sun\([a-z0-9]*\) / __sun\1__ /g
		s/ tahoe / __tahoe__ /g
		s/ tower\([_0-9]*\) / __tower\1__ /g
		s/ u370 / __u370__ /g
		s/ u3b\([0-9]*\) / __u3b\1__ /g
		s/ unix / __unix__ /g
		s/ vax / __vax__ /g
		s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
		s/ _*\([Rr][34]\)000 / __\1000__ /g
		s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g

		s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
	  }
	  /^#define.NULL[ 	]/	i\
		#undef NULL
	' $2/$file > $2/$file.
	mv $2/$file. $2/$file
	if cmp $file $2/$file >/dev/null 2>&1 \
	    || egrep 'This file is part of the GNU C Library' $2/$file >/dev/null 2>&1; then
	   rm $2/$file
	else
	   echo Fixed $file
	   # Find any include directives that use "file".
	   for include in `egrep '^[ 	]*#[ 	]*include[ 	]*"[^/]' $2/$file | sed -e 's/^[ 	]*#[ 	]*include[ 	]*"\([^"]*\)".*$/\1/'`; do
	      dir=`echo $file | sed -e s'|/[^/]*$||'`
	      required="$required $1 $dir/$include $2/$dir/$include"
	   done
	fi
      fi
    fi
  done
  shift; shift
done

cd ${INPUT}

# Install the proper definition of the three standard types in header files
# that they come from.
for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi

  if [ -r ${LIB}/$file ]; then
    echo Fixing size_t, ptrdiff_t and wchar_t in $file
    sed \
      -e '/^[ 	]*\*[ 	]*typedef unsigned int size_t;/N'	\
      -e 's/^\([ 	]*\*[ 	]*typedef unsigned int size_t;\n[ 	]*\*\/\)/\1\
#ifndef __SIZE_TYPE__\
#define __SIZE_TYPE__ long unsigned int\
#endif\
typedef __SIZE_TYPE__ size_t;\
/'	\
      -e '/typedef[ 	][ 	]*[a-z_][ 	a-z_]*[ 	]size_t/i\
#ifndef __SIZE_TYPE__\
#define __SIZE_TYPE__ long unsigned int\
#endif
' \
      -e 's/typedef[ 	][ 	]*[a-z_][ 	a-z_]*[ 	]size_t/typedef __SIZE_TYPE__ size_t/' \
      -e '/typedef[ 	][ 	]*[a-z_][ 	a-z_]*[ 	]ptrdiff_t/i\
#ifndef __PTRDIFF_TYPE__\
#define __PTRDIFF_TYPE__ long int\
#endif
' \
      -e 's/typedef[ 	][ 	]*[a-z_][ 	a-z_]*[ 	]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
      -e '/typedef[ 	][ 	]*[a-z_][ 	a-z_]*[ 	]wchar_t/i\
#ifndef __WCHAR_TYPE__\
#define __WCHAR_TYPE__ int\
#endif\
#ifndef __cplusplus
' \
      -e '/typedef[ 	][ 	]*[a-z_][ 	a-z_]*[ 	]wchar_t/a\
#endif
' \
      -e 's/typedef[ 	][ 	]*[a-z_][ 	a-z_]*[ 	]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
      ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
        dir=`echo $file | sed -e s'|/[^/]*$||'`
        required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
done

# Fix #defines under Alpha OSF/1:
# The following files contain '#pragma extern_prefix "_FOO"' followed by
# a '#define something(x,y,z) _FOOsomething(x,y,z)'.  The intent of these
# statements is to reduce namespace pollution.  While these macros work
# properly in most cases, they don't allow you to take a pointer to the
# "something" being modified.  To get around this limitation, change these
# statements to be of the form '#define something _FOOsomething'.
for file in libgen.h dirent.h ftw.h grp.h ndbm.h pthread.h pwd.h signal.h standards.h stdlib.h string.h stropts.h time.h unistd.h
do
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi

  if [ -r ${LIB}/$file ]; then
    echo Fixing $file extern_prefix
    sed -e 's/^[ 	]*#[ 	]*define[ 	]*\([^(]*\)\(([^)]*)\)[ 	]*\(_.\)\1\2[ 	]*$/#define \1 \3\1/' ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
	dir=`echo $file | sed -e s'|/[^/]*$||'`
	required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
done
 
# Fix one other error in this file: a mismatched quote not inside a C comment.
file=sundev/vuid_event.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/sundev 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file comment
  sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
file=sunwindow/win_cursor.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
#  mkdir ${LIB}/sunwindow 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
fi
if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi
file=sunwindow/win_lock.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
#  mkdir ${LIB}/sunwindow 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
fi
if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix this Sun file to avoid interfering with stddef.h.
file=sys/stdtypes.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
sed -e '/[	 ]size_t.*;/i\
#ifndef _GCC_SIZE_T\
#define _GCC_SIZE_T
' \
    -e '/[	 ]size_t.*;/a\
#endif
' \
    -e '/[	 ]ptrdiff_t.*;/i\
#ifndef _GCC_PTRDIFF_T\
#define _GCC_PTRDIFF_T
' \
    -e '/[	 ]ptrdiff_t.*;/a\
#endif
' \
    -e '/[	 ]wchar_t.*;/i\
#ifndef _GCC_WCHAR_T\
#define _GCC_WCHAR_T
' \
    -e '/[	 ]wchar_t.*;/a\
#endif
' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
# in cc1plus.
file=stdlib.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e "s/\(#[ 	]*ifndef[ 	]*\)__wchar_t/\1_GCC_WCHAR_T/" \
      -e "s/\(#[ 	]*define[ 	]*\)__wchar_t/\1_GCC_WCHAR_T/" \
     ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix this ARM/RISCiX file where ___type is a Compiler hint that is specific to
# the Norcroft compiler.
file=X11/Intrinsic.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e "s/___type p_type/p_type/" \
     ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[         ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix this file to avoid interfering with stddef.h, but don't mistakenly
# match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
# set) size_t.
file=sys/types.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
sed -e '/typedef[ 	][ 	]*[A-Za-z_][ 	A-Za-z_]*[ 	]size_t/i\
#ifndef _GCC_SIZE_T\
#define _GCC_SIZE_T
' \
    -e '/typedef[ 	][ 	]*[A-Za-z_][ 	A-Za-z_]*[ 	]size_t/a\
#endif
' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix HP's use of ../machine/inline.h to refer to
# /usr/include/machine/inline.h
file=sys/spinlock.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file
fi
if [ -r ${LIB}/$file ] ; then
  echo Fixing $file
  sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
    -e 's,"../machine/psl.h",<machine/psl.h>,' \
  ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix an error in this file: the #if says _cplusplus, not the double
# underscore __cplusplus that it should be
file=tinfo.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/rpcsvc 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, __cplusplus macro
  sed -e 's/[ 	]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix an error in this file: a missing semi-colon at the end of the statsswtch
# structure definition.
file=rpcsvc/rstat.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/rpcsvc 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, definition of statsswtch
  sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix an error in this file: a missing semi-colon at the end of the nodeent
# structure definition.
file=netdnet/dnetdb.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/netdnet 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, definition of nodeent
  sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Check for bad #ifdef line (in Ultrix 4.1)
file=sys/file.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, bad \#ifdef line
  sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Check for (...) in C++ code in HP/UX sys/file.h.
file=sys/file.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  if egrep HPUX_SOURCE ${LIB}/$file > /dev/null; then
    echo Fixing $file, use of '(...)'
    sed -e 's/(\.\.\.)/(struct file * ...)/' ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
	dir=`echo $file | sed -e s'|/[^/]*$||'`
	required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
fi

# Check for superfluous `static' (in Ultrix 4.2)
# On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
file=machine/cpu.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/machine 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, superfluous static and broken includes of other files.
  sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
      -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
      -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
      ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
# This file has an alternative name, mips/cpu.h.  Fix that name, too.
    if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
      mkdir ${LIB}/mips 2>&-
# Don't remove the file first, they may be the same file!
      ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
    fi
  fi
fi

# Incorrect sprintf declaration in X11/Xmu.h
file=X11/Xmu.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/X11 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file sprintf declaration
  sed -e 's,^extern char \*	sprintf();$,#ifndef __STDC__\
extern char *	sprintf();\
#endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Incorrect sprintf declaration in X11/Xmu/Xmu.h
# (It's not clear whether the right file name is this or X11/Xmu.h.)
file=X11/Xmu/Xmu.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/X11/Xmu 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file sprintf declaration
  sed -e 's,^extern char \*	sprintf();$,#ifndef __STDC__\
extern char *	sprintf();\
#endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Check for missing ';' in struct
file=netinet/ip.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/netinet 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix the CAT macro in SunOS memvar.h.
file=pixrect/memvar.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/pixrect 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e '/^#define.CAT(a,b)/ i\
#ifdef __STDC__ \
#define CAT(a,b) a##b\
#else
/^#define.CAT(a,b)/ a\
#endif
' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Check for yet more missing ';' in struct (in SunOS 4.0.x)
file=rpcsvc/rusers.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/rpcsvc 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
# Also wrap protection around size_t for m88k-sysv3 systems.
file=stdlib.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  if grep _GCC_SIZE_T ${LIB}/$file >/dev/null
  then size_t_pattern='<<< do not double-wrap the size_t typedef >>>'
  else size_t_pattern='typedef[ 	a-zA-Z_]*[ 	]size_t[ 	]*;'
  fi
  sed -e 's/int	abort/void	abort/g' \
  -e 's/int	free/void	free/g' \
  -e 's/char[ 	]*\*[ 	]*calloc/void \*	calloc/g' \
  -e 's/char[ 	]*\*[ 	]*malloc/void \*	malloc/g' \
  -e 's/char[ 	]*\*[ 	]*realloc/void \*	realloc/g' \
  -e 's/int[ 	][ 	]*exit/void	exit/g' \
  -e "/$size_t_pattern/"'i\
#ifndef _GCC_SIZE_T\
#define _GCC_SIZE_T
' \
  -e "/$size_t_pattern/"'a\
#endif
' \
      ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
# Also fix return type of {m,re}alloc in <malloc.h> on sysV68
file=malloc.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e 's/typedef[ 	]char \*	malloc_t/typedef void \*	malloc_t/g' \
  -e 's/int[ 	][ 	]*free/void	free/g' \
  -e 's/char\([ 	]*\*[ 	]*malloc\)/void\1/g' \
  -e 's/char\([ 	]*\*[ 	]*realloc\)/void\1/g' \
  ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
file=hsfs/hsfs_spec.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/hsfs 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
    ${LIB}/$file > ${LIB}/${file}.
  rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
file=hsfs/hsnode.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/hsfs 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
file=hsfs/iso_spec.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/hsfs 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Incorrect #include in Sony News-OS 3.2.
file=machine/machparam.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/machine 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, incorrect \#include
  sed -e 's@@"../machine/endian.h"@@<machine/endian.h>@@' \
    ${LIB}/$file > ${LIB}/${file}.
  rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Multiline comment after typedef on IRIX 4.0.1.
file=sys/types.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/sys 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, comment in the middle of \#ifdef
  sed -e 's@@type of the result@@type of the result */@@' \
    -e 's@@of the sizeof@@/* of the sizeof@@' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Turning // comments into /* */ comments trashes this IRIX 4.0.1
# header file, which embeds // comments inside multi-line /* */
# comments.  If this looks like the IRIX header file, we refix it by
# just throwing away the // comments.
file=fam.h
if [ -r ${LIB}/$file ]; then
  if egrep indigo.esd ${LIB}/$file > /dev/null; then
    echo Fixing $file, overeager sed script
    rm ${LIB}/$file
    sed -e 's|//.*$||g' $file > ${LIB}/$file
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi
fi

# There is a similar problem with the VxWorks drv/netif/if_med.h file.
file=drv/netif/if_med.h
if [ -r ${LIB}/$file ]; then
  if egrep 'Wind River' ${LIB}/$file > /dev/null; then
    echo Fixing $file, overeager sed script
    rm ${LIB}/$file
    sed -e 's|//.*$||g' $file > ${LIB}/$file
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi
fi

# And also with the HP-UX 10 and HP-UX 11 sys/pci.h file
file=sys/pci.h
if [ -r ${LIB}/$file ]; then
  if egrep 'System Private Structures' ${LIB}/$file > /dev/null; then
    echo Fixing $file, overeager sed script
    rm ${LIB}/$file
    sed -e 's|//.*$||g' $file > ${LIB}/$file
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi
fi

# And also with a few more HP-UX 11 headers which are only broken
# after they are "fixed".
file=sys/ki_iface.h
if [ -r ${LIB}/$file ]; then
  if egrep 'These definitions are for HP Internal developers' ${LIB}/$file > /dev/null; then
    echo Fixing $file, overeager sed script
    rm ${LIB}/$file
  fi
fi

file=sys/ki.h
if [ -r ${LIB}/$file ]; then
  if egrep '11.00 HP-UX LP64' ${LIB}/$file > /dev/null; then
    echo Fixing $file, overeager sed script
    rm ${LIB}/$file
  fi
fi

file=sys/ki_calls.h
if [ -r ${LIB}/$file ]; then
  if egrep 'KI_MAX_PROCS is an arbitrary number' ${LIB}/$file > /dev/null; then
    echo Fixing $file, overeager sed script
    rm ${LIB}/$file
  fi
fi

file=sys/ki_defs.h
if [ -r ${LIB}/$file ] ; then
  if egrep 'Kernel Instrumentation Definitions' ${LIB}/$file > /dev/null; then
    echo Fixing $file, overeager sed script
    rm ${LIB}/$file
  fi
fi

file=sys/time.h
if [ -r ${LIB}/$file ] ; then
  if egrep 'For CASPEC, look in' ${LIB}/$file > /dev/null; then
    echo Fixing $file, overeager sed script
    rm ${LIB}/$file
  fi
fi

# Some IRIX header files contains the string "//"
for file in elf_abi.h elf.h; do
  if [ -r ${LIB}/$file ]; then
    echo Fixing $file, overeager sed script
    sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
    fi
  fi
done

# IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
# previous definition.
file=rpc/auth.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/rpc 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, undefined type
  sed -e '/authdes_create.*struct sockaddr/i\
struct sockaddr;
' \
    ${LIB}/$file > ${LIB}/$file.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
# definition.
file=rpc/xdr.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/rpc 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, undefined type
  sed -e '/xdrstdio_create.*struct __file_s/i\
struct __file_s;
' \
    ${LIB}/$file > ${LIB}/$file.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Same problem with a file from SunOS 4.1.3 : a header file containing
# the string "//" embedded in "/**/"
file=sbusdev/audiovar.h
if [ -r ${LIB}/$file ]; then
  echo Fixing $file, overeager sed script
  rm ${LIB}/$file
  sed -e 's|//.*$||g' $file > ${LIB}/$file
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

# Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
# declaration on Sun OS 4.x.  We must only fix this on Sun OS 4.x, because
# many other systems have similar text but correct versions of the file.
# To ensure only Sun's is fixed, we grep for a likely unique string.
# Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
file=memory.h
if [ -r $file ] && egrep '/\*	@@\(#\)(head/memory.h	50.1	 |memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2	)\*/' $file > /dev/null; then
  if [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi
  if [ -r ${LIB}/$file ]; then
    echo Replacing $file
    cat > ${LIB}/$file << EOF
/* This file was generated by fixincludes */
#ifndef __memory_h__
#define __memory_h__

#ifdef __STDC__
extern void *memccpy();
extern void *memchr();
extern void *memcpy();
extern void *memset();
#else
extern char *memccpy();
extern char *memchr();
extern char *memcpy();
extern char *memset();
#endif /* __STDC__ */

extern int memcmp();

#endif /* __memory_h__ */
EOF
  fi
fi

# Fix return type of fread and fwrite on sysV68
file=stdio.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, fread and fwrite return type
  sed -e 's/^\(extern int	fclose(), fflush()\), \(fread(), fwrite()\)\(.*\)$/extern unsigned int	\2;\
\1\3/' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# parameters not const on DECstation Ultrix V4.0 and OSF/1.
file=stdio.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, non-const arg
  sed -e 's@@perror( char \*__s );@@perror( const char *__s );@@' \
      -e 's@@fputs( char \*__s,@@fputs( const char *__s,@@' \
      -e 's@@fopen( char \*__filename, char \*__type );@@fopen( const char *__filename, const char *__type );@@' \
      -e 's@@fwrite( void \*__ptr,@@fwrite( const void *__ptr,@@' \
      -e 's@@fscanf( FILE \*__stream, char \*__format,@@fscanf( FILE *__stream, const char *__format,@@' \
      -e 's@@scanf( char \*__format,@@scanf( const char *__format,@@' \
      -e 's@@sscanf( char \*__s, char \*__format,@@sscanf( const char *__s, const char *__format,@@' \
      -e 's@@popen(char \*, char \*);@@popen(const char *, const char *);@@' \
      -e 's@@tempnam(char\*,char\*);@@tempnam(const char*,const char*);@@' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# parameters conflict with C++ new on rs/6000 
for file in stdio.h unistd.h ; do
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
  fi

  if [ -r ${LIB}/$file ]; then
    echo Fixing $file, parameter name conflicts
    sed -e 's@@rename(const char \*old, const char \*new)@@rename(const char *_old, const char *_new)@@' \
      ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm -f ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
        dir=`echo $file | sed -e s'|/[^/]*$||'`
        required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
done

# function class(double x) conflicts with C++ keyword on rs/6000 
file=math.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  if grep '[^a-zA-Z_]class[(]' ${LIB}/$file >/dev/null; then
    echo Fixing $file
    sed -e '/class[(]/i\
#ifndef __cplusplus
' \
        -e '/class[(]/a\
#endif
' ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
        dir=`echo $file | sed -e s'|/[^/]*$||'`
        required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
fi

# Wrong fchmod prototype on RS/6000.
file=sys/stat.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/sys 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, fchmod prototype
  sed -e 's/fchmod(char \*/fchmod(int/' \
    ${LIB}/$file > ${LIB}/$file.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# There are several name conflicts with C++ reserved words in X11
# header files.  These are fixed in some versions, so don't do the
# fixes if we find __cplusplus in the file.  These were found on the
# RS/6000.

# class in X11/ShellP.h
file=X11/ShellP.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/sys 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
    true;
  else
    echo Fixing $file, field class
    sed -e '/char [*]class;/i\
#ifdef __cplusplus\
	char *c_class;\
#else
' \
        -e '/char [*]class;/a\
#endif
' ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  fi
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi
# new in Xm/Traversal.h
file=Xm/Traversal.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/sys 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
    true;
  else
    echo Fixing $file, uses of new
    sed -e '/Widget	old, new;/i\
#ifdef __cplusplus\
	Widget	old, c_new;\
#else
' \
        -e '/Widget	old, new;/a\
#endif
' \
	-e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  fi
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi
# class in Xm/BaseClassI.h
file=Xm/BaseClassI.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/sys 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
    true;
  else
    echo Fixing $file, prototype parameter name
    sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  fi
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# NeXT 3.2 adds const prefix to some math functions. These conflict
# with the built-in functions.
file=ansi/math.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
fi
if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e '/^extern.*double.*__const__.*sqrt(/s/__const__//' \
      -e '/^extern.*double.*__const__.*fabs(/s/__const__//' \
      -e '/^extern.*double.*__const__.*cos(/s/__const__//' \
      -e '/^extern.*double.*__const__.*sin(/s/__const__//' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# NeXT 3.2 uses the word "template" as a parameter for some 
# functions. GCC reports an invalid use of a reserved key word
# with the built-in functions. NeXT 3.2 includes the keyword
# volatile in the prototype for abort(). This conflicts with
# the built-in definition.
file=bsd/libc.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
fi
if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e '/\(.*template\)/s/template//' \
      -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# NeXT 3.2 includes the keyword volatile in the abort() and 
# exit() function prototypes. That conflicts with the 
# built-in functions.
file=ansi/stdlib.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
fi
if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e '/extern.*volatile.*void.*exit/s/volatile//' \
      -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the definition
# of struct rusage, so the prototype (added by fixproto) causes havoc.
file=sys/wait.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ] \
  && grep 'bos325,' ${LIB}/$file >/dev/null; then
  echo Fixing $file, wait3 declaration
  sed -e '/^extern pid_t wait3();$/i\
struct rusage;
'\
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
# Note that version 3 of the NeXT system has wait.h in a different directory,
# so that this code won't do anything.  But wait.h in version 3 has a
# conditional, so it doesn't need this fix.  So everything is okay.
file=sys/wait.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ] \
  && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
  echo Fixing $file, bad wait formal
  sed -e 's@@wait(union wait@@wait(void@@' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Don't use or define the name va_list in stdio.h.
# This is for ANSI and also to interoperate properly with gcc's varargs.h.
file=stdio.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, use of va_list
  # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
  if egrep "__need___va_list" ${LIB}/$file >/dev/null 2>&1; then
    touch ${LIB}/${file}.sed
  else
    (echo "#define __need___va_list"
     echo "#include <stdarg.h>") > ${LIB}/${file}.sed
  fi
  # Use __gnuc_va_list in arg types in place of va_list.
  # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
  # trailing parentheses and semicolon save all other systems from this.
  # Define __va_list__ (something harmless and unused) instead of va_list.
  # Don't claim to have defined va_list.
  sed -e 's@@ va_list @@ __gnuc_va_list @@' \
      -e 's@@ va_list)@@ __gnuc_va_list)@@' \
      -e 's@@ _BSD_VA_LIST_));@@ __gnuc_va_list));@@' \
      -e 's@@ _VA_LIST_));@@ __gnuc_va_list));@@' \
      -e 's@@ va_list@@ __va_list__@@' \
      -e 's@@\*va_list@@*__va_list__@@' \
      -e 's@@ __va_list)@@ __gnuc_va_list)@@' \
      -e 's@@GNUC_VA_LIST@@GNUC_Va_LIST@@' \
      -e 's@@_NEED___VA_LIST@@_NEED___Va_LIST@@' \
      -e 's@@VA_LIST@@DUMMY_VA_LIST@@' \
      -e 's@@_Va_LIST@@_VA_LIST@@' \
    ${LIB}/$file >> ${LIB}/${file}.sed
  
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Cancel out ansi_compat.h on Ultrix.  Replace it with empty file.
file=ansi_compat.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  if grep -s ULTRIX $file; then
    echo "/* This file intentionally left blank.  */" > $LIB/$file
  fi
fi

# parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
# also get rid of bogus inline definitions in HP-UX 8.0
file=math.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, non-const arg
  sed -e 's@@atof(\([ 	]*char[ 	]*\*[^)]*\))@@atof(const \1)@@' \
      -e 's@@inline int abs(int [a-z][a-z]*) {.*}@@extern "C" int abs(int);@@' \
      -e 's@@inline double abs(double [a-z][a-z]*) {.*}@@@@' \
      -e 's@@inline int sqr(int [a-z][a-z]*) {.*}@@@@' \
      -e 's@@inline double sqr(double [a-z][a-z]*) {.*}@@@@' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# fix bogus recursive stdlib.h in NEWS-OS 4.0C
file=stdlib.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, recursive inclusion
  sed -e '/^#include <stdlib.h>/i\
#if 0
' \
      -e '/^#include <stdlib.h>/a\
#endif
' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Avoid nested comments on Ultrix 4.3.
file=rpc/svc.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/rpc 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, nested comment
  sed -e 's@@^\( \*	int protocol;  \)/\*@@\1*/ /*@@' \
    ${LIB}/$file > ${LIB}/$file.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# This file in RISC/os uses /**/ to concatenate two tokens.
file=bsd43/bsd43_.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi
if [ -r ${LIB}/$file ]; then
  sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

file=rpc/rpc.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/rpc 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, nested comment
  sed -e 's@@^\(/\*.*rpc/auth_des.h>.*\)/\*@@\1*/ /*@@' \
    ${LIB}/$file > ${LIB}/$file.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# rpc/types.h on OSF1/2.0 is not C++ ready, even though NO_IMPLICIT_EXTERN_C
# is defined for the alpha.  The problem is the declaration of malloc.
file=rpc/types.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/rpc 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi
if [ -r ${LIB}/$file ]; then
  if egrep '"C"' ${LIB}/$file >/dev/null 2>&1; then
    true
  else
    echo Fixing $file
    echo '#ifdef __cplusplus
extern "C" {
#endif' > ${LIB}/${file}.sed
    cat ${LIB}/${file} >> ${LIB}/${file}.sed
    echo '#ifdef __cplusplus
}
#endif' >> ${LIB}/${file}.sed 
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm -f ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
        dir=`echo $file | sed -e s'|/[^/]*$||'`
        required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
fi

# In limits.h, put #ifndefs around things that are supposed to be defined
# in float.h to avoid redefinition errors if float.h is included first.
# On HP/UX this patch does not work, because on HP/UX limits.h uses
# multi line comments and the inserted #endif winds up inside the
# comment.  Fortunately, HP/UX already uses #ifndefs in limits.h; if
# we find a #ifndef FLT_MIN we assume that all the required #ifndefs
# are there, and we do not add them ourselves.
# Also fix a nested comment problem in sys/limits.h on Motorola sysV68 R3V7.1
for file in limits.h sys/limits.h; do
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    mkdir ${LIB}/sys 2>/dev/null
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi

  if [ -r ${LIB}/$file ]; then
    if egrep 'ifndef[ 	]+FLT_MIN' ${LIB}/$file >/dev/null; then
      true
    else
      echo Fixing $file
      sed -e '/[ 	]FLT_MIN[ 	]/i\
#ifndef FLT_MIN
'\
	  -e '/[ 	]FLT_MIN[ 	]/a\
#endif
'\
	  -e '/[ 	]FLT_MAX[ 	]/i\
#ifndef FLT_MAX
'\
	  -e '/[ 	]FLT_MAX[ 	]/a\
#endif
'\
	  -e '/[ 	]FLT_DIG[ 	]/i\
#ifndef FLT_DIG
'\
	  -e '/[ 	]FLT_DIG[ 	]/a\
#endif
'\
	  -e '/[ 	]DBL_MIN[ 	]/i\
#ifndef DBL_MIN
'\
	  -e '/[ 	]DBL_MIN[ 	]/a\
#endif
'\
	  -e '/[ 	]DBL_MAX[ 	]/i\
#ifndef DBL_MAX
'\
	  -e '/[ 	]DBL_MAX[ 	]/a\
#endif
'\
	  -e '/[ 	]DBL_DIG[ 	]/i\
#ifndef DBL_DIG
'\
	  -e '/[ 	]DBL_DIG[ 	]/a\
#endif
'\
	  -e '/^\(\/\*#define	HUGE_VAL	3\.[0-9e+]* *\)\/\*/s//\1/'\
	${LIB}/$file > ${LIB}/${file}.sed
      rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    fi
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      echo Deleting ${LIB}/$file\; no fixes were needed.
      rm -f ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
        dir=`echo $file | sed -e s'|/[^/]*$||'`
        required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
done

# In math.h, put #ifndefs around things that might be defined in a gcc
# specific math-*.h file.
file=math.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e '/define[ 	]HUGE_VAL[ 	]/i\
#ifndef HUGE_VAL
'\
      -e '/define[ 	]HUGE_VAL[ 	]/a\
#endif
'\
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file

  # In addition, copy the definition of DBL_MAX from float.h
  # if math.h requires one.  The Lynx math.h requires it.
  if egrep '#define[ 	]*HUGE_VAL[ 	]+DBL_MAX' $file >/dev/null 2>&1; then
    if egrep '#define[ 	]+DBL_MAX[ 	]+' $file >/dev/null 2>&1; then
      true;
    else
      dbl_max_def=`egrep 'define[ 	]+DBL_MAX[ 	]+.*' float.h 2>/dev/null`
      if [ "$dbl_max_def" != "" ]; then
        dbl_max_def=`echo $dbl_max_def | sed 's/.*define[ 	]*DBL_MAX[ 	]*//'`
        sed -e "/define[ 	]HUGE_VAL[ 	]DBL_MAX/s/DBL_MAX/$dbl_max_def/" \
          ${LIB}/$file > ${LIB}/${file}.sed
	rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
      fi
    fi
  fi

  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    echo Deleting ${LIB}/$file\; no fixes were needed.
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Remove erroneous parentheses in sym.h on Alpha OSF/1.
file=sym.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
# in string.h on sysV68
# Correct the return type for strlen in string.h on Lynx.
# Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
# Add missing const for strdup on OSF/1 V3.0.
# On sysV88 layout is slightly different.
file=string.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, mem{ccpy,chr,cpy,set} and str{len,spn,cspn} return value
  sed -e 's/extern[ 	]*int[ 	]*strlen();/extern unsigned int strlen();/' \
      -e 's/extern[ 	]*int[ 	]*ffs[ 	]*(long);/extern int ffs(int);/' \
      -e 's/strdup(char \*s1);/strdup(const char *s1);/' \
      -e '/^extern char$/N' \
      -e 's/^extern char\(\n	\*memccpy(),\)$/extern void\1/'\
      -e '/^	strncmp(),$/N'\
      -e 's/^\(	strncmp()\),\n\(	strlen(),\)$/\1;\
extern unsigned int\
\2/'\
      -e '/^extern int$/N'\
      -e 's/^extern int\(\n	strlen(),\)/extern size_t\1/' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Correct the return type for strlen in strings.h in SunOS 4.
file=strings.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e 's/int[ 	]*strlen();/__SIZE_TYPE__ strlen();/' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Delete the '#define void int' line from curses.h on Lynx
file=curses.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e '/#[ 	]*define[ 	][ 	]*void[ 	]int/d' \
     ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix `typedef struct term;' on hppa1.1-hp-hpux9.
file=curses.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e 's/^[ 	]*typedef[ 	][ 	]*\(struct[ 	][ 	]*term[ 	]*;[ 	]*\)$/\1/' \
     ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# For C++, avoid any typedef or macro definition of bool, and use the
# built in type instead.
for files in curses.h; do
  if [ -r $file ] && egrep bool $file >/dev/null 2>&1; then
    if [ ! -r ${LIB}/$file ]; then
      cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
      chmod +w ${LIB}/$file 2>/dev/null
      chmod a+r ${LIB}/$file 2>/dev/null
    fi

    echo Fixing $file
    sed -e '/^#[ 	]*define[ 	][ 	]*bool[ 	][ 	]*char[ 	]*$/i\
#ifndef __cplusplus
'\
	-e '/^#[ 	]*define[ 	][ 	]*bool[ 	][ 	]*char[ 	]*$/a\
#endif
'\
	-e '/^typedef[ 	][ 	]*char[ 	][ 	]*bool[ 	]*;/i\
#ifndef __cplusplus
'\
	-e '/^typedef[ 	][ 	]*char[ 	][ 	]*bool[ 	]*;/a\
#endif
'\
	${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm -f ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
        dir=`echo $file | sed -e s'|/[^/]*$||'`
        required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
done

# Fix incorrect S_IF* definitions on m88k-sysv3.
file=sys/stat.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e 's/^\(#define[ 	]*S_IS[A-Z]*(m)\)[ 	]*(m[ 	]*&[ 	]*\(S_IF[A-Z][A-Z][A-Z][A-Z]*\)[ 	]*)/\1 (((m)\&S_IFMT)==\2)/' \
      -e 's/^\(#define[ 	]*S_IS[A-Z]*(m)\)[ 	]*(m[ 	]*&[ 	]*\(0[0-9]*\)[ 	]*)/\1 (((m)\&S_IFMT)==\2)/' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
for file in stdio.h stdlib.h; do
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi

  if [ -r ${LIB}/$file ]; then
    echo Fixing $file, getopt declaration
    sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
      ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm -f ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
        dir=`echo $file | sed -e s'|/[^/]*$||'`
        required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
done

# Fix __page_size* declarations in pthread.h AIX 4.1.[34].
# The original ones fail if uninitialized externs are not common.
# This is the default for all ANSI standard C++ compilers.
for file in pthread.h; do
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi

  if [ -r ${LIB}/$file ]; then
    echo Fixing $file, __page_size* declarations
    sed -e 's/^int __page_size/extern int __page_size/' \
      ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm -f ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
        dir=`echo $file | sed -e s'|/[^/]*$||'`
        required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
done

# Determine if we're on Interactive Unix 2.2 or later, in which case we
# need to fix some additional files.  This is the same test for ISC that
# Autoconf uses.
if test -d /etc/conf/kconfig.d \
    && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
  echo "Fixing ISC __STDC__ goof in several files..."
  for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
    echo $name
    if test -r ${LIB}/$name; then
      file=${LIB}/$name
    else
      file=${INPUT}/$name
    fi
    # On Interactive 2.2, certain traditional Unix definitions
    # (notably getc and putc in stdio.h) are omitted if __STDC__ is
    # defined, not just if _POSIX_SOURCE is defined.  This makes it
    # impossible to compile any nontrivial program except with -posix.
    sed \
's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
	    < $file > ${LIB}/$name.
    mv ${LIB}/$name. ${LIB}/$name
  done
  
  echo "Fixing ISC fmod declaration"
  # This one's already been fixed for other things.
  file=${LIB}/math.h
  sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
  mv $file. $file
  
  echo "Fixing nested comments in ISC <sys/limits.h>"
  file=sys/limits.h
  sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
  sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
fi

# These files in Sun OS 4.x use /**/ to concatenate tokens.
for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h	\
	sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h	\
	sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
do
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi

  if [ -r ${LIB}/$file ]; then
    sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm -f ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
        dir=`echo $file | sed -e s'|/[^/]*$||'`
        required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
done

# These files in ARM/RISCiX use /**/ to concatenate tokens.
for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
	dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
do
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi

  if [ -r ${LIB}/$file ]; then
    sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
    fi
  fi
done

# libm.a on m88k-motorola-sysv3 contains a stupid optimization for function
# hypot(), which returns the second argument without even looking at its value
# if the other is 0.0
# Another drawback is that fix-header doesn't fix fabs' prototype, and I have
#  no idea why.
file=math.h
if [ $target_canonical = m88k-motorola-sysv3 ]; then
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi

  if [ -r ${LIB}/$file ]; then
    echo Fixing $file, fabs/hypot definition
    sed \
      -e 's/extern double floor(), ceil(), fmod(), fabs();/extern double floor(), ceil(), fmod(), fabs _PARAMS((double));/' \
      -e '/^extern double hypot();$/a\
\/* Workaround a stupid Motorola optimization if one\
   of x or y is 0.0 and the other is negative!  *\/\
#ifdef __STDC__\
static __inline__ double fake_hypot (double x, double y)\
#else\
static __inline__ double fake_hypot (x, y)\
	double x, y;\
#endif\
{\
	return fabs (hypot (x, y));\
}\
#define hypot	fake_hypot
' \
      ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm -f ${LIB}/$file
    fi
  fi
fi

# math.h on SunOS 4 puts the declaration of matherr before the definition
# of struct exception, so the prototype (added by fixproto) causes havoc.
file=math.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, matherr declaration
  sed -e '/^struct exception/,$b' \
      -e '/matherr/i\
struct exception;
'\
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# assert.h and sys/mman.h on HP/UX are not C++ ready, even though
# NO_IMPLICIT_EXTERN_C is defined on HP/UX.
for file in assert.h sys/mman.h; do
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi

  if [ -r ${LIB}/$file ]; then
    if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
       || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
      true
    else
      echo Fixing $file
      echo '#ifdef __cplusplus
extern "C" {
#endif' > ${LIB}/${file}.sed
      cat ${LIB}/${file} >> ${LIB}/${file}.sed
      echo '#ifdef __cplusplus
}
#endif' >> ${LIB}/${file}.sed 
      rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    fi
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm -f ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
	dir=`echo $file | sed -e s'|/[^/]*$||'`
	required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
done

# check for broken assert.h that needs stdio.h or stdlib.h
file=assert.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  if grep 'stderr' ${LIB}/$file >/dev/null 2>/dev/null; then
    if grep 'include.*stdio.h' ${LIB}/$file >/dev/null 2>/dev/null; then
      true
    else
      echo "Fixing $file (needs stdio.h)"
      echo '#include <stdio.h>' >>${LIB}/$file
    fi
  fi
  if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null || 
     grep 'abort *(' ${LIB}/$file >/dev/null 2>/dev/null; then
    if grep 'include.*stdlib.h' ${LIB}/$file >/dev/null 2>/dev/null; then
      true
    else
      echo "Fixing $file (needs stdlib.h)"
      echo '#ifdef __cplusplus
#include <stdlib.h>
#endif' >>${LIB}/$file
    fi
  fi
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
file=unistd.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, sbrk declaration
  sed -e 's/char\([ 	]*\*[	 ]*sbrk[ 	]*(\)/void\1/' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# This file on SunOS 4 has a very large macro.  When the sed loop
# tries pull it in, it overflows the pattern space size of the SunOS
# sed (GNU sed does not have this problem).  Since the file does not
# require fixing, we remove it from the fixed directory.
file=sundev/ipi_error.h
if [ -r ${LIB}/$file ]; then
  echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
  rm -f ${LIB}/$file
fi

# Put cpp wrappers around these include files to avoid redeclaration
# errors during multiple inclusion on m88k-tektronix-sysv3.
for file in time.h sys/time.h ; do
  if egrep '#ifndef' $file >/dev/null 2>&1; then
    true
  else
    if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
      cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
      chmod +w ${LIB}/$file 2>/dev/null
    fi
    if [ -r ${LIB}/$file ]; then
      echo Fixing $file, to protect against multiple inclusion.
      cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
      (echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
      echo "#define __GCC_GOT_${cpp_wrapper}_"
      cat ${LIB}/${file}
      echo '#endif /* !_GCC_GOT_'${cpp_wrapper}_' */')  > ${LIB}/${file}.new
      rm -f ${LIB}/$file; mv ${LIB}/${file}.new ${LIB}/$file
    fi
  fi
done

# Fix fcntl prototype in fcntl.h on LynxOS.
file=fcntl.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, fcntl declaration
  sed -e 's/\(fcntl.*(int, int, \)int)/\1...)/' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix definitions of macros used by va-i960.h in VxWorks header file.
file=arch/i960/archI960.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e 's/__vsiz/__vxvsiz/' -e 's/__vali/__vxvali/' \
      -e s'/__vpad/__vxvpad/' -e 's/__alignof__/__vxalignof__/' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Make VxWorks header which is almost gcc ready fully gcc ready.
file=types/vxTypesBase.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e 's/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/#if 1/' \
      -e '/[ 	]size_t/i\
#ifndef _GCC_SIZE_T\
#define _GCC_SIZE_T
' \
      -e '/[ 	]size_t/a\
#endif
' \
      -e '/[ 	]ptrdiff_t/i\
#ifndef _GCC_PTRDIFF_T\
#define _GCC_PTRDIFF_T
' \
      -e '/[ 	]ptrdiff_t/a\
#endif
' \
      -e '/[ 	]wchar_t/i\
#ifndef _GCC_WCHAR_T\
#define _GCC_WCHAR_T
' \
      -e '/[ 	]wchar_t/a\
#endif
' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
file=sys/stat.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/sys 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  if egrep '#include' ${LIB}/$file >/dev/null 2>&1; then
    :
  else
    if egrep 'ULONG' ${LIB}/$file >/dev/null 2>&1 \
       && [ -r types/vxTypesOld.h ]; then
      echo Fixing $file
      sed -e '/#define[ 	][ 	]*__INCstath/a\
#include <types/vxTypesOld.h>
' \
    ${LIB}/$file > ${LIB}/${file}.sed
      rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    fi
  fi
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Fix VxWorks <time.h> to not require including <vxTypes.h>.
file=time.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/sys 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  if egrep 'uint_t[ 	][ 	]*_clocks_per_sec' ${LIB}/$file >/dev/null 2>&1; then
    echo Fixing $file
    sed -e 's/uint_t/unsigned int/' ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  fi
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi
    
# Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
file=sys/time.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/sys 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  if egrep '^extern struct sigevent;' ${LIB}/$file >/dev/null 2>&1; then
    echo Fixing $file
    sed -e 's/^extern struct sigevent;/struct sigevent;/' ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  fi
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi
    
# Another bad dependency in VxWorks 5.2 <time.h>.
file=time.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/sys 2>/dev/null
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  if egrep VOIDFUNCPTR ${LIB}/$file >/dev/null 2>&1; then
    if [ -r vxWorks.h ]; then
      echo Fixing $file
      sed -e '/VOIDFUNCPTR/i\
#ifndef __gcc_VOIDFUNCPTR_defined\
#ifdef __cplusplus\
typedef void (*__gcc_VOIDFUNCPTR) (...);\
#else\
typedef void (*__gcc_VOIDFUNCPTR) ();\
#endif\
#define __gcc_VOIDFUNCPTR_defined\
#endif
' \
	  -e 's/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g' \
	${LIB}/$file > ${LIB}/${file}.sed
      rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    fi
  fi
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi
    
# This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89; gcc
# doesn't understand it.
file=sys/param.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo "Fixing __asm directive in sys/param.h"
  sed -e 's|#ifndef NOINLINE|#if !defined(NOINLINE) \&\& !defined(__GNUC__)|' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# signal.h on SunOS defines signal using (), which causes trouble when
# compiling with g++ -pedantic.
for file in signal.h sys/signal.h; do
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi

  if [ -r ${LIB}/$file ]; then
    echo "Checking for bad C++ prototype in $file"
    sed -e '/^void	(\*signal())();$/i\
  #ifdef __cplusplus\
  void	(*signal(...))(...);\
  #else
  ' \
	-e '/^void	(\*signal())();$/a\
  #endif
  ' \
      ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm -f ${LIB}/$file
    else
      # Find any include directives that use "file".
      for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
	dir=`echo $file | sed -e s'|/[^/]*$||'`
	required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
      done
    fi
  fi
done

# sys/signal.h on some versions of AIX uses volatile in the typedef of
# sig_atomic_t, which causes gcc to generate a warning about duplicate
# volatile when a sig_atomic_t variable is declared volatile, as
# required by ANSI C.
file=sys/signal.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo "Checking for duplicate volatile in sys/signal.h"
  sed -e 's/typedef volatile int sig_atomic_t/typedef int sig_atomic_t/' \
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# Some math.h files define struct exception, which conflicts with
# the class exception defined in the C++ file std/stdexcept.h.  We
# redefine it to __math_exception.  This is not a great fix, but I
# haven't been able to think of anything better.
file=math.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, exception
  sed -e '/struct exception/i\
#ifdef __cplusplus\
#define exception __math_exception\
#endif'\
      -e '/struct exception/a\
#ifdef __cplusplus\
#undef exception\
#endif' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if egrep 'matherr()' ${LIB}/$file >/dev/null 2>&1; then
    sed -e '/matherr/i\
#ifdef __cplusplus\
#define exception __math_exception\
#endif'\
        -e '/matherr/a\
#ifdef __cplusplus\
#undef exception\
#endif' ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  fi
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# rpc/xdr.h on SunOS needs prototypes for its XDR->xdr_ops function pointers.
file=rpc/xdr.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo "Checking for needed C++ prototype in $file"
  sed -e 's/^\(.*\)\*\(x_.*\)();\(.*\)/\
#ifdef __cplusplus\
\1*\2(...);\3\
#else\
\1*\2();\3\
#endif/g' \
     $LIB/$file > ${LIB}/${file}.sed

  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
	dir=`echo $file | sed -e s'|/[^/]*$||'`
	required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
fi

# sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
# defining regex.h types.  This causes C++ library build and usage failures.
# Fixing this correctly requires checking and modifying 3 files.
for file in reg_types.h regex.h sys/lc_core.h; do
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi
done
if [ -r ${LIB}/reg_types.h ]; then
  if egrep '} regex_t;' ${LIB}/reg_types.h >/dev/null 2>&1; then
    if [ -r ${LIB}/sys/lc_core.h ]; then
      if egrep ' regex_t ' ${LIB}/sys/lc_core.h >/dev/null 2>&1; then
        if [ -r ${LIB}/regex.h ]; then
	  if egrep '__regex_t' ${LIB}/regex.h >/dev/null 2>&1; then
	    true;
	  else
	    echo Fixing reg_types.h, regex.h, sys/lc_core.h
	    for file in reg_types.h sys/lc_core.h; do
	      sed -e 's/regex_t/__regex_t/g' \
	        -e 's/regoff_t/__regoff_t/g' \
		-e 's/regmatch_t/__regmatch_t/g' \
		${LIB}/$file > ${LIB}/${file}.sed
	      rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
	    done
	    sed -e '/#include <reg_types.h>/a\
typedef __regex_t	regex_t;\
typedef __regoff_t	regoff_t;\
typedef __regmatch_t	regmatch_t;\
' \
	      ${LIB}/regex.h > ${LIB}/regex.h.sed
	    rm -f ${LIB}/regex.h; mv ${LIB}/regex.h.sed ${LIB}/regex.h
	  fi
	fi
      fi
    fi
  fi
fi
for file in reg_types.h regex.h sys/lc_core.h; do
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  else
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
done

# AIX headers define NULL to be cast to a void pointer, which is illegal
# in ANSI C++.
for file in curses.h dbm.h locale.h stdio.h stdlib.h string.h time.h unistd.h sys/dir.h sys/param.h sys/types.h ; do
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
    chmod a+r ${LIB}/$file 2>/dev/null
  fi

  if [ -r ${LIB}/$file ]; then
    if egrep '#.*define.*NULL.*void' ${LIB}/$file >/dev/null 2>&1; then
      echo "Fixing $file, bad NULL macro"
      sed -e 's/^#[ 	]*define[ 	]*NULL[ 	]*((void[ 	]*\*)0)/#define NULL 0/' \
        ${LIB}/$file > ${LIB}/${file}.sed
      rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
      if cmp $file ${LIB}/$file >/dev/null 2>&1; then
        rm -f ${LIB}/$file
      else
        # Find any include directives that use "file".
        for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`; do
  	  dir=`echo $file | sed -e s'|/[^/]*$||'`
	  required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
        done
      fi
    fi
  fi
done

# HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
file=sys/param.h
base=`basename $file`
if [ -r ${LIB}/$file ]; then
  file_to_fix=${LIB}/$file
else
  if [ -r ${INPUT}/$file ]; then
    file_to_fix=${INPUT}/$file
  else
    file_to_fix=""
  fi
fi
if [ \! -z "$file_to_fix" ]; then
  echo Checking $file_to_fix
  sed -e '/[  ]MAXINT[        ]/i\
#ifndef MAXINT
'\
      -e '/[  ]MAXINT[        ]/a\
#endif
' $file_to_fix > /tmp/$base
  if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
    true
  else
    echo Fixed $file_to_fix
    rm -f ${LIB}/$file
    cp /tmp/$base ${LIB}/$file
    chmod a+r ${LIB}/$file
    # Find any include directives that use "file".
    for include in `egrep '^[       ]*#[    ]*include[      ]*"[^/]' ${LIB}/$file | sed -e 's/^[    ]*#[    ]*include[ 	]*"\([^"]*\)".*$/\1/'`; do
      dir=`echo $file | sed -e s'|/[^/]*$||'`
      required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
    done
  fi
  rm -f /tmp/$base
fi


# This loop does not appear to do anything, because it uses file
# rather than $file when setting target.  It also appears to be
# unnecessary, since the main loop processes symbolic links.
#if $LINKS; then
#  echo 'Making internal symbolic non-directory links'
#  cd ${INPUT}
#  files=`find . -type l -print`
#  for file in $files; do
#    dest=`ls -ld $file | sed -n 's/.*-> //p'`
#    if expr "$dest" : '[^/].*' > /dev/null; then    
#      target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
#      if [ -f $target ]; then
#        ln -s $dest ${LIB}/$file >/dev/null 2>&1
#      fi
#    fi
#  done
#fi

# Make sure that any include files referenced using double quotes
# exist in the fixed directory.  This comes last since otherwise
# we might end up deleting some of these files "because they don't
# need any change."
set x $required
shift
while [ $# != 0 ]; do
  newreq=
  while [ $# != 0 ]; do
    # $1 is the directory to copy from, $2 is the unfixed file,
    # $3 is the fixed file name.
    cd ${INPUT}
    cd $1
    if [ -r $2 ] && [ ! -r $3 ]; then
      cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
      chmod +w $3 2>/dev/null
      chmod a+r $3 2>/dev/null
      echo Copied $2
      for include in `egrep '^[ 	]*#[ 	]*include[ 	]*"[^/]' $3 | sed -e 's/^[ 	]*#[ 	]*include[ 	]*"\([^"]*\)".*$/\1/'`; do
	dir=`echo $2 | sed -e s'|/[^/]*$||'`
	dir2=`echo $3 | sed -e s'|/[^/]*$||'`
	newreq="$newreq $1 $dir/$include $dir2/$include"
      done
    fi
    shift; shift; shift
  done
  set x $newreq
  shift
done

echo 'Cleaning up DONE files.'
cd $LIB
find . -name DONE -exec rm -f '{}' ';'

echo 'Removing unneeded directories:'
cd $LIB
files=`find . -type d -print | sort -r`
for file in $files; do
  rmdir $LIB/$file > /dev/null 2>&1
done


exit 0
@


1.194
log
@Discard empty C++ comments.
@
text
@d1169 1
a1169 1
# And also with the HP-UX 10 sys/pci.h file
d1178 42
@


1.193
log
@Remove specification of parameters when renaming functions in Alpha
DEC Unix include files.
@
text
@d293 1
@


1.192
log
@Avoid using '0-~' in egrep.
@
text
@d413 31
@


1.191
log
@(sys/limits.h): Fix a nested comment problem with HUGE_VAL definition
on sysV68 R3V7.1.
@
text
@d255 1
a255 1
# We use the pattern [!-.0-~] instead of [^/ 	] to match a noncomment
d258 1
d267 1
a267 1
    if egrep '//|[ 	_]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ 	]+[!-.0-~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-zA-Z][a-zA-Z0-9]' $file >/dev/null; then
@


1.190
log
@(stdlib.h): Do not double-wrap the size_t typedef.
@
text
@d1862 1
d1912 1
@


1.189
log
@Update comments.
@
text
@d925 4
d935 1
a935 1
  -e '/typedef[ 	a-zA-Z_]*[ 	]size_t[ 	]*;/i\
d939 1
a939 1
  -e '/typedef[ 	a-zA-Z_]*[ 	]size_t[ 	]*;/a\
@


1.188
log
@(target_canonical): New variable.
(size_t): Add support for Motorola's stdlib.h which fails to provide
a definition for size_t.
(str{len,spn,cspn} return value): Handle different layout on sysV88.
(fabs/hypot): Provide a fake for hypot which is broken on
m88k-motorola-sysv3; emit a prototype for fabs on m88k-motorola-sysv3.
@
text
@d2883 1
a2883 1
# defining regex.h related types.  This causes libg++ build and usage failures.
@


1.187
log
@       * fixincludes: Fix sys/param.h so that MAXINT will not be redefined
        on HPUX.
@
text
@d15 8
d369 7
d2000 1
d2019 2
d2305 39
@


1.186
log
@Fixincludes patches for HP/UX 10.20.
@
text
@d2904 37
d2999 1
@


1.185
log
@	* fixincludes: Also fix AIX NULL macro in sys/{dir,param,types}.h.
@
text
@d286 3
a288 2
	  /#define._IO/			s/'\''\([cgxtf]\)'\''/\1/g
	  /#define.BSD43__IO/		s/'\''\([cgx]\)'\''/\1/g
d291 3
a293 3
	  /#define[ 	]*[ 	]CTRL/		s/'\''\([cgx]\)'\''/\1/g
	  /#define[ 	]*[ 	]_CTRL/		s/'\''\([cgx]\)'\''/\1/g
	  /#define.BSD43_CTRL/		s/'\''\([cgx]\)'\''/\1/g
d1109 12
@


1.184
log
@        * fixincludes: Fix AIX NULL macro use of void*.
@
text
@d2865 1
a2865 1
for file in curses.h dbm.h locale.h stdio.h stdlib.h string.h time.h unistd.h ; do
@


1.183
log
@(sys/lc_core.h): Fix OSF1/4.x namespace pollution.
@
text
@d2863 28
@


1.182
log
@Remove more cases of __const__ from math.h for NeXT
@
text
@d2812 51
@


1.181
log
@        * fixincludes: Fix need of prototypes for C++ in rpc/xdr.h on SunOS4.
@
text
@d1486 3
a1488 1
  sed -e '/^extern.*double.*__const__.*cos(/s/__const__//' \
@


1.180
log
@        * fixincludes: Fix incorrect forward structure declaration in
        sys/time.h on hpux10.20.
@
text
@d2780 30
@


1.179
log
@Include <stdio.h> unconditionally in <assert.h> if stderr is needed
@
text
@d2586 26
@


1.178
log
@Hack around HP/UX 10.20 sed bug
@
text
@d2351 1
a2351 3
      echo '#ifdef __cplusplus
#include <stdio.h>
#endif' >>${LIB}/$file
@


1.177
log
@Redefine exception in math.h
@
text
@d264 2
d275 1
d277 1
@


1.176
log
@Add extern "C" to <sys/mman.h> on HP/UX.
@
text
@d1325 1
a1325 1
  if grep 'class[(]' ${LIB}/$file >/dev/null; then
d2697 44
@


1.175
log
@Insert newlines just before end of 'sed' command strings if last 'sed'
command is 'a' or 'i'.
@
text
@d2297 8
a2304 8
# assert.h on HP/UX is not C++ ready, even though NO_IMPLICIT_EXTERN_C
# is defined on HP/UX.
file=assert.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi
d2306 7
a2312 7
if [ -r ${LIB}/$file ]; then
  if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
     || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
    true
  else
    echo Fixing $file
    echo '#ifdef __cplusplus
d2315 2
a2316 2
    cat ${LIB}/${file} >> ${LIB}/${file}.sed
    echo '#ifdef __cplusplus
d2319 2
a2320 1
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
d2326 2
a2327 2
        dir=`echo $file | sed -e s'|/[^/]*$||'`
        required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
d2331 1
a2331 1
fi
@


1.174
log
@Remove duplicate volatile from sig_atomic_t in AIX sys/signal.h
@
text
@d2081 2
a2082 1
#ifndef __cplusplus'\
d2084 2
a2085 1
#endif'\
d2087 2
a2088 1
#ifndef __cplusplus'\
d2090 2
a2091 1
#endif'\
@


1.173
log
@* fixincludes:  When running find, add "/." to directory name
to force expanding symlinks to directories.
@
text
@d2676 27
@


1.172
log
@(pthread.h): Add extern to __page_size* declarations
for AIX 4.1.x.
@
text
@a77 4
	if [ "$d" != . ]
	then
	    d=$d/.
	fi
d80 3
a82 2
        files="$files `find $d -type d -print | \
		       sed -e '/\/\.$/d' -e '/^\.$/d'`"
d90 1
a90 1
	  theselinks=`find $d -type l -print`
d185 1
a185 1
	      $file/./*)
@


1.171
log
@Fix undefined VOIDFUNCPTR in VxWorks 5.2 <time.h>
@
text
@d2155 27
@


1.170
log
@Fix signal prototype on SunOS to avoid C++ pedantic error
@
text
@d2555 39
@


1.169
log
@(sys/param.h): Fix c89 __asm statements.
@
text
@d2571 6
d2579 33
@


1.168
log
@(rpc/types.h): Remove spurios "ls" command.
@
text
@d2555 18
@


1.167
log
@(memory.h): Fix it also on sysV68.
@
text
@a1788 1
ls -l $file ${LIB}/$file
@


1.166
log
@	* fixincludes: Wrap rpc/types.h in extern "C", for osf2.0.
@
text
@d1204 1
d1206 1
a1206 1
if [ -r $file ] && egrep '/\*	@@\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2	\*/' $file > /dev/null; then
@


1.165
log
@(stdio.h): Fix return type of fread and fwrite on sysV68.
@
text
@d1785 35
@


1.164
log
@(sys/wait.h): Add forward declaration of struct rusage on AIX 3.2.5.
@
text
@d1237 25
@


1.163
log
@(curses.h): Allow space or tab after bool keyword, instead of tab or tab.
@
text
@d1523 27
@


1.162
log
@(malloc.h):  Fix return type of {m,re}alloc.
@
text
@d2000 1
a2000 1
	-e '/^typedef[ 	][ 	]*char[ 	][ 	]*bool[		]*;/i\
d2002 1
a2002 1
	-e '/^typedef[ 	][ 	]*char[ 	][ 	]*bool[		]*;/a\
@


1.161
log
@(stdlib.h): Be more general in edit to change declaration of
{c,m,re}alloc.
@
text
@d935 1
d947 2
@


1.160
log
@Fix HP/UX <sys/file.h> for g++ -pedantic-errors.
@
text
@d910 4
a913 4
  -e 's/char \*	calloc/void \*	calloc/g' \
  -e 's/char \*	malloc/void \*	malloc/g' \
  -e 's/char \*	realloc/void \*	realloc/g' \
  -e 's/int	exit/void	exit/g' \
@


1.159
log
@(curses.h): typedef bool need not take up entire line.
@
text
@d707 25
@


1.158
log
@Avoid clobbering VxWorks drv/netif/if_med.h file
@
text
@d1972 1
a1972 1
	-e '/^typedef[ 	][ 	]*char[ 	][ 	]*bool[		]*;[ 	]*$/i\
d1974 1
a1974 1
	-e '/^typedef[ 	][ 	]*char[ 	][ 	]*bool[		]*;[ 	]*$/a\
@


1.157
log
@(string.h): Fix return value for mem{ccpy,chr,cpy,set} and
str{len,spn,cspn} on sysV68.
@
text
@d1075 12
@


1.156
log
@Don't define wchar_t under C++.
@
text
@d1837 2
d1850 1
a1850 1
  echo Fixing $file
d1854 6
@


1.155
log
@(math.h):  Keep declaration of abs on HPUX.
@
text
@d374 4
@


1.154
log
@Fix bogus recursive <stdlib.h> in NEWS-OS 4.0C.
@
text
@d1573 1
a1573 1
      -e 's@@inline int abs(int [a-z][a-z]*) {.*}@@@@' \
@


1.153
log
@Allow white space between `#' and `if' when looking for lines to
patch.
@
text
@d1590 29
@


1.152
log
@Add `sel', `tahoe', `r3000', `r4000' to the list of pre-ANSI symbols
that need to be surrounded with __ __.
@
text
@d292 1
a292 1
	  /#[el]*if/{
@


1.151
log
@(stdio.h): BSDI 2.0 changed the spelling of _VA_LIST_ to
_BSD_VA_LIST_.
@
text
@d308 1
d312 1
d319 1
a319 1
		s/ _*R\([34]\)000 / __R\1000__ /g
@


1.150
log
@Fix `typedef struct term;' on hppa1.1-hp-hpux9.
@
text
@d1528 1
@


1.149
log
@Patch some VxWorks header files
@
text
@d1877 24
@


1.148
log
@Only include <stdio.h> and <stdlib.h> in <assert.h> for C++
@
text
@d2230 131
@


1.147
log
@Fix bool test to permit spaces before the semicolon
@
text
@d2123 3
a2125 1
      echo '#include <stdio.h>' >>${LIB}/$file
d2134 3
a2136 1
      echo '#include <stdlib.h>' >>${LIB}/$file
@


1.146
log
@(strings.h): Fix return type of strlen.
@
text
@d1892 1
a1892 1
	-e '/^typedef[ 	][ 	]*char[ 	][ 	]*bool;[ 	]*$/i\
d1894 1
a1894 1
	-e '/^typedef[ 	][ 	]*char[ 	][ 	]*bool;[ 	]*$/a\
@


1.145
log
@Fix non-const atof parameter on NEWS-OS 4.2R
@
text
@d1829 24
@


1.144
log
@Fixes for NextStep 3.2.  Remove ``__const__'' from sin and cos
prototypes in ansi/math.h.  Remove keyword ``template'' from
bfd/libc.h.  Remove ``volatile'' from abort in bsd/libc.h and abort
and exit in ansi/stdlib.h.
@
text
@d1558 1
a1558 1
# parameter to atof not const on DECstation Ultrix V4.0.
d1569 1
a1569 1
  sed -e 's@@atof( char \*__nptr );@@atof( const char *__nptr );@@' \
@


1.143
log
@Make argument type const for popen and tempnam in stdio.h and for
strdup in string.h, for OSF/1 V3.0.
@
text
@d1404 72
@


1.142
log
@Fix X11/Intrinsic.h on RISCiX; add files to REQUIRED as needed
@
text
@d1191 1
a1191 1
# parameters not const on DECstation Ultrix V4.0.
d1208 2
d1731 1
d1743 1
@


1.141
log
@Comment out loop which handled symbolic links to files
@
text
@d379 6
d404 6
d426 6
d446 6
d489 6
d515 31
d571 6
d594 6
d619 6
d644 6
d669 6
d692 6
d721 5
d752 6
d779 6
d803 6
d833 6
d857 6
d894 6
d919 6
d944 6
d969 6
d994 6
d1019 6
d1045 6
d1077 6
d1106 6
d1134 6
d1212 6
d1235 6
d1265 6
d1291 6
d1331 6
d1366 6
d1393 6
d1420 6
d1467 6
d1504 6
d1529 6
d1550 6
d1574 6
d1645 6
d1694 6
d1718 6
d1744 6
d1766 8
a1773 2
    if cmp $file ${LIB}/$file >/dev/null 2>&1; then
      rm -f ${LIB}/$file
d1800 6
d1826 6
d1850 6
d1911 6
d1936 6
d1965 6
d1999 6
d2037 6
d2061 6
d2117 6
@


1.140
log
@Tweaks for LynxOS 2.2.2
@
text
@d1766 17
a1782 14
if $LINKS; then
  echo 'Making internal symbolic non-directory links'
  cd ${INPUT}
  files=`find . -type l -print`
  for file in $files; do
    dest=`ls -ld $file | sed -n 's/.*-> //p'`
    if expr "$dest" : '[^/].*' > /dev/null; then    
      target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
      if [ -f $target ]; then
        ln -s $dest ${LIB}/$file >/dev/null 2>&1
      fi
    fi
  done
fi
@


1.139
log
@Don't remove empty directories until after removing DONE files
@
text
@d1469 1
a1469 1
  sed -e '/#define[ 	][ 	]*void[ 	]int/d' \
d1747 18
@


1.138
log
@Handle a symlink to root/* from a subdirectory of a symlink to root/*
@
text
@a1747 7
echo 'Removing unneeded directories:'
cd $LIB
files=`find . -type d -print | sort -r`
for file in $files; do
  rmdir $LIB/$file > /dev/null 2>&1
done

d1796 7
@


1.137
log
@Canonicalize ${INPUT} to avoid automounter problems.
@
text
@d201 4
d206 1
a206 2
	  dots=`echo "$file" |
	    sed -e 's@@^./@@@@' -e 's@@/./@@/@@g' -e 's@@[^/][^/]*@@..@@g' -e 's@@..$@@@@'`
@


1.136
log
@Various changes to avoid clobbering glibc header files
@
text
@d145 3
d149 1
a149 1
	if [ $x = $INPUT ]; then
d155 1
a155 1
	elif expr $x : "${INPUT}/.*" > /dev/null; then
d157 1
a157 1
	  y=`echo $x | sed -n "s&${INPUT}/&&p"`
@


1.135
log
@Rework required loop to avoid crash on decstation
@
text
@d320 2
a321 1
	if cmp $file $2/$file >/dev/null 2>&1; then
d1195 6
a1200 2
  (echo "#define __need___va_list"
   echo "#include <stdarg.h>") > ${LIB}/${file}.sed
d1212 1
d1215 1
a1215 1
      -e 's@@_NEED___Va_LIST@@_NEED___VA_LIST@@' \
d1642 2
a1643 1
  if egrep '"C"' ${LIB}/$file >/dev/null 2>/dev/null; then
d1723 16
a1738 12
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
    cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
    chmod +w ${LIB}/$file 2>/dev/null
  fi
  if [ -r ${LIB}/$file ]; then
    echo Fixing $file, to protect against multiple inclusion.
    cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
    (echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
    echo "#define __GCC_GOT_${cpp_wrapper}_"
    cat ${LIB}/${file}
    echo '#endif /* !_GCC_GOT_'${cpp_wrapper}_' */')  > ${LIB}/${file}.new
    rm -f ${LIB}/$file; mv ${LIB}/${file}.new ${LIB}/$file
@


1.134
log
@Wrap <time.h> and <sys/time.h> to avoid multiple inclusion errors.
@
text
@d1757 3
a1759 1
while [ -n "$required" ]; do
a1760 2
  set x $required
  shift
d1779 2
a1780 1
  required=$newreq
@


1.133
log
@Fix sbrk return type in <unistd.h> on Alpha OSF/1 V2.0.
@
text
@d1713 18
@


1.132
log
@include stdio.h and stdlib.h into assert.h as necessary
@
text
@d1663 2
a1664 2
  if grep 'stderr' ${LIB}/$file >/dev/null ; then
    if grep 'include.*stdio.h' ${LIB}/$file >/dev/null ; then
d1671 3
a1673 3
  if grep 'exit *(' ${LIB}/$file >/dev/null || 
     grep 'abort *(' ${LIB}/$file >/dev/null ; then
    if grep 'include.*stdlib.h' ${LIB}/$file >/dev/null ; then
d1680 18
@


1.131
log
@Correct math.h handling on Lynx again.
@
text
@d1654 31
@


1.130
log
@Correct argument type for ffs in string.h on Alpha OSF/1 V2.0
@
text
@d1398 1
a1401 1
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
@


1.129
log
@Wrap assert.h in extern "C" { }
@
text
@d1428 1
d1439 1
@


1.128
log
@Protect bool in curses.h
@
text
@d1401 2
d1621 28
@


1.127
log
@Don't pass $(srcdir) to fixincludes scripts; don't explicitly copy files
which are now copied by ${required} code.
@
text
@d1461 27
@


1.126
log
@Make OSF/1 getopt.h fix work on AIX also
@
text
@a7 5
# Directory where gcc sources (and sometimes special include files) live.
# fixincludes doesn't use this, but fixinc.svr4 does, and I want to make
# sure somebody doesn't try to use arg3 for something incompatible. -- gumby
SRCDIR=${3-${SRCDIR-.}}

a41 10
# Make SRCDIR absolute only if needed to avoid problems with the amd.
cd $ORIGDIR
case $SRCDIR in
/*)
	;;
*)
	cd $SRCDIR; SRCDIR=`${PWDCMD}`
	;;
esac

a1497 12

# These two files on SunOS 4 are included by other files
# in the same directory, using "...".  So we must make sure they exist
# in the same directory as the other fixed files.
if [ -r ${INPUT}/multimedia/audio_errno.h ]
then
  ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
fi
if [ -r ${INPUT}/multimedia/audio_hdr.h ]
then
  ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
fi
@


1.125
log
@Add forward declaration of struct exception to
        SunOS 4 math.h.
@
text
@d1495 1
a1495 1
# Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1.
d1505 1
a1505 1
    sed -e 's/getopt(int, char \*\[\],char \*)/getopt(int, char *const[], const char *)/' \
@


1.124
log
@Various Lynx-related fixups.  To math.h, string.h and curses.h.
@
text
@d1600 22
@


1.123
log
@Don't recursively search symlinks to `.'.
@
text
@d1401 15
d1437 36
@


1.122
log
@        * fixincludes: Fix ptrdiff_t and wchar_t in system headers like we
        do size_t.
@
text
@d115 5
a119 1
		newdirs="$newdirs $d1"
a123 1
    files="$files $newdirs"
@


1.121
log
@Modify comment referring to gvarargs.h.
@
text
@d350 2
a351 1
# Install the proper definition of size_t in header files that it comes from.
d360 3
a362 2
    echo Fixing size_t in $file
    sed -e '/typedef[ 	][ 	]*[a-z_][ 	a-z_]*[ 	]size_t/i\
d367 14
a380 1
      -e 's/typedef[ 	][ 	]*[a-z_][ 	a-z_]*[ 	]size_t/typedef __SIZE_TYPE__ size_t/' ${LIB}/$file > ${LIB}/${file}.sed
@


1.120
log
@Insert newlines for sed 'a' and 'i' commands.
@
text
@d1180 1
a1180 1
# This is for ANSI and also to interoperate properly with gvarargs.h.
@


1.119
log
@* fixincludes: Fix including of machine/r3_cpu.h and machine/r4_cpu.h
in machine/cpu.h on Ultrix 4.3.
@
text
@d363 2
a364 1
#endif' \
d433 2
a434 1
#define _GCC_SIZE_T' \
d436 2
a437 1
#endif' \
d440 2
a441 1
#define _GCC_PTRDIFF_T' \
d443 2
a444 1
#endif' \
d447 2
a448 1
#define _GCC_WCHAR_T' \
d450 2
a451 1
#endif' ${LIB}/$file > ${LIB}/${file}.sed
d492 2
a493 1
#define _GCC_SIZE_T' \
d495 2
a496 1
#endif' ${LIB}/$file > ${LIB}/${file}.sed
d743 2
a744 1
#define _GCC_SIZE_T' \
d746 2
a747 1
#endif' \
d910 2
a911 1
struct sockaddr;' \
d932 2
a933 1
struct __file_s;' \
d1043 2
a1044 1
#ifndef __cplusplus' \
d1046 2
a1047 1
#endif' ${LIB}/$file > ${LIB}/${file}.sed
d1096 2
a1097 1
#else' \
d1099 2
a1100 1
#endif' ${LIB}/$file > ${LIB}/${file}.sed
d1124 2
a1125 1
#else' \
d1127 2
a1128 1
#endif' \
d1319 2
a1320 1
#ifndef FLT_MIN'\
d1322 2
a1323 1
#endif'\
d1325 2
a1326 1
#ifndef FLT_MAX'\
d1328 2
a1329 1
#endif'\
d1331 2
a1332 1
#ifndef FLT_DIG'\
d1334 2
a1335 1
#endif'\
d1337 2
a1338 1
#ifndef DBL_MIN'\
d1340 2
a1341 1
#endif'\
d1343 2
a1344 1
#ifndef DBL_MAX'\
d1346 2
a1347 1
#endif'\
d1349 2
a1350 1
#ifndef DBL_DIG'\
d1352 2
a1353 1
#endif'\
d1376 2
a1377 1
#ifndef HUGE_VAL'\
d1379 2
a1380 1
#endif'\
@


1.118
log
@Put double underscores around M32, m88k, pdp11, tower[_0-9]*, u370, u3b[0-9]*
@
text
@d586 1
d596 5
a600 2
  echo Fixing $file, superfluous static
  sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.sed
d608 2
a609 1
      ln ${LIB}/$file ${LIB}/mips/cpu.h 
@


1.117
log
@Permit upper case characters in typedef of size_t in <sys/types.h>.
@
text
@d304 1
d308 1
d312 1
d317 3
@


1.116
log
@Fix uses of new in Xm/Traversal.h.
@
text
@d477 1
a477 1
sed -e '/typedef[ 	][ 	]*[a-z_][ 	a-z_]*[ 	]size_t/i\
d480 1
a480 1
    -e '/typedef[ 	][ 	]*[a-z_][ 	a-z_]*[ 	]size_t/a\
@


1.115
log
@Use __SIZE_TYPE__ for size_t type, rather than running gcc to get it.
@
text
@d1092 1
a1092 1
    echo Fixing $file, field new
d1098 2
a1099 1
#endif' ${LIB}/$file > ${LIB}/${file}.sed
@


1.114
log
@Clean up some X11 header files for C++; problems found on RS/6000.
@
text
@a7 3
# Command to run gcc.
GCCCMD=${4-${GCCCMD-gcc}}

d353 6
a358 9
    echo Fixing $file comment
    # Get the definition of __SIZE_TYPE__, if any.
    # (This file must be called something.c).
    echo "__SIZE_TYPE__" > ${LIB}/types.c
    foo=`${GCCCMD} -E -P ${LIB}/types.c`
    rm -f ${LIB}/types.c
    # Default to our preferred type.
    if [ "$foo" = __SIZE_TYPE__ ]; then foo="unsigned long int"; fi
    sed -e "s/typedef[ 	][ 	]*[a-z_][ 	a-z_]*[ 	]size_t/typedef $foo size_t/" ${LIB}/$file > ${LIB}/${file}.sed
@


1.113
log
@When edit size_t typedef, modify sed pattern to
avoid matching typedef uses of size_t.  Likewise when adding
#ifndef GCC_SIZE_T.
@
text
@d1054 80
@


1.112
log
@Do not fix <syndev/ipi_error.h> to avoid problems with SunOS sed
@
text
@d364 1
a364 1
    sed -e "s/typedef[ 	a-z_]*[ 	]size_t/typedef $foo size_t/" ${LIB}/$file > ${LIB}/${file}.sed
d472 2
a473 1
# match e.g. ssize_t present in AIX for the ps/2.
d483 1
a483 1
sed -e '/[ 	]size_t.*;/i\
d486 1
a486 1
    -e '/[ 	]size_t.*;/a\
@


1.111
log
@Merge in changes from fixinc.mips.  Fix identifiers
host_mips, mips, MIPSE[LB], R[34]000, SYSTYPE_*.  Fix size_t uses
in stddef.h, memory.h, unistd.h.  Fix /**/ in bsd43/bsd43_.h.
@
text
@d1411 10
@


1.110
log
@(rpc/auth.h, rpc/xdr.h): Declare structures before using them in
prototypes, for Irix 4.0.5.
(rpc/rpc.h): Avoid a nested comment on Ultrix 4.3.
@
text
@d270 1
a270 1
    if egrep '//|[ 	_]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ 	]+[!-.0-~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-z][a-z0-9]' $file >/dev/null; then
d305 1
d310 1
d319 3
d348 1
a348 1
for file in sys/types.h stdlib.h sys/stdtypes.h; do
d1153 15
@


1.109
log
@Do not preserve _HIDDEN_VA_LIST in <stdio.h>
@
text
@d875 42
d1147 18
@


1.108
log
@(stdio.h): Fix typos (missing quote) in previous change.
@
text
@a1051 1
      -e 's@@_HIDDEN_VA_LIST@@_HIDDEN_Va_LIST@@' \
a1053 1
      -e 's@@_HIDDEN_Va_LIST@@_HIDDEN_VA_LIST@@' \
@


1.107
log
@Preserve _HIDDEN_VA_LIST when changing VA_LIST to DUMMY_VA_LIST.
Change __va_list to __gnuc_va_list.  For AIX 3.2.5.
@
text
@d1052 1
a1052 1
      -e 's@@_HIDDEN_VA_LIST@@_HIDDEN_Va_LIST@@ \
d1055 1
a1055 1
      -e 's@@_HIDDEN_Va_LIST@@_HIDDEN_VA_LIST@@ \
@


1.106
log
@(math.h): When deleting inline sqrt and abs,
be flexible about arg name and function body.
@
text
@d1050 1
d1052 1
d1055 1
@


1.105
log
@When compute DOTS, convert /./ to / to avoid
accidentally converting it to /../.
@
text
@d1081 4
a1084 4
      -e 's@@inline int abs(int d) { return (d>0)?d:-d; }@@@@' \
      -e 's@@inline double abs(double d) { return fabs(d); }@@@@' \
      -e 's@@inline int sqr(int x) {return(x\*x);}  /\* For AT&T compatibility \*/@@@@' \
      -e 's@@inline double sqr(double x) {return(x\*x);}@@@@' \
@


1.104
log
@(math.h): Add missing quoting of `*' when fixing prototype of `sqr'.
@
text
@d172 1
a172 1
		sed -e 's@@^./@@@@' -e 's@@[^/][^/]*@@..@@g' -e 's@@..$@@@@'`
d215 1
a215 1
		sed -e 's@@^./@@@@' -e 's@@[^/][^/]*@@..@@g' -e 's@@..$@@@@'`
@


1.103
log
@Copy files needed for other files at the very end.
@
text
@d1083 2
a1084 2
      -e 's@@inline int sqr(int x) {return(x*x);}  /* For AT&T compatibility */@@@@' \
      -e 's@@inline double sqr(double x) {return(x*x);}@@@@' \
@


1.102
log
@(math.h): Delete inline definitions for sqr.
@
text
@a339 27
# Make sure that any include files referenced using double quotes
# exist in the fixed directory.
while [ -n "$required" ]; do
  newreq=
  set x $required
  shift
  while [ $# != 0 ]; do
    # $1 is the directory to copy from, $2 is the unfixed file,
    # $3 is the fixed file name.
    cd ${INPUT}
    cd $1
    if [ -r $2 ] && [ ! -r $3 ]; then
      cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
      chmod +w $3 2>/dev/null
      chmod a+r $3 2>/dev/null
      echo Copied $2
      for include in `egrep '^[ 	]*#[ 	]*include[ 	]*"[^/]' $3 | sed -e 's/^[ 	]*#[ 	]*include[ 	]*"\([^"]*\)".*$/\1/'`; do
	dir=`echo $2 | sed -e s'|/[^/]*$||'`
	dir2=`echo $3 | sed -e s'|/[^/]*$||'`
	newreq="$newreq $1 $dir/$include $dir2/$include"
      done
    fi
    shift; shift; shift
  done
  required=$newreq
done

d1351 29
@


1.101
log
@(loop on $required): When a file is copied
because another file needs it, scan it for what files it needs.
@
text
@d1110 2
@


1.100
log
@Don't fix /**/ in X11 files; unnecessary
@
text
@d342 23
a364 14
set x $required
shift
while [ $# != 0 ]; do
  # $1 is the directory to copy from, $2 is the unfixed file,
  # $3 is the fixed file name.
  cd ${INPUT}
  cd $1
  if [ -r $2 ] && [ ! -r $3 ]; then
    cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
    chmod +w $3 2>/dev/null
    chmod a+r $3 2>/dev/null
    echo Copied $2
  fi
  shift; shift; shift
@


1.99
log
@(sys/stat.h) Fix fchmod prototype, first arg is int, not char * [AIX 3.2.4].
(rpc/svc.h): Avoid nested comments [Ultrix 4.3].
(stdio.h, stdlib.h): Fixed getopt prototypes to match POSIX.2
[DEC Alpha OSF/1 1.3].

Fix <sys/limits.h> like <limits.h>.
@
text
@d1329 1
a1329 2
	dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h \
	X11/extensions/multibufst.h X11/Xlibinit.h Xm.acorn/XmP.h
@


1.98
log
@Unquote 'f' in #define _IO.  Fix elf.h like
elf_abi.h.  For Irix 5.
@
text
@d1005 19
d1108 19
d1134 7
a1140 6
file=limits.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi
d1142 6
a1147 6
if [ -r ${LIB}/$file ]; then
  if egrep 'ifndef[ 	]+FLT_MIN' ${LIB}/$file >/dev/null; then
    true
  else
    echo Fixing $file
    sed -e '/[ 	]FLT_MIN[ 	]/i\
d1149 1
a1149 1
        -e '/[ 	]FLT_MIN[ 	]/a\
d1151 1
a1151 1
        -e '/[ 	]FLT_MAX[ 	]/i\
d1153 1
a1153 1
        -e '/[ 	]FLT_MAX[ 	]/a\
d1155 1
a1155 1
        -e '/[ 	]FLT_DIG[ 	]/i\
d1157 1
a1157 1
        -e '/[ 	]FLT_DIG[ 	]/a\
d1159 1
a1159 1
        -e '/[ 	]DBL_MIN[ 	]/i\
d1161 1
a1161 1
        -e '/[ 	]DBL_MIN[ 	]/a\
d1163 1
a1163 1
        -e '/[ 	]DBL_MAX[ 	]/i\
d1165 1
a1165 1
        -e '/[ 	]DBL_MAX[ 	]/a\
d1167 1
a1167 1
        -e '/[ 	]DBL_DIG[ 	]/i\
d1169 1
a1169 1
        -e '/[ 	]DBL_DIG[ 	]/a\
d1171 7
a1177 2
      ${LIB}/$file > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
d1179 1
a1179 5
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    echo Deleting ${LIB}/$file\; no fixes were needed.
    rm -f ${LIB}/$file
  fi
fi
d1240 19
@


1.97
log
@Don't remove /**/ from X11/xmd.h.
@
text
@d294 1
a294 1
	  /#define._IO/			s/'\''\([cgxt]\)'\''/\1/g
d881 9
a889 8
# Another IRIX 4.0.1 header file contains the string "//"
file=elf_abi.h
if [ -r ${LIB}/$file ]; then
  echo Fixing $file, overeager sed script
  sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
d891 1
a891 1
fi
@


1.96
log
@(bsd/sys/wait.h): Undo previous change.
@
text
@d1270 1
a1270 2
	X11/extensions/multibufst.h X11/Xmd.h X11/Xlibinit.h \
	Xm.acorn/XmP.h
@


1.95
log
@Fix NeXT <sys/wait.h> problem in <bsd/sys/wait.h>
as well, since that is where the file is in NeXTStep 3.0.
@
text
@d1004 4
a1007 1
# NeXT defines 'int wait(union wait*)', which conflicts with Posix.1.
a1009 20
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ] \
  && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
  echo Fixing $file, bad wait formal
  sed -e 's@@wait(union wait@@wait(void@@' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  fi
fi

# Some versions of NeXTStep apparently have the file fixed above in
# bsd/sys/wait.h, instead.
file=bsd/sys/wait.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  mkdir ${LIB}/bsd 2>/dev/null
  mkdir ${LIB}/bsd/sys 2>/dev/null
@


1.94
log
@Fix bad S_IS* macros in <sys/stat.h> on m88k-sysv3.
@
text
@d1021 20
@


1.93
log
@Remove nested brackets in change of Oct 21.
Fix token pasting operator in ARM/RISCiX include files.
@
text
@d1178 19
@


1.92
log
@Avoid #define of __wchar_t on ARM/RISCiX <stdlib.h>
@
text
@d475 2
a476 2
  sed -e "s/\(#[ 	]*\(ifndef\)[ 	]*\)__wchar_t/\1_GCC_WCHAR_T/" \
      -e "s/\(#[ 	]*\(define\)[ 	]*\)__wchar_t/\1_GCC_WCHAR_T/" \
d1229 21
@


1.91
log
@(required): Accept a space instead of a tab
between #define and CTRL (or _CTRL).
@
text
@d464 20
@


1.90
log
@Remove erroneous parens from Alpha OSF/1 <sym.h>.
@
text
@d298 2
a299 2
	  /#define[ 	]*[	]CTRL/		s/'\''\([cgx]\)'\''/\1/g
	  /#define[ 	]*[	]_CTRL/		s/'\''\([cgx]\)'\''/\1/g
@


1.89
log
@If a file is referenced with double quotes from
a fixed file, make sure it is copied into the fixed include directory.

Remove DPS/XDPSlib.h special-case code.
@
text
@d1140 18
@


1.88
log
@Quote braces on `find' looking for DONE files.
@
text
@d226 1
d328 5
d340 18
a496 14
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm ${LIB}/$file
  fi
fi

# Fix AIX use of "XDPS.h" to refer to <DPS/XDPS.h>
file=DPS/XDPSlib.h
if [ -r $file ] && [ ! -r ${LIB}/$file ] ; then
  cp $file ${LIB}/$file
fi
if [ -r ${LIB}/$file ] ; then
  echo Fixing $file
  sed -e 's,"XDPS.h",<DPS/XDPS.h>,' ${LIB}/$file > ${LIB}/${file}.sed
@


1.87
log
@Fix typo
@
text
@d1221 1
a1221 1
find . -name DONE -exec rm -f {} ';'
@


1.86
log
@Fix typo
@
text
@d481 1
a481 1
if [ -r $file] && [ ! -r ${LIB}/$file ] ; then
@


1.85
log
@(sys/spinlock.h): Don't copy it if it doesn't exist.
(DPS/XDPSlib.h): Change "XDPS.h" to <DPS/XDPS.h>, for AIX.
@
text
@d481 1
a481 1
if [-r $file] && [ ! -r ${LIB}/$file ] ; then
@


1.84
log
@When fixing _IO's definition, handle t as arg name.
@
text
@d465 1
a465 1
if [ ! -r ${LIB}/$file ] ; then
d473 14
@


1.83
log
@* fixincludes (sys/spinlock.h): change references of
"../machine/*.h" to <machine/*.h>
@
text
@d293 1
a293 1
	  /#define._IO/			s/'\''\([cgx]\)'\''/\1/g
@


1.82
log
@({sparc,sun3,sun3x,sun4,sun4c,sun4m}/asm_linkage.h,
{sun4c,sun4m}/debug/asm_linkage.h: Replace /**/ with ##.
@
text
@d462 17
@


1.81
log
@(math.h): Put #ifndef around HUGE_VAL define.
@
text
@d1146 20
@


1.80
log
@(sbusdev/audiovar.h): Fix wrongly edited // comments
nested within /* */ comments.
@
text
@d1076 23
@


1.79
log
@Get size_t typedef using gcc, not cc
@
text
@d831 11
@


1.78
log
@Fix some AIX and NeXT problems.
@
text
@d8 3
d346 1
a346 1
    # Extract the definition of SIZE_TYPE, if any.
d348 2
a349 3
    echo "#include \"tm.h\"
gobblegobble SIZE_TYPE" > ${LIB}/types.c
    foo=`cd ${LIB}; cc -E -I${ORIGDIR} -I${SRCDIR} -I${SRCDIR}/config types.c | grep gobblegobble | sed -e "s/gobblegobble[ 	]*//"`
d352 1
a352 1
    if [ "$foo" = SIZE_TYPE ]; then foo="unsigned long int"; else foo=`echo $foo | sed -e 's/^.*"\(.*\)".*$/\1/'`; fi
@


1.77
log
@(sys/types.h sys/stdtypes.h): Delete newline before do.
(machine/cpu.h): Delete space in `2>& 1'.
@
text
@d891 19
a909 1
file=stdio.h
d913 1
d917 24
a940 3
  echo Fixing $file, parameter name conflicts
  sed -e 's@@rename(const char \*old, const char \*new)@@rename(const char *_old, const char *_new)@@' \
    ${LIB}/$file > ${LIB}/${file}.sed
@


1.76
log
@(stdlib.h): Check carefully for definition of size_t.
@
text
@d334 1
a334 2
for file in sys/types.h stdlib.h sys/stdtypes.h;
do
d551 1
a551 1
    if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
@


1.75
log
@Don't discard comment end characters on lines that
look like "#endif */".  Fixes Esix 4.0.4 problem.
@
text
@d677 1
a677 1
  -e '/[ 	]size_t[ 	]*;/i\
d680 1
a680 1
  -e '/[ 	]size_t[ 	]*;/a\
@


1.74
log
@(file): Fix size_t definition in stdlib.h as in types.h.
Also a conditional to prevent repeated definition.
@
text
@d285 2
a286 1
	  s%^\([ 	]*#[ 	]*endif\)[ 	]*[^/ 	].*%\1%
@


1.73
log
@Check for symlinks being available in /tmp.
@
text
@d293 2
a294 2
	  /#define.CTRL/		s/'\''\([cgx]\)'\''/\1/g
	  /#define._CTRL/		s/'\''\([cgx]\)'\''/\1/g
d333 1
a333 1
for file in sys/types.h sys/stdtypes.h;
d660 1
d675 7
a681 1
  -e 's/int	exit/void	exit/g' ${LIB}/$file > ${LIB}/${file}.sed
@


1.72
log
@Don't create absolute symbolic links;
make them relative instead.
@
text
@d69 3
@


1.71
log
@Remove special case for IRIX 4.0.1 that was superseded
by a more general fix to fixincludes.
@
text
@d164 4
a167 1
	  echo $file '->' $y ': Making link'
d169 1
a169 1
	  ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
d207 3
d211 1
a211 1
	  ln -s ${LIB}/root$x ${LIB}/$file > /dev/null 2>&1
@


1.70
log
@Remove everything after #endif, instead of trying
to turn it into comments, which loses inside comments.
Remove #endif workarounds for Ultrix 4.[12]
and SunOS 4.1, which are no longer needed because of this bug fix.
@
text
@a786 14
# Fix line in IRIX 4.0.1 header file.  The sed script turns
# #define EM_CTRL		(CUTIOC|0x1)
# into
# #define EM_CTRL		(CUTIOC|0x'1')
file=sys/t3270reg.h
if [ -r ${LIB}/$file ]; then
  echo Fixing $file, overeager sed script
  sed -e "s/0x'1'/0x1/" ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  fi
fi

@


1.69
log
@(stdtypes.h): Verify that size_t etc. follow whitespace.
@
text
@d273 4
a276 2
	  s%^\([ 	]*#[ 	]*endif[ 	]*\)\([^/ 	].*\)$%\1/* \2 */%
	  s%^\([ 	]*#[ 	]*else[ 	]*\)\([^/ 	].*\)$%\1/* \2 */%
a524 18
# Remove nested comments created by #endifs in a comment (Ultrix 4.1)
# Only needed if commenting out junk after #endif.
file=signal.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file, nested comments
  sed -e 's/^[ 	]*#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  fi
fi

a690 18

# Fix bogus comment in <locale.h> on SunOS 4.1.
file=locale.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
  chmod +w ${LIB}/$file 2>/dev/null
  chmod a+r ${LIB}/$file 2>/dev/null
fi

if [ -r ${LIB}/$file ]; then
  echo Fixing $file
  sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
    rm -f ${LIB}/$file
  fi
fi

a1066 11

# These files on Ultrix 4.2 put comments around instances of #endif
# __mips.  When the sed expression turns that into #endif /* __mips */
# the comment ends prematurely.
for file in sys/audit.h sys/signal.h; do
  if [ -r ${LIB}/${file} ]; then
    echo Fixing $file, early comment termination
    sed -e 's|^#endif /\*.*\*/|#endif|g' ${LIB}/${file} > ${LIB}/${file}.sed
    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
  fi
done
@


1.68
log
@(file): When changing VA_LIST to DUMMY_VA_LIST, preserve _NEED___VA_LIST.
@
text
@d406 1
a406 1
sed -e '/size_t.*;/i\
d409 1
a409 1
    -e '/size_t.*;/a\
d411 1
a411 1
    -e '/ptrdiff_t.*;/i\
d414 1
a414 1
    -e '/ptrdiff_t.*;/a\
d416 1
a416 1
    -e '/wchar_t.*;/i\
d419 1
a419 1
    -e '/wchar_t.*;/a\
@


1.67
log
@(stdio.h math.h ctype.h sys/{limits.h,fcntl.h,dirent.h}):
Fix STDC/POSIX and other things for Interactive	Unix 2.2 or later.
@
text
@d963 1
d965 1
@


1.66
log
@(signal.h): FIx typo in last change.

(signal.h): Don't mung #endif if nonwhite stuff precedes.
@
text
@d1065 35
@


1.65
log
@(Fixing CTRL): Reject CTRL or _CTRL following digit.
@
text
@d534 1
a534 1
  sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
@


1.64
log
@Use $file. rather than $file.sed
when $file is or might be more than 10 characters long.
@
text
@d280 2
a281 2
	  /[^A-Z_]CTRL[ 	]*(/		s/\([^'\'']\))/'\''\1'\'')/
	  /[^A-Z]_CTRL[ 	]*(/		s/\([^'\'']\))/'\''\1'\'')/
@


1.63
log
@(memory.h): Don't try to read it if it doesn't exist.
@
text
@d306 2
a307 2
	' $2/$file > $2/$file.sed
	mv $2/$file.sed $2/$file
d737 2
a738 2
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
d794 2
a795 2
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
@


1.62
log
@When finding SIZE_TYPE, cd to ${LIB} to run cc.
@
text
@d866 2
a867 2
if egrep '/\*	@@\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2	\*/' $file > /dev/null; then
  if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
@


1.61
log
@More fixes for IRIX 4.0.1
@
text
@d336 1
a336 1
    foo=`cc -E -I${ORIGDIR} -I${SRCDIR} -I${SRCDIR}/config ${LIB}/types.c | grep gobblegobble | sed -e "s/gobblegobble[ 	]*//"`
@


1.60
log
@Patches for IRIX 4.0.1
@
text
@d280 2
a281 1
	  /[^A-Z]CTRL[ 	]*(/		s/\([^'\'']\))/'\''\1'\'')/
d848 11
@


1.59
log
@Fix #endif comments
@
text
@d276 1
a276 1
	  /[ 	]_IO[A-Z]*[ 	]*(/	s/(\(.\),/('\''\1'\'',/
d818 29
@


1.58
log
@Don't put #ifndefs in limits.h if they are already there
@
text
@d1024 11
@


1.57
log
@Move comments about big sed command outside the command itself.
@
text
@d962 5
d975 5
a979 2
  echo Fixing $file
  sed -e '/[ 	]FLT_MIN[ 	]/i\
d981 1
a981 1
      -e '/[ 	]FLT_MIN[ 	]/a\
d983 1
a983 1
      -e '/[ 	]FLT_MAX[ 	]/i\
d985 1
a985 1
      -e '/[ 	]FLT_MAX[ 	]/a\
d987 1
a987 1
      -e '/[ 	]FLT_DIG[ 	]/i\
d989 1
a989 1
      -e '/[ 	]FLT_DIG[ 	]/a\
d991 1
a991 1
      -e '/[ 	]DBL_MIN[ 	]/i\
d993 1
a993 1
      -e '/[ 	]DBL_MIN[ 	]/a\
d995 1
a995 1
      -e '/[ 	]DBL_MAX[ 	]/i\
d997 1
a997 1
      -e '/[ 	]DBL_MAX[ 	]/a\
d999 1
a999 1
      -e '/[ 	]DBL_DIG[ 	]/i\
d1001 1
a1001 1
      -e '/[ 	]DBL_DIG[ 	]/a\
d1003 3
a1005 2
    ${LIB}/$file > ${LIB}/${file}.sed
  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
@


1.56
log
@(memory.h): Use proper ANSI syntax in `#endif __memory_h__'.
@
text
@d263 6
a284 1
		# Surround each word with spaces, to simplify matching below.
a286 2
		# ANSIfy each pre-ANSI machine-dependent symbol
		# by surrounding it with __ __.
a300 1
		# Remove the spaces that we inserted around each word.
@


1.55
log
@Fix #endif foo; don't alter sh options; clean up all DONE files
@
text
@d850 1
a850 1
#endif __memory_h__
@


1.54
log
@Delete ${LIB}/DONE just before exit.
@
text
@d214 2
a215 1
set - $treetops
d245 13
a257 2
# rms: I removed `|#[el].*if.*[^/ 	]' because it made egrep fail.
    if egrep '//|[ 	_]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then
a262 4
# Following two lines removed.
#	  s%^\([ 	]*#[ 	]*endif[ 	]*\)\([^/ 	].*\)$%\1/* \2 */%
#	  s%^\([ 	]*#[ 	]*else[ 	]*\)\([^/ 	].*\)$%\1/* \2 */%

d267 2
d273 1
a273 1
	  /#define.BSD43__IO/		s/'\''\(]cgx]\)'\''/\1/g
d278 23
a300 11
	  /#[a-z]*if.*[	 (]m68k/	s/\([^_]\)m68k/\1__m68k__/g
	  /#[a-z]*if.*[	 (]__i386/	s/__i386/__i386__/g
	  /#[a-z]*if.*[	 (]i386/	s/\([^_]\)i386/\1__i386__/g
	  /#[a-z]*if.*[	 (]sparc/	s/\([^_]\)sparc/\1__sparc__/g
	  /#[a-z]*if.*[	 (]mc68000/	s/\([^_]\)mc68000/\1__mc68000__/g
	  /#[a-z]*if.*[	 (]vax/		s/\([^_]\)vax/\1__vax__/g
	  /#[a-z]*if.*[	 (]sun/		s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
	  /#[a-z]*if.*[	 (]sun/		s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
	  /#[a-z]*if.*[	 (]ns32000/	s/\([^_]\)ns32000/\1__ns32000__/g
	  /#[a-z]*if.*[	 (]pyr/		s/\([^_]\)pyr/\1__pyr__/g
	  /#[a-z]*if.*[	 (]is68k/	s/\([^_]\)is68k/\1__is68k__/g
d522 15
a536 15
#file=signal.h
#if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
#  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
#  chmod +w ${LIB}/$file 2>/dev/null
#  chmod a+r ${LIB}/$file 2>/dev/null
#fi
#
#if [ -r ${LIB}/$file ]; then
#  echo Fixing $file, nested comments
#  sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
#  rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
#  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
#    rm -f ${LIB}/$file
#  fi
#fi
d1035 3
a1037 2
# Prevent premature exit when subsequently processing OTHER_FIXINCLUDES_DIRS.
rm ${LIB}/DONE
@


1.53
log
@(SRCDIR): Make absolute from ORIGDIR.
(sys/types.h): Quote variables that might expand with spaces.
Strip quotes from expansion of SIZE_TYPE.

Also fix incorrect installation of previous patch.
@
text
@d1013 3
@


1.52
log
@Change "va_list)" to "__gnuc_va_list)".
@
text
@d47 10
d314 1
a314 1
    if [ $foo = SIZE_TYPE ]; then foo="unsigned long int"; else true; fi
a839 1
      -e 's@@ va_list)@@ __gnuc_va_list)@@' \
d894 1
@


1.51
log
@* Save temp file in ${LIB}. Use -I${ORIGDIR} when compiling types.c.
@
text
@d830 1
@


1.50
log
@(sys/types.h): Replace definition of size_t based on SIZE_TYPE.
@
text
@d30 3
d300 3
a302 3
gobblegobble SIZE_TYPE" > types.c
    foo=`cc -E -I. -I$SRCDIR -I$SRCDIR/config types.c | grep gobblegobble | sed -e "s/gobblegobble[ 	]*//"`
    rm -f types.c
@


1.49
log
@Don't assume that macros defining IO and CTRL ioctl codes always use
`x'; some use `c' or `g'.
@
text
@d283 27
@


1.48
log
@        * fixincludes: Fix logic about when to duplicate entries under the
        `FILE' link.
@
text
@d249 2
a250 2
	  /#define._IO/			s/'\''x'\''/x/g
	  /#define.BSD43__IO/		s/'\''x'\''/x/g
d252 3
a254 3
	  /#define.CTRL/		s/'\''c'\''/c/g
	  /#define._CTRL/		s/'\''c'\''/c/g
	  /#define.BSD43_CTRL/		s/'\''c'\''/c/g
@


1.47
log
@(stdio.h): Change _VA_LIST_ to __gnuc_va_list for 386BSD.
@
text
@d178 1
a178 3
	      $file/.*)
		;;
	      *)
d186 2
@


1.46
log
@(sys/types.h): Don't match on ssize_t.
@
text
@d849 2
d854 1
@


1.45
log
@(egrep and sed loop): Don't print messages about files that need no change.
@
text
@d373 1
a373 1
sed -e '/size_t.*;/i\
d376 1
a376 1
    -e '/size_t.*;/a\
@


1.44
log
@Do not consider //* to be a C++ comment which needs to be fixed.
@
text
@a232 1
      echo Fixing $file
d272 2
@


1.43
log
@(stdio.h): Fix the rename prototype on the rs6000,
which conflicted with c++ use of new.
@
text
@d247 1
a247 1
	  /\/\//			s|//\(.*\)$|/*\1*/|
@


1.42
log
@Don't "make LIB absolute" if already absolute,
to avoid problems with the automounter.
@
text
@d816 17
@


1.41
log
@(limits.h):  Add #ifndef/#endif around macros that
are supposed to be defined in float.h.
@
text
@d35 8
a42 2
# Make LIB absolute.
cd $LIB; LIB=`${PWDCMD}`
@


1.40
log
@(Xmu.h): Add missing ${LIB}/.
@
text
@d868 43
@


1.39
log
@(making dirs and links): If we already made subdirs
for a dir foo and foo turns out to be a symlink outside /usr/include,
after we have made a dir for it in ./root/, make similar subdirs there.
@
text
@d506 1
a506 1
#endif /* !defined __STDC__ */,' ${LIB}/$file > ${file}.sed
d527 1
a527 1
#endif /* !defined __STDC__ */,' ${LIB}/$file > ${file}.sed
@


1.38
log
@Delete `no change needed' messages.  Delete all uses of `ex'.
@
text
@d168 17
@


1.37
log
@(sunwindow/{win_cursor.h,win_lock.h}): Change invalid
#ifdef identifier `ecd.cursor' to `ecd_cursor'.
@
text
@d17 2
a18 11
# This prevents /bin/ex from failing if the current terminal type is
# unrecognizable.
TERM=unknown
export TERM
# This prevents two problems:
# Either ex might find a .exrc file and get confused,
# or ex might complain if the EXINIT variable is invalid. 
# We know there is no .exrc in the GCC source.
# `set' is a no-op ex command.
EXINIT=set
export EXINIT
a29 3
# Directory in which to store the results.
LIB=${1?"fixincludes: output directory not specified"}

a248 1
	   echo Deleting $2/$file\; no fixes were needed.
d270 2
a271 4
  ex ${LIB}/$file <<EOF
  g/doesn't/s/doesn't/does not/
  wq
EOF
a272 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
d317 16
a332 30
  ex ${LIB}/$file <<EOF
  /size_t.*;/
  i
#ifndef _GCC_SIZE_T
#define _GCC_SIZE_T
.
  /size_t/+1
  i
#endif
.
  /ptrdiff_t.*;/
  i
#ifndef _GCC_PTRDIFF_T
#define _GCC_PTRDIFF_T
.
  /ptrdiff_t/+1
  i
#endif
.
  /wchar_t.*;/
  i
#ifndef _GCC_WCHAR_T
#define _GCC_WCHAR_T
.
  /wchar_t/+1
  i
#endif
.
  wq
EOF
a333 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
d349 6
a354 12
  ex ${LIB}/$file <<EOF
  /typedef.*[ 	]size_t.*;/
  i
#ifndef _GCC_SIZE_T
#define _GCC_SIZE_T
.
  /size_t/+1
  i
#endif
.
  wq
EOF
a355 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
d391 2
a392 4
  ex ${LIB}/$file <<EOF
  g/boottime$/s//&;/
  wq
EOF
a393 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
d410 2
a411 4
  ex ${LIB}/$file <<EOF
  g/char.*na_addr *$/s//&;/
  wq
EOF
a412 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
d427 2
a428 5
  ex ${LIB}/$file <<EOF
  g/^#ifdef KERNEL && !defined/
  s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/
  wq
EOF
a429 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a447 1
#    echo Deleting ${LIB}/$file\; no fixes were needed.
d463 2
a464 5
  ex ${LIB}/$file <<EOF
  g/^static struct tlb_pid_state/
  s/static//
  wq
EOF
a465 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
d487 4
a490 8
  ex ${LIB}/$file <<EOF
  /^extern char \*	sprintf();$/c
#ifndef __STDC__
extern char *	sprintf();
#endif /* !defined __STDC__ */
.
  wq
EOF
a491 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
d508 4
a511 8
  ex ${LIB}/$file <<EOF
  /^extern char \*	sprintf();$/c
#ifndef __STDC__
extern char *	sprintf();
#endif /* !defined __STDC__ */
.
  wq
EOF
a512 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a530 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a554 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a572 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a594 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a613 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a631 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a650 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a669 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a688 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a707 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a727 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a788 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a817 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
a846 1
    echo Deleting ${LIB}/$file\; no fixes were needed.
@


1.36
log
@Chmod each copied file a+r.
@
text
@d293 30
@


1.35
log
@fix _cplusplus typo in SCO's tinfo.h
@
text
@d227 1
d278 1
d298 1
d345 1
d375 1
d394 1
d416 1
d436 1
d458 1
d477 1
d505 1
d531 1
d556 1
d575 1
d600 1
d618 1
d641 1
d662 1
d681 1
d701 1
d721 1
d741 1
d761 1
d785 1
d818 1
d844 1
d882 1
@


1.34
log
@(sys/types.h): Check for [ \t]size_t not size_t.
@
text
@d364 18
@


1.33
log
@Use eval, not parens, in Apollo version of PWDCMD.
@
text
@d336 2
a337 1
# Fix this file to avoid interfering with stddef.h.
d347 1
a347 1
  /typedef.*size_t.*;/
@


1.32
log
@(PWDCMD): New variable, set specially for Apollos.
Use it to get the working dir.
@
text
@d35 1
a35 1
	PWDCMD="(pwd) | sed -e 's,.*/usr/,/usr/,'"
@


1.31
log
@(math.h): Get rid of inconsistent inline definitions
for abs that are present in HP-UX 8.0.
@
text
@d29 10
d48 1
a48 1
cd $LIB; LIB=`pwd`
d136 1
a136 1
      cwd=`pwd`
d146 1
a146 1
	x=`pwd`
@


1.30
log
@(EXINIT): Use `set'.
@
text
@d822 1
d832 2
@


1.29
log
@(EXINIT): Set it to `true', not null.
@
text
@d25 2
a26 1
EXINIT=true
@


1.28
log
@Convert //-style comments to /*...*/ style.
@
text
@d21 5
a25 3
# This prevents /bin/ex from failing if the EXINIT environment variable
# was set to something invalid.
EXINIT=""
@


1.27
log
@(stdio.h): Fix va_list when preceeded by a *.
@
text
@d208 1
a208 1
    if egrep '[ 	_]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then
d222 1
@


1.26
log
@Don't look for *.h symlinks if the host doesn't have symlinks.
@
text
@d798 1
@


1.25
log
@(EXINIT): Clear it to avoid problems with bad values.
@
text
@d192 5
a196 1
    files=`find . -name '*.h' \( -type f -o -type l \) -print`
@


1.24
log
@If we find a link pointing to ., make a similar
link to ., not a link to an absolute name.
(stdio.h): Change stdio.h to use stdarg.h to get va_list.

When link points to a dir $dirname outside $INPUT,
copy that dir into $LIB/root$dirname.  Translate the link itself
into a link to that new dir.  Make a file DONE in each treetop dir
so no treetop is scanned twice.  Improve progress messages.
@
text
@d21 4
@


1.23
log
@(ansi_compat.h): Replace this with an empty file.
@
text
@d39 1
a39 1
echo 'Building fixincludes in ' ${LIB}
d49 1
a49 1
echo 'Making directories:'
d65 1
d84 2
a85 1
	    # If it is a directory, add it to $newdirs
d98 1
a98 1
echo all directories:
d107 1
d115 1
a115 1
  echo 'Making internal symbolic directory links'
d130 5
d137 1
a137 1
	if expr $x : "${INPUT}/.*" > /dev/null; then
d144 3
a146 1
	  # If the link is to outside ${INPUT},
d148 18
a165 4
# This line used to have $dest instead of $x.
# $dest seemed to be wrong for links found in subdirectories
# of ${INPUT}.  Does this change break anything?
	  treetops="$treetops $x ${LIB}/$file"
a175 1
  echo "Finding header files in $1:"
d178 8
d188 3
a190 2
  files=`find . -name '*.h' \( -type f -o -type l \) -print`
  echo 'Checking header files:'
d765 28
@


1.22
log
@(finding all .h files): Look for links as well as ordinary files.
(memory.h): Fix versions 1.2 and 1.3 as well as 1.4.
@
text
@d740 8
@


1.21
log
@Find the links to directories by finding each link and testing it with test.
@
text
@d155 3
a157 1
  files=`find . -name '*.h' -type f -print`
d685 1
a685 1
if egrep '/\*	@@\(#\)memory.h 1.4 88/08/19 SMI; from S5R2 1.2	\*/' $file > /dev/null; then
@


1.20
log
@Add $newdirs into $files.
@
text
@d71 8
a78 1
        files="$files `find $d -type d -print | sed '|/\.$|d'`"
d80 9
a88 1
	  newdirs="$newdirs `find $d -type l -exec test -d '{}' \; -print`"
@


1.19
log
@Don't repeat the directory-link-chasing loop more than twice.
Combine $prevdirs with $dirs--they had same value.
Properly discard $d itself from the output of find.
@
text
@d76 1
@


1.18
log
@(X11/Xmu/Xmu.h): Fix this or X11/Xmu.h, whichever exists.
@
text
@d58 2
a59 2
prevdirs="."
while [ -n "$dirs" ]
d61 1
d63 1
a63 1
    for d in $prevdirs
d70 2
a71 3
	# Find all directories under $d, relative to $d, including $d itself.
	# Get rid of ./ at the end!
        files="$files `find $d -type d -print | sed '/^.$/d' | sed '/\/\.$/ s|/\.$||'`"
a76 1
    prevdirs="$newdirs"
@


1.17
log
@Take third argument, like fixinc.svr4.
@
text
@d423 25
@


1.16
log
@Replace the code that finds all directories
so that it looks for subdirs of dir reached via symlinks.
@
text
@d8 5
@


1.15
log
@entered into RCS
@
text
@d47 32
a78 2
files=`	find . -type d -print | sed '/^.$/d'
	$LINKS && find . -type l -exec test -d '{}' \; -print`
@


1.14
log
@*** empty log message ***
@
text
@d18 1
a18 1
LIB=${1-${LIB-/usr/local/lib/gcc-include}}
@


1.13
log
@*** empty log message ***
@
text
@d132 1
a132 1
	  /#define._IO/		s/'\''x'\''/x/g
d134 1
a134 1
	  /[^A-Z]CTRL[ 	]*(/	s/\([^'\'']\))/'\''\1'\'')/
d138 1
a138 1
	  /#[a-z]*if.*[	 (]m68k/		s/\([^_]\)m68k/\1__m68k__/g
d140 1
a140 1
	  /#[a-z]*if.*[	 (]i386/		s/\([^_]\)i386/\1__i386__/g
@


1.12
log
@*** empty log message ***
@
text
@d683 2
a684 2
# in the same directory as the fixed other files.
if [ -r ${LIB}/multimedia/audio_errno.h ]
d686 1
a686 1
  ln -s ${LIB}/multimedia/audio_errno.h multimedia 2>/dev/null
d688 1
a688 1
if [ -r ${LIB}/multimedia/audio_hdr.h ]
d690 1
a690 1
  ln -s ${LIB}/multimedia/audio_hdr.h multimedia 2>/dev/null
@


1.11
log
@*** empty log message ***
@
text
@d681 12
@


1.10
log
@*** empty log message ***
@
text
@d149 1
a149 1
	  /#define.NULL[ 	]/	i\
d240 1
a240 1
  /size_t.*;/
d290 1
a290 1
  g/na_addr/s//&;/
@


1.9
log
@*** empty log message ***
@
text
@d480 1
@


1.8
log
@*** empty log message ***
@
text
@d479 1
a479 1
  sed -e 's/typedef char \*	malloc_t/typedef void \*	malloc_t/g' \
@


1.7
log
@*** empty log message ***
@
text
@d638 42
@


1.6
log
@*** empty log message ***
@
text
@d602 36
@


1.5
log
@*** empty log message ***
@
text
@d470 19
@


1.4
log
@*** empty log message ***
@
text
@d185 1
a185 1
# Fix this Sun file to avoid intefering with stddef.h.
d230 1
a230 1
# Fix this file to avoid intefering with stddef.h.
@


1.3
log
@*** empty log message ***
@
text
@d458 4
@


1.2
log
@*** empty log message ***
@
text
@d46 3
a48 5
if $LINKS; then
  files=`ls -LR | sed -n s/:$//p`
else
  files=`find . -type d -print | sed '/^.$/d'`
fi
d111 2
d116 1
a116 1
    if egrep '[ 	_]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|#e[nl]|sparc|vax|sun|pyr)' $file > /dev/null; then
d197 2
a198 2
#ifndef _SIZE_T
#define _SIZE_T
d206 2
a207 2
#ifndef _PTRDIFF_T
#define _PTRDIFF_T
d215 2
a216 2
#ifndef _WCHAR_T
#define _WCHAR_T
d242 2
a243 2
#ifndef _SIZE_T
#define _SIZE_T
@


1.1
log
@Initial revision
@
text
@d115 1
d122 4
a129 2
	  s%\(#[ 	]*endif[ 	]*\)\([^/ 	].*\)$%\1/* \2 */%
	  s%\(#[ 	]*else[ 	]*\)\([^/ 	].*\)$%\1/* \2 */%
d319 18
d364 1
a364 1
# Deal with yet another challenge, this in X11/Xmu.h
d406 1
a406 1
# Fix the CAT macro in memvar.h.
d532 39
@
