File: initmake

package info (click to toggle)
procmail 3.22-25+deb9u1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 2,116 kB
  • sloc: ansic: 9,885; sh: 1,957; makefile: 136
file content (530 lines) | stat: -rwxr-xr-x 12,553 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
#! /bin/sh
:
# Copyright (c) 1992-1999, S.R. van den Berg, The Netherlands
#$Id: initmake,v 1.71 2000/09/28 01:23:03 guenther Exp $

if test -z "$IFS"
then IFS=" \
	\

"
  export IFS
fi

PATH=.:$PATH
BSHELL=$1

O="cd ."
if $O
then
:
else
  echo "Your BSHELL=$BSHELL seems to be severely handicapped."
  case "$BSHELL" in
     *zsh*) ;;
     *) echo "(If I wouldn't know better, I'd say you're trying to sell"
	echo "me an incompatible zsh :-)" ;;
  esac
  echo "Please edit the Makefile and try setting BSHELL to a shell which"
  echo "is more backwards compatible with a Bourne, Korn or POSIX shell."
  exit 1
fi

shift; MSHELL=$1
shift; RM="$1"
shift; MV="$1"
shift; LN="$1"
shift; SEARCHLIBS="$1"
shift; LIBPATHS="$1"
shift; DEVNULL=$1
shift; MAKE="$1"
shift; O=$1
shift; CC="$1"
shift; CFLAGS1="$1"
shift; LDFLAGS1="$1"
shift; BINSS="$1"
shift; MANS1S="$1"
shift; MANS5S="$1"
shift; SUBDIRS="$1"
shift; VISIBLE_BINDIR="$1"
shift; STRIP="$1"

test 1 != $# &&
 echo "Don't start this script directly, use \`make init'" && exit 1

test -z "$MSHELL" || SHELL=$MSHELL
case "$SHELL" in
  *sh*)
     case "$SHELL" in
	*[zc]sh*) echo "Warning: really perverted make detected"; SHELL="";;
     esac
     if test ! -z "$SHELL"
     then
	$SHELL <<HERE
	exec 2>$DEVNULL
	echo test >src/_autotst
	echo test >src/_autotst
HERE
	if test $? = 1
	then
	   echo "Warning: your $SHELL has noclobber turned on, avoiding it"
	   SHELL=""
	fi
     fi
     $RM src/_autotst;;
  *) echo "Warning: perverted make detected"; SHELL="";;
esac
test -z "$SHELL" && SHELL=$BSHELL

export SHELL PATH

FGREP="fgrep"		# POSIX, or not POSIX, that is the question...
if test \^hello = "`echo '^hello' | grep -F '^hello' 2>&1`"
then FGREP="grep -F"				# and POSIX it is!
fi

echo hi | $FGREP hi >$DEVNULL
t=$?
echo ho | $FGREP hi >$DEVNULL
f=$?
if test 0 != $t -o 0 = $f
then
  echo "Your \"$FGREP\" program seems to be incapable of returning a proper"
  echo "exitvalue depending on the success of the search.  This script can"
  echo "not work without it."
  exit 2
fi

case a in
  [!a]) classok=no ;;		# This shell is *very* old
  *) classok=yes ;;
esac

if test ! -z "$LD_LIBRARY_PATH"
then
  echo '***************************** WARNING *********************************'
  echo '* You seem to have set the LD_LIBRARY_PATH variable, this might cause *'
  echo '* some trouble during the compilation of this package.	If the make   *'
  echo '* does not finish by itself, do a: "make clean", clear		      *'
  echo '* LD_LIBRARY_PATH from the environment, and start over.		      *'
  echo '***************************** WARNING *********************************'
fi

cd src				# diving into the source directory ######

newln=""
$RM _autotst.rrr ../man/core_ln
echo hi >_autotst.rrr
if $LN ../src/_autotst.rrr ../man/core_ln 2>$DEVNULL
then
:
else
   $RM ../man/core_ln
   $LN -s ../src/_autotst.rrr ../man/core_ln && LN="$LN -s" && newln=yes
fi

cat >_autotst.c <<HERE
main()
{ return 0;
}
HERE
$RM _autotst.rrr _autotst.$O _autotst ../man/core_ln

dostrip=no

case "$LDFLAGS1" in
  *-s*)
     LDF=""
     for a in __dummy__ $LDFLAGS1
     do
       if test __dummy__ != $a
       then
	  if test X-s = X$a
	  then
	     dostrip=yes
	  else
	     LDF="$LDF $a"
	  fi
       fi
     done
     LDFLAGS1="$LDF";;
