#!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 "$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 "$target:\n"; foreach $dir ( keys %dir_written ) { print MAKEOUT "\tmake -j $nprocs -C $dir $target #$dir_conf_type{$dir}\n" if ($dir_conf_type{$dir} eq "lib"); } foreach $dir ( keys %dir_written ) { print MAKEOUT "\tmake -j $nprocs -C $dir $target #$dir_conf_type{$dir}\n" if ($dir_conf_type{$dir} ne "lib"); } } print MAKEOUT "\n\nmakefiles:\n\tperl $srcdir/devtools/bin/vpc2linuxmake.pl\n"; print MAKEOUT "\ntags:\n\trm -f $srcdir/TAGS\n"; print MAKEOUT "\tetags -a -C -o $srcdir/TAGS public/*.cpp public/*.h public/*/*.cpp public/*/*.h common/*.cpp common/*.h\n"; foreach $dir ( keys %dir_written ) { print MAKEOUT "\tmake -C $dir tags\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; } } if ( /_include\.vpc$/i ) { unless ( /hk_base\.vpc$/i ) { return; } } if (/\.vpc$/) { (%ignore_file,@DEFINES, @CPPFILES, @CXXFILES,@CFILES, @LITERAL_LIBFILES,@LIBFILES, %define_seen,%macros,%include_seen,@INCLUDEDIRS)=undef; undef $buildforlinux; undef $conf_type; $OptimizerLevel='$(SAFE_OPTFLAGS_GCC_422)'; $SymbolVisibility='hidden'; # 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 "$_\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"; $dir_conf_type{$projdir}=$conf_type; &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 <