the build of static perl method on loongson fedora13-o32
the main reference comes frome this site:
http://ucla.jamesyxu.com/?p=303
the detail steps as follow:
1. build the openssl library is needed,just only configure,make,make install is ok
2. download the App-staticperl tar, use the App-staticperl directory with the replaced staticperl.sh script
run command: ./staticperl.sh install
this will take a long time and for the most case, it will not be success,because some already compiled file in the directory ".staticperl/cpan/build/" not been copied to the ".staticperl/perl/lib/" directory, so we should manually copy the missing directory and file into this directory
like the
common-sense-3.74-Paa2df/blib/arch/common to the .staticperl/perl/lib/ Module-Build-Tiny-0.039-0Y19u5/lib/Module/Build/Tiny.pm to the .staticperl/perl/lib/Module/Build/ ExtUtils-Config-0.008-tzplFT/lib/ExtUtils/Config.pm to the .staticperl/perl/lib/ExtUtils/ ExtUtils-Helpers-0.022-_CJAC_/lib/ExtUtils/* to the .staticperl/perl/lib/ExtUtils/ ExtUtils-InstallPaths-0.011-d2cyqq/lib/ExtUtils/InstallPaths.pm to the .staticperl/perl/lib/ExtUtils/ ExtUtils-MakeMaker-7.10-oU70GN/lib/ExtUtils/MakeMaker* to the .staticperl/perl/lib/ExtUtils/ also some other directory and files
4.Copy ./mkbundle to ~/.staticperl/bin/SP-mkbundle. This step is required to work around a script error in staticperl.sh that prevents it from generating the mkbundle script
5.Run ./staticperl.sh mkperl, if there are any missing module errors then install the corresponding module from CPAN using ~/.staticperl/bin/perl
6.download Crypt-CBC, Build and install CBC::Crypt:
Untar Crypt-CBC
cd into the new directory and issue:
~/.staticperl/bin/perl Makefile.PL make make install
7.Build and install Crypt::OpenSSL::AES. This require modification to Makefile.PL to statically link in the OpenSSL library built during step 1
Untar Crypt::OpenSSL::AES
cd into the new directory and modify the Makefile.PL
Comment out LIBS
Add path to the build openssl's include dir to INC
Add MYEXTLIB => 'POINT TO libcrypto.a FILE' # this gets directly added to the linker
the above modify already done in the Makefile.PL of Crypt-OpenSSL-AES
AS FOLLOW:
# LIBS => ['-lcrypto'], # e.g., '-lm'
MYEXTLIB => '/usr/local/ssl/lib/libcrypto.a', # e.g., '-lm'
DEFINE => '', # e.g., '-DHAVE_SOMETHING'
INC => '-I. -I/usr/local/ssl/include', # e.g., '-I. -I/usr/include/other'
# Un-comment this if you add C files to link with later:
# OBJECT => '$(O_FILES)', # link all the C files too
);
Issue commands:
~/.staticperl/bin/perl Makefile.PL make make install
8. Build staticperl, CD into App-Staticperl and issue
./staticperl.sh mkperl --incglob '*' --static
9. solve the error during build(this did not show up in the ubuntu system, so if use x86 ubuntu,maybe ignore this step)
when building the static perl the link of libcrypt.a has some problem, this lib is compiled out from glibc,can find out with the "rpm -qf /usr/lib/libcrypt.a" command, the error is undefined reference to `NSSLOW_Init' and some else
this is because the glibc compiled with nss-crypt support, so recompiled the glibc with the following configure
CC=gcc -march=mips3 -mabi=32 -mplt -fPIC -fexceptions CXX=g++ -march=mips3 -mabi=32 -mplt -fPIC -fexceptions CFLAGS=-Wp,-D_FORTIFY_SOURCE=0 -fasynchronous-unwind-tables -DNDEBUG -g -march=mips3 -mabi=32 -O3 --prefix=/opt/glibc-static --enable-add-ons=nptl,ports,c_stubs,libidn --without-cvs --enable-kernel=2.6.18 --with-headers=/usr/include --enable-bind-now --enable-static --disable-nss-crypt --with-tls --with-__thread --build mipsel-redhat-linux --host mipsel-redhat-linux --disable-profile --enable-experimental-malloc build_alias=mipsel-redhat-linux host_alias=mipsel-redhat-linux --no-create --no-recursion
the main modify is --enable-static --disable-nss-crypt ,then recompile glibc,replace the /usr/lib/libcrypt.a with the newly build one
reference:
https://bitbucket.org/abensonca/galacticus/issues/3/libcrypta-results-in-errors-when-compile
http://serverfault.com/questions/571104/libcrypt-a-undefined-reference-to-nsslow
rerun the command in step 8 to build out the static perl
10. run ./perl test1.pl to test the perl