help-make
[Top][All Lists]
Advanced

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

"source(ing)"


From: Maya
Subject: "source(ing)"
Date: Thu, 22 Jul 2004 09:43:09 -0400

There are a few things I just cannot understand about GNUMake when it comes to 
'sourcing' other Makefile files. 
I must say that I have not reached the level where I can write very advanced 
make files, but I have managed to compile all my programs with the help of 
GNUMake. Thus, the questions I am posting are about some things I have not jet 
tested or checked out, so pleas bear with me.
Now here is my question:
The make file for program that handles all my exceptions is called, of course,  
'exception' and it looks like this:

# Compiler name
CPP=g++

# Flagas
CFLAGS = -Wall -g -ansi

# Variables
OBJS = main.o  exception.o
EXEC = Exception

#Application name
my_app: $(OBJS)
    $(CC) $(LDLIBS) $(OBJS) -o $(EXEC)

main.o: main.C exception.hpp
    $(CC) $(CFLAGS) -c main.C

exception.o: exception.hpp 
    $(CC) $(CFLAGS) -c exception.cpp

clean:
    rm -f $(OBJS)
    rm -f $(EXEC)

PHONY: clean


I also have another program that provides a set of tools to handle character 
strings and it is call strtools, and its Makefile goes like this:
# name Makefile

# Compiler name
CPP=g++

# Libraries to be included
EXCEPTION_H = ../exception/exception.hpp
EXCEPTION_C = ../exception/exception.cpp

# Flagas
CFLAGS= -Wall -g #-ansi

# Variables
OBJS = main.o exception.o strtools.o 
EXEC = strtools.exe

#Application name
my_app: $(OBJS)
    $(CPP) $(LDLIBS) $(OBJS) -o $(EXEC)

main.o: main.C #strtools.hpp
    $(CPP) $(CFLAGS) -c main.C

strtools.o: strtools.hpp #excetion.hpp
    $(CPP) $(CFLAGS) -c strtools.cpp
    
exception.o: $(EXCEPTION_H)
    $(CPP) $(CFLAGS) -c $(EXCEPTION_C)
clean:
    rm -f *.o   # rm -f main.o  # rm -f exception.o
    rm -f $(EXEC)

PHONY: clean


Please note that there are some variable names that not only repeat themselves, 
but that also have different values as is the case of $(CFLAGS); and that there 
are other variables that have different meanings as is the 'target' main.o.

Does this mean that I have to make the variable's name unique in every Makefile 
for each program I have written?

How do you suggest I should write my Makefiles in order to reuse them from 
another program?


TIA

-- 
You experience miracles everyday, the first one today happened when you first 
opened your eyes!
     --- Jorge Escalante


__________________________________________________________________
Switch to Netscape Internet Service.
As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register

Netscape. Just the Net You Need.

New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at http://channels.netscape.com/ns/search/install.jsp




reply via email to

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