GNU Build Utilities

Chris F.A. Johnson c.f.a.johnson-bJEeYj9oJeDQT0dZR+AlfA at public.gmane.org
Sat Oct 2 01:26:25 UTC 2004


On Fri, 1 Oct 2004, John Wildberger wrote:

> On Friday 01 October 2004 04:24 pm, Peter L. Peres wrote:
>> On Thu, 30 Sep 2004, John Wildberger wrote:
>>> I would like to use the GNU build utiities automake and autoconfig to
>>> generate an executable file from a simple c program.
>
>>> John
>>
>> Automake/autoconfig tutorials do not fit in an email but did you look at
>> 'info automake' -> Examples -> Hello ?
>>
>> Peter
> Well, I have to admit it, I approached this problem with a very simplistic
> attitude. My c program is only a few lines long and contains only the bare
> minimum to print Hello World.
> Following your advice I got hold of the Example "hello-1.3.tar.gz"  .
> I untared it, then used configure, make and then make install.
> Lo and behold I got an executable file called 'hello' that printed happily
> 'Hello, World!
> Examining all the produced files I was in for some surprises.
> The source c file is 263 lines long,
> There are 35 files in the source tree.
> The configure file is 554 lines long
> The Makefile is only 124 lines long.
> Most of the other files are a mystery in their makeup and usage.
> Enough said, I will stick with simple cc compiler and let the wizards worry
> about the GNU build system.

    Better would be to learn about make. When you write programs that
    have multiple source files, or source files that are used in more
    than one executable, your life will be much easier.

    For example, if you have the files hello.c, what.c and love.c in the
    same directory, just put these lines in Makefile:

all: hello what love
hello: hello.o
what: what.o
love: love.o

    Now, just typing "make" will compile all three.

    Typing "make love" will create a "love" executable.

    If "love" needs some other files, besides love.c change that line:

love: love.o money.o

    Makefiles can get a lot more complicated, but even a simple one can
    save a lot of work.

-- 
 	Chris F.A. Johnson                      http://cfaj.freeshell.org
 	=================================================================
                 Everything in moderation -- including moderation
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list