fun with make

I’m trying to write a new generation of makefile that sort of writes itself.
I’ve had a lot of luck except for implicit targets that aren’t in the
current directory. My example makefile is listed at the end of this post.

It assumes that abc.c & xyz.c are source files.
It assumes that header.h is a header file.
It assumes that lib is a library file.

Basically what I want to accomplish is:

  1. if a .c or the header files changes I want to recompile the source
    file(s)
  2. if a .o is missing or is newer than the executable or the lib file is
    newer than the executable I want to relink the executable.
  3. BTW, if lib is missing it is OK to just say don’t know how to make lib.
    It is outside the scope of this makefile

This is pretty vanilla stuff, no?

For th purpose of testing the make file I’ve changed compiles and links to
‘cp -t’.

As long as all targets are in the current directory the make works as
expected. But if I define the TMP make variable to be '/tmp/ (just delete
the ‘#’ pound sign on line 3) then then it will compile if necessary but not
link.

To try this make file just create the files as follows:
touch abc.c xyz.c header.h lib
it doesn’t matter what’s in them.

Here is the makefile. If someone can tell me how to get it to put the
targets in the $(TMP) directory I would appreciate it.

NOTE: Make sure that all leading white space is a tab character. I think my
news reader is substituting spaces.


…SUFFIXES:

TMP = /tmp/

HEADERS would normally be a list of header files

#HEADERS = $(wildcard *.h)
HEADERS = header.h

LIST would normally be a list of source files

#LIST = $(wildcard *.c *.cc *.cpp *.C)
LIST = abc xyz
OBJS = $(foreach x, $(LIST), $(TMP)$(x).o)
XLIST = $(foreach x, $(LIST), $(TMP)$(x))

…PRECIOUS: $(OBJS)

\

the primary goal

…PHONY: all
all: $(XLIST) $(OBJS)

\

I want my .o to be remade if any header files change

$(OBJS): $(HEADERS)

$(TMP)%.o: %.c
@echo COMPILING
cp -t $(notdir $(basename $@)).c $@

I want my executable to remade if my library is remade

$(XLIST) : lib

$(TMP)% : %.o
@echo LINKING
cp -t $(notdir $@).o $@


…PHONY: clean
clean:
rm $(OBJS) $(XLIST)

“Bill Caroselli (Q-TPS)” <QTPS@EarthLink.net> wrote in message
news:aetl7p$ol3$1@inn.qnx.com

$(TMP)% : %.o

$(TMP)%:$(TMP)%.o should do it.

By the way may have a look at makedepend to
take care of headers file dependencies

@echo LINKING
cp -t $(notdir $@).o $@


.PHONY: clean
clean:
rm $(OBJS) $(XLIST)

Gee I keep hoping that someone knows this stuff off the top of their heads
but that never seems to be the case.

Well, having spent way too much time on it I figured it out. It required
using a construct that I hadn’t previously used in a makefile called a
Static Pattern Rule.

For anyone who actually cares I’m reposting my makefile, not the simplified
one but the real one that actually works. You can see why I say it writes
itself.

The important thing for me is that it can be located anywhere in pathname
space. It assumes that:

  1. …/… is a parent directory for the whole project
  2. …/…/inc is an include directory for the whole project
  3. …/…/bin is a bin directory for the project

Normally the project parent directory is the root directory but I can copy
the whole project to under my home directory and no path names need to be
changed.

(Don’t forget to convert leading spaces to tab characters)


…SUFFIXES:

these macros may be redefined on the make command line

#DEBUG = -g2d
DEBUG = -Oinertx
MODEL = f
OBJ = /tmp/obj/$(MODEL)/
SHELL = /tmp/bin/ksh

these are all indended to be self defining macros

