diff mbox series

Revert "kbuild: merge scripts/mkmakefile to top Makefile"

Message ID 20210526173855.5963-1-msuchanek@suse.de (mailing list archive)
State New, archived
Headers show
Series Revert "kbuild: merge scripts/mkmakefile to top Makefile" | expand

Commit Message

Michal Suchanek May 26, 2021, 5:38 p.m. UTC
This reverts commit 243b50c141d71fcf7b88e94474b3b9269f0b1f9d.

When packaging the kernel it is built in different place from the one in
which it will be installed. After build the makefile needs to be
regenerated with the target location but with mkmakefile merged into
Makefile tehre is no way to do that.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 Makefile           | 15 +++------------
 scripts/mkmakefile | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 12 deletions(-)
 create mode 100755 scripts/mkmakefile

Comments

Masahiro Yamada May 26, 2021, 6:56 p.m. UTC | #1
On Thu, May 27, 2021 at 2:39 AM Michal Suchanek <msuchanek@suse.de> wrote:
>
> This reverts commit 243b50c141d71fcf7b88e94474b3b9269f0b1f9d.
>
> When packaging the kernel it is built in different place from the one in
> which it will be installed. After build the makefile needs to be
> regenerated with the target location but with mkmakefile merged into
> Makefile tehre is no way to do that.
>
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>

My patch was not working as expected
regardless of packaging.

Does the following fix-up work for you?


diff --git a/Makefile b/Makefile
index 54bb019a7da3..504327207d66 100644
--- a/Makefile
+++ b/Makefile
@@ -552,16 +552,13 @@ ifdef building_out_of_srctree
 # At the same time when output Makefile generated, generate .gitignore to
 # ignore whole output directory

-quiet_cmd_makefile = GEN     $@
+quiet_cmd_makefile = GEN     Makefile
       cmd_makefile = { \
        echo "\# Automatically generated by $(srctree)/Makefile: don't edit"; \
        echo "include $(srctree)/Makefile"; \
-       } > $@
+       } > Makefile

