Debian Codegraph @

initmake

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #! /bin/sh
2 :
3 # Copyright (c) 1992-1999, S.R. van den Berg, The Netherlands
4 #$Id: initmake,v 1.71 2000/09/28 01:23:03 guenther Exp $
5
6 if test -z "$IFS"
7 then IFS=" \
8 \
9
10 "
11 export IFS
12 fi
13
14 PATH=.:$PATH
15 BSHELL=$1
16
17 O="cd ."
18 if $O
19 then
20 :
21 else
22 echo "Your BSHELL=$BSHELL seems to be severely handicapped."
23 case "$BSHELL" in
24 *zsh*) ;;
25 *) echo "(If I wouldn't know better, I'd say you're trying to sell"
26 echo "me an incompatible zsh :-)" ;;
27 esac
28 echo "Please edit the Makefile and try setting BSHELL to a shell which"
29 echo "is more backwards compatible with a Bourne, Korn or POSIX shell."
30 exit 1
31 fi
32
33 shift; MSHELL=$1
34 shift; RM="$1"
35 shift; MV="$1"
36 shift; LN="$1"
37 shift; SEARCHLIBS="$1"
38 shift; LIBPATHS="$1"
39 shift; DEVNULL=$1
40 shift; MAKE="$1"
41 shift; O=$1
42 shift; CC="$1"
43 shift; CFLAGS1="$1"
44 shift; LDFLAGS1="$1"
45 shift; BINSS="$1"
46 shift; MANS1S="$1"
47 shift; MANS5S="$1"
48 shift; SUBDIRS="$1"
49 shift; VISIBLE_BINDIR="$1"
50 shift; STRIP="$1"
51
52 test 1 != $# &&
53 echo "Don't start this script directly, use \`make init'" && exit 1
54
55 test -z "$MSHELL" || SHELL=$MSHELL
56 case "$SHELL" in
57 *sh*)
58 case "$SHELL" in
59 *[zc]sh*) echo "Warning: really perverted make detected"; SHELL="";;
60 esac
61 if test ! -z "$SHELL"
62 then
63 $SHELL <<HERE
64 exec 2>$DEVNULL
65 echo test >src/_autotst
66 echo test >src/_autotst
67 HERE
68 if test $? = 1
69 then
70 echo "Warning: your $SHELL has noclobber turned on, avoiding it"
71 SHELL=""
72 fi
73 fi
74 $RM src/_autotst;;
75 *) echo "Warning: perverted make detected"; SHELL="";;
76 esac
77 test -z "$SHELL" && SHELL=$BSHELL
78
79 export SHELL PATH
80
81 FGREP="fgrep" # POSIX, or not POSIX, that is the question...
82 if test \^hello = "`echo '^hello' | grep -F '^hello' 2>&1`"
83 then FGREP="grep -F" # and POSIX it is!
84 fi
85
86 echo hi | $FGREP hi >$DEVNULL
87 t=$?
88 echo ho | $FGREP hi >$DEVNULL
89 f=$?
90 if test 0 != $t -o 0 = $f
91 then
92 echo "Your \"$FGREP\" program seems to be incapable of returning a proper"
93 echo "exitvalue depending on the success of the search. This script can"
94 echo "not work without it."
95 exit 2
96 fi
97
98 case a in
99 [!a]) classok=no ;; # This shell is *very* old
100 *) classok=yes ;;
101 esac
102
103 if test ! -z "$LD_LIBRARY_PATH"
104 then
105 echo '***************************** WARNING *********************************'
106 echo '* You seem to have set the LD_LIBRARY_PATH variable, this might cause *'
107 echo '* some trouble during the compilation of this package. If the make *'
108 echo '* does not finish by itself, do a: "make clean", clear *'
109 echo '* LD_LIBRARY_PATH from the environment, and start over. *'
110 echo '***************************** WARNING *********************************'
111 fi
112
113 cd src # diving into the source directory ######
114
115 newln=""
116 $RM _autotst.rrr ../man/core_ln
117 echo hi >_autotst.rrr
118 if $LN ../src/_autotst.rrr ../man/core_ln 2>$DEVNULL
119 then
120 :
121 else
122 $RM ../man/core_ln
123 $LN -s ../src/_autotst.rrr ../man/core_ln && LN="$LN -s" && newln=yes
124 fi
125
126 cat >_autotst.c <<HERE
127 main()
128 { return 0;
129 }
130 HERE
131 $RM _autotst.rrr _autotst.$O _autotst ../man/core_ln
132
133 dostrip=no
134
135 case "$LDFLAGS1" in
136 *-s*)
137 LDF=""
138 for a in __dummy__ $LDFLAGS1
139 do
140 if test __dummy__ != $a
141 then
142 if test X-s = X$a
143 then
144 dostrip=yes
145 else
146 LDF="$LDF $a"
147 fi
148 fi
149 done
150 LDFLAGS1="$LDF";;
151 esac
152
153 cc=""
154
155 for a in "$CC" cc gcc
156 do
157 echo $a $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1 >>_autotst.rrr
158 test -z "$cc" -a ! -z "$a" &&
159 (exec >>_autotst.rrr 2>&1; $a $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1) &&
160 cc="$a"
161 echo "::::" >>_autotst.rrr
162 done
163 if test -z "$cc"
164 then
165 echo 2>&1 "Whoeaaa! There's something fishy going on here."
166 echo 2>&1 "You have a look and see if you detect anything uncanny:"
167 echo 2>&1 "*******************************************************"
168 cat 2>&1 _autotst.rrr
169 echo 2>&1 "*******************************************************"
170 echo 2>&1 "I suggest you take a look at the definition of CFLAGS* and CC"
171 echo 2>&1 "in the Makefile before you try make again."
172 exit 1
173 fi
174 $RM _autotst.rrr _autotst.$O _autotst
175 echo "$cc seems to work fine, using that as the C-compiler"
176
177 if test $dostrip = yes
178 then
179 if $cc $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1 -s >$DEVNULL 2>&1
180 then
181 LDFLAGS1="$LDFLAGS1 -s"
182 dostrip=no
183 STRIP=""
184 else
185 $cc $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1 >$DEVNULL 2>&1
186 if test ! -z "$STRIP" && $STRIP _autotst >$DEVNULL 2>&1
187 then
188 :
189 else
190 STRIP=""
191 fi
192 fi
193 $RM _autotst.rrr _autotst.$O _autotst
194 else
195 STRIP=""
196 fi
197
198
199 cat >_autotst.c <<HERE
200 #include <sys/types.h>
201 #include <stdio.h>
202 #include <sys/stat.h>
203 main()
204 { struct stat buf;return!&buf;
205 }
206 HERE
207
208 CFLAGS=""
209
210 case "$CFLAGS1" in
211 *-D_POSIX_SOURCE*);;
212 *)
213 if $cc -c $CFLAGS1 _autotst.c >$DEVNULL 2>&1
214 then
215 :
216 else
217 $RM _autotst.$O
218 $cc -c $CFLAGS1 -D_POSIX_SOURCE _autotst.c >$DEVNULL 2>&1 &&
219 CFLAGS=" -D_POSIX_SOURCE"
220 fi;;
221 esac
222
223 LDFLAGSC=""
224
225 if test -f _autotst.$O || $cc -c $CFLAGS1 $CFLAGS _autotst.c >_autotst.rrr 2>&1
226 then
227 :
228 else
229 echo 2>&1 "Whoeaaa! There's something fishy going on here."
230 echo 2>&1 "You have a look and see if you detect anything uncanny:"
231 echo 2>&1 "*******************************************************"
232 cat 2>&1 _autotst.rrr
233 echo 2>&1 "*******************************************************"
234 echo 2>&1 "I suggest you take a look at the definition of CC and CFLAGS*"
235 echo 2>&1 "in the Makefile before you try make again."
236 echo 2>&1 "Also: write me a mail showing the errorlog you just generated."
237 echo 2>&1 "The errorlog can still be found in src/_autotst.rrr"
238 echo 2>&1 "It would be helpful if you could mention what machine and OS"
239 echo 2>&1 "you are trying to compile this on (uname -a). Thanks."
240 exit 1
241 fi
242 $cc $CFLAGS1 $CFLAGS _autotst.$O -o _autotst $LDFLAGS1 -lc >_autotst.rrr 2>&1 \
243 && if grep "[\"']c['\"]" _autotst.rrr >$DEVNULL ||
244 $FGREP libc _autotst.rrr >$DEVNULL
245 then
246 :
247 else
248 LDFLAGSC=" -lc"
249 fi
250
251 LDFLAGS="$SEARCHLIBS"
252 firstrun=yes
253 checkpath=no
254 runcombination=no
255
256 while $RM _autotst
257 $cc $CFLAGS1 $CFLAGS _autotst.$O -o _autotst $LDFLAGS1 $LDFLAGS \
258 $LDFLAGSC >_autotst.rrr 2>&1 || firstrun=yes
259 test $firstrun = yes -o ! -f _autotst
260 do
261 if test $runcombination = yes
262 then
263 LDFLAGS=""
264 read NEWLDFLAGS 0>&9
265 echo 2>&1 " ...trying $NEWLDFLAGS"
266 else
267 set dummy $LDFLAGS
268 shift
269 echo 2>&1 " ...scanning for $# libraries..."
270 NEWLDFLAGS=""
271 fi
272 for lib in `echo _dummy_ $LDFLAGS | sed -e s/-l//g`
273 do
274 if test _dummy_ != $lib
275 then
276 a=-l$lib
277 ( exec <_autotst.rrr
278 while read b
279 do
280 if test $classok = yes
281 then
282 case ":$b:" in
283 *$cc*_autotst.$O*) ;;
284 *"not used for resolving"*) ;;
285 *lib$lib[!a-z_]*|*$a[!a-z_]*|*[!a-z]$lib[!a-z_]*) exit 1;;
286 esac
287 else
288 case ":$b:" in
289 *$cc*_autotst.$O*) ;;
290 *"not used for resolving"*) ;;
291 *) for c in $b
292 do
293 case ":$c:" in
294 *lib$lib[a-z_]*|*$a[a-z_]*|\
295 *[a-z]$lib*|*$lib[a-z_]*) ;;
296 *$a*|*$lib*) exit 1;;
297 esac
298 done ;;
299 esac
300 fi
301 done
302 exit 0
303 )
304 if test $? = 0
305 then
306 found=yes
307 if test $checkpath = yes
308 then
309 OLDIFS="$IFS"; IFS=":$IFS"
310 found=no
311 for libpath in $LIBPATHS $LD_LIBRARY_PATH
312 do
313 set $libpath/*lib$lib[A-Z.]*
314 test -f $1 && found=yes
315 done
316 IFS="$OLDIFS"
317 fi
318 test yes = $found && NEWLDFLAGS="$NEWLDFLAGS $a"
319 fi
320 fi
321 done
322 if test a"$LDFLAGS" = a"$NEWLDFLAGS"
323 then
324 if test $checkpath = yes
325 then
326 if test $runcombination = yes
327 then
328 echo 2>&1 "Whoeaaa! There's something fishy going on here."
329 echo 2>&1 "You have a look and see if you detect anything uncanny:"
330 echo 2>&1 "*******************************************************"
331 echo \ $cc $CFLAGS1 $CFLAGS _autotst.$O -o _autotst $LDFLAGS1\
332 $LDFLAGS >>_autotst.rrr
333 echo " $LDFLAGSC" >>_autotst.rrr
334 cat 2>&1 _autotst.rrr
335 echo 2>&1 "*******************************************************"
336 echo 2>&1 \
337 "I suggest you take a look at the definition of LDFLAGS* and SEARCHLIBS"
338 echo 2>&1 "in the Makefile before you try make again."
339 echo 2>&1 \
340 "Also: write me a mail showing the errorlog you just generated."
341 echo 2>&1 "The errorlog can still be found in src/_autotst.rrr"
342 echo 2>&1 \
343 "It would be helpful if you could mention what machine and OS"
344 echo 2>&1 "you are trying to compile this on (uname -a). Thanks."
345 exit 1
346 fi
347 echo 2>&1 "Inconsistent libraries found, trying to accomodate..."
348 runcombination=yes
349 cat >_autotst <<\HERE
350 #!/bin/sh
351
352 exec awk '
353 { split($0,lib);
354 nf=0;
355 for(a in lib)
356 nf++;
357 p[0]=nf;
358 while(!p[nf-1])
359 { for(j=i=0;p[i];i++)
360 while(++j<p[i])
361 printf(" %s",lib[j]);
362 while(++j<=nf)
363 printf(" %s",lib[j]);
364 printf("\n");
365 for(k=0;;k++)
366 { if(!p[k])
367 { p[k]=nf;
368 break;
369 }
370 if(p[k]!=k+1)
371 { --p[k];
372 break;
373 }
374 }
375 while(--k>=0)
376 p[k]=p[k+1]-1;
377 }
378 exit;
379 }'
380 HERE
381 chmod 755 _autotst
382 echo " $LDFLAGS" | ./_autotst >_autotst.lst
383 echo "" >>_autotst.lst
384 exec 8<&0 <_autotst.lst 9<&0 0<&8 8<&-
385 read NEWLDFLAGS 0<&9
386 echo 2>&1 " ...trying $NEWLDFLAGS"
387 fi
388 checkpath=yes
389 else
390 checkpath=no
391 fi
392 LDFLAGS="$NEWLDFLAGS"
393 firstrun=no
394 done
395
396 $RM _autotst.$O _autotst.c _autotst _autotst.rrr _autotst.lst
397 cd .. # returning to the main procmail directory ######
398
399 LDFLAGS="$LDFLAGS$LDFLAGSC"
400
401 test -z "$CFLAGS" || echo "Added CFLAGS=$CFLAGS"
402 test -z "$LDFLAGS" || echo "Added LDFLAGS=$LDFLAGS"
403 if test $dostrip = yes
404 then
405 LDFLAGS="$LDFLAGS1$LDFLAGS"
406 echo "Evaded -s in LDFLAGS1"
407 else
408 LDFLAGS="\$(LDFLAGS1)$LDFLAGS"
409 fi
410
411 for a in $SUBDIRS
412 do
413 if test ! -f $a/Makefile.init
414 then
415 case "$LN" in
416 ln|*/ln|link|*/link) $LN $a/Makefile $a/Makefile.init
417 $RM $a/Makefile
418 $LN $a/Makefile.init $a/Makefile ;;
419 *) cp $a/Makefile $a/Makefile.init ;;
420 esac
421 fi
422 done
423
424 test -f Makefile.0 || sed -e '/^# Makefile - mark/,$ !d' <Makefile >Makefile.0
425 sed -e '/^# Makefile - mark/,$ d' <Makefile >_Makefile
426 echo "# Makefile.1 - mark, don't (re)move this, a sed script needs it
427 " >>_Makefile
428
429 test a$SHELL != a$MSHELL && echo "SHELL = $SHELL" >>_Makefile
430 echo "FGREP = $FGREP" >>_Makefile
431 echo "STRIP = $STRIP" >>_Makefile
432 test -z "$newln" || echo "LN = $LN" >>_Makefile
433 test -z "$MAKE" && echo "MAKE = make" >>_Makefile
434 test a"$cc" != a"$CC" && echo "CC = $cc" >>_Makefile
435
436 echo "CFLAGS = \$(CFLAGS1)$CFLAGS" >>_Makefile
437 echo "LDFLAGS = $LDFLAGS" >>_Makefile
438 echo >>_Makefile
439
440 MANSS=""
441 MANS1=""
442 MANS5=""
443 MANS=""
444 NMANS=""
445 BINS=""
446 NBINS=""
447 for a in $MANS1S
448 do
449 MANSS="$MANSS $a.1"
450 MANS1="$MANS1 $a.\$(MAN1SUFFIX)"
451 done
452 for a in $MANS5S
453 do
454 MANSS="$MANSS $a.5"
455 MANS5="$MANS5 $a.\$(MAN5SUFFIX)"
456 done
457 for a in $MANSS
458 do
459 MANS="$MANS new/$a"
460 NMANS="$NMANS ../new/$a"
461 done
462 for a in $BINSS
463 do
464 BINS="$BINS new/$a"
465 NBINS="$NBINS ../new/$a"
466 done
467
468 echo "BINS=$BINS" >>_Makefile
469 echo "MANS=$MANS" >>_Makefile
470 echo "MANS1=$MANS1" >>_Makefile
471 echo "MANS5=$MANS5" >>_Makefile
472 echo "MANSS=$MANSS" >>_Makefile
473 echo "NBINS=$NBINS" >>_Makefile
474 echo "NMANS=$NMANS" >>_Makefile
475 echo >>_Makefile
476
477 for a in $SUBDIRS
478 do
479 sed -e '1,/^# Makefile.0 - mark/ d' <_Makefile >$a/_Makefile
480 cat $a/Makefile.0 >>$a/_Makefile
481 done
482
483 echo "VISIBLE_BINDIR=$VISIBLE_BINDIR" >>src/_Makefile
484
485 for a in $BINSS
486 do
487 echo >>src/_Makefile
488 echo "../new/$a: $a ../config.check" >>src/_Makefile
489 echo " @test -d ../new || mkdir ../new" >>src/_Makefile
490 echo " @\$(RM) \$@" >>src/_Makefile
491 echo " \$(LN) ../src/$a \$@" >>src/_Makefile
492 done
493
494 for a in $MANSS
495 do
496 echo >>man/_Makefile
497 echo "../new/$a: $a ../config.check" >>man/_Makefile
498 echo " @test -d ../new || mkdir ../new" >>man/_Makefile
499 echo " @\$(RM) \$@" >>man/_Makefile
500 echo " \$(LN) ../man/$a \$@" >>man/_Makefile
501 done
502
503 for a in $MANS1S
504 do
505 echo >>man/_Makefile
506 echo "$a.1: $a.man man.sed mansed" >>man/_Makefile
507 echo \
508 " \$(SHELL) ./mansed \$(SHELL) $a.man \$@ \"\$(RM)\" \$(DEVNULL)" \
509 >>man/_Makefile
510 done
511
512 for a in $MANS5S
513 do
514 echo >>man/_Makefile
515 echo "$a.5: $a.man man.sed mansed" >>man/_Makefile
516 echo \
517 " \$(SHELL) ./mansed \$(SHELL) $a.man \$@ \"\$(RM)\" \$(DEVNULL)" \
518 >>man/_Makefile
519 done
520
521 cat Makefile.1 >>_Makefile
522 $MV _Makefile Makefile
523
524 sleep 1 # Some machines are just too speedy, make gets confused
525
526 for a in $SUBDIRS
527 do
528 echo "#" >>$a/_Makefile
529 $MV $a/_Makefile $a/Makefile
530 done