* [PATCH] Support splitting SOURCE in multiple rmk files
@ 2009-06-24 8:52 Bean
2009-06-24 12:06 ` Robert Millan
0 siblings, 1 reply; 11+ messages in thread
From: Bean @ 2009-06-24 8:52 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 2007 bytes --]
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
[-- Attachment #2: genmk.diff --]
[-- Type: text/x-diff, Size: 530 bytes --]
diff --git a/genmk.rb b/genmk.rb
index e3866c1..30efbc5 100644
--- a/genmk.rb
+++ b/genmk.rb
@@ -235,8 +235,13 @@ class Utility
"CLEANFILES += #{@name}$(EXEEXT) #{objs_str}
MOSTLYCLEANFILES += #{deps_str}
+ifdef #{@name}_DEFINED
+#{@name}: #{objs_str}
+else
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
- $(CC) -o $@ #{objs_str} $(LDFLAGS) $(#{prefix}_LDFLAGS)
+ $(CC) -o $@ $(filter %.o,$^) $(LDFLAGS) $(#{prefix}_LDFLAGS)
+#{@name}_DEFINED=1
+endif
" + objs.collect_with_index do |obj, i|
src = sources[i]
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] Support splitting SOURCE in multiple rmk files
2009-06-24 8:52 [PATCH] Support splitting SOURCE in multiple rmk files Bean
@ 2009-06-24 12:06 ` Robert Millan
2009-06-24 12:13 ` Bean
0 siblings, 1 reply; 11+ messages in thread
From: Robert Millan @ 2009-06-24 12:06 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Jun 24, 2009 at 04:52:26PM +0800, Bean wrote:
> 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)
This looks very confusing. If what is actually doing is append a new
string to the grub_mkelfimage_SOURCES variable, why not with "+=" ?
"=" means override the previous value.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Support splitting SOURCE in multiple rmk files
2009-06-24 12:06 ` Robert Millan
@ 2009-06-24 12:13 ` Bean
2009-06-24 20:07 ` Vladimir 'phcoder' Serbinenko
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Bean @ 2009-06-24 12:13 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Jun 24, 2009 at 8:06 PM, Robert Millan<rmh@aybabtu.com> wrote:
> On Wed, Jun 24, 2009 at 04:52:26PM +0800, Bean wrote:
>> 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)
>
> This looks very confusing. If what is actually doing is append a new
> string to the grub_mkelfimage_SOURCES variable, why not with "+=" ?
>
> "=" means override the previous value.
Hi,
You can use = or +=, actually the macro is used by genmk.rb to
generate the rules, it's not used by Makefile itself, so no problem
overriding it.
>
> --
> Robert Millan
>
> The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
> how) you may access your data; but nobody's threatening your freedom: we
> still allow you to remove your data and not access it at all."
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
--
Bean
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Support splitting SOURCE in multiple rmk files
2009-06-24 12:13 ` Bean
@ 2009-06-24 20:07 ` Vladimir 'phcoder' Serbinenko
2009-06-25 1:56 ` Bean
2009-06-24 20:53 ` Robert Millan
2009-06-25 19:31 ` Pavel Roskin
2 siblings, 1 reply; 11+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-06-24 20:07 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 1200 bytes --]
Sory for not being present last few days - I split my time between non-grub
things and making zfs work welll in grub2 (I'm already able to boot FreeBSD
off ZFS with branch I have in my personal repo)
>
> Hi,
>
> You can use = or +=, actually the macro is used by genmk.rb to
> generate the rules, it's not used by Makefile itself, so no problem
> overriding it.
>
+= is clearer and using it may avoid problems in future. Also I suggest
having a look at my patch about the same subject.
>
> >
> > --
> > Robert Millan
> >
> > The DRM opt-in fallacy: "Your data belongs to us. We will decide when
> (and
> > how) you may access your data; but nobody's threatening your freedom: we
> > still allow you to remove your data and not access it at all."
> >
> >
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > http://lists.gnu.org/mailman/listinfo/grub-devel
> >
>
>
>
> --
> Bean
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
--
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
[-- Attachment #2: Type: text/html, Size: 2175 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Support splitting SOURCE in multiple rmk files
2009-06-24 12:13 ` Bean
2009-06-24 20:07 ` Vladimir 'phcoder' Serbinenko
@ 2009-06-24 20:53 ` Robert Millan
2009-06-25 19:31 ` Pavel Roskin
2 siblings, 0 replies; 11+ messages in thread
From: Robert Millan @ 2009-06-24 20:53 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Jun 24, 2009 at 08:13:35PM +0800, Bean wrote:
> >> +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)
> >
> > This looks very confusing. If what is actually doing is append a new
> > string to the grub_mkelfimage_SOURCES variable, why not with "+=" ?
> >
> > "=" means override the previous value.
>
> Hi,
>
> You can use = or +=, actually the macro is used by genmk.rb to
> generate the rules, it's not used by Makefile itself, so no problem
> overriding it.
Yes, but using = to generate a rule that actually means += is very confusing.
Please don't do that.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Support splitting SOURCE in multiple rmk files
2009-06-24 20:07 ` Vladimir 'phcoder' Serbinenko
@ 2009-06-25 1:56 ` Bean
0 siblings, 0 replies; 11+ messages in thread
From: Bean @ 2009-06-25 1:56 UTC (permalink / raw)
To: The development of GRUB 2
On Thu, Jun 25, 2009 at 4:07 AM, Vladimir 'phcoder'
Serbinenko<phcoder@gmail.com> wrote:
> Sory for not being present last few days - I split my time between non-grub
> things and making zfs work welll in grub2 (I'm already able to boot FreeBSD
> off ZFS with branch I have in my personal repo)
>>
>> Hi,
>>
>> You can use = or +=, actually the macro is used by genmk.rb to
>> generate the rules, it's not used by Makefile itself, so no problem
>> overriding it.
>
> += is clearer and using it may avoid problems in future. Also I suggest
> having a look at my patch about the same subject.
Hi,
Oh, could you give me a link ?
>>
>> >
>> > --
>> > Robert Millan
>> >
>> > The DRM opt-in fallacy: "Your data belongs to us. We will decide when
>> > (and
>> > how) you may access your data; but nobody's threatening your freedom:
>> > we
>> > still allow you to remove your data and not access it at all."
>> >
>> >
>> > _______________________________________________
>> > Grub-devel mailing list
>> > Grub-devel@gnu.org
>> > http://lists.gnu.org/mailman/listinfo/grub-devel
>> >
>>
>>
>>
>> --
>> Bean
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> http://lists.gnu.org/mailman/listinfo/grub-devel
>
>
>
> --
> Regards
> Vladimir 'phcoder' Serbinenko
>
> Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
>
--
Bean
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Support splitting SOURCE in multiple rmk files
2009-06-24 12:13 ` Bean
2009-06-24 20:07 ` Vladimir 'phcoder' Serbinenko
2009-06-24 20:53 ` Robert Millan
@ 2009-06-25 19:31 ` Pavel Roskin
2009-06-26 3:13 ` Bean
2 siblings, 1 reply; 11+ messages in thread
From: Pavel Roskin @ 2009-06-25 19:31 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, 2009-06-24 at 20:13 +0800, Bean wrote:
> You can use = or +=, actually the macro is used by genmk.rb to
> generate the rules, it's not used by Makefile itself, so no problem
> overriding it.
While at that, it would be nice to use a special notation for the
partial dependencies.
Something like:
aa:+ aa.o
aa:+ bb.o
Please don't use "_DEFINED" to mean "rule emitted", it's confusing.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Support splitting SOURCE in multiple rmk files
2009-06-25 19:31 ` Pavel Roskin
@ 2009-06-26 3:13 ` Bean
2009-06-26 22:32 ` Pavel Roskin
0 siblings, 1 reply; 11+ messages in thread
From: Bean @ 2009-06-26 3:13 UTC (permalink / raw)
To: The development of GRUB 2
On Fri, Jun 26, 2009 at 3:31 AM, Pavel Roskin<proski@gnu.org> wrote:
> On Wed, 2009-06-24 at 20:13 +0800, Bean wrote:
>
>> You can use = or +=, actually the macro is used by genmk.rb to
>> generate the rules, it's not used by Makefile itself, so no problem
>> overriding it.
>
> While at that, it would be nice to use a special notation for the
> partial dependencies.
>
> Something like:
>
> aa:+ aa.o
> aa:+ bb.o
Hi,
Is this new syntax for GNU make ? My version report error when using :+ .
>
> Please don't use "_DEFINED" to mean "rule emitted", it's confusing.
How about _RULES_DEFINED ?
>
> --
> Regards,
> Pavel Roskin
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
--
Bean
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Support splitting SOURCE in multiple rmk files
2009-06-26 3:13 ` Bean
@ 2009-06-26 22:32 ` Pavel Roskin
2009-06-27 3:44 ` Bean
0 siblings, 1 reply; 11+ messages in thread
From: Pavel Roskin @ 2009-06-26 22:32 UTC (permalink / raw)
To: The development of GRUB 2
On Fri, 2009-06-26 at 11:13 +0800, Bean wrote:
> On Fri, Jun 26, 2009 at 3:31 AM, Pavel Roskin<proski@gnu.org> wrote:
> > While at that, it would be nice to use a special notation for the
> > partial dependencies.
> >
> > Something like:
> >
> > aa:+ aa.o
> > aa:+ bb.o
>
> Hi,
>
> Is this new syntax for GNU make ? My version report error when using :+ .
No. I suggested syntax that would indicate that it's not a complete
make rule.
If we use Ruby to join the rules, we can replace ":+" with ":" in the
result.
> > Please don't use "_DEFINED" to mean "rule emitted", it's confusing.
>
> How about _RULES_DEFINED ?
I'm fine with anything that is descriptive.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Support splitting SOURCE in multiple rmk files
2009-06-26 22:32 ` Pavel Roskin
@ 2009-06-27 3:44 ` Bean
2009-06-27 3:56 ` Pavel Roskin
0 siblings, 1 reply; 11+ messages in thread
From: Bean @ 2009-06-27 3:44 UTC (permalink / raw)
To: The development of GRUB 2
On Sat, Jun 27, 2009 at 6:32 AM, Pavel Roskin<proski@gnu.org> wrote:
> On Fri, 2009-06-26 at 11:13 +0800, Bean wrote:
>> On Fri, Jun 26, 2009 at 3:31 AM, Pavel Roskin<proski@gnu.org> wrote:
>
>> > While at that, it would be nice to use a special notation for the
>> > partial dependencies.
>> >
>> > Something like:
>> >
>> > aa:+ aa.o
>> > aa:+ bb.o
>>
>> Hi,
>>
>> Is this new syntax for GNU make ? My version report error when using :+ .
>
> No. I suggested syntax that would indicate that it's not a complete
> make rule.
>
> If we use Ruby to join the rules, we can replace ":+" with ":" in the
> result.
Hi,
Oh, actually aa: aa.o is already a ruby generated rule, it doesn't
exist in rmk file. The original line from rmk would be something like
this:
aa_SOURCES += aa.c
--
Bean
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Support splitting SOURCE in multiple rmk files
2009-06-27 3:44 ` Bean
@ 2009-06-27 3:56 ` Pavel Roskin
0 siblings, 0 replies; 11+ messages in thread
From: Pavel Roskin @ 2009-06-27 3:56 UTC (permalink / raw)
To: The development of GRUB 2
On Sat, 2009-06-27 at 11:44 +0800, Bean wrote:
> Oh, actually aa: aa.o is already a ruby generated rule, it doesn't
> exist in rmk file. The original line from rmk would be something like
> this:
>
> aa_SOURCES += aa.c
I see. Sorry for the noise.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2009-06-27 3:56 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-24 8:52 [PATCH] Support splitting SOURCE in multiple rmk files Bean
2009-06-24 12:06 ` Robert Millan
2009-06-24 12:13 ` Bean
2009-06-24 20:07 ` Vladimir 'phcoder' Serbinenko
2009-06-25 1:56 ` Bean
2009-06-24 20:53 ` Robert Millan
2009-06-25 19:31 ` Pavel Roskin
2009-06-26 3:13 ` Bean
2009-06-26 22:32 ` Pavel Roskin
2009-06-27 3:44 ` Bean
2009-06-27 3:56 ` Pavel Roskin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.