#!perl use IO::File; use File::Basename; use File::Find; use Cwd; use Cwd 'abs_path'; $nprocs=`grep vendor_id /proc/cpuinfo | wc -l `; $nprocs=~s/[\n\r]//g; print "$nprocs processors found\n"; #find where to include master make file from $srcdir=getcwd; die "can't determine path to src" unless ($srcdir=~s@/src.*$@/src@); find( { wanted=> \&handle_vpc_file } ,"$srcdir"); # search through all directories for .vpc files @MAINTARGETS=("all", "clean", "objs"); @TARGETS=("all", "clean", "objs", "tags"); # now, write a master makefile in each dir, and a master-master makefile in ~/src foreach $dir ( keys %dir_written ) { open( MAKEOUT,">$dir/Makefile" ) || die "can't write $dir/Makefile"; foreach $target ( @TARGETS ) { print MAKEOUT ".PHONY: $target\n\n"; print MAKEOUT "$target:\n"; foreach $_ (split(/,/,$dir_written{$dir}) ) { print MAKEOUT "\tmake -j $nprocs -f $_ $target\n" if length($_); } } close MAKEOUT; } # now, write a master makefile in ~/src open( MAKEOUT,">$srcdir/Makefile" ) || die "can't write master makefile to $srcdir"; foreach $target ( @MAINTARGETS ) { print MAKEOUT ".PHONY: $target\n\n"; print MAKEOUT "$target:\n"; foreach $dir ( keys %dir_written ) { if ($target ne "clean" ) { print MAKEOUT "\tmake -j $nprocs -C $dir $target\n"; } else { print MAKEOUT "\tmake -C $dir $target\n"; } } } print MAKEOUT "\n\nmakefiles:\n\tperl $srcdir/devtools/bin/vpc2linuxmake.pl\n"; print MAKEOUT "\ntags:\n\tctags --languages=c++ -eR\n"; close MAKEOUT; sub handle_vpc_file { # called for each file in the callers dir tree my $dir=$File::Find::dir; return if ( $dir=~/vpc_scripts/i ); if ( /_base\.vpc$/i ) { unless ( /hk_base\.vpc$/i ) { return; } } return if (/_inc\.vpc/i); if (/\.vpc$/) { (%ignore_file,@DEFINES, @CPPFILES, @CXXFILES,@CFILES, @LITERAL_LIBFILES,@LIBFILES, %define_seen,%macros,%include_seen,@INCLUDEDIRS)=undef; undef $buildforlinux; undef $conf_type; undef $gccflags; $OptimizeLevel=3; # some defines to ignore in vpc files when generating linux include files $define_seen{'WIN32'}=1; $define_seen{'_WIN32'}=1; $define_seen{'_WINDOWS'}=1; $define_seen{'_USRDLL'}=1; $define_seen{'DEBUG'}=1; $define_seen{'_DEBUG'}=1; $define_seen{'NDEBUG'}=1; $define_seen{'_CRT_SECURE_NO_DEPRECATE'}=1; $define_seen{'_CRT_NONSTDC_NO_DEPRECATE'}=1; $define_seen{'fopen'}=1; # print STDERR "parsing project $pname\n"; &ParseVPC($_); $pname=lc($pname); $pname=~s/\s+/_/g; $pname=~s/[\(\)]//g; # if anything seen, output a makefile if ( $buildforlinux && ( @CPPFILES || @CXXFILES || @CFILES || @LIBFILES ) ) { print STDERR "writing project $pname\n"; $projdir=getcwd; $projdir=~s@/$@@; $dir_written{$projdir}.=",$pname.mak"; &WriteMakefile("$projdir/$pname.mak"); &WriteCodeBlocksProj("$projdir/$pname.cbp"); } else { die "no .lib or source files found in .vpc" if ( $buildforlinux ); } } } sub WriteCodeBlocksProj { local($_)=@_; open(CBPROJ,">$_") || die "can't write $_"; print CBPROJ <