-Makefile: FORCE
-       $(call cmd,makefile)
-
-outputmakefile: Makefile
+outputmakefile:
        $(Q)if [ -f $(srctree)/.config -o \
                 -d $(srctree)/include/config -o \
                 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
@@ -572,6 +569,7 @@ outputmakefile: Makefile
                false; \
        fi
        $(Q)ln -fsn $(srctree) source
+       $(call cmd,makefile)
        $(Q)test -e .gitignore || \
        { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
 endif















> ---
>  Makefile           | 15 +++------------
>  scripts/mkmakefile | 17 +++++++++++++++++
>  2 files changed, 20 insertions(+), 12 deletions(-)
>  create mode 100755 scripts/mkmakefile
>
> diff --git a/Makefile b/Makefile
> index 58b086b30144..462899c1b5d7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -573,24 +573,14 @@ scripts_basic:
>         $(Q)rm -f .tmp_quiet_recordmcount
>
>  PHONY += outputmakefile
> -ifdef building_out_of_srctree
>  # Before starting out-of-tree build, make sure the source tree is clean.
>  # outputmakefile generates a Makefile in the output directory, if using a
>  # separate output directory. This allows convenient use of make in the
>  # output directory.
>  # At the same time when output Makefile generated, generate .gitignore to
>  # ignore whole output directory
> -
> -quiet_cmd_makefile = GEN     $@
> -      cmd_makefile = { \
> -       echo "\# Automatically generated by $(srctree)/Makefile: don't edit"; \
> -       echo "include $(srctree)/Makefile"; \
> -       } > $@
> -
> -Makefile: FORCE
> -       $(call cmd,makefile)
> -
> -outputmakefile: Makefile
> +outputmakefile:
> +ifdef building_out_of_srctree
>         $(Q)if [ -f $(srctree)/.config -o \
>                  -d $(srctree)/include/config -o \
>                  -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
> @@ -601,6 +591,7 @@ outputmakefile: Makefile
>                 false; \
>         fi
>         $(Q)ln -fsn $(srctree) source
> +       $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
>         $(Q)test -e .gitignore || \
>         { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
>  endif
> diff --git a/scripts/mkmakefile b/scripts/mkmakefile
> new file mode 100755
> index 000000000000..1cb174751429
> --- /dev/null
> +++ b/scripts/mkmakefile
> @@ -0,0 +1,17 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# Generates a small Makefile used in the root of the output
> +# directory, to allow make to be started from there.
> +# The Makefile also allow for more convinient build of external modules
> +
> +# Usage
> +# $1 - Kernel src directory
> +
> +if [ "${quiet}" != "silent_" ]; then
> +       echo "  GEN     Makefile"
> +fi
> +
> +cat << EOF > Makefile
> +# Automatically generated by $0: don't edit
> +include $1/Makefile
> +EOF
> --
> 2.26.2
>
Michal Suchanek May 26, 2021, 8:28 p.m. UTC | #2
On Thu, May 27, 2021 at 03:56:41AM +0900, Masahiro Yamada wrote:
> On Thu, May 27, 2021 at 2:39 AM Michal Suchanek <msuchanek@suse.de> wrote:
> >
> > This reverts commit 243b50c141d71fcf7b88e94474b3b9269f0b1f9d.
> >
> > When packaging the kernel it is built in different place from the one in
> > which it will be installed. After build the makefile needs to be
> > regenerated with the target location but with mkmakefile merged into
> > Makefile tehre is no way to do that.
> >
> > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> 
> My patch was not working as expected
> regardless of packaging.
> 
> Does the following fix-up work for you?

For the packaging I need some way to regenerate the Makefile and fake
the directory where the Makefile will be on the user system (ie DESTDIR)

Without the mkmakefile I do not see any way to do it.

If the kernel makefile is no longer location dependent there is no need
any more, of course.

Thanks

Michal
> 
> 
> diff --git a/Makefile b/Makefile
> index 54bb019a7da3..504327207d66 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -552,16 +552,13 @@ ifdef building_out_of_srctree
>  # At the same time when output Makefile generated, generate .gitignore to
>  # ignore whole output directory
> 
> -quiet_cmd_makefile = GEN     $@
> +quiet_cmd_makefile = GEN     Makefile
>        cmd_makefile = { \
>         echo "\# Automatically generated by $(srctree)/Makefile: don't edit"; \
>         echo "include $(srctree)/Makefile"; \
> -       } > $@
> +       } > Makefile
> 
> -Makefile: FORCE
> -       $(call cmd,makefile)
> -
> -outputmakefile: Makefile
> +outputmakefile:
>         $(Q)if [ -f $(srctree)/.config -o \
>                  -d $(srctree)/include/config -o \
>                  -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
> @@ -572,6 +569,7 @@ outputmakefile: Makefile
>                 false; \
>         fi
>         $(Q)ln -fsn $(srctree) source
> +       $(call cmd,makefile)
>         $(Q)test -e .gitignore || \
>         { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
>  endif
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> > ---
> >  Makefile           | 15 +++------------
> >  scripts/mkmakefile | 17 +++++++++++++++++
> >  2 files changed, 20 insertions(+), 12 deletions(-)
> >  create mode 100755 scripts/mkmakefile
> >
> > diff --git a/Makefile b/Makefile
> > index 58b086b30144..462899c1b5d7 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -573,24 +573,14 @@ scripts_basic:
> >         $(Q)rm -f .tmp_quiet_recordmcount
> >
> >  PHONY += outputmakefile
> > -ifdef building_out_of_srctree
> >  # Before starting out-of-tree build, make sure the source tree is clean.
> >  # outputmakefile generates a Makefile in the output directory, if using a
> >  # separate output directory. This allows convenient use of make in the
> >  # output directory.
> >  # At the same time when output Makefile generated, generate .gitignore to
> >  # ignore whole output directory
> > -
> > -quiet_cmd_makefile = GEN     $@
> > -      cmd_makefile = { \
> > -       echo "\# Automatically generated by $(srctree)/Makefile: don't edit"; \
> > -       echo "include $(srctree)/Makefile"; \
> > -       } > $@
> > -
> > -Makefile: FORCE
> > -       $(call cmd,makefile)
> > -
> > -outputmakefile: Makefile
> > +outputmakefile:
> > +ifdef building_out_of_srctree
> >         $(Q)if [ -f $(srctree)/.config -o \
> >                  -d $(srctree)/include/config -o \
> >                  -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
> > @@ -601,6 +591,7 @@ outputmakefile: Makefile
> >                 false; \
> >         fi
> >         $(Q)ln -fsn $(srctree) source
> > +       $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
> >         $(Q)test -e .gitignore || \
> >         { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
> >  endif
> > diff --git a/scripts/mkmakefile b/scripts/mkmakefile
> > new file mode 100755
> > index 000000000000..1cb174751429
> > --- /dev/null
> > +++ b/scripts/mkmakefile
> > @@ -0,0 +1,17 @@
> > +#!/bin/sh
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Generates a small Makefile used in the root of the output
> > +# directory, to allow make to be started from there.
> > +# The Makefile also allow for more convinient build of external modules
> > +
> > +# Usage
> > +# $1 - Kernel src directory
> > +
> > +if [ "${quiet}" != "silent_" ]; then
> > +       echo "  GEN     Makefile"
> > +fi
> > +
> > +cat << EOF > Makefile
> > +# Automatically generated by $0: don't edit
> > +include $1/Makefile
> > +EOF
> > --
> > 2.26.2
> >
> 
> 
> -- 
> Best Regards
> Masahiro Yamada
Masahiro Yamada May 28, 2021, 5:15 p.m. UTC | #3
On Thu, May 27, 2021 at 5:28 AM Michal Suchánek <msuchanek@suse.de> wrote:
>
> On Thu, May 27, 2021 at 03:56:41AM +0900, Masahiro Yamada wrote:
> > On Thu, May 27, 2021 at 2:39 AM Michal Suchanek <msuchanek@suse.de> wrote:
> > >
> > > This reverts commit 243b50c141d71fcf7b88e94474b3b9269f0b1f9d.
> > >
> > > When packaging the kernel it is built in different place from the one in
> > > which it will be installed. After build the makefile needs to be
> > > regenerated with the target location but with mkmakefile merged into
> > > Makefile tehre is no way to do that.
> > >
> > > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> >
> > My patch was not working as expected
> > regardless of packaging.
> >
> > Does the following fix-up work for you?
>
> For the packaging I need some way to regenerate the Makefile and fake
> the directory where the Makefile will be on the user system (ie DESTDIR)
>
> Without the mkmakefile I do not see any way to do it.
>
> If the kernel makefile is no longer location dependent there is no need
> any more, of course.
>
> Thanks
>
> Michal

Sorry, I do not understand this.

IIUC, this patch does not change any functionality.
The generated Makefile is still the same.
Why is it a problem?
Michal Suchanek May 29, 2021, 5:35 a.m. UTC | #4
On Sat, May 29, 2021 at 02:15:55AM +0900, Masahiro Yamada wrote:
> On Thu, May 27, 2021 at 5:28 AM Michal Suchánek <msuchanek@suse.de> wrote:
> >
> > On Thu, May 27, 2021 at 03:56:41AM +0900, Masahiro Yamada wrote:
> > > On Thu, May 27, 2021 at 2:39 AM Michal Suchanek <msuchanek@suse.de> wrote:
> > > >
> > > > This reverts commit 243b50c141d71fcf7b88e94474b3b9269f0b1f9d.
> > > >
> > > > When packaging the kernel it is built in different place from the one in
> > > > which it will be installed. After build the makefile needs to be
> > > > regenerated with the target location but with mkmakefile merged into
> > > > Makefile tehre is no way to do that.
> > > >
> > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> > >
> > > My patch was not working as expected
> > > regardless of packaging.
> > >
> > > Does the following fix-up work for you?
> >
> > For the packaging I need some way to regenerate the Makefile and fake
> > the directory where the Makefile will be on the user system (ie DESTDIR)
> >
> > Without the mkmakefile I do not see any way to do it.
> >
> > If the kernel makefile is no longer location dependent there is no need
> > any more, of course.
> >
> > Thanks
> >
> > Michal
> 
> Sorry, I do not understand this.
> 
> IIUC, this patch does not change any functionality.
> The generated Makefile is still the same.
> Why is it a problem?

It cannot be regenerated.

During package build you have four directories

 - the source directory
 - the build directory
 - the staging directory where files are installed to be included in the
   package
 - the target directory where files will be installed on the target
   system once the package is installed by the user

The makefile is generated for the build directory, not the target
directory. What is needed is a way to generate a makefile in the staging
directory that will work when installed in the target directory.
When mkmakefile is folded into makefile the makefile can no longer be
regenerated because it is up-to-date, and it can no longer be specified
that it should be generated for the target directory, not the staging
directory.

Thanks

Michal
Masahiro Yamada June 2, 2021, 9:45 a.m. UTC | #5
On Sat, May 29, 2021 at 2:35 PM Michal Suchánek <msuchanek@suse.de> wrote:
>
> On Sat, May 29, 2021 at 02:15:55AM +0900, Masahiro Yamada wrote:
> > On Thu, May 27, 2021 at 5:28 AM Michal Suchánek <msuchanek@suse.de> wrote:
> > >
> > > On Thu, May 27, 2021 at 03:56:41AM +0900, Masahiro Yamada wrote:
> > > > On Thu, May 27, 2021 at 2:39 AM Michal Suchanek <msuchanek@suse.de> wrote:
> > > > >
> > > > > This reverts commit 243b50c141d71fcf7b88e94474b3b9269f0b1f9d.
> > > > >
> > > > > When packaging the kernel it is built in different place from the one in
> > > > > which it will be installed. After build the makefile needs to be
> > > > > regenerated with the target location but with mkmakefile merged into
> > > > > Makefile tehre is no way to do that.
> > > > >
> > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> > > >
> > > > My patch was not working as expected
> > > > regardless of packaging.
> > > >
> > > > Does the following fix-up work for you?
> > >
> > > For the packaging I need some way to regenerate the Makefile and fake
> > > the directory where the Makefile will be on the user system (ie DESTDIR)
> > >
> > > Without the mkmakefile I do not see any way to do it.
> > >
> > > If the kernel makefile is no longer location dependent there is no need
> > > any more, of course.
> > >
> > > Thanks
> > >
> > > Michal
> >
> > Sorry, I do not understand this.
> >
> > IIUC, this patch does not change any functionality.
> > The generated Makefile is still the same.
> > Why is it a problem?
>
> It cannot be regenerated.

This is an issue regardless of your packaging.
That is why I suggested a patch in my previous reply.

https://lore.kernel.org/linux-kbuild/CAK7LNASEqKwQeLPXedyut+ykSJGPuq3CO1g_fS=sVDaZrwBPBQ@mail.gmail.com/


Anyway, please try next-20210602
and see if you still have a problem.






>
> During package build you have four directories
>
>  - the source directory
>  - the build directory
>  - the staging directory where files are installed to be included in the
>    package
>  - the target directory where files will be installed on the target
>    system once the package is installed by the user
>
> The makefile is generated for the build directory, not the target
> directory. What is needed is a way to generate a makefile in the staging
> directory that will work when installed in the target directory.
> When mkmakefile is folded into makefile the makefile can no longer be
> regenerated because it is up-to-date, and it can no longer be specified
> that it should be generated for the target directory, not the staging
> directory.
>
> Thanks
>
> Michal
Michal Suchanek June 2, 2021, 10:03 a.m. UTC | #6
On Wed, Jun 02, 2021 at 06:45:58PM +0900, Masahiro Yamada wrote:
> On Sat, May 29, 2021 at 2:35 PM Michal Suchánek <msuchanek@suse.de> wrote:
> >
> > On Sat, May 29, 2021 at 02:15:55AM +0900, Masahiro Yamada wrote:
> > > On Thu, May 27, 2021 at 5:28 AM Michal Suchánek <msuchanek@suse.de> wrote:
> > > >
> > > > On Thu, May 27, 2021 at 03:56:41AM +0900, Masahiro Yamada wrote:
> > > > > On Thu, May 27, 2021 at 2:39 AM Michal Suchanek <msuchanek@suse.de> wrote:
> > > > > >
> > > > > > This reverts commit 243b50c141d71fcf7b88e94474b3b9269f0b1f9d.
> > > > > >
> > > > > > When packaging the kernel it is built in different place from the one in
> > > > > > which it will be installed. After build the makefile needs to be
> > > > > > regenerated with the target location but with mkmakefile merged into
> > > > > > Makefile tehre is no way to do that.
> > > > > >
> > > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> > > > >
> > > > > My patch was not working as expected
> > > > > regardless of packaging.
> > > > >
> > > > > Does the following fix-up work for you?
> > > >
> > > > For the packaging I need some way to regenerate the Makefile and fake
> > > > the directory where the Makefile will be on the user system (ie DESTDIR)
> > > >
> > > > Without the mkmakefile I do not see any way to do it.
> > > >
> > > > If the kernel makefile is no longer location dependent there is no need
> > > > any more, of course.
> > > >
> > > > Thanks
> > > >
> > > > Michal
> > >
> > > Sorry, I do not understand this.
> > >
> > > IIUC, this patch does not change any functionality.
> > > The generated Makefile is still the same.
> > > Why is it a problem?
> >
> > It cannot be regenerated.
> 
> This is an issue regardless of your packaging.
> That is why I suggested a patch in my previous reply.
> 
> https://lore.kernel.org/linux-kbuild/CAK7LNASEqKwQeLPXedyut+ykSJGPuq3CO1g_fS=sVDaZrwBPBQ@mail.gmail.com/
> 
> 
> Anyway, please try next-20210602
> and see if you still have a problem.

Yes, I still have a problem.

My packaging script calls mkmakefile which no longer exists.

Regardless of whther the new code works correctly or not in the usual
case it removes the ability to regenearte the makefile for a specific
target location.

Thanks

Michal

> >
> > During package build you have four directories
> >
> >  - the source directory
> >  - the build directory
> >  - the staging directory where files are installed to be included in the
> >    package
> >  - the target directory where files will be installed on the target
> >    system once the package is installed by the user
> >
> > The makefile is generated for the build directory, not the target
> > directory. What is needed is a way to generate a makefile in the staging
> > directory that will work when installed in the target directory.
> > When mkmakefile is folded into makefile the makefile can no longer be
> > regenerated because it is up-to-date, and it can no longer be specified
> > that it should be generated for the target directory, not the staging
> > directory.
> >
> > Thanks
> >
> > Michal
> 
> 
> 
> -- 
> Best Regards
> Masahiro Yamada
Masahiro Yamada June 2, 2021, 3:44 p.m. UTC | #7
On Thu, Jun 3, 2021 at 12:18 AM Michal Suchánek <msuchanek@suse.de> wrote:
>
> On Wed, Jun 02, 2021 at 06:45:58PM +0900, Masahiro Yamada wrote:
> > On Sat, May 29, 2021 at 2:35 PM Michal Suchánek <msuchanek@suse.de> wrote:
> > >
> > > On Sat, May 29, 2021 at 02:15:55AM +0900, Masahiro Yamada wrote:
> > > > On Thu, May 27, 2021 at 5:28 AM Michal Suchánek <msuchanek@suse.de> wrote:
> > > > >
> > > > > On Thu, May 27, 2021 at 03:56:41AM +0900, Masahiro Yamada wrote:
> > > > > > On Thu, May 27, 2021 at 2:39 AM Michal Suchanek <msuchanek@suse.de> wrote:
> > > > > > >
> > > > > > > This reverts commit 243b50c141d71fcf7b88e94474b3b9269f0b1f9d.
> > > > > > >
> > > > > > > When packaging the kernel it is built in different place from the one in
> > > > > > > which it will be installed. After build the makefile needs to be
> > > > > > > regenerated with the target location but with mkmakefile merged into
> > > > > > > Makefile tehre is no way to do that.
> > > > > > >
> > > > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> > > > > >
> > > > > > My patch was not working as expected
> > > > > > regardless of packaging.
> > > > > >
> > > > > > Does the following fix-up work for you?
> > > > >
> > > > > For the packaging I need some way to regenerate the Makefile and fake
> > > > > the directory where the Makefile will be on the user system (ie DESTDIR)
> > > > >
> > > > > Without the mkmakefile I do not see any way to do it.
> > > > >
> > > > > If the kernel makefile is no longer location dependent there is no need
> > > > > any more, of course.
> > > > >
> > > > > Thanks
> > > > >
> > > > > Michal
> > > >
> > > > Sorry, I do not understand this.
> > > >
> > > > IIUC, this patch does not change any functionality.
> > > > The generated Makefile is still the same.
> > > > Why is it a problem?
> > >
> > > It cannot be regenerated.
> >
> > This is an issue regardless of your packaging.
> > That is why I suggested a patch in my previous reply.
> >
> > https://lore.kernel.org/linux-kbuild/CAK7LNASEqKwQeLPXedyut+ykSJGPuq3CO1g_fS=sVDaZrwBPBQ@mail.gmail.com/
> >
> >
> > Anyway, please try next-20210602
> > and see if you still have a problem.
>
> Yes, I still have a problem.
>
> My packaging script calls mkmakefile which no longer exists.


So, we are not talking about the functionality any more.

What is important for you is, you have a separate file.

You overwrite scripts/mkmakefile for doing
whatever hacks you like.

If the code is moved into the Makefile,
it will be more difficult to insert hacks.

This is what I understood from your statement.







>
> Regardless of whther the new code works correctly or not in the usual
> case it removes the ability to regenearte the makefile for a specific
> target location.
>
> Thanks
>
> Michal
>
> > >
> > > During package build you have four directories
> > >
> > >  - the source directory
> > >  - the build directory
> > >  - the staging directory where files are installed to be included in the
> > >    package
> > >  - the target directory where files will be installed on the target
> > >    system once the package is installed by the user
> > >
> > > The makefile is generated for the build directory, not the target
> > > directory. What is needed is a way to generate a makefile in the staging
> > > directory that will work when installed in the target directory.
> > > When mkmakefile is folded into makefile the makefile can no longer be
> > > regenerated because it is up-to-date, and it can no longer be specified
> > > that it should be generated for the target directory, not the staging
> > > directory.
> > >
> > > Thanks
> > >
> > > Michal
> >
> >
> >
> > --
> > Best Regards
> > Masahiro Yamada
Michal Suchanek June 2, 2021, 5:59 p.m. UTC | #8
On Thu, Jun 03, 2021 at 12:44:48AM +0900, Masahiro Yamada wrote:
> On Thu, Jun 3, 2021 at 12:18 AM Michal Suchánek <msuchanek@suse.de> wrote:
> >
> > On Wed, Jun 02, 2021 at 06:45:58PM +0900, Masahiro Yamada wrote:
> > > On Sat, May 29, 2021 at 2:35 PM Michal Suchánek <msuchanek@suse.de> wrote:
> > > >
> > > > On Sat, May 29, 2021 at 02:15:55AM +0900, Masahiro Yamada wrote:
> > > > > On Thu, May 27, 2021 at 5:28 AM Michal Suchánek <msuchanek@suse.de> wrote:
> > > > > >
> > > > > > On Thu, May 27, 2021 at 03:56:41AM +0900, Masahiro Yamada wrote:
> > > > > > > On Thu, May 27, 2021 at 2:39 AM Michal Suchanek <msuchanek@suse.de> wrote:
> > > > > > > >
> > > > > > > > This reverts commit 243b50c141d71fcf7b88e94474b3b9269f0b1f9d.
> > > > > > > >
> > > > > > > > When packaging the kernel it is built in different place from the one in
> > > > > > > > which it will be installed. After build the makefile needs to be
> > > > > > > > regenerated with the target location but with mkmakefile merged into
> > > > > > > > Makefile tehre is no way to do that.
> > > > > > > >
> > > > > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> > > > > > >
> > > > > > > My patch was not working as expected
> > > > > > > regardless of packaging.
> > > > > > >
> > > > > > > Does the following fix-up work for you?
> > > > > >
> > > > > > For the packaging I need some way to regenerate the Makefile and fake
> > > > > > the directory where the Makefile will be on the user system (ie DESTDIR)
> > > > > >
> > > > > > Without the mkmakefile I do not see any way to do it.
> > > > > >
> > > > > > If the kernel makefile is no longer location dependent there is no need
> > > > > > any more, of course.
> > > > > >
> > > > > > Thanks
> > > > > >
> > > > > > Michal
> > > > >
> > > > > Sorry, I do not understand this.
> > > > >
> > > > > IIUC, this patch does not change any functionality.
> > > > > The generated Makefile is still the same.
> > > > > Why is it a problem?
> > > >
> > > > It cannot be regenerated.
> > >
> > > This is an issue regardless of your packaging.
> > > That is why I suggested a patch in my previous reply.
> > >
> > > https://lore.kernel.org/linux-kbuild/CAK7LNASEqKwQeLPXedyut+ykSJGPuq3CO1g_fS=sVDaZrwBPBQ@mail.gmail.com/
> > >
> > >
> > > Anyway, please try next-20210602
> > > and see if you still have a problem.
> >
> > Yes, I still have a problem.
> >
> > My packaging script calls mkmakefile which no longer exists.
> 
> 
> So, we are not talking about the functionality any more.
> 
> What is important for you is, you have a separate file.
> 
> You overwrite scripts/mkmakefile for doing
> whatever hacks you like.
> 
> If the code is moved into the Makefile,
> it will be more difficult to insert hacks.
> 
> This is what I understood from your statement.

I did not insert hacks. I called the script that your patch removes.

That's functionality that is lost.

Now without the script separate from the makefile inserting hacks will
be required.

I would like to avoid that.

Thanks

Michal

> > Regardless of whther the new code works correctly or not in the usual
> > case it removes the ability to regenearte the makefile for a specific
> > target location.
> >
> > Thanks
> >
> > Michal
> >
> > > >
> > > > During package build you have four directories
> > > >
> > > >  - the source directory
> > > >  - the build directory
> > > >  - the staging directory where files are installed to be included in the
> > > >    package
> > > >  - the target directory where files will be installed on the target
> > > >    system once the package is installed by the user
> > > >
> > > > The makefile is generated for the build directory, not the target
> > > > directory. What is needed is a way to generate a makefile in the staging
> > > > directory that will work when installed in the target directory.
> > > > When mkmakefile is folded into makefile the makefile can no longer be
> > > > regenerated because it is up-to-date, and it can no longer be specified
> > > > that it should be generated for the target directory, not the staging
> > > > directory.
> > > >
> > > > Thanks
> > > >
> > > > Michal
> > >
> > >
> > >
> > > --
> > > Best Regards
> > > Masahiro Yamada
> 
> 
> 
> -- 
> Best Regards
> Masahiro Yamada
Masahiro Yamada June 2, 2021, 6:35 p.m. UTC | #9
On Thu, Jun 3, 2021 at 2:59 AM Michal Suchánek <msuchanek@suse.de> wrote:
>
> On Thu, Jun 03, 2021 at 12:44:48AM +0900, Masahiro Yamada wrote:
> > On Thu, Jun 3, 2021 at 12:18 AM Michal Suchánek <msuchanek@suse.de> wrote:
> > >
> > > On Wed, Jun 02, 2021 at 06:45:58PM +0900, Masahiro Yamada wrote:
> > > > On Sat, May 29, 2021 at 2:35 PM Michal Suchánek <msuchanek@suse.de> wrote:
> > > > >
> > > > > On Sat, May 29, 2021 at 02:15:55AM +0900, Masahiro Yamada wrote:
> > > > > > On Thu, May 27, 2021 at 5:28 AM Michal Suchánek <msuchanek@suse.de> wrote:
> > > > > > >
> > > > > > > On Thu, May 27, 2021 at 03:56:41AM +0900, Masahiro Yamada wrote:
> > > > > > > > On Thu, May 27, 2021 at 2:39 AM Michal Suchanek <msuchanek@suse.de> wrote:
> > > > > > > > >
> > > > > > > > > This reverts commit 243b50c141d71fcf7b88e94474b3b9269f0b1f9d.
> > > > > > > > >
> > > > > > > > > When packaging the kernel it is built in different place from the one in
> > > > > > > > > which it will be installed. After build the makefile needs to be
> > > > > > > > > regenerated with the target location but with mkmakefile merged into
> > > > > > > > > Makefile tehre is no way to do that.
> > > > > > > > >
> > > > > > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> > > > > > > >
> > > > > > > > My patch was not working as expected
> > > > > > > > regardless of packaging.
> > > > > > > >
> > > > > > > > Does the following fix-up work for you?
> > > > > > >
> > > > > > > For the packaging I need some way to regenerate the Makefile and fake
> > > > > > > the directory where the Makefile will be on the user system (ie DESTDIR)
> > > > > > >
> > > > > > > Without the mkmakefile I do not see any way to do it.
> > > > > > >
> > > > > > > If the kernel makefile is no longer location dependent there is no need
> > > > > > > any more, of course.
> > > > > > >
> > > > > > > Thanks
> > > > > > >
> > > > > > > Michal
> > > > > >
> > > > > > Sorry, I do not understand this.
> > > > > >
> > > > > > IIUC, this patch does not change any functionality.
> > > > > > The generated Makefile is still the same.
> > > > > > Why is it a problem?
> > > > >
> > > > > It cannot be regenerated.
> > > >
> > > > This is an issue regardless of your packaging.
> > > > That is why I suggested a patch in my previous reply.
> > > >
> > > > https://lore.kernel.org/linux-kbuild/CAK7LNASEqKwQeLPXedyut+ykSJGPuq3CO1g_fS=sVDaZrwBPBQ@mail.gmail.com/
> > > >
> > > >
> > > > Anyway, please try next-20210602
> > > > and see if you still have a problem.
> > >
> > > Yes, I still have a problem.
> > >
> > > My packaging script calls mkmakefile which no longer exists.
> >
> >
> > So, we are not talking about the functionality any more.
> >
> > What is important for you is, you have a separate file.
> >
> > You overwrite scripts/mkmakefile for doing
> > whatever hacks you like.
> >
> > If the code is moved into the Makefile,
> > it will be more difficult to insert hacks.
> >
> > This is what I understood from your statement.
>
> I did not insert hacks. I called the script that your patch removes.


You can copy scripts/mkmakefile
to your packaging project if it is needed.

It is a very short code that generates two lines.

cat << EOF > Makefile
# Automatically generated by $0: don't edit
include $1/Makefile
EOF

You can also copy-paste it to your packaging script.







> That's functionality that is lost.
>
> Now without the script separate from the makefile inserting hacks will
> be required.
>
> I would like to avoid that.
>
> Thanks
>






--
Best Regards
Masahiro Yamada
Michal Suchanek June 17, 2021, 7:57 a.m. UTC | #10
On Thu, Jun 03, 2021 at 03:35:24AM +0900, Masahiro Yamada wrote:
> On Thu, Jun 3, 2021 at 2:59 AM Michal Suchánek <msuchanek@suse.de> wrote:
> >
> > On Thu, Jun 03, 2021 at 12:44:48AM +0900, Masahiro Yamada wrote:
> > > On Thu, Jun 3, 2021 at 12:18 AM Michal Suchánek <msuchanek@suse.de> wrote:
> > > >
> > > > On Wed, Jun 02, 2021 at 06:45:58PM +0900, Masahiro Yamada wrote:
> > > > > On Sat, May 29, 2021 at 2:35 PM Michal Suchánek <msuchanek@suse.de> wrote:
> > > > > >
> > > > > > On Sat, May 29, 2021 at 02:15:55AM +0900, Masahiro Yamada wrote:
> > > > > > > On Thu, May 27, 2021 at 5:28 AM Michal Suchánek <msuchanek@suse.de> wrote:
> > > > > > > >
> > > > > > > > On Thu, May 27, 2021 at 03:56:41AM +0900, Masahiro Yamada wrote:
> > > > > > > > > On Thu, May 27, 2021 at 2:39 AM Michal Suchanek <msuchanek@suse.de> wrote:
> > > > > > > > > >
> > > > > > > > > > This reverts commit 243b50c141d71fcf7b88e94474b3b9269f0b1f9d.
> > > > > > > > > >
> > > > > > > > > > When packaging the kernel it is built in different place from the one in
> > > > > > > > > > which it will be installed. After build the makefile needs to be
> > > > > > > > > > regenerated with the target location but with mkmakefile merged into
> > > > > > > > > > Makefile tehre is no way to do that.
> > > > > > > > > >
> > > > > > > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> > > > > > > > >
> > > > > > > > > My patch was not working as expected
> > > > > > > > > regardless of packaging.
> > > > > > > > >
> > > > > > > > > Does the following fix-up work for you?
> > > > > > > >
> > > > > > > > For the packaging I need some way to regenerate the Makefile and fake
> > > > > > > > the directory where the Makefile will be on the user system (ie DESTDIR)
> > > > > > > >
> > > > > > > > Without the mkmakefile I do not see any way to do it.
> > > > > > > >
> > > > > > > > If the kernel makefile is no longer location dependent there is no need
> > > > > > > > any more, of course.
> > > > > > > >
> > > > > > > > Thanks
> > > > > > > >
> > > > > > > > Michal
> > > > > > >
> > > > > > > Sorry, I do not understand this.
> > > > > > >
> > > > > > > IIUC, this patch does not change any functionality.
> > > > > > > The generated Makefile is still the same.
> > > > > > > Why is it a problem?
> > > > > >
> > > > > > It cannot be regenerated.
> > > > >
> > > > > This is an issue regardless of your packaging.
> > > > > That is why I suggested a patch in my previous reply.
> > > > >
> > > > > https://lore.kernel.org/linux-kbuild/CAK7LNASEqKwQeLPXedyut+ykSJGPuq3CO1g_fS=sVDaZrwBPBQ@mail.gmail.com/
> > > > >
> > > > >
> > > > > Anyway, please try next-20210602
> > > > > and see if you still have a problem.
> > > >
> > > > Yes, I still have a problem.
> > > >
> > > > My packaging script calls mkmakefile which no longer exists.
> > >
> > >
> > > So, we are not talking about the functionality any more.
> > >
> > > What is important for you is, you have a separate file.
> > >
> > > You overwrite scripts/mkmakefile for doing
> > > whatever hacks you like.
> > >
> > > If the code is moved into the Makefile,
> > > it will be more difficult to insert hacks.
> > >
> > > This is what I understood from your statement.
> >
> > I did not insert hacks. I called the script that your patch removes.
> 
> 
> You can copy scripts/mkmakefile
> to your packaging project if it is needed.
> 
> It is a very short code that generates two lines.
> 
> cat << EOF > Makefile
> # Automatically generated by $0: don't edit
> include $1/Makefile
> EOF
> 
> You can also copy-paste it to your packaging script.

Hello

In fact the mkmakefile script dropped support for the second argument
that tells it where to genereate the makefile and thus became unusable
for packaging some time ago already.

With simplification of the makefile to the point it is trivial no script
to regenereate it is necessary. It can be generated with a simple echo
command.

Thanks

Michal
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 58b086b30144..462899c1b5d7 100644
--- a/Makefile
+++ b/Makefile
@@ -573,24 +573,14 @@  scripts_basic:
 	$(Q)rm -f .tmp_quiet_recordmcount
 
 PHONY += outputmakefile
-ifdef building_out_of_srctree
 # Before starting out-of-tree build, make sure the source tree is clean.
 # outputmakefile generates a Makefile in the output directory, if using a
 # separate output directory. This allows convenient use of make in the
 # output directory.
 # At the same time when output Makefile generated, generate .gitignore to
 # ignore whole output directory
-
-quiet_cmd_makefile = GEN     $@
-      cmd_makefile = { \
-	echo "\# Automatically generated by $(srctree)/Makefile: don't edit"; \
-	echo "include $(srctree)/Makefile"; \
-	} > $@
-
-Makefile: FORCE
-	$(call cmd,makefile)
-
-outputmakefile: Makefile
+outputmakefile:
+ifdef building_out_of_srctree
 	$(Q)if [ -f $(srctree)/.config -o \
 		 -d $(srctree)/include/config -o \
 		 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
@@ -601,6 +591,7 @@  outputmakefile: Makefile
 		false; \
 	fi
 	$(Q)ln -fsn $(srctree) source
+	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
 	$(Q)test -e .gitignore || \
 	{ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
 endif
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
new file mode 100755
index 000000000000..1cb174751429
--- /dev/null
+++ b/scripts/mkmakefile
@@ -0,0 +1,17 @@ 
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# Generates a small Makefile used in the root of the output
+# directory, to allow make to be started from there.
+# The Makefile also allow for more convinient build of external modules
+
+# Usage
+# $1 - Kernel src directory
+
+if [ "${quiet}" != "silent_" ]; then
+	echo "  GEN     Makefile"
+fi
+
+cat << EOF > Makefile
+# Automatically generated by $0: don't edit
+include $1/Makefile
+EOF