#!/usr/bin/perl -w =head1 NAME dh_illumos_make - build illumos sources =cut use strict; use Debian::Debhelper::Dh_Lib; use Cwd; =head1 SYNOPSIS B [S>] [B<-m>I] [B<-t>I] [B<--debug>] [B<--ctf>] [B<--no-onbld>] [B<--native>] [directories] =head1 DESCRIPTION C is responsible for building illumos sources. If no directories specified, it will build entire illumos gate (not recommended, and probably will fail). If directories are given, it will build within those directories in order. Illumos sources should be previously unpacked with L. =head1 EXAMPLES dh_illumos_make -t install_h usr/src/uts is equivalent to ksh93 usr/bldenv.sh usr/env.sh -c "cd usr/src/uts && /usr/bin/make --sun install_h" dh_illumos_make -m /opt/SUNWspro/bin/dmake usr/src/lib is equivalent to ksh93 usr/bldenv.sh usr/env.sh -c "cd usr/src/lib && /opt/SUNWspro/bin/dmake install" =head1 OPTIONS =over 4 =item B<--root=>I Defines root directory where build result will be installed: executables, libraries, headers, etc. Overrides one configured by L. Proto directory to install build results in. If absent, it will be created. =item B<-m>I B<--make=>I Make program to use. Default is F. =item B<-t>I B<--target=>I Target for I. Default is C which will build sources and install into proto area. =item B<--debug> Turn on debug build. This will execute ksh93 usr/bldenv.sh -d usr/env.sh ... instead of ksh93 usr/bldenv.sh usr/env.sh ... =item B<--ctf> Do use CTF (I) tools during build. Every ELF object built from illumos sources used to be processed by these tools, even F itself. As a side effect any debug information is being stripped out from resulting binaries. This is not acceptable on Debian, so CTF is not used by default. =item B<--no-onbld> Do not use C tools installed in system (F). Normally it only works and useful for building C itself. Otherwise F must be unpacked and built before any other component. If this option is given, F is called with C<-t> option instead of C<+t>. =item B<--native> Some components have both 32- and 64-bit versions, others have no architecture specific versions. Such components assumed to be 32-bit, and on 64-bit system it is incorrect. With this option C will build those components using system native compiler. =back =head1 NOTES If illumos sources were unpacked with L, proto area is F. =cut $dh{'MAKE'} = '/usr/bin/make --sun'; $dh{'TARGET'} = 'install'; $dh{'CTF'} = 0; $dh{'NO_ONBLD'} = 0; my $cwd = getcwd(); init( options => { 'ctf!' => \$dh{'CTF'}, 'debug' => \$dh{'DEBUG'}, 'make|m=s' => \$dh{'MAKE'}, 'native' => \$dh{'NATIVE'}, 'no-onbld' => \$dh{'NO_ONBLD'}, 'root=s' => \$dh{'ROOT'}, 'target|t=s' => \$dh{'TARGET'}, } ); my @dirs = ('usr/src'); if (@ARGV) { @dirs = @ARGV; } # Check whether all dirs exist before doing anything: foreach (@dirs) { s,.*illumos-gate/+,,; if ( !-d "$_" ) { error("`$_' does not exist or not a directory"); } } my $opts = ''; $opts .= '-d' if $dh{'DEBUG'}; my $onbld = $dh{'NO_ONBLD'} ? '-t' : '+t'; $opts .= $onbld; my $override = ''; if ( !$dh{CTF} ) { $override .= ' CTFCONVERT=: CTFMERGE=:'; } if ( $dh{ROOT} ) { doit( 'mkdir', '-p', $dh{ROOT} ); chdir $dh{ROOT}; $override .= ' ROOT="' . getcwd() . '"'; chdir $cwd; } if ( $dh{'NATIVE'} ) { my $deb_host_arch_cpu = `dpkg-architecture -qDEB_HOST_ARCH_CPU`; chomp $deb_host_arch_cpu; $override .= ' i386_XARCH='; # We need to propogate it through perl and shell to make: $override .= " LDLIBS32='\\\$(LDLIBS_NATIVE)'"; $override .= " MAPFILE.NGB='\\\$(MAPFILE.NGB_$deb_host_arch_cpu)'"; } foreach (@dirs) { my $root = s!(.*)usr/.*!$1!r; complex_doit( qq!ksh93 ${root}usr/bldenv.sh $opts ${root}usr/env.sh -c "cd $_ && $dh{'MAKE'} $dh{'TARGET'} $override"! ); } =head1 SEE ALSO L, L. =head1 AUTHOR Igor Pashev =cut