esac

cc=""

for a in "$CC" cc gcc
do
  echo $a $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1 >>_autotst.rrr
  test -z "$cc" -a ! -z "$a" &&
   (exec >>_autotst.rrr 2>&1; $a $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1) &&
   cc="$a"
  echo "::::" >>_autotst.rrr
done
if test -z "$cc"
then
  echo 2>&1 "Whoeaaa!  There's something fishy going on here."
  echo 2>&1 "You have a look and see if you detect anything uncanny:"
  echo 2>&1 "*******************************************************"
  cat 2>&1 _autotst.rrr
  echo 2>&1 "*******************************************************"
  echo 2>&1 "I suggest you take a look at the definition of CFLAGS* and CC"
  echo 2>&1 "in the Makefile before you try make again."
  exit 1
fi
$RM _autotst.rrr _autotst.$O _autotst
echo "$cc seems to work fine, using that as the C-compiler"

if test $dostrip = yes
then
  if $cc $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1 -s >$DEVNULL 2>&1
  then
     LDFLAGS1="$LDFLAGS1 -s"
     dostrip=no
     STRIP=""
  else
     $cc $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1 >$DEVNULL 2>&1
     if test ! -z "$STRIP" && $STRIP _autotst >$DEVNULL 2>&1
     then
	:
     else
	STRIP=""
     fi
  fi
  $RM _autotst.rrr _autotst.$O _autotst
else
  STRIP=""
fi


cat >_autotst.c <<HERE
#include <sys/types.h>
#include <stdio.h>
#include <sys/stat.h>
main()
{ struct stat buf;return!&buf;
}
HERE

CFLAGS=""

case "$CFLAGS1" in
  *-D_POSIX_SOURCE*);;
  *)
     if $cc -c $CFLAGS1 _autotst.c >$DEVNULL 2>&1
     then
     :
     else
	$RM _autotst.$O
	$cc -c $CFLAGS1 -D_POSIX_SOURCE _autotst.c >$DEVNULL 2>&1 &&
	 CFLAGS=" -D_POSIX_SOURCE"
     fi;;
esac

LDFLAGSC=""

if test -f _autotst.$O || $cc -c $CFLAGS1 $CFLAGS _autotst.c >_autotst.rrr 2>&1
then
:
else
  echo 2>&1 "Whoeaaa!  There's something fishy going on here."
  echo 2>&1 "You have a look and see if you detect anything uncanny:"
  echo 2>&1 "*******************************************************"
  cat 2>&1 _autotst.rrr
  echo 2>&1 "*******************************************************"
  echo 2>&1 "I suggest you take a look at the definition of CC and CFLAGS*"
  echo 2>&1 "in the Makefile before you try make again."
  echo 2>&1 "Also: write me a mail showing the errorlog you just generated."
  echo 2>&1 "The errorlog can still be found in src/_autotst.rrr"
  echo 2>&1 "It would be helpful if you could mention what machine and OS"
  echo 2>&1 "you are trying to compile this on (uname -a).  Thanks."
  exit 1
fi
$cc $CFLAGS1 $CFLAGS _autotst.$O -o _autotst $LDFLAGS1 -lc >_autotst.rrr 2>&1 \
 && if grep "[\"']c['\"]" _autotst.rrr >$DEVNULL ||
   $FGREP libc _autotst.rrr >$DEVNULL
  then
  :
  else
     LDFLAGSC=" -lc"
  fi

LDFLAGS="$SEARCHLIBS"
firstrun=yes
checkpath=no
runcombination=no

while $RM _autotst
 $cc $CFLAGS1 $CFLAGS _autotst.$O -o _autotst $LDFLAGS1 $LDFLAGS \
  $LDFLAGSC >_autotst.rrr 2>&1 || firstrun=yes
 test $firstrun = yes -o ! -f _autotst
