Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MJODb-0008MZ-W8 for mharc-grub-devel@gnu.org; Wed, 24 Jun 2009 04:52:36 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MJODZ-0008L1-BL for grub-devel@gnu.org; Wed, 24 Jun 2009 04:52:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MJODU-0008JU-At for grub-devel@gnu.org; Wed, 24 Jun 2009 04:52:32 -0400 Received: from [199.232.76.173] (port=37160 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MJODU-0008JP-7D for grub-devel@gnu.org; Wed, 24 Jun 2009 04:52:28 -0400 Received: from mail-px0-f176.google.com ([209.85.216.176]:58358) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MJODT-00080H-Ho for grub-devel@gnu.org; Wed, 24 Jun 2009 04:52:27 -0400 Received: by pxi6 with SMTP id 6so549614pxi.14 for ; Wed, 24 Jun 2009 01:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=5zNrN4sDZYUEG5uE+LPTpFAv1sXHsYK8TxRrtBY/TgU=; b=Hn4Ku/h116Rp5lCgo82HmnMIoJJLKuBM/vT1K0MJZOon/SFec8rmKrp/L9b7W1OnSi pBtqqjSVlWNhhc7XonX73ZCjlXwo+qHSQuTCPwH9EQamv54IlRAAHn4sVwQ9SNb/ICAg 8+pROOG4biHUBxqlBssx31gUEwT+F+d1UxyQE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=ImRW3MF1Zzj0lPKDz/Kacbm+TrYsRgfPd8bhdUZJm8jkyP5H0pQXCcQub5K5+tKr26 QTx72R0ln96D37ygwPx2UKMKTxePlBrv7IvcudAjCgOwd1cu8tR9TxGr0VJEat8JNIon xgPhRSFYaeEQxbrZdoZbqdafpyW7p9xeB4EyU= MIME-Version: 1.0 Received: by 10.114.37.1 with SMTP id k1mr1676967wak.28.1245833546154; Wed, 24 Jun 2009 01:52:26 -0700 (PDT) Date: Wed, 24 Jun 2009 16:52:26 +0800 Message-ID: From: Bean To: The development of GRUB 2 Content-Type: multipart/mixed; boundary=00163646c506f7c4f9046d14397a X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [PATCH] Support splitting SOURCE in multiple rmk files X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jun 2009 08:52:33 -0000 --00163646c506f7c4f9046d14397a Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, In the current build system, all source files to build an executable must reside in a single rmk file, this makes it difficult to break down the build system in more logical blocks. This patch fixes this by utilizing some tricks of GNU make. First, you can specify the dependence of target in multiple lines, for example: aa: aa.o aa: bb.o $^ represent all dependence, so aa: aa.o gcc -oaa $^ aa: bb.o is the same as aa: aa.o bb.o gcc -oaa aa.o bb.o Second, you can use ifdef so that only the first occurrence would define a rule, for example: ifdef aa_DEFINED aa: aa.o else aa: aa.o gcc -oaa $^ aa_DEFINED=1 endif ifdef aa_DEFINED aa: bb.o else aa: bb.o gcc -oaa $^ aa_DEFINED=1 endif Then, this two blocks can be placed in different makefile, in any order. Third, there could be other dependence file that would cause problem with gcc, but we can filter them out by replacing $^ with $(filter %o,$^). I've post the patch file for genmk.rb, it only changes the rules for *_UTILITIES, but this applies to other targets as well. This is an example to show how to move source file resolve.c of grub_mkelfimage from common.rmk to i386.rmk. diff --git a/conf/common.rmk b/conf/common.rmk index dc78df9..3402faf 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -2,8 +2,9 @@ # For grub-mkelfimage. bin_UTILITIES += grub-mkelfimage -grub_mkelfimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \ - util/resolve.c +#grub_mkelfimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \ +# util/resolve.c +grub_mkelfimage_SOURCES = util/elf/grub-mkimage.c util/misc.c util/elf/grub-mkimage.c_DEPENDENCIES = Makefile # For grub-probe. diff --git a/conf/i386.rmk b/conf/i386.rmk index 89496ae..8e9e582 100644 --- a/conf/i386.rmk +++ b/conf/i386.rmk @@ -1,5 +1,8 @@ # -*- makefile -*- +bin_UTILITIES += grub-mkelfimage +grub_mkelfimage_SOURCES = util/resolve.c + pkglib_MODULES += cpuid.mod cpuid_mod_SOURCES = commands/i386/cpuid.c cpuid_mod_CFLAGS = $(COMMON_CFLAGS) -- Bean --00163646c506f7c4f9046d14397a Content-Type: text/x-diff; charset=US-ASCII; name="genmk.diff" Content-Disposition: attachment; filename="genmk.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_fwbsh2fl0 ZGlmZiAtLWdpdCBhL2dlbm1rLnJiIGIvZ2VubWsucmIKaW5kZXggZTM4NjZjMS4uMzBlZmJjNSAx MDA2NDQKLS0tIGEvZ2VubWsucmIKKysrIGIvZ2VubWsucmIKQEAgLTIzNSw4ICsyMzUsMTMgQEAg Y2xhc3MgVXRpbGl0eQogICAgICJDTEVBTkZJTEVTICs9ICN7QG5hbWV9JChFWEVFWFQpICN7b2Jq c19zdHJ9CiBNT1NUTFlDTEVBTkZJTEVTICs9ICN7ZGVwc19zdHJ9CiAKK2lmZGVmICN7QG5hbWV9 X0RFRklORUQKKyN7QG5hbWV9OiAje29ianNfc3RyfQorZWxzZQogI3tAbmFtZX06ICQoI3twcmVm aXh9X0RFUEVOREVOQ0lFUykgI3tvYmpzX3N0cn0KLQkkKENDKSAtbyAkQCAje29ianNfc3RyfSAk KExERkxBR1MpICQoI3twcmVmaXh9X0xERkxBR1MpCisJJChDQykgLW8gJEAgJChmaWx0ZXIgJS5v LCReKSAkKExERkxBR1MpICQoI3twcmVmaXh9X0xERkxBR1MpCisje0BuYW1lfV9ERUZJTkVEPTEK K2VuZGlmCiAKICIgKyBvYmpzLmNvbGxlY3Rfd2l0aF9pbmRleCBkbyB8b2JqLCBpfAogICAgICAg c3JjID0gc291cmNlc1tpXQo= --00163646c506f7c4f9046d14397a--