#!/usr/bin/perl $prefix="/usr/X11"; $target=shift @ARGV; $ENV{DESTDIR}=$ENV{DSTROOT}; $ENV{LD_LIBRARY_PATH}="$prefix/lib:$ENV{LD_LIBRARY_PATH}" unless $ENV{LD_LIBRARY_PATH} =~ /$prefix/; $ENV{PATH}="$ENV{DSTROOT}$prefix/bin:$prefix/bin:$ENV{PATH}" unless $ENV{PATH} =~ /$prefix/; $ENV{FREETYPE_LIBS}="-L$prefix/lib -lfreetype -lz -Xlinker -framework -Xlinker CoreServices -Xlinker -framework -Xlinker ApplicationServices"; $ENV{PKG_CONFIG_PATH}="$ENV{DSTROOT}$prefix/lib/pkgconfig:$prefix/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}"; $ENV{FONTCONFIG_FILE}="$ENV{OBJROOT}/build-fonts.conf"; if($target eq 'installsrc') { sys_print("ditto . $ENV{SRCROOT}"); chdir($ENV{SRCROOT}); foreach $module (glob('*')) { next if $module =~ /build/; next if $module =~ /Make/; next if $module =~ /uvn/; next if $module =~ /\./; print "installing source for $module\n"; chdir($module); sys_print("../uvn extract; ../uvn patch"); chdir('..'); } exit(); } if($target eq 'clean') { print "Cleaning out directory $ENV{SRCROOT}\n"; chdir($ENV{SRCROOT}); sys_print("find . -name .svn | xargs rm -rf"); sys_print("find . -name .uvn | xargs rm -rf"); sys_print("find . -name \"*.gz\" | xargs rm"); sys_print("find . -name \"*.bz2\" | xargs rm"); sys_print("find . -name patches | xargs rm -rf"); exit(); } if($target eq 'install') { # Must create local aclocal dir or aclocal fails $ACLOCAL_LOCALDIR="$ENV{DSTROOT}$prefix/share/aclocal"; system "mkdir -p $ACLOCAL_LOCALDIR"; # The following is required to make aclocal find our .m4 macros $ENV{ACLOCAL}="aclocal -I $ACLOCAL_LOCALDIR -I $prefix/share/aclocal"; $ENV{LIBTOOLIZE}="/usr/bin/glibtoolize"; print "Install phase: \n"; print "SRCROOT = $ENV{SRCROOT}\n"; print "DSTROOT = $ENV{DSTROOT}\n"; print "OBJROOT = $ENV{OBJROOT}/\n"; print "SYMROOT = $ENV{SYMROOT}\n"; sys_print("ditto $ENV{SRCROOT} $ENV{OBJROOT}"); # All fonts require mkfontscale and mkfontdir to be available # # The following fonts require bdftopcf to be available: # adobe-100dpi, adobe-75dpi, adobe-utopia-100dpi, adobe-utopia-75dpi, # arabic-misc, bh-100dpi, bh-75dpi, bh-lucidatypewriter-100dpi, # bh-lucidatypewriter-75dpi, bitstream-100dpi, bitstream-75dpi, # cronyx-cyrillic, cursor-misc, daewoo-misc, dec-misc, isas-misc, # jis-misc, micro-misc, misc-cyrillic, misc-misc, mutt-misc, # schumacher-misc, screen-cyrillic, sony-misc, sun-misc and # winitzki-cyrillic # # Within the font module, the util component must be built before the # following fonts: # adobe-100dpi, adobe-75dpi, adobe-utopia-100dpi, adobe-utopia-75dpi, # bh-100dpi, bh-75dpi, bh-lucidatypewriter-100dpi, bh-lucidatypewriter-75dpi, # misc-misc and schumacher-misc # # The alias component is recommended to be installed after the other fonts # since the fonts.alias files reference specific fonts installed from the # other font components chdir($ENV{OBJROOT}); while() { next if /util/; next if /alias/; push @font_packages, $_; } foreach $arch (split(/ /,$ENV{RC_ARCHS})) { $arch_flags_lib .= "-arch $arch "; if($ENV{MACOSFORGE_RELEASE} eq "YES") { $arch_flags_exec .= " -arch $arch " unless $arch =~ /64/; } else { $arch_flags_exec .= " -arch $arch " unless $arch =~ /ppc/; } } set_arch_exec(); build("font-util"); build("encodings"); sys_print("sed -i.bak 's_^prefix=.*_prefix=$ENV{DSTROOT}$prefix"."_' $ENV{DSTROOT}$prefix/lib/pkgconfig/*.pc"); foreach (@font_packages) { build($_); } sys_print("sed -i.bak 's_^prefix=.*_prefix=$prefix"."_' $ENV{DSTROOT}$prefix/lib/pkgconfig/*.pc"); sys_print("rm $ENV{DSTROOT}$prefix/lib/pkgconfig/*.bak"); build("font-alias"); make_dsyms(); } sub build { ($module)=@_; $m1=$module; print("build($module): "); die "$module not found" unless -e "$ENV{SRCROOT}/$module"; chdir ("$ENV{SRCROOT}/$module"); $full_path="/$module/".get_workdir(); print "full_path=$full_path\n"; sys_print("mkdir -p $ENV{OBJROOT}/$full_path"); sys_print("ditto $ENV{SRCROOT}/$full_path $ENV{OBJROOT}/$full_path"); sys_print("find . -depth 1 -type f -print | xargs -I foo cp -pv foo $ENV{OBJROOT}/$module"); chdir("$ENV{OBJROOT}/$full_path"); sys_print("autoreconf -fvi"); print "Configuring...\n"; $conf_flags=" --prefix=$prefix --disable-static --disable-dependency-tracking --disable-nls --mandir=$prefix/share/man "; $conf_flags_path=$ENV{OBJROOT}."/$module/conf_flags"; $post_config_path=$ENV{OBJROOT}."/$module/post-config"; if(-e $conf_flags_path) { $conf_flags .= `cat $conf_flags_path`; chomp $conf_flags; } sys_print("./configure $conf_flags"); if(-e $post_config_path) { sys_print("cd .. && $post_config_path"); } sys_print("make -j".`sysctl -n hw.activecpu`); sys_print("make install"); chdir('../..'); } sub get_workdir { system "pwd"; system "ls -l"; foreach (glob('*')) { if(-e "$_/configure") { return $_; } } die "Unable to determine workdir"; } sub set_arch_exec { $ENV{CFLAGS}="-I$ENV{DSTROOT}$prefix/include -D__DEBUG__ -ggdb3 -Os -pipe $arch_flags_exec -D_FORTIFY_SOURCE=2 -Wall -Wformat-security"; $ENV{LDFLAGS}="-pipe $arch_flags_exec"; } sub set_arch_lib { $ENV{CFLAGS}="-I$ENV{DSTROOT}$prefix/include -D__DEBUG__ -ggdb3 -Os -pipe $arch_flags_lib -D_FORTIFY_SOURCE=2 -Wall -Wformat-security"; $ENV{LDFLAGS}="-pipe $arch_flags_lib"; } sub sys_print { $command=shift; print "$command\n"; system $command; $retval=$? >> 8; die "returned code $retval" if $retval; } sub sys_print_nodie { $command=shift; print "$command\n"; system $command; $retval=$? >> 8; print "returned code $retval\n" if $retval; } sub make_dsyms { open(FIND,"find $ENV{DSTROOT} -type f -exec file {} +|"); while() { if(/(.*): .*Mach-O/) { $basename=$1; $fullpath=$1; $basename =~ s/\/.*\///; sys_print_nodie("dsymutil --out=$ENV{SYMROOT}/$basename.dSYM $fullpath"); sys_print_nodie("strip -S $fullpath"); } } close FIND; }