From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 16 13:15:17 2009 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 06BAD106566C for ; Fri, 16 Oct 2009 13:15:17 +0000 (UTC) (envelope-from uqs@spoerlein.net) Received: from acme.spoerlein.net (cl-43.dus-01.de.sixxs.net [IPv6:2a01:198:200:2a::2]) by mx1.freebsd.org (Postfix) with ESMTP id A2F008FC15 for ; Fri, 16 Oct 2009 13:15:16 +0000 (UTC) Received: from elmar.spoerlein.net (e180130196.adsl.alicedsl.de [85.180.130.196]) by acme.spoerlein.net (8.14.3/8.14.3) with ESMTP id n9GDF4t8011190 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 16 Oct 2009 15:15:05 +0200 (CEST) (envelope-from uqs@spoerlein.net) Received: from elmar.spoerlein.net (localhost [127.0.0.1]) by elmar.spoerlein.net (8.14.3/8.14.3) with ESMTP id n9GDF4UV069866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 16 Oct 2009 15:15:04 +0200 (CEST) (envelope-from uqs@spoerlein.net) Received: (from uqs@localhost) by elmar.spoerlein.net (8.14.3/8.14.3/Submit) id n9GDF4uJ069865; Fri, 16 Oct 2009 15:15:04 +0200 (CEST) (envelope-from uqs@spoerlein.net) Date: Fri, 16 Oct 2009 15:15:04 +0200 From: Ulrich =?utf-8?B?U3DDtnJsZWlu?= To: Dag-Erling =?utf-8?B?U23DuHJncmF2?= Message-ID: <20091016131504.GA5222@elmar.spoerlein.net> Mail-Followup-To: Dag-Erling =?utf-8?B?U23DuHJncmF2?= , hackers@freebsd.org References: <20091011145021.GG36937@acme.spoerlein.net> <861vl8sxxb.fsf@ds4.des.no> <20091012155421.GJ36937@acme.spoerlein.net> <86zl7wpnzh.fsf@ds4.des.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="7JfCtLOvnd9MIVvH" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86zl7wpnzh.fsf@ds4.des.no> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: hackers@freebsd.org Subject: Re: RFC: Big Makefile patch for WARNS settings X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Oct 2009 13:15:17 -0000 --7JfCtLOvnd9MIVvH Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Mon, 12.10.2009 at 18:37:38 +0200, Dag-Erling Smørgrav wrote: > Ulrich Spörlein writes: > > Is there some easy way to do cross-compiles (like make universe) in just > > one of the subdirs? That would help tremendously. > > % cd /usr/src > % make toolchain TARGET=powerpc > % make buildenv TARGET=powerpc > %% cd usr.sbin/rwhod > %% make > > ('make buildenv' starts a subshell) Excellent, I now smashed together the following expect script, which can be used to compile a single subdir with these toolchains. It requires that you build all toolchains once, upfront. It's a total hack, but hey it works for me, example usage would be: $ cd /usr/src $ universe-build -t (builds toolchain for all targets, needs to be done every once in a while) $ universe-build games/grdc WARNS=6 sparc64 amd64 i386 (build grdc with WARNS=6 for 3 archs specified, using the buildenv target above) Pardon my weak tcl/expect-fu Regards, Uli --7JfCtLOvnd9MIVvH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename=universe-build #!/usr/local/bin/expect # Does the following for variable subdirs and a given set of target archs, # exits upon first failure. # % cd /usr/src # % make toolchain TARGET=powerpc # % make buildenv TARGET=powerpc # %% cd usr.sbin/rwhod # %% make set timeout -1 set toolchain 0 proc usage {argv0} { send_user "usage: $argv0 -t \[target1 target2 ...\]\n" send_user " $argv0 subdir \[make-args\] \[target1 target2 ...\]\n" exit } while {[llength $argv]>0} { set flag [lindex $argv 0] switch -- $flag \ "-t" { set toolchain 1 set argv [lrange $argv 1 end] set argc [expr ($argc - 1)] } default { break } } if {$toolchain!=1} { if {$argc<1} { usage $argv0 exit 1 } set subdir [lindex $argv 0] set argv [lrange $argv 1 end] set argc [expr ($argc - 1)] # if something is present, use it as make args if {$argc>=1} { set margs [lindex $argv 0] set argv [lrange $argv 1 end] set argc [expr ($argc - 1)] } else { set margs {} } } # if there is still something, use it as target list, # else default to everything if {$argc>=1} { set targets [lrange $argv 0 end] } else { set input [open "|make universe -V TARGETS" r] set targets [split [string trimright [read $input]] " "] close $input } if {$toolchain==1} { foreach target $targets { spawn /bin/sh expect "$ " send "env MAKEOBJDIRPREFIX=/usr/obj/$target make toolchain __MAKE_CONF=/dev/null TARGET=$target\n" expect "$ " send "exit \$?\n" expect eof } puts "\n" exit } foreach target $targets { spawn /bin/sh set sid($target) $spawn_id expect "$ " send "env MAKEOBJDIRPREFIX=/usr/obj/$target make buildenv __MAKE_CONF=/dev/null TARGET=$target\n" expect "$ " send "make -C $subdir clean; make -C $subdir $margs\n" expect "$ " # Stupid buildenv is doing sh || true, so we cannot propagate by doing exit $rc :( # grab echo output instead send "echo rc=\$?\n" expect -re "echo rc=..\r" expect -re "rc=(.*)\n" # TODO: save rc per target, don't exit below but print rcs for all archs on exit set rc $expect_out(1,string) send "exit \$?\n" expect "$ " send "exit \$?\n" expect eof if {$rc!=0} { puts "" exit $rc } ## if we expect eof, the wait below will not return, wtf? ## XXX sid($target) wont work here?? #catch {close -i $spawn_id} ## wait returns PID, TYPE, CODE, grab code #set rc [lindex [wait sid($target)] 3] } --7JfCtLOvnd9MIVvH--