Menu

#349 Modernize build system and C++ code

Undefined
applied
AutoTools (3)
Patch
2016-12-17
2016-05-07
No

Dear Code::Blocks maintainers,
I have put together a comprehensive patch for modernizing Code::Blocks. The changes I have done to SVN trunk:

  • moved all .m4 files into the m4/ directory.
  • Check if CFLAGS/CXXFLAGS/CPPFLAGS/LDFLAGS are to be set. If the user provides none of these, then the build system sets its preferred defaults. On the other hand, if one of these variables is defined and set, the buildsystem will not set its defaults. This is especially important for distributions, which use their own set of flags.
  • zlib is now detected via pkg-config and not using AC_SEARCH_LIBS, which is more cumbersome and less reliable than PKG_CHECK_MODULES.
  • Instead of the hack to detect boost, the AX_BOOST_BASE macro from the autoconf archive is now used.
  • Shuffling around some arguments in the Makefile.am's that do not belong in the CXXFLAGS (which is a user flag anyway) but rather in the AM_CPPFLAGS.
  • Replacing all occurrences of std::auto_ptr with std::unique_ptr. std::unique_ptr is much safer and future-proof, whereas std::auto_ptr is deprecated and could be removed in future C++ standards.

Please apply the patch as a whole, as the {C,CXX,CPP,LD}FLAGS detection code in acinclude.m4 required some edits, hence this file is not just a pure move.

1 Attachments

Related

Tickets: #349