PWD = $(shell /usr/bin/fullpath -t .)
PRODUCT_PATH = $(shell /usr/bin/fullpath -t …/…)
BIN = $(PRODUCT_PATH)/bin/
INCLUDE_DIRS = $(PRODUCT_PATH)/inc
I_INCLUDE_DIRS = $(foreach DIR, $(INCLUDE_DIRS), -I$(DIR))
HEADER_FILES = $(foreach DIR, $(INCLUDE_DIRS) ., $(wildcard $(DIR)/.h
$(DIR)/
.hpp) )
SOURCE_FILES = $(wildcard *.c *.cc *.cpp *.C)
PROGS = $(foreach FILE, $(SOURCE_FILES), $(basename $(FILE) ) )
OBJS = $(foreach FILE, $(SOURCE_FILES), $(OBJ)$(basename $(FILE)).o )
MAPS = $(foreach X, $(PROGS), $(BIN)$(X).map )
XPROGS = $(foreach X, $(PROGS), $(BIN)$(X) )
LIBS = $(OBJ)myLib.lib
L_LIBS = $(foreach X, $(LIBS), -l$(X))

CFLAGS = -Q -5 $(I_INCLUDE_DIRS) -m$(MODEL)
$(DEBUG) -w4 -WC,-we -WC,-xs -WC,-fo=$(OBJ)${@F}
#CFLAGS = -P



$(I_INCLUDE_DIRS) -m$(MODEL) -w4 -WC,-we -WC,-xs -WC,-fo=$(OBJ)${@F
}
LDFLAGS = -Wl,“op map=$@.map” $(L_LIBS) -L/tmp/lib


…PRECIOUS: $(OBJS)

the primary goal

…PHONY: all
all: $(XPROGS) $(OBJS)


$(OBJS) : $(OBJ)%.o : %.cpp $(HEADER_FILES) Makefile
@echo “\033<Compiling $(DEBUG) $<\033>”
@$(CC) $(CFLAGS) $(DEBUG) -c $<

$(XPROGS) : $(BIN)% : $(OBJ)%.o $(LIBS)
@echo “Linking $@”
@$(CC) -Q -m$(MODEL) $(LDFLAGS) $(DEBUG) -o$@ $(OBJ)${@F}.o
@usemsg -c $@ ${@F}.c??

\

phony targets

…PHONY: clean
clean:
@echo Removing .o’s and .lib for $(PWD) modules only
@rm -f *.err $(OBJS) $(MAPS) $(XPROGS)

…PHONY: uncond
uncond: clean all

…PHONY: testMake
testMake:
@echo SHELL=$(SHELL) Command line=$(MAKE) $(MAKEFLAGS)
MAKELEVEL=$(MAKELEVEL)
@echo CC=$(CC) CFLAGS=$(CFLAGS) CCFLAGS=$(CCFLAGS) CPPFLAGS=$(CPPFLAGS)
CXXFLAGS=$(CXXFLAGS) CPP=$(CPP) CXX=$(CXXFLAGS)
@echo LD=$(LD) LDFLAGS=$(LDFLAGS)
@echo SUFFIXES=$(SUFFIXES)
@echo PRODUCT_PATH=$(PRODUCT_PATH) INCLUDE_DIRS=$(INCLUDE_DIRS)
@echo HEADER_FILES=$(HEADER_FILES)
@echo SOURCE_FILES=$(SOURCE_FILES)
@echo BIN=$(BIN) OBJ=$(OBJ) LIBS=$(LIBS) OBJS=$(OBJS)
@echo PROGS=$(PROGS)
@echo MAPS=$(MAPS)
@echo XPROGS=$(XPROGS)


“Bill Caroselli (Q-TPS)” <QTPS@EarthLink.net> wrote in message
news:aetl7p$ol3$1@inn.qnx.com

I’m trying to write a new generation of makefile that sort of writes
itself.
I’ve had a lot of luck except for implicit targets that aren’t in the
current directory. My example makefile is listed at the end of this post.

It assumes that abc.c & xyz.c are source files.
It assumes that header.h is a header file.
It assumes that lib is a library file.

