Help on Makefile

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

 



Hi,

I am having a Makfile file that build one of module in debug mode ie with debug symbols.
Attached the make file


the directiory strcuture is

ModuleBaseDir - All CPP FIles
ModuleBaseDir/depends - all the dependency info files come here.
ModuleBaseDir/Debug - all the object and library here.

Now i do gmake to build

I want to alter - such way that it builds both debug and release
doing gmake debug / gmake release.

Wht all i can do in the enclosed Makefile -

CC = g++
CC_COMPILE = -c
CC_DEBUG = -g

include ../makeopts.mk

CPPFLAGS += -I$(DIR_INCDIR)

# this module's objects
CPPFILES = \
A.cpp \
B.cpp \
C.cpp

OBJS = $(CPPFILES:%.cpp=Debug/%.o)

# default compile command to be used
CURRENT_DEFAULT_COMPILE = $(CC) $(CC_COMPILE) $(CC_DEBUG) $(CPPFLAGS) $<

MAKEDEPEND = $(CC) $(CC_COMPILE) $(CC_DEBUG) $(CPPFLAGS) -M -o depends/$(*F).d $<

DEPDIR = depends
df = $(DEPDIR)/$(*F)

# Final binary to be produced by this build
FINAL = Debug/libA.a

# default target
all : $(FINAL)
	@echo "+----------------------------------------------------+"
	@echo "|                                                    |"
	@echo "| Module [A] : Compiled successfully  |"
	@echo "|                                                    |"
	@echo "+----------------------------------------------------+"

$(FINAL) : $(OBJS)
	ar cr $@ $(OBJS)

$(DEPDIR)/%.P : %.cpp
@ set -e; \
$(MAKEDEPEND); \
cp $(df).d $(df).P; \
sed 's/\(.*\)\.o[ :]*/Debug\/\1.o $(DEPDIR)\/\1.P : /' < $(df).d > $(df).P; \
rm -f $(df).d


Debug/%.o : %.cpp
	$(CURRENT_DEFAULT_COMPILE) -o $@

include $(CPPFILES:%.cpp=$(DEPDIR)/%.P)


.PHONY: clean

clean:
	rm -f Debug/*.a;
	rm -f Debug/*.o;
	rm -f depends/*.P;

# DO NOT DELETE


Many Thanks

_________________________________________________________________
Get head-hunted by 10,500 recruiters. http://www.naukri.com/msn/index.php?source=hottag Post your CV on naukri.com today.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux