Hi,

 

Sorry for long mail.

 

I want to use a single makefile to build multiple applications.
Following is a makefile written for client application:

 

/******* Makefile start *******/

 

# Clear out default suffixes and set our own.

.SUFFIXES:

.SUFFIXES: .o .c

 

# component build flags, used for naming output

debug : COMPFLAGS = D

release : COMPFLAGS =

 

TARGETNAME = c${COMPFLAGS}

 

# output directories

CPOUT = .

 

# CFLAGS

debug : OSCDBGFLAGS = -g

release : OSCDBGFLAGS =

 

OSCC = gcc

# command used to build the target

MAKETARGET = ${OSCC} ${OSCDBGFLAGS} \

        -o ${CPOUT}/${TARGETNAME} \

        ${OBJS}

 

# Fill in the source files for SRCS, OBJS will use macro substitution to

# replace .cpp extensions with a .o extension.

CSRCS         = client.c

 

# Build object names from source names.

COBJS=${CSRCS:%.c=%.o}

OBJS=${COBJS}

 

# targets

.PHONY : all

all : debug release

 

.PHONY : debug

.PHONY : release

debug release :

        OBJS="${OBJS}" \

        TARGETNAME="${TARGETNAME}" MAKETARGET="${MAKETARGET}" \

        MAKECOBJS="${OSCC} -c ${ OSCDBGFLAGS }" \

        $(MAKE) -f Make.mk

        @echo "$@ version built."

 

# cleanup

.PHONY : clean

clean :

        -rm -f ${CPOUT}/${TARGETNAME}

 

/******* Makefile end *******/

 

So 'gmake debug' builds debug versions and 'gmake release' builds
release version.

Now I want to modify above makefile to build server application also.
Only 'CSRC' and 'TARGETNAME 'values are going to change in case of other
applications.

 

I want to achieve following:

gmake client (should build both debug and release for client)

gmake client debug or gmake debug client (should build client debug
versions)

gmake server (should build both debug and release for server)

gmake server debug or gmake debug server (should build server debug
versions)

gmake client server (should build both debug and release for client and
server)

gmake client server debug or gmake debug client server (should build
debug versions for both client and server)

and different combinations...

 

I tried using 'client debug' phony target but then it builds client
twice.

 

How to achieve above?

 

Any help is greatly appreciated.

 

Thanks,

Mehul

 

_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to