[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Target in - help newbe!

From: Ralf Wildenhues
Subject: Re: Target in - help newbe!
Date: Sun, 6 Nov 2005 08:43:44 +0100
User-agent: Mutt/1.5.9i

Hi Michael,

* Michael Schulz wrote on Sat, Nov 05, 2005 at 05:23:30PM CET:
> I'm newbe to autoconf, automake.
> I try to make a target in that compiles the base source code 
> with some extra code and extra libs.
> But a 'make fb' only compiles the base source code.

> fb:
>    @if test "$(LINUX_FRAMEBUFFER)" = "yes"; then \
>        echo -e "\n*** Compile moll with image support via Linux 
> framebuffer! ***\n"; \
>        echo -e "\n/* Define to 1 if you have Linux framebuffer. 
> */\n#define HAVE_LINUX_FB 1" >> $(srcdir)/config.h; \
>        SOURCES="$(SOURCES) $(moll_fb_sources)"; \
>        LIBS="$(LIBS) $(LIBS_IMAGE)"; \
>        $(MAKE) all; \
>    else \
>        echo -e "\nNo support for Linux framebuffer!\n"; \
>    fi

Well, I don't quite understand what you are trying to achieve.

First, I guess there is a typo in your Did you mean
    moll_SOURCES="$(moll_SOURCES) $(moll_fb_SOURCES)"

above?  My following explanations assume you did.

Next thing: setting of environment variables does not override the value
of make macros (variables) by default.  One uses either
  make target FOO=bar

to set $(FOO), or
  FOO=bar make -e target

or, equivalently,
  FOO=bar; export FOO; make -e target

but the latter two cause all other environment variables to influence
the make settings as well!  (Imagine you had SHELL=/bin/csh, which is
not so uncommon, unfortunately; that would be pretty bad.)

Let's go on: Your snippet uses
  echo -e
which is not quite portable; under ksh or ash, it will print "-e", for
example.  For non-ancient hosts, printf is quite portable and easier to

Third, automake needs to know all sources at the time it is run.
Fortunately, you can achieve this by either: defining two different
targets you would like to build, or by using an automake conditional.

Example with automake conditional:  Put

in (in case $LINUX_FRAMEBUFFER is set in there), and
in, put

moll_SOURCES += $(moll_fb_sources)

Be sure to also look at the Automake documentation of conditionals,

The other way (two targets) would be similar to this:

bin_PROGRAMS = moll moll_fb
moll_SOURCES = ...
moll_fb_SOURCES = $(moll_SOURCES) $(moll_fb_sources)

but I don't know whether that's applicable in your case.

Lastly, it's not too good an idea to invoke 'make' from within a
Makefile, unless you have to.  It basically destroys its ability
to know what has already been updated and what hasn't.

I hope this helps you a bit further.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]