Basically what I want to accomplish is:

  1. if a .c or the header files changes I want to recompile the source
    file(s)
  2. if a .o is missing or is newer than the executable or the lib file is
    newer than the executable I want to relink the executable.
  3. BTW, if lib is missing it is OK to just say don’t know how to make lib.
    It is outside the scope of this makefile

This is pretty vanilla stuff, no?

For th purpose of testing the make file I’ve changed compiles and links to
‘cp -t’.

As long as all targets are in the current directory the make works as
expected. But if I define the TMP make variable to be '/tmp/ (just delete
the ‘#’ pound sign on line 3) then then it will compile if necessary but
not
link.

To try this make file just create the files as follows:
touch abc.c xyz.c header.h lib
it doesn’t matter what’s in them.

Here is the makefile. If someone can tell me how to get it to put the
targets in the $(TMP) directory I would appreciate it.

NOTE: Make sure that all leading white space is a tab character. I think
my
news reader is substituting spaces.


.SUFFIXES:

TMP = /tmp/

HEADERS would normally be a list of header files

#HEADERS = $(wildcard *.h)
HEADERS = header.h

LIST would normally be a list of source files

#LIST = $(wildcard *.c *.cc *.cpp *.C)
LIST = abc xyz
OBJS = $(foreach x, $(LIST), $(TMP)$(x).o)
XLIST = $(foreach x, $(LIST), $(TMP)$(x))

.PRECIOUS: $(OBJS)

\

the primary goal

.PHONY: all
all: $(XLIST) $(OBJS)

\

I want my .o to be remade if any header files change

$(OBJS): $(HEADERS)

$(TMP)%.o: %.c
@echo COMPILING
cp -t $(notdir $(basename $@)).c $@

I want my executable to remade if my library is remade

$(XLIST) : lib

$(TMP)% : %.o
@echo LINKING
cp -t $(notdir $@).o $@


.PHONY: clean
clean:
rm $(OBJS) $(XLIST)

“Bill Caroselli (Q-TPS)” <QTPS@EarthLink.net> wrote in message
news:aeu26m$438$1@inn.qnx.com

Gee I keep hoping that someone knows this stuff off the top of their heads
but that never seems to be the case.

You missed my other post by a few minutes :wink:

Well, having spent way too much time on it I figured it out. It required
using a construct that I hadn’t previously used in a makefile called a
Static Pattern Rule.

For anyone who actually cares I’m reposting my makefile, not the
simplified
one but the real one that actually works. You can see why I say it writes
itself.

The important thing for me is that it can be located anywhere in pathname
space. It assumes that:

  1. …/… is a parent directory for the whole project
  2. …/…/inc is an include directory for the whole project
  3. …/…/bin is a bin directory for the project

Normally the project parent directory is the root directory but I can copy
the whole project to under my home directory and no path names need to be
changed.

(Don’t forget to convert leading spaces to tab characters)


.SUFFIXES:

these macros may be redefined on the make command line

#DEBUG = -g2d
DEBUG = -Oinertx
MODEL = f
OBJ = /tmp/obj/$(MODEL)/
SHELL = /tmp/bin/ksh

these are all indended to be self defining macros

PWD = $(shell /usr/bin/fullpath -t .)
PRODUCT_PATH = $(shell /usr/bin/fullpath -t …/…)
BIN = $(PRODUCT_PATH)/bin/
INCLUDE_DIRS = $(PRODUCT_PATH)/inc
I_INCLUDE_DIRS = $(foreach DIR, $(INCLUDE_DIRS), -I$(DIR))
HEADER_FILES = $(foreach DIR, $(INCLUDE_DIRS) ., $(wildcard $(DIR)/.h
$(DIR)/
.hpp) )
SOURCE_FILES = $(wildcard *.c *.cc *.cpp *.C)
PROGS = $(foreach FILE, $(SOURCE_FILES), $(basename $(FILE) ) )
OBJS = $(foreach FILE, $(SOURCE_FILES), $(OBJ)$(basename $(FILE)).o )
MAPS = $(foreach X, $(PROGS), $(BIN)$(X).map )
XPROGS = $(foreach X, $(PROGS), $(BIN)$(X) )
LIBS = $(OBJ)myLib.lib
L_LIBS = $(foreach X, $(LIBS), -l$(X))

