Author Topic: cbp2make - makefile generation tool  (Read 139810 times)

Offline ripcordjones

  • Single posting newcomer
  • *
  • Posts: 2
Re: cbp2make - makefile generation tool
« Reply #45 on: April 23, 2011, 12:58:17 am »
Well, the program expects that libraries are named as GNU linker expects them to be, i.e., that a static library has file name "lib<something>.a" and corresponding linking option "-l<something>" without prefix "lib" and extension ".a", where <something> can be name or name plus version or anything else. If you have a library that does not follow this naming scheme, cbp2make may fail (and it actually does).

I can try to fix this by adding some logic to check if a library follows active naming scheme and change linking options accordingly.
Another solution is to rename that library file in the way that matches linker expectations or create a well-named symbolic link to the library inside your project tree or somewhere else withing linking path.


Thanks for the reply.  Just to clarify, the library is actually called libtcl8.4.a, but it's stored in the .cbp without the lib and .a, so the line in the .cbp looks like this
    <Add library="tcl8.4" />
but this gets put in the Makefile without the "-l"
    LIB = [... a bunch of libraries ...] -lrt -lz tcl8.4 -ldl

I can try some workarounds, but I thought you might want to know about it in case there are other libraries that use a similar naming scheme.

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbp2make - makefile generation tool
« Reply #46 on: April 23, 2011, 02:21:15 am »
Thanks for the reply.  Just to clarify, the library is actually called libtcl8.4.a, but it's stored in the .cbp without the lib and .a, so the line in the .cbp looks like this
    <Add library="tcl8.4" />
but this gets put in the Makefile without the "-l"
    LIB = [... a bunch of libraries ...] -lrt -lz tcl8.4 -ldl
A linkage command should contain either "libtcl8.4.a" or "-ltcl8.4", but not simply "tcl8.4", generated command is wrong.
I know why: cbp2make was looking for any extension (not just valid ".a") to tell which one of ways to instruct linker is the right one.
Look forward to next revision, this bug is already fixed.

I can try some workarounds, but I thought you might want to know about it in case there are other libraries that use a similar naming scheme.
Yes, thank you. I do need real-world examples of projects to be capable to manage different conditions.

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbp2make - makefile generation tool
« Reply #47 on: April 27, 2011, 11:20:05 am »
Update: (see rev.99) This is a major preliminary update prior to switching to multiple toolchain architecture.

  • Rewrote plaform-specific command generation logic to template-based. Platform-specific commands can be generated in a more flexible way now, probably as it should have been done in the first place. You can find default settings in automatically created cbp2make.cfg configuration file.
  • Rewrote dependency search for C/C++ source/header files. Extracting dependencies is much faster now, and also you can get some additional info like project statistics on unit usage when running cbp2make with "--verbose" option [prepare a big screen or redirect output to a text file].
  • Switched makefile generation code to rule-based version. Makefiles became nicer and look more clean, project unit dependencies are also converted into makefile rules now.
  • Changed format of configuration file to more human-readable form. Old configuration files are partially incompatible, but cbp2make will rewrite new sections with defaults, so just check if everything works fine.
  • Prepared infrastructure for multiple toolchains (to be completed soon). You can find an example of configuration in cbp2make.cfg. This feature it yet incomplete, and hence will not be activated until (probably) next release, so it is just like a technology preview :) . Toolchain management is planned to be CB-like, but more detailed up to individual tools.
  • And the last but not least, cbp2make finally got a (imo) funny simple logo.


Well... test it, use it, feel free to report any problems or suggestions. Download link: http://sourceforge.net/projects/cbp2make/files/

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbp2make - makefile generation tool
« Reply #48 on: May 07, 2011, 09:51:32 pm »
Update: (see rev.100) bugfix release

  • Added global (per-project) pre-build and post-build steps. When global pre/post build steps are in use, makefile rules are rewritten in slightly different way to allow CB-like behavior (whatever is being built, pre/post build commands are executed only once) when make tool is invoked for either a single virtual target or a single real target ("make all", "make debug", "make release"). However, this won't work completely as intended if make tool is invoked for any multiple targets ("make debug release").
  • Changed makefile rules naming for build targets. A build target output file name (makefile macro), if any, is no longer used as makefile target name to resolve ambiguity between multiple build targets sharing the same output file name.


Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5209
Re: cbp2make - makefile generation tool
« Reply #49 on: May 09, 2011, 09:37:44 pm »
a remark with respect to casing :

I have a cbp project, with the following targets : Debug and Release

