diff mbox

[2/6] samples: refactor Makefile

Message ID 1405276974-17323-2-git-send-email-sam@ravnborg.org (mailing list archive)
State New, archived
Headers show

Commit Message

Sam Ravnborg July 13, 2014, 6:42 p.m. UTC
Use one line per module/program in Makefile.
This style is easier to read/extend.

Introduce inverse xmas style sorting.
This may prevent some merge conflicts in the future

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 samples/Makefile | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

Comments

Randy Dunlap July 13, 2014, 7:25 p.m. UTC | #1
On 07/13/14 11:42, Sam Ravnborg wrote:
> Use one line per module/program in Makefile.
> This style is easier to read/extend.
> 
> Introduce inverse xmas style sorting.

google search couldn't tell me what that means and I cannot
deduce it from the new Makefile ordering (if there is some ordering).
Please explain.

Thanks.

> This may prevent some merge conflicts in the future
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  samples/Makefile | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/samples/Makefile b/samples/Makefile
> index 1a60c62..7c08028 100644
> --- a/samples/Makefile
> +++ b/samples/Makefile
> @@ -1,4 +1,15 @@
>  # Makefile for Linux samples code
> +# Sort entries using inverse xmas style
> +#
> +# kernel modules
> +obj-$(CONFIG_SAMPLES) += hw_breakpoint/
> +obj-$(CONFIG_SAMPLES) += trace_events/
> +obj-$(CONFIG_SAMPLES) += kprobes/
> +obj-$(CONFIG_SAMPLES) += kobject/
> +obj-$(CONFIG_SAMPLES) += kfifo/
> +obj-$(CONFIG_SAMPLES) += rpmsg/
> +obj-$(CONFIG_SAMPLES) += kdb/
>  
> -obj-$(CONFIG_SAMPLES)	+= kobject/ kprobes/ trace_events/ \
> -			   hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/
> +# user space programs
> +obj-$(CONFIG_SAMPLES) += seccomp/
> +obj-$(CONFIG_SAMPLES) += hidraw/
>
Sam Ravnborg July 13, 2014, 7:52 p.m. UTC | #2
Hi Randy - thanks for the feedback.

On Sun, Jul 13, 2014 at 12:25:33PM -0700, Randy Dunlap wrote:
> On 07/13/14 11:42, Sam Ravnborg wrote:
> > Use one line per module/program in Makefile.
> > This style is easier to read/extend.
> > 
> > Introduce inverse xmas style sorting.
> 
> google search couldn't tell me what that means and I cannot
> deduce it from the new Makefile ordering (if there is some ordering).
> Please explain.

Sort by length - with longest entry first. Like an xmas tree upside-down.
For entries with same lenght sort alphabetically.

Advocated in some places for includes and other places for local variables.

One recent reference is for example this:
http://marc.info/?l=linux-netdev&m=140510662905580&w=2

I will rephrase it like this:

# Sort entries using inverse xmas style:
# Longest entries first, alphabetically when legth is the same.

OK?
	Sam



> 
> Thanks.
> 
> > This may prevent some merge conflicts in the future
> > 
> > Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> > ---
> >  samples/Makefile | 15 +++++++++++++--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/samples/Makefile b/samples/Makefile
> > index 1a60c62..7c08028 100644
> > --- a/samples/Makefile
> > +++ b/samples/Makefile
> > @@ -1,4 +1,15 @@
> >  # Makefile for Linux samples code
> > +# Sort entries using inverse xmas style
> > +#
> > +# kernel modules
> > +obj-$(CONFIG_SAMPLES) += hw_breakpoint/
> > +obj-$(CONFIG_SAMPLES) += trace_events/
> > +obj-$(CONFIG_SAMPLES) += kprobes/
> > +obj-$(CONFIG_SAMPLES) += kobject/
> > +obj-$(CONFIG_SAMPLES) += kfifo/
> > +obj-$(CONFIG_SAMPLES) += rpmsg/
> > +obj-$(CONFIG_SAMPLES) += kdb/
> >  
> > -obj-$(CONFIG_SAMPLES)	+= kobject/ kprobes/ trace_events/ \
> > -			   hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/
> > +# user space programs
> > +obj-$(CONFIG_SAMPLES) += seccomp/
> > +obj-$(CONFIG_SAMPLES) += hidraw/
> > 
> 
> 
> -- 
> ~Randy
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Randy Dunlap July 13, 2014, 8:13 p.m. UTC | #3
On 07/13/14 12:52, Sam Ravnborg wrote:
> Hi Randy - thanks for the feedback.
> 
> On Sun, Jul 13, 2014 at 12:25:33PM -0700, Randy Dunlap wrote:
>> On 07/13/14 11:42, Sam Ravnborg wrote:
>>> Use one line per module/program in Makefile.
>>> This style is easier to read/extend.
>>>
>>> Introduce inverse xmas style sorting.
>>
>> google search couldn't tell me what that means and I cannot
>> deduce it from the new Makefile ordering (if there is some ordering).
>> Please explain.
> 
> Sort by length - with longest entry first. Like an xmas tree upside-down.
> For entries with same lenght sort alphabetically.
> 
> Advocated in some places for includes and other places for local variables.
> 
> One recent reference is for example this:
> http://marc.info/?l=linux-netdev&m=140510662905580&w=2
> 
> I will rephrase it like this:
> 
> # Sort entries using inverse xmas style:
> # Longest entries first, alphabetically when legth is the same.

                                               length

