Menu

#284 Made cartconv and petcat tools buildable by themselves.

v3.x
closed-fixed
compyx
None
bugfix
2021-04-03
2021-03-10
Greg King
No

The

make cartconv
make petcat

build commands won't work if "svnversion.h" doesn't exist already.

  • Added the makefile prerequisite rules that build that header when it's needed.
  • Fixed recipes that looked for a Makefile in the source tree instead of the build tree.
1 Attachments

Discussion

  • compyx

    compyx - 2021-03-10

    I thought I had that working, but it looks like it wouldn't work out-of-tree. Good catch on the LD_FLAGS vs LDFLAGS, not that that matters in this specific case (yet).

    I wonder if:

    (cd ../..; $(MAKE) svnversion.h)
    

    Wouldn't be written better like:

    (cd $(top_builddir)/src; ($MAKE) svnversion.h)
    
     
  • Greg King

    Greg King - 2021-03-10

    In the other makefiles, the cd commands use simple relative paths. They don't use make variables. cd ../..; is consistent with those other makefiles.

     
  • Greg King

    Greg King - 2021-03-10

    By the way, those tool Makefiles didn't work in-tree, either. (Note that make clean doesn't remove an old "svnversion.h". Therefore, your tests probably never had a truely "virgin" build environment.)

     
  • compyx

    compyx - 2021-03-10

    You're right about the relative paths, so I'll keep that.

    But the fact that make clean doesn't remove an old svnversion.h shouldn't matter I think, there should be a rule to remake svnversion.h whenever its dependencies change.
    Let me check out a fresh copy and check that assumption, for my own sanity.

     
  • compyx

    compyx - 2021-03-10

    Well, the patch makes standalone builds of petcat and cartconv work, either in-tree or out-of-tree. But svnversion.h gets generated in trunk/vice/src/, not in any builddir, which feels wrong.

     
  • compyx

    compyx - 2021-03-10

    Thanks for the patch, I've applied it in r39852.

    Now I need to work on creating svnversion.h inside $(top_builddir)src/, not $(top_srcdir)/src, since I feel any generated file should end up in the builddir, not the sourcedir.

     

    Last edit: compyx 2021-03-10
  • Greg King

    Greg King - 2021-03-10

    This is what I get:

    Wed Mar 10, 04:26 AM; (error 0) /usr/local/src/svn-vice-build
    $ make petcat
    make[1]: Entering directory '/usr/local/src/svn-vice-build/src/tools/petcat'
     cd ../../../../svn-vice && automake-1.16 --foreign src/tools/petcat/Makefile
     cd ../../.. && /bin/sh ./config.status src/tools/petcat/Makefile depfiles
    config.status: creating src/tools/petcat/Makefile
    config.status: executing depfiles commands
    (cd ../..; make svnversion.h)
    make[2]: Entering directory '/usr/local/src/svn-vice-build/src'
    generating svnversion.h
    make[2]: Leaving directory '/usr/local/src/svn-vice-build/src'
    gcc -DHAVE_CONFIG_H -I. -I../../../../svn-vice/src/tools/petcat -I../../../src  -I../../../../svn-vice/src/systemheaderoverride -DNDEBUG -mwindows -I../../../../svn-vice/src -I../../../src -I../../../../svn-vice/src/arch/shared   -Ofast -march=native -MT petcat.o -MD -MP -MF .deps/petcat.Tpo -c -o petcat.o ../../../../svn-vice/src/tools/petcat/petcat.c
    mv -f .deps/petcat.Tpo .deps/petcat.Po
    gcc  -Ofast -march=native -mconsole  -o petcat.exe petcat.o
    make[1]: Leaving directory '/usr/local/src/svn-vice-build/src/tools/petcat'
    Wed Mar 10, 04:26 AM; (error 0) /usr/local/src/svn-vice-build
    $
    

    "svn-vice" is the source tree.
    "svn-vice-build" is the build tree.
    "svnversion.h" is created in "svn-vice-build/src/"!

     
  • compyx

    compyx - 2021-03-10

    I have:

    ~/vice-trunk/vice -- sourcedir
    ~/vice-trunk/gtk3-build -- builddir

    I run ./autogen.sh in vice/ and then cd into ../gtk3-build and run ./configure
    (Running make distclean inside vice/ doesn't work, so that's clean)
    I run rm vice/src/svnversion.h

    compyx@debian:~/vice-trunk$ find . -name 'svnversion.h'
    compyx@debian:~/vice-trunk$
    

    No svnversion.h.

    cd ../gtk3-build
    make clean
    compyx@debian:~/vice-trunk/gtk3-build$ make petcat
    generating svnversion.h
    

    svnversion.h gets generated, but where?

    compyx@debian:~/vice-trunk/gtk3-build$ cd ..
    compyx@debian:~/vice-trunk$ find . -name 'svnversion.h'
    ./vice/src/svnversion.h
    

    So, where do we get the message?

    grep -n 'generating svnversion.h' `find . -name '*.sh'`
    ./vice/src/buildtools/gensvnversion.sh:51:echo "generating svnversion.h"
    

    That script takes $2 as the target path.
    So we grep for the call to the script:

    compyx@debian:~/vice-trunk/vice$ grep -n 'gensvnversion' `find . -name Makefile.am`
    ./src/buildtools/Makefile.am:6: gensvnversion.sh \
    ./src/Makefile.am:613:  @$(SHELL) $(srcdir)/buildtools/gensvnversion.sh $(SVNVERSION) $(top_srcdir) $(srcdir)/svnversion.h
    

    And there we go: $(srcdir)/svnversion.h, which appears to work differently on my box than yours?

     
  • Greg King

    Greg King - 2021-03-10

    You're right! I apologize; my patch was incomplete. I forgot about a fix that I did a long time ago:

    Index: src/Makefile.am
    ===================================================================
    --- vice/src/Makefile.am    (revision 39852)
    +++ vice/src/Makefile.am    (working copy)
    @@ -610,7 +610,7 @@ BUILT_SOURCES = $(EMBEDDED_H_FILES) $(SVN_VERSION_
     .PHONY: svnversion.h.indirect
    
     svnversion.h.indirect:
    
    -   @$(SHELL) $(srcdir)/buildtools/gensvnversion.sh $(SVNVERSION) $(top_srcdir) $(srcdir)/svnversion.h
    +   @$(SHELL) $(srcdir)/buildtools/gensvnversion.sh $(SVNVERSION) $(top_srcdir) svnversion.h
    
     svnversion.h: svnversion.h.indirect
    
     
  • Greg King

    Greg King - 2021-03-11

    I disagree with revision 39853. Two rules are used to build the header. The first rule should name the header in the same way that the second rule names it. There is no path in

    svnversion.h: svnversion.h.indirect
    

    That is the way that it should be; it's a local file (in the current directory).

    Therefore, there should be no path at the end of the first rule's recipe.

     
  • compyx

    compyx - 2021-03-11

    You are correct. Changed in r39854.

    Thanks for spotting that.

     
  • compyx

    compyx - 2021-03-21
    • status: open --> pending-fixed
    • assigned_to: compyx
     
  • compyx

    compyx - 2021-03-21

    As far as I can tell, this now works correctly. So I suggest we close this.

     
  • compyx

    compyx - 2021-04-03
    • status: pending-fixed --> closed-fixed
     
  • compyx

    compyx - 2021-04-03

    No response. Closing.

     

Log in to post a comment.

MongoDB Logo MongoDB