Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

specifying source files in nmake

Status
Not open for further replies.

ranadhir

Programmer
Nov 4, 2003
54
IN
I have a very simple question.I speficy the source files for a program in makefile as follows

PROGRAM = sq.exe
all: $(PROGRAM)

########### list of C++ source files
CPPSRCS = \
main.cpp

.......
........
########### build a list of all .obj files
OBJS = $(CPPSRCS:.cpp=.obj) $(CSRCS:.c=.obj)

########### how to link .obj files to create an executable
$(PROGRAM): $(OBJS)
$(link32) -out:$@ $(OBJS) $(LIBS) $(linkflags)

Now in case i have a large number of source files - how can i specify at directory level - viz. all cpp files under directory 'source'?
 
You have to use nmake recursively. This is the Linux equivalent for the child directory. I don't have access to a Windows env at the moment
Code:
#=========#=========#=========#=========#=========#=========#=========
# Macro definitions
GROUP=OB
INCLUDE=-I.
LIB=lib$(GROUP).a
#=========#=========#=========#=========#=========#=========#=========
# Suffix rules
.SUFFIXES :
.SUFFIXES : .cpp .o .h .a .so
.cpp.o:
	g++ -g -c $< $(INCLUDE) -o $@
	ar r $(LIB) $@

#=========#=========#=========#=========#=========#=========#=========
# Default rule
all:
	for srcfile in $(GROUP)*.cpp; \
	do \
	   make -f make$(GROUP) $$(basename $$srcfile .cpp).o ; \
	done;
For the parent directory it is
Code:
all:
        cd RS
	make -f makeRS
        cd ../OB
	make -f makeOB
        cd ../UI
	make -f makeUI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top