CFLAGS = -Q -5 $(I_INCLUDE_DIRS) -m$(MODEL)
$(DEBUG) -w4 -WC,-we -WC,-xs -WC,-fo=$(OBJ)${@F}
#CFLAGS = -P




$(I_INCLUDE_DIRS) -m$(MODEL) -w4 -WC,-we -WC,-xs -WC,-fo=$(OBJ)${@F
}
LDFLAGS = -Wl,“op map=$@.map” $(L_LIBS) -L/tmp/lib


.PRECIOUS: $(OBJS)

the primary goal

.PHONY: all
all: $(XPROGS) $(OBJS)


$(OBJS) : $(OBJ)%.o : %.cpp $(HEADER_FILES) Makefile
@echo “\033<Compiling $(DEBUG) $<\033>”
@$(CC) $(CFLAGS) $(DEBUG) -c $

$(XPROGS) : $(BIN)% : $(OBJ)%.o $(LIBS)
@echo “Linking $@”
@$(CC) -Q -m$(MODEL) $(LDFLAGS) $(DEBUG) -o$@ $(OBJ)${@F}.o
@usemsg -c $@ ${@F}.c??

\

phony targets

.PHONY: clean
clean:
@echo Removing .o’s and .lib for $(PWD) modules only
@rm -f *.err $(OBJS) $(MAPS) $(XPROGS)

.PHONY: uncond
uncond: clean all

.PHONY: testMake
testMake:
@echo SHELL=$(SHELL) Command line=$(MAKE) $(MAKEFLAGS)
MAKELEVEL=$(MAKELEVEL)
@echo CC=$(CC) CFLAGS=$(CFLAGS) CCFLAGS=$(CCFLAGS) CPPFLAGS=$(CPPFLAGS)
CXXFLAGS=$(CXXFLAGS) CPP=$(CPP) CXX=$(CXXFLAGS)
@echo LD=$(LD) LDFLAGS=$(LDFLAGS)
@echo SUFFIXES=$(SUFFIXES)
@echo PRODUCT_PATH=$(PRODUCT_PATH) INCLUDE_DIRS=$(INCLUDE_DIRS)
@echo HEADER_FILES=$(HEADER_FILES)
@echo SOURCE_FILES=$(SOURCE_FILES)
@echo BIN=$(BIN) OBJ=$(OBJ) LIBS=$(LIBS) OBJS=$(OBJS)
@echo PROGS=$(PROGS)
@echo MAPS=$(MAPS)
@echo XPROGS=$(XPROGS)


“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in message
news:aetl7p$ol3$> 1@inn.qnx.com> …
I’m trying to write a new generation of makefile that sort of writes
itself.
I’ve had a lot of luck except for implicit targets that aren’t in the
current directory. My example makefile is listed at the end of this
post.

It assumes that abc.c & xyz.c are source files.
It assumes that header.h is a header file.
It assumes that lib is a library file.

Basically what I want to accomplish is:

  1. if a .c or the header files changes I want to recompile the source
    file(s)
  2. if a .o is missing or is newer than the executable or the lib file is
    newer than the executable I want to relink the executable.
  3. BTW, if lib is missing it is OK to just say don’t know how to make
    lib.
    It is outside the scope of this makefile

This is pretty vanilla stuff, no?

For th purpose of testing the make file I’ve changed compiles and links
to
‘cp -t’.

As long as all targets are in the current directory the make works as
expected. But if I define the TMP make variable to be '/tmp/ (just
delete
the ‘#’ pound sign on line 3) then then it will compile if necessary but
not
link.