Discussion

  • Teodor Petrov

    Teodor Petrov - 2016-05-07

    Some notes:

    1. not a good idea to mix different kinds of changes - build system and unique_ptr stuff in this case
    2. there are changes to files that don't belong to the project - python pluigns and wxcrafter
    3. why add empty virtual function?

    I'm testing the patch and probably will apply it.

     
  • Teodor Petrov

    Teodor Petrov - 2016-05-07
    • assigned_to: Teodor Petrov
    • Type: Undefined --> Patch
     
  • David Seifert

    David Seifert - 2016-05-08

    if you want I can strip the two apart. When I did an SVN checkout, I edited everything that was there, which included the plugins. The empty virtual function wasn't added, it was just moved from private to public because the virtual dtor is needed for std::unique_ptr's deleter.

     
  • Teodor Petrov

    Teodor Petrov - 2016-05-08

    No need, I've already done this.

     
  • Teodor Petrov

    Teodor Petrov - 2016-05-12

    I'll apply all other changes, but this one is questionable.

    In your version you omit the -DCB_AUTOTOOLS flag. If you do this some bad things will happen.

    My patch (see attachment) tries to fix the problem but it fails, because I don't speak auto-fu. If you do please fix it and upload the correct version, thanks.

     
  • Teodor Petrov

    Teodor Petrov - 2016-05-12
    • labels: --> AutoTools
     
  • David Seifert

    David Seifert - 2016-05-12

    Teodor, it actually looks correct. I've amended it a bit (because "-Dfoo" flags should go into CPPFLAGS and not C{,XX}FLAGS). What hasn't worked? The patch might need some offsets to apply, as I don't have access to your tree. With this patch, -DCB_AUTOTOOLS is added either how.

     

    Last edit: David Seifert 2016-05-12
  • Teodor Petrov

    Teodor Petrov - 2016-05-12

    For some not apparent reason I get these flags appended:

    1. for release: -O2 -ffast-math -g -O2
    2. for debug: -g -g -O2

    It seems that -g -O2 is coming from somewhere and I don't know from where.
    Does this happen for you, too?

     
  • David Seifert

    David Seifert - 2016-05-13

    The main problem comes from all the AC_PROG_CXX etc macros. These do exactly the same thing as the lines I have inserted: they try to detect whether CFLAGS and friends are unset, and if so, they set "-g -O2". The problem is, in the case were we want to set default flags, the setting of the flags happens after the AC_PROG_CXX macro, namely in the CODEBLOCKS_CHECK_DEBUG macro. Moving this macro before the block of AC_PROG_CXX macros fixes the problem.

     
  • Teodor Petrov

    Teodor Petrov - 2016-05-15

    There are lots of "XXX does not appear in AM_CONDITIONAL" warnings that have started to appear with this commit:

    commit 6c8c51619085922fc733cc2996a2d7006d3a19a2
    Author: T Petrov <tpetrov@codeblocks.org>
    Date:   Thu May 12 03:25:54 2016 +0300
    
    
        - autotools: Move m4 files in the m4 folder (ticket 349, thanks David Seifert)
    

    Can you post a patch that fixes this problem?

     

    Last edit: Teodor Petrov 2016-05-15
    • David Seifert

      David Seifert - 2016-05-15

      Dear Teodor,
      attached the patch. The m4_include() is necessary to call the
      AM_CONDITIONALs. I've shuffled some flags around, as -DPIC belongs into
      CPPFLAGS.

      David

       
  • Teodor Petrov

    Teodor Petrov - 2016-05-18

    Any explanation why the CODEBLOCKS_CHECK_DEBUG is move once again? Is this related to the m4_include or the changes to the other flags, or even a separate issue?

     
    • David Seifert

      David Seifert - 2016-05-20

      CODEBLOCKS_CHECK_DEBUG has to occur before AC_PROG_CC and AC_PROG_CXX,
      as both latter macros will set CFLAGS resp. CXXFLAGS (to "-g -O2"). By
      moving it before both of them, we set the CFLAGS to our defaults and
      then AC_PROG_CC and AC_PROG_CXX stop setting and values.

      On Mi, 2016-05-18 at 08:02 +0000, Teodor Petrov wrote:

      Any explanation why the CODEBLOCKS_CHECK_DEBUG is move once again? Is
      this related to the m4_include or the changes to the other flags, or
      even a separate issue?
      [tickets:#349] Modernize build system and C++ code
      Status: open
      Milestone: Undefined
      Labels: AutoTools 
      Created: Sat May 07, 2016 09:18 PM UTC by David Seifert
      Last Updated: Sun May 15, 2016 12:33 PM UTC
      Owner: Teodor Petrov
      Attachments:
      modernize.patch (109.9 kB; text/x-patch)
      Dear Code::Blocks maintainers,
      I have put together a comprehensive patch for modernizing
      Code::Blocks. The changes I have done to SVN trunk:
      moved all .m4 files into the m4/ directory.
      Check if CFLAGS/CXXFLAGS/CPPFLAGS/LDFLAGS are to be set. If the user
      provides none of these, then the build system sets its preferred
      defaults. On the other hand, if one of these variables is defined and
      set, the buildsystem will not set its defaults. This is especially
      important for distributions, which use their own set of flags.
      zlib is now detected via pkg-config and not using AC_SEARCH_LIBS,
      which is more cumbersome and less reliable than PKG_CHECK_MODULES.
      Instead of the hack to detect boost, the AX_BOOST_BASE macro from the
      autoconf archive is now used.
      Shuffling around some arguments in the Makefile.am's that do not
      belong in the CXXFLAGS (which is a user flag anyway) but rather in
      the AM_CPPFLAGS.
      Replacing all occurrences of std::auto_ptr with std::unique_ptr.
      std::unique_ptr is much safer and future-proof, whereas std::auto_ptr
      is deprecated and could be removed in future C++ standards.
      Please apply the patch as a whole, as the {C,CXX,CPP,LD}FLAGS
      detection code in acinclude.m4 required some edits, hence this file
      is not just a pure move.
      Sent from sourceforge.net because you indicated interest in https://s
      ourceforge.net/p/codeblocks/tickets/349/
      To unsubscribe from further messages, please visit https://sourceforg
      e.net/auth/subscriptions/

       

      Related

      Tickets: #349

  • Teodor Petrov

    Teodor Petrov - 2016-05-24
       CFLAGS:     -g  -fPIC -std=c90
       CXXFLAGS:   -Wno-unused-local-typedefs -g  -Winvalid-pch -fPIC -fexceptions
       CPPFLAGS:   -DCB_AUTOCONF -DDEBUG  -DCB_PRECOMP -DPIC -DTIXML_USE_STL
       LDFLAGS:    -Wl,--no-undefined
       CXX:        g++ -std=c++11
       CC:         gcc
    

    I see a discrepancy here: -std=c90 is set in CFLAGS and -std=c++11 is set in the CXX. Could we fix this? I'm not sure which option I like more though.

     
  • Teodor Petrov

    Teodor Petrov - 2016-12-17
    • status: open --> applied
     
  • Teodor Petrov

    Teodor Petrov - 2016-12-17

    Applied in rev 10945, thanks for the contribution.

     

Log in to post a comment.