2 # Hints for the Cray XT4 Catamount/Qk system:
3 # cross-compilation host is a SuSE x86_64-linux,
4 # execution at the target with the 'yod' utility,
5 # linux.sh will run this hints file when necessary.
7 # cc.sh: compiles the code with the cross-compiler, patches main/exit/_exit
8 # (and traps signals) to be wrappers that echo the exit code.
10 # run.sh: runs the executable with yod and collects the exit status,
11 # and exits with that status.
13 # You probably should do the compilation in non-Lustre filesystem
14 # because Lustre does not support all the POSIX system calls, which may
15 # cause weird errors during the Perl build:
16 # 1182003549.604836:3-24:(super.c:1516:llu_iop_fcntl()): unsupported fcntl cmd 2
18 # As of 2007-Sep (pre-5.10) miniperl, libperl.a, and perl can be successfully
19 # built; no extensions are built. It would be hard since Perl cannot run
20 # anything external (pipes, system(), backticks or fork/exec, or globbing)
21 # (which breaks MakeMaker, and confuses ext/util/make_ext).
28 # "make install" won't work since it assumes file globbing (see above).
29 # You can try the following manual way:
31 # mkdir -p /opt/perl-catamount
32 # mkdir -p /opt/perl-catamount/include
33 # mkdir -p /opt/perl-catamount/lib
34 # mkdir -p /opt/perl-catamount/lib/perl5/5.33.3
35 # mkdir -p /opt/perl-catamount/bin
36 # cp *.h /opt/perl-catamount/include
37 # cp libperl.a /opt/perl-catamount/lib
38 # cp -pr lib/* /opt/perl-catamount/lib/perl5/5.33.3
39 # cp miniperl perl run.sh cc.sh /opt/perl-catamount/lib
41 # With the headers and the libperl.a you can embed Perl to your Catamount
42 # application, see pod/perlembed.pod. You can do for example:
44 # cc -I/opt/perl-catamount/include -L/opt/perl-catamount/lib -o embed embed.c
45 # yod -sz 1 ./embed -le 'print sqrt(2)'
47 # You might want to have the run.sh execution wrapper around (it gets created
48 # in the Perl build directory) if you want to run the miniperl or perl in
49 # the XT4. It collects the exit status (note that yod is run with "-sz 1",
50 # so only one instance is run), and possible crash status (bare yod does
51 # not collect the exit status). For example:
53 # sh /opt/perl-catamount/bin/run.sh /opt/perl-catamount/bin/perl -le 'print 42'
55 # or if you are still in the build directory:
57 # sh run.sh ./perl -le 'print 2*3*7'
59 # The cc.sh is a wrapper for the Catamount cc used when building Perl
60 # (and before that, when running Configure), it arranges for the main()
61 # exit(), _exit() to be wrapped so that the exit/crash status can be
62 # collected (by run.sh).
66 '') prefix=/opt/perl-catamount ;;
70 *** You seem to be compiling in Linux for the Catamount/Qk environment.
71 *** I'm therefore not going to install perl as /usr/bin/perl.
72 *** Perl will be installed under $prefix.
76 archname='x86_64-catamount'
79 d_setlocale='undef' # There is setlocale() but no locales.
86 installusrbinperl='undef'
87 libswanted="m crypt c"
96 uselargefiles='define'
103 case "`yod -Version 2>&1`" in
104 Red*) ;; # E.g. "Red Storm Protocol Release 2.1.0"
105 *) echo >&4 "Could not find 'yod', aborting."
109 cat > $run <<'__EOF2__'
114 yod -sz 1 "$@" 2> .yod$$e > .yod$$o
115 status=`awk '/^cata: exe .* pid [0-9][0-9]* (main|exit|_exit) [0-9][0-9]*$/ {print $NF}' .yod$$o|tail -1`
116 grep -v "sz is 1" .yod$$e
117 grep -v "^cata: exe .* pid [0-9][0-9]* " .yod$$o
118 grep "^cata: exe .* signal " .yod$$o
119 rm -f .yod$$o .yod$$e
123 case "`cc -V 2>&1`" in
124 *catamount*) ;; # E.g. "/opt/xt-pe/1.5.41/bin/snos64/cc: INFO: catamount target is being used"
125 *) echo "Could not find 'cc' for catamount, aborting."
130 cat > $cc <<__EOF3a__
135 # This is essentially a frontend driver for the Catamount cc.
137 # (1) the main(), exit(), _exit() being wrapped (cpp-defined)
138 # catamain(), cataexit(), and _cataexit()
139 # (2) the actual main() etc. are in cata.c, and cata*.o are
140 # linked in when needed
141 # (3) signals being caught
142 # All this mostly for being able to catch the exit status (or crash cause).
148 defs='-Dmain=catamain -Dexit=cataexit -D_exit=_cataexit'
152 cat >> $cc <<'__EOF3b__'
155 *) if test ! -f catalib.o
157 if test ! -f catalib.c
159 if test -f ../catalib.c # If compiling in UU during Configure.
161 cp ../catalib.c catalib.c
162 cp ../catamain.c catamain.c
166 $0 --cata_o -c catalib.c || exit 1
167 $0 --cata_o -c catamain.c || exit 1
182 echo "$0: $i: No such file or directory"
187 if grep -q -s '#include "cata.h"' $i
197 if grep -q -s 'int main()' $i
201 if grep -q -s 'int main([^,]*,[^,]*)' $i
205 if grep -q -s 'int main([^,]*,[^,]*,[^,]*)' $i
218 c=$(echo $i|sed 's/\.o$/.c/')
225 argv="$argv -o $exe -Dargv0=$exe"
236 *catalib.o*|*" perlmain.o "*) ;;
237 *) argv="$argv catalib.o" ;;
241 *) argv="$argv catamain.o" ;;
245 cc -I$BUILD $argv 2> .cc$$e > .cc$$o
247 egrep -v 'catamount target|'$$'\.c:$' .cc$$e 1>&2
248 case "`grep "is not implemented" .cc$$e`" in
249 *"will always fail"*) status=1 ;;
254 0) rm -f .cc$$e $srct
257 objt=`echo $srct|sed -e 's/\.c$/.o/'`
258 objo=`echo $srco|sed -e 's/\.c$/.o/'`
259 if test -n "$objt" -a -f "$objt"
267 cat >cata.h<<__EOF6__
270 void cataexit(int status);
271 void _cataexit(int status);
273 void catasighandle(int signum);
278 int main(int argc, char **argv);
280 int main(int argc, char **argv, char **env);
285 #define ARGV0 STRINGIFY(argv0)
291 cat >catalib.c<<__EOF7__
300 void cataexit(int status) {
301 printf("cata: exe %s pid %d exit %d\n", ARGV0, getpid(), status);
304 void _cataexit(int status) {
305 printf("cata: exe %s pid %d _exit %d\n", ARGV0, getpid(), status);
308 void catasighandle(int signum) {
310 printf("cata: exe %s pid %d signal %d\n", ARGV0, getpid(), signum);
325 cataexit(core << 8 | signum);
327 void catasigsetup() {
328 signal(SIGHUP, catasighandle);
329 signal(SIGINT, catasighandle);
330 signal(SIGQUIT, catasighandle);
331 signal(SIGILL, catasighandle);
332 signal(SIGTRAP, catasighandle);
333 signal(SIGABRT, catasighandle);
334 signal(SIGIOT, catasighandle);
336 signal(SIGBUS, catasighandle);
337 signal(SIGFPE, catasighandle);
338 signal(SIGUSR1, catasighandle);
339 signal(SIGUSR2, catasighandle);
340 signal(SIGSEGV, catasighandle);
341 signal(SIGPIPE, catasighandle);
342 signal(SIGALRM, catasighandle);
343 signal(SIGTERM, catasighandle);
344 signal(SIGSTKFLT, catasighandle);
345 signal(SIGCHLD, catasighandle);
346 signal(SIGCONT, catasighandle);
348 signal(SIGTSTP, catasighandle);
349 signal(SIGTTIN, catasighandle);
350 signal(SIGTTOU, catasighandle);
351 signal(SIGURG, catasighandle);
352 signal(SIGXCPU, catasighandle);
353 signal(SIGXFSZ, catasighandle);
354 signal(SIGVTALRM, catasighandle);
355 signal(SIGPROF, catasighandle);
356 signal(SIGWINCH, catasighandle);
357 signal(SIGIO, catasighandle);
358 signal(SIGPWR, catasighandle);
359 signal(SIGSYS, catasighandle);
361 void boot_DynaLoader (void* cv) { }
363 cat >catamain.c<<__EOF8__
371 int main(int argc, char *argv[], char *envv[]) {
382 catamain(argc, argv);
384 catamain(argc, argv, envv);
387 printf("cata: exe %s pid %d main %d\n", ARGV0, getpid(), status);
392 echo "Faking DynaLoader"
393 touch DynaLoader.o # Oh, the agony.