To try this make file just create the files as follows:
touch abc.c xyz.c header.h lib
it doesn’t matter what’s in them.

Here is the makefile. If someone can tell me how to get it to put the
targets in the $(TMP) directory I would appreciate it.

NOTE: Make sure that all leading white space is a tab character. I
think
my
news reader is substituting spaces.


.SUFFIXES:

TMP = /tmp/

HEADERS would normally be a list of header files

#HEADERS = $(wildcard *.h)
HEADERS = header.h

LIST would normally be a list of source files

#LIST = $(wildcard *.c *.cc *.cpp *.C)
LIST = abc xyz
OBJS = $(foreach x, $(LIST), $(TMP)$(x).o)
XLIST = $(foreach x, $(LIST), $(TMP)$(x))

.PRECIOUS: $(OBJS)

\

the primary goal

.PHONY: all
all: $(XLIST) $(OBJS)

\

I want my .o to be remade if any header files change

$(OBJS): $(HEADERS)

$(TMP)%.o: %.c
@echo COMPILING
cp -t $(notdir $(basename $@)).c $@

I want my executable to remade if my library is remade

$(XLIST) : lib

$(TMP)% : %.o
@echo LINKING
cp -t $(notdir $@).o $@


.PHONY: clean
clean:
rm $(OBJS) $(XLIST)

\

“Bill Caroselli (Q-TPS)” <QTPS@EarthLink.net> wrote in message
news:aeu26m$438$1@inn.qnx.com

Gee I keep hoping that someone knows this stuff off the top of their heads
but that never seems to be the case.

Well, having spent way too much time on it I figured it out. It required
using a construct that I hadn’t previously used in a makefile called a
Static Pattern Rule.

For anyone who actually cares I’m reposting my makefile, not the
simplified
one but the real one that actually works. You can see why I say it writes
itself.

The important thing for me is that it can be located anywhere in pathname
space. It assumes that:

  1. …/… is a parent directory for the whole project
  2. …/…/inc is an include directory for the whole project
  3. …/…/bin is a bin directory for the project

I beleive you can speed up that makefile by doing
SOURCE_FILES := $(wildcard *.c *.cc *.cpp *.C)
instead of
SOURCE_FILES = $(wildcard *.c *.cc *.cpp *.C)

With the = SOURCE_FILES is revaluated (resulting in directory scan)
everytime it is used, but with := it’s only done once.

What I also like to do is have the makefiles of a project include a
“root file” that contains all the compiler option. That way if for
example I want to change CPU type for example (-3r, -4r, -5r)
I don’t have to go into every makefile in the project.

Normally the project parent directory is the root directory but I can copy
the whole project to under my home directory and no path names need to be
changed.

(Don’t forget to convert leading spaces to tab characters)


.SUFFIXES:

these macros may be redefined on the make command line

#DEBUG = -g2d
DEBUG = -Oinertx
MODEL = f
OBJ = /tmp/obj/$(MODEL)/
SHELL = /tmp/bin/ksh

these are all indended to be self defining macros

PWD = $(shell /usr/bin/fullpath -t .)
PRODUCT_PATH = $(shell /usr/bin/fullpath -t …/…)
BIN = $(PRODUCT_PATH)/bin/
INCLUDE_DIRS = $(PRODUCT_PATH)/inc
I_INCLUDE_DIRS = $(foreach DIR, $(INCLUDE_DIRS), -I$(DIR))
HEADER_FILES = $(foreach DIR, $(INCLUDE_DIRS) ., $(wildcard $(DIR)/.h
$(DIR)/
.hpp) )
SOURCE_FILES = $(wildcard *.c *.cc *.cpp *.C)
PROGS = $(foreach FILE, $(SOURCE_FILES), $(basename $(FILE) ) )
OBJS = $(foreach FILE, $(SOURCE_FILES), $(OBJ)$(basename $(FILE)).o )
MAPS = $(foreach X, $(PROGS), $(BIN)$(X).map )
XPROGS = $(foreach X, $(PROGS), $(BIN)$(X) )
LIBS = $(OBJ)myLib.lib
L_LIBS = $(foreach X, $(LIBS), -l$(X))