do
  if test $runcombination = yes
  then
     LDFLAGS=""
     read NEWLDFLAGS 0>&9
     echo 2>&1 " ...trying $NEWLDFLAGS"
  else
     set dummy $LDFLAGS
     shift
     echo 2>&1 "	...scanning for $# libraries..."
     NEWLDFLAGS=""
  fi
  for lib in `echo _dummy_ $LDFLAGS | sed -e s/-l//g`
  do
     if test _dummy_ != $lib
     then
	a=-l$lib
	 ( exec <_autotst.rrr
	   while read b
	   do
	      if test $classok = yes
	      then
		 case ":$b:" in
		    *$cc*_autotst.$O*) ;;
		    *"not used for resolving"*) ;;
		    *lib$lib[!a-z_]*|*$a[!a-z_]*|*[!a-z]$lib[!a-z_]*) exit 1;;
		 esac
	      else
		 case ":$b:" in
		    *$cc*_autotst.$O*) ;;
		    *"not used for resolving"*) ;;
		    *) for c in $b
		       do
			  case ":$c:" in
			     *lib$lib[a-z_]*|*$a[a-z_]*|\
			      *[a-z]$lib*|*$lib[a-z_]*) ;;
			     *$a*|*$lib*) exit 1;;
			  esac
		       done ;;
		 esac
	      fi
	   done
	   exit 0
	 )
	if test $? = 0
	then
	   found=yes
	   if test $checkpath = yes
	   then
	      OLDIFS="$IFS"; IFS=":$IFS"
	      found=no
	      for libpath in $LIBPATHS $LD_LIBRARY_PATH
	      do
		 set $libpath/*lib$lib[A-Z.]*
		 test -f $1 && found=yes
	      done
	      IFS="$OLDIFS"
	   fi
	   test yes = $found && NEWLDFLAGS="$NEWLDFLAGS $a"
	fi
     fi
  done
  if test a"$LDFLAGS" = a"$NEWLDFLAGS"
  then
     if test $checkpath = yes
     then
	if test $runcombination = yes
	then
	   echo 2>&1 "Whoeaaa!	There's something fishy going on here."
	   echo 2>&1 "You have a look and see if you detect anything uncanny:"
	   echo 2>&1 "*******************************************************"
	   echo \ $cc $CFLAGS1 $CFLAGS _autotst.$O -o _autotst $LDFLAGS1\
	    $LDFLAGS >>_autotst.rrr
	   echo "	$LDFLAGSC" >>_autotst.rrr
	   cat 2>&1 _autotst.rrr
	   echo 2>&1 "*******************************************************"
	   echo 2>&1 \
       "I suggest you take a look at the definition of LDFLAGS* and SEARCHLIBS"
	   echo 2>&1 "in the Makefile before you try make again."
	   echo 2>&1 \
	    "Also: write me a mail showing the errorlog you just generated."
	   echo 2>&1 "The errorlog can still be found in src/_autotst.rrr"
	   echo 2>&1 \
	    "It would be helpful if you could mention what machine and OS"
	   echo 2>&1 "you are trying to compile this on (uname -a).  Thanks."
	   exit 1
	fi
	echo 2>&1 "Inconsistent libraries found, trying to accomodate..."
	runcombination=yes
	cat >_autotst <<\HERE
#!/bin/sh

exec awk '
 { split($0,lib);
   nf=0;
   for(a in lib)
      nf++;
   p[0]=nf;
   while(!p[nf-1])
    { for(j=i=0;p[i];i++)
	 while(++j<p[i])
	    printf(" %s",lib[j]);
      while(++j<=nf)
	 printf(" %s",lib[j]);
      printf("\n");
      for(k=0;;k++)
       { if(!p[k])
	  { p[k]=nf;
	    break;
	  }
	 if(p[k]!=k+1)
	  { --p[k];
	    break;
	  }
       }
      while(--k>=0)
	 p[k]=p[k+1]-1;
    }
   exit;
 }'
HERE
	chmod 755 _autotst
	echo " $LDFLAGS" | ./_autotst >_autotst.lst
	echo "" >>_autotst.lst
	exec 8<&0 <_autotst.lst 9<&0 0<&8 8<&-
	read NEWLDFLAGS 0<&9
	echo 2>&1 " ...trying $NEWLDFLAGS"
     fi
     checkpath=yes
  else
     checkpath=no
  fi
  LDFLAGS="$NEWLDFLAGS"
  firstrun=no
done

$RM _autotst.$O _autotst.c _autotst _autotst.rrr _autotst.lst
cd ..			# returning to the main procmail directory ######

LDFLAGS="$LDFLAGS$LDFLAGSC"

test -z "$CFLAGS" || echo "Added CFLAGS=$CFLAGS"
test -z "$LDFLAGS" || echo "Added LDFLAGS=$LDFLAGS"
if test $dostrip = yes
then
  LDFLAGS="$LDFLAGS1$LDFLAGS"
  echo "Evaded -s in LDFLAGS1"
else
  LDFLAGS="\$(LDFLAGS1)$LDFLAGS"
fi

for a in $SUBDIRS
do
  if test ! -f $a/Makefile.init
  then
     case "$LN" in
	ln|*/ln|link|*/link) $LN $a/Makefile $a/Makefile.init
	   $RM $a/Makefile
	   $LN $a/Makefile.init $a/Makefile ;;
	*) cp $a/Makefile $a/Makefile.init ;;
     esac
  fi