> 
> OK?

Yes.  Thanks.

> 	Sam
> 
> 
> 
>>
>> Thanks.
>>
>>> This may prevent some merge conflicts in the future
>>>
>>> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
>>> ---
>>>  samples/Makefile | 15 +++++++++++++--
>>>  1 file changed, 13 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/samples/Makefile b/samples/Makefile
>>> index 1a60c62..7c08028 100644
>>> --- a/samples/Makefile
>>> +++ b/samples/Makefile
>>> @@ -1,4 +1,15 @@
>>>  # Makefile for Linux samples code
>>> +# Sort entries using inverse xmas style
>>> +#
>>> +# kernel modules
>>> +obj-$(CONFIG_SAMPLES) += hw_breakpoint/
>>> +obj-$(CONFIG_SAMPLES) += trace_events/
>>> +obj-$(CONFIG_SAMPLES) += kprobes/
>>> +obj-$(CONFIG_SAMPLES) += kobject/
>>> +obj-$(CONFIG_SAMPLES) += kfifo/
>>> +obj-$(CONFIG_SAMPLES) += rpmsg/
>>> +obj-$(CONFIG_SAMPLES) += kdb/
>>>  
>>> -obj-$(CONFIG_SAMPLES)	+= kobject/ kprobes/ trace_events/ \
>>> -			   hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/
>>> +# user space programs
>>> +obj-$(CONFIG_SAMPLES) += seccomp/
>>> +obj-$(CONFIG_SAMPLES) += hidraw/
Stephen Rothwell July 14, 2014, 12:26 a.m. UTC | #4
Hi Sam,

On Sun, 13 Jul 2014 21:52:36 +0200 Sam Ravnborg <sam@ravnborg.org> wrote:
>
> On Sun, Jul 13, 2014 at 12:25:33PM -0700, Randy Dunlap wrote:
> > On 07/13/14 11:42, Sam Ravnborg wrote:
> > > Use one line per module/program in Makefile.
> > > This style is easier to read/extend.
> > > 
> > > Introduce inverse xmas style sorting.
> > 
> > google search couldn't tell me what that means and I cannot
> > deduce it from the new Makefile ordering (if there is some ordering).
> > Please explain.
> 
> Sort by length - with longest entry first. Like an xmas tree upside-down.
> For entries with same lenght sort alphabetically.

If you are going to sort, just sort alphabetically ... this length
based sorting just means you have to search to find anything ... It
looks pretty, but that is about all.
diff mbox

Patch

diff --git a/samples/Makefile b/samples/Makefile
index 1a60c62..7c08028 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -1,4 +1,15 @@ 
 # Makefile for Linux samples code
+# Sort entries using inverse xmas style
+#
+# kernel modules
+obj-$(CONFIG_SAMPLES) += hw_breakpoint/
+obj-$(CONFIG_SAMPLES) += trace_events/
+obj-$(CONFIG_SAMPLES) += kprobes/
+obj-$(CONFIG_SAMPLES) += kobject/
+obj-$(CONFIG_SAMPLES) += kfifo/
+obj-$(CONFIG_SAMPLES) += rpmsg/
+obj-$(CONFIG_SAMPLES) += kdb/
 
-obj-$(CONFIG_SAMPLES)	+= kobject/ kprobes/ trace_events/ \
-			   hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/
+# user space programs
+obj-$(CONFIG_SAMPLES) += seccomp/
+obj-$(CONFIG_SAMPLES) += hidraw/