CFLAGS = -Q -5 $(I_INCLUDE_DIRS) -m$(MODEL)
$(DEBUG) -w4 -WC,-we -WC,-xs -WC,-fo=$(OBJ)${@F}
#CFLAGS = -P




$(I_INCLUDE_DIRS) -m$(MODEL) -w4 -WC,-we -WC,-xs -WC,-fo=$(OBJ)${@F
}
LDFLAGS = -Wl,“op map=$@.map” $(L_LIBS) -L/tmp/lib


.PRECIOUS: $(OBJS)

the primary goal

.PHONY: all
all: $(XPROGS) $(OBJS)


$(OBJS) : $(OBJ)%.o : %.cpp $(HEADER_FILES) Makefile
@echo “\033<Compiling $(DEBUG) $<\033>”
@$(CC) $(CFLAGS) $(DEBUG) -c $

$(XPROGS) : $(BIN)% : $(OBJ)%.o $(LIBS)
@echo “Linking $@”
@$(CC) -Q -m$(MODEL) $(LDFLAGS) $(DEBUG) -o$@ $(OBJ)${@F}.o
@usemsg -c $@ ${@F}.c??

\

phony targets

.PHONY: clean
clean:
@echo Removing .o’s and .lib for $(PWD) modules only
@rm -f *.err $(OBJS) $(MAPS) $(XPROGS)

.PHONY: uncond
uncond: clean all

.PHONY: testMake
testMake:
@echo SHELL=$(SHELL) Command line=$(MAKE) $(MAKEFLAGS)
MAKELEVEL=$(MAKELEVEL)
@echo CC=$(CC) CFLAGS=$(CFLAGS) CCFLAGS=$(CCFLAGS) CPPFLAGS=$(CPPFLAGS)
CXXFLAGS=$(CXXFLAGS) CPP=$(CPP) CXX=$(CXXFLAGS)
@echo LD=$(LD) LDFLAGS=$(LDFLAGS)
@echo SUFFIXES=$(SUFFIXES)
@echo PRODUCT_PATH=$(PRODUCT_PATH) INCLUDE_DIRS=$(INCLUDE_DIRS)
@echo HEADER_FILES=$(HEADER_FILES)
@echo SOURCE_FILES=$(SOURCE_FILES)
@echo BIN=$(BIN) OBJ=$(OBJ) LIBS=$(LIBS) OBJS=$(OBJS)
@echo PROGS=$(PROGS)
@echo MAPS=$(MAPS)
@echo XPROGS=$(XPROGS)


“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in message
news:aetl7p$ol3$> 1@inn.qnx.com> …
I’m trying to write a new generation of makefile that sort of writes
itself.
I’ve had a lot of luck except for implicit targets that aren’t in the
current directory. My example makefile is listed at the end of this
post.

It assumes that abc.c & xyz.c are source files.
It assumes that header.h is a header file.
It assumes that lib is a library file.

Basically what I want to accomplish is:

  1. if a .c or the header files changes I want to recompile the source
    file(s)
  2. if a .o is missing or is newer than the executable or the lib file is
    newer than the executable I want to relink the executable.
  3. BTW, if lib is missing it is OK to just say don’t know how to make
    lib.
    It is outside the scope of this makefile

This is pretty vanilla stuff, no?

For th purpose of testing the make file I’ve changed compiles and links
to
‘cp -t’.

As long as all targets are in the current directory the make works as
expected. But if I define the TMP make variable to be '/tmp/ (just
delete
the ‘#’ pound sign on line 3) then then it will compile if necessary but
not
link.

To try this make file just create the files as follows:
touch abc.c xyz.c header.h lib
it doesn’t matter what’s in them.