done

test -f Makefile.0 || sed -e '/^# Makefile - mark/,$ !d' <Makefile >Makefile.0
sed -e '/^# Makefile - mark/,$ d' <Makefile >_Makefile
echo "# Makefile.1 - mark, don't (re)move this, a sed script needs it
" >>_Makefile

test a$SHELL != a$MSHELL && echo  "SHELL	= $SHELL"	>>_Makefile
echo "FGREP	= $FGREP"				>>_Makefile
echo "STRIP	= $STRIP"				>>_Makefile
test -z "$newln" || echo "LN	= $LN"			>>_Makefile
test -z "$MAKE" && echo "MAKE	= make"			>>_Makefile
test a"$cc" != a"$CC" && echo "CC	= $cc"		>>_Makefile

echo "CFLAGS	= \$(CFLAGS1)$CFLAGS"			>>_Makefile
echo "LDFLAGS	= $LDFLAGS"				>>_Makefile
echo							>>_Makefile

MANSS=""
MANS1=""
MANS5=""
MANS=""
NMANS=""
BINS=""
NBINS=""
for a in $MANS1S
do
  MANSS="$MANSS $a.1"
  MANS1="$MANS1 $a.\$(MAN1SUFFIX)"
done
for a in $MANS5S
do
  MANSS="$MANSS $a.5"
  MANS5="$MANS5 $a.\$(MAN5SUFFIX)"
done
for a in $MANSS
do
  MANS="$MANS new/$a"
  NMANS="$NMANS ../new/$a"
done
for a in $BINSS
do
  BINS="$BINS new/$a"
  NBINS="$NBINS ../new/$a"
done

echo "BINS=$BINS"					>>_Makefile
echo "MANS=$MANS"					>>_Makefile
echo "MANS1=$MANS1"					>>_Makefile
echo "MANS5=$MANS5"					>>_Makefile
echo "MANSS=$MANSS"					>>_Makefile
echo "NBINS=$NBINS"					>>_Makefile
echo "NMANS=$NMANS"					>>_Makefile
echo							>>_Makefile

for a in $SUBDIRS
do
  sed -e '1,/^# Makefile.0 - mark/ d' <_Makefile >$a/_Makefile
  cat $a/Makefile.0 >>$a/_Makefile
done

echo "VISIBLE_BINDIR=$VISIBLE_BINDIR"			>>src/_Makefile

for a in $BINSS
do
  echo							>>src/_Makefile
  echo "../new/$a: $a ../config.check"			>>src/_Makefile
  echo "	@test -d ../new || mkdir ../new"	>>src/_Makefile
  echo "	@\$(RM) \$@"				>>src/_Makefile
  echo "	\$(LN) ../src/$a \$@"			>>src/_Makefile
done

for a in $MANSS
do
  echo							>>man/_Makefile
  echo "../new/$a: $a ../config.check"			>>man/_Makefile
  echo "	@test -d ../new || mkdir ../new"	>>man/_Makefile
  echo "	@\$(RM) \$@"				>>man/_Makefile
  echo "	\$(LN) ../man/$a \$@"			>>man/_Makefile
done

for a in $MANS1S
do
  echo							>>man/_Makefile
  echo "$a.1: $a.man man.sed mansed"			>>man/_Makefile
  echo \
   "	\$(SHELL) ./mansed \$(SHELL) $a.man \$@ \"\$(RM)\" \$(DEVNULL)" \
   >>man/_Makefile
done

for a in $MANS5S
do
  echo							>>man/_Makefile
  echo "$a.5: $a.man man.sed mansed"			>>man/_Makefile
  echo \
   "	\$(SHELL) ./mansed \$(SHELL) $a.man \$@ \"\$(RM)\" \$(DEVNULL)" \
   >>man/_Makefile
done

cat Makefile.1 >>_Makefile
$MV _Makefile Makefile

sleep 1			# Some machines are just too speedy, make gets confused

for a in $SUBDIRS
do
  echo "#" >>$a/_Makefile
  $MV $a/_Makefile $a/Makefile
done