blob: c58621ed58623c94408f87b2320deaffb4573de7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/bin/sh
set -e
set -x
# from perlembed(1)
cat > perlembed.c <<EOF
#include <EXTERN.h> /* from the Perl distribution */
#include <perl.h> /* from the Perl distribution */
static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
int main(int argc, char **argv, char **env)
{
PERL_SYS_INIT3(&argc,&argv,&env);
my_perl = perl_alloc();
perl_construct(my_perl);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
PERL_SYS_TERM();
}
EOF
CC=$(perl -MConfig -E 'say $Config{cc}')
CCOPTS=$(perl -MExtUtils::Embed -e ccopts)
LDOPTS=$(perl -MExtUtils::Embed -e ldopts)
$CC $CCOPTS perlembed.c -o perlembed.bin $LDOPTS -lperl
./perlembed.bin -E 'say "OK"' | grep -q -x OK
|