Here is the makefile. If someone can tell me how to get it to put the
targets in the $(TMP) directory I would appreciate it.

NOTE: Make sure that all leading white space is a tab character. I
think
my
news reader is substituting spaces.


.SUFFIXES:

TMP = /tmp/

HEADERS would normally be a list of header files

#HEADERS = $(wildcard *.h)
HEADERS = header.h

LIST would normally be a list of source files

#LIST = $(wildcard *.c *.cc *.cpp *.C)
LIST = abc xyz
OBJS = $(foreach x, $(LIST), $(TMP)$(x).o)
XLIST = $(foreach x, $(LIST), $(TMP)$(x))

.PRECIOUS: $(OBJS)

\

the primary goal

.PHONY: all
all: $(XLIST) $(OBJS)

\

I want my .o to be remade if any header files change

$(OBJS): $(HEADERS)

$(TMP)%.o: %.c
@echo COMPILING
cp -t $(notdir $(basename $@)).c $@

I want my executable to remade if my library is remade

$(XLIST) : lib

$(TMP)% : %.o
@echo LINKING
cp -t $(notdir $@).o $@


.PHONY: clean
clean:
rm $(OBJS) $(XLIST)

\

What I also like to do is have the makefiles of a project include a
“root file” that contains all the compiler option. That way if for
example I want to change CPU type for example (-3r, -4r, -5r)
I don’t have to go into every makefile in the project.

That’s exactly what I’m hoping to do for my next-generation set of
Makefiles (which I’ll get to next month, theoretically). Would you mind
posting how you’ve done it? Thanks.

Josh Hamacher
FAAC Incorporated

“Josh Hamacher” <hamacher@NOSPAM.faac.com> wrote in message
news:3D1335DA.8030303@NOSPAM.faac.com

What I also like to do is have the makefiles of a project include a
“root file” that contains all the compiler option. That way if for
example I want to change CPU type for example (-3r, -4r, -5r)
I don’t have to go into every makefile in the project.


That’s exactly what I’m hoping to do for my next-generation set of
Makefiles (which I’ll get to next month, theoretically). Would you mind
posting how you’ve done it? Thanks.

Root makefile contains things like
CCFLAG=-3r etc…

All other makefile file do

include makefile.common

In fact I try to put everything in the root makefile file, default rules etc
and
as little as possible in each project makefile.



Josh Hamacher
FAAC Incorporated

“Mario Charest” postmaster@l127.0.0.1 wrote in message
news:aev0p4$pev$1@inn.qnx.com

I beleive you can speed up that makefile by doing
SOURCE_FILES := $(wildcard *.c *.cc *.cpp *.C)
instead of
SOURCE_FILES = $(wildcard *.c *.cc *.cpp *.C)

With the = SOURCE_FILES is revaluated (resulting in directory scan)
everytime it is used, but with := it’s only done once.

Thank you. That works nicely as some of these directories have many source
files in them.


What I also like to do is have the makefiles of a project include a
“root file” that contains all the compiler option. That way if for
example I want to change CPU type for example (-3r, -4r, -5r)
I don’t have to go into every makefile in the project.

I have done that in many make files but more and more I find that I’m only
working with x86/QNX 4/flat model.

You might want to look at a PhAB application set of makefiles.
There is one makefile under the /src/ directory and one makefile under each
platform directory.

“Josh Hamacher” <hamacher@NOSPAM.faac.com> wrote in message
news:3D1335DA.8030303@NOSPAM.faac.com

What I also like to do is have the makefiles of a project include a
“root file” that contains all the compiler option. That way if for
example I want to change CPU type for example (-3r, -4r, -5r)
I don’t have to go into every makefile in the project.


That’s exactly what I’m hoping to do for my next-generation set of
Makefiles (which I’ll get to next month, theoretically). Would you mind
posting how you’ve done it? Thanks.

Josh Hamacher
FAAC Incorporated