However in the created make file, all is talking about 'debug' and 'release'. I would expect the same casing is used :

Eg :
Code: [Select]
debug: before_debug out_debug after_debug

would become  (and all other likewise occurrences ) :

Code: [Select]
Debug: before_Debug out_Debug after_Debug

What do you think ?

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbp2make - makefile generation tool
« Reply #50 on: May 09, 2011, 10:11:20 pm »
I have a cbp project, with the following targets : Debug and Release
I would expect the same casing is used :
Code: [Select]
Debug: before_Debug out_Debug after_DebugWhat do you think ?
Generally speaking, I have nothing serious to oppose this idea.
Current naming scheme for both macro variables and targets was designed with two things in mind:
1) remove characters unwanted in makefile;
2) bring up some style to make makefile look nice and readable;
and 3) [just came up with this now] when everything is in low case, you don't have to switch case when typing "make <something>" ;) [this is merely a joke]

How do you think, would a kind of "--keep-target-case" option be a solution?

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5209
Re: cbp2make - makefile generation tool
« Reply #51 on: May 09, 2011, 11:12:57 pm »
sounds ok for me. I personally would have expected this the default behavior.
But then again, I can live with your suggestion ;-)

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbp2make - makefile generation tool
« Reply #52 on: May 10, 2011, 10:55:42 am »
sounds ok for me. I personally would have expected this the default behavior.
But then again, I can live with your suggestion ;-)
Considering the default and a non-default behavior, I have another idea. I'm thinking of putting a thing like "<default_options>bla bla bla</default_options>" into cbp2make.cfg and adding "--def-options "bla bla bla"" option to command line configuration. This way if you want options "--wrap-objects --with-deps --keep-target-case" (for example) to be default options, you have to run cbp2make once with "--def-options "--wrap-objects --with-deps --keep-target-case"" option among others. Those additional options are intended to be immediately attached to other options after reading cbp2make.cfg configuration file, but before doing anything else.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5209
Re: cbp2make - makefile generation tool
« Reply #53 on: May 10, 2011, 01:03:03 pm »
this can work too, but a command line option is always nice, so no copying of config files is needed to wherever you need within to over systems.

Let me explain  : why I expected it to be default behavior. If I decide in my cbp project to call, the target "Debug", then that was my choice. Then I would prefer that no-one is changing it to lowercase, even when it creates new stuff derived from my cbp file.
Say my output directory is Debug, then that one is case preserving, but the name is not when it is translated into a makefile target. Seems a bit inconsistent.

But as said, I can live with your other solutions.
« Last Edit: May 10, 2011, 02:26:38 pm by killerbot »

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbp2make - makefile generation tool
« Reply #54 on: May 10, 2011, 01:47:25 pm »
Let me explain  : why I expected it to be default behavior. ...
Good point, I agree.

But as said, I can live with your other solutions.
I would prefer the default solution to fit user needs better, not just that people could live with my other solutions.

How about that: add an option "--target-case" or "--target-style" with valid values "keep", "lower"/"lowercase", "upper"/"uppercase" and the default value "keep"?
Same solution may be applied to macro variables too...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5209
Re: cbp2make - makefile generation tool
« Reply #55 on: May 10, 2011, 02:27:25 pm »
sounds good : target-case

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12195
    • Travis build status
Re: cbp2make - makefile generation tool
« Reply #56 on: May 10, 2011, 03:08:50 pm »
I'm not a user of cbp2make, but I guess less options is better.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbp2make - makefile generation tool
« Reply #57 on: May 12, 2011, 12:46:37 am »
Update: (see rev.101)

I implemented both of ideas discussed above, you may try them now.

  • Default options can be stored in configuration file. Use "cbp2make --config options --default-options "<your_options>"" command to pass some of frequently used options to configuration, they will be applied every time you run cbp2make with this configuration, so the actual command line can be shortened.
  • Implemented optional build target name casing. Use "--target-case <case>" option to select one of possible casings "keep", "lower" or "upper", default value is "keep".
     

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbp2make - makefile generation tool
« Reply #58 on: June 20, 2011, 07:48:50 pm »
Update: (see rev.107) an intermediate release

The next [stable] release is not ready yet, but there were few important changes and I thought it would be nice to indicate that the project is alive.

  • Fixed small ugly bug which made makefiles for individual projects and workspace projects completely different.
  • Partially rewrote makefile generation for multiple toolchain architecture. Commands for build tools are generated with CB-compatible command templates. It mostly works fine with a couple of exceptions: 1) option switches for includes and defines "/I" "/D" in Windows won't work - they can be configured, but not taken into account (hardcoded "-I" "-D" are still in use); 2) linker requirements for paths, prefixes and extensions of libraries are also managed by old code;
  • Updated tool chain and build tools configuration interface.


While some features are yet incomplete, I hope nothing is seriously broken.
 
Quote
Usage syntax:

        Generate makefile:
                cbp2make -in <project_file> [-cfg <configuration>] [-out <makefile>]
                         [-unix] [-windows] [-mac] [--all-os] [--flat-objects] [--flat-objpath]
                         [--wrap-objects] [--wrap-options] [--target-case keep|lower|upper]
                cbp2make -list -in <project_file_list> [-cfg <configuration>]
                         [-unix] [-windows] [-mac] [--all-os] [--flat-objects] [--flat-objpath]
                         [--wrap-objects] [--wrap-options] [--with-deps] [--target-case <case>]

        Manage toolchains:
                cbp2make --config toolchain --add [-unix|-windows|-mac] -chain <toolchain>
                cbp2make --config toolchain --remove [-unix|-windows|-mac] -chain <toolchain>

        Manage build tools:
                cbp2make --config tool --add [-unix|-windows|-mac] -chain <toolchain>
                         -tool <tool> -type <type> <tool options>
                cbp2make --config tool --remove [-unix|-windows|-mac] -chain <toolchain>
                         -tool <tool>

        Tool types:      pp=preprocessor as=assembler cc=compiler rc=resource compiler
                         sl=static linker dl=dynamic linker el=executable linker
                         nl=native linker
        Tool options (common):
                         -desc <description> -program <executable> -command <command_template>
                         -mkv <make_variable> -srcext <source_extensions> -outext <output_extension>
                         -quotepath <yes|no> -fullpath <yes|no> -unixpath <yes|no>
        Tool options (compiler):
                         -incsw <include_switch> -defsw <define_sqitch> -deps <yes|no>
        Tool options (linker):
                         -ldsw <library_dir_switch> -llsw <link_library_switch> -lpfx <library_prefix>
                         -lext <library_extension> -objext <object_extension> -lflat <yes|no>

        Manage platforms:
                cbp2make --config platform [-unix|-windows|-mac] [-pwd <print_dir_command>]
                         [-cd <change_dir_command>] [-rm <remove_file_command>]
                         [-rmf <remove_file_forced>] [-rmd <remove_dir_command>]
                         [-cp <copy_file_command>] [-mv <move_file_command>]
                         [-md <make_dir_command>] [-mdf <make_dir_forced>]
                         [-make <default_make_tool>]

        Manage global compiler variables:
                cbp2make --config variable --add [-set <set_name>] -name <var_name>
                         [-desc <description>] [-field <field_name>] -value <var_value>
                cbp2make --config variable --remove [-set <set_name>] [-name <var_name>]
                         [-field <field_name>]

        Manage options:
                cbp2make --config options --default-options "<options>"
                cbp2make --config show

        Common options:
                cbp2make --local        // use configuration from current directory
                cbp2make --global       // use configuration from home directory
                cbp2make --verbose      // show project information
                cbp2make --quiet        // hide all messages
                cbp2make --help         // display this message
                cbp2make --version      // display version information

Offline pacrook

  • Single posting newcomer
  • *
  • Posts: 3
Re: cbp2make - makefile generation tool
« Reply #59 on: July 15, 2011, 09:45:34 pm »
Tried out rev.107 on a relatively simple project. Works well - thanks for very useful tool.

One small gotcha, if I use a command like `pkg-config --libs someLib` for linking I have to put it (in Codeblocks) under Linker settings; Other linker options.  Then in the generated Makefile it appears under the parameter LDFLAGS (i.e. LDFLAGS = `pkg-config --libs someLib`) which results in a call to g++ along the lines of:

g++  `pkg-config --libs someLib`   somethingA.o   somethingB.o   -o  sometthingExec

This fails due to the linker not finding the pkg-config libraries associated with someLib.

If I manually change the Makefile such that the linking pkg-config command appears instead under LIB (i.e. LIB = `pkg-config --libs someLib`).  Then the resulting g++ linking call is:

g++   somethingA.o   somethingB.o  `pkg-config --libs someLib`  -o  sometthingExec

which works fine.

Not sure if this is something that could easily be fixed?  You could look out for special cases starting with `pkg-config --libs?

Thanks again for a useful tool.