help-make
[Top][All Lists]
Advanced

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

(recursive) MAKE with different compilers


From: Peter J Schmitt
Subject: (recursive) MAKE with different compilers
Date: Mon, 9 Aug 2004 11:15:32 -0500 (CDT)

Hi,
I'm having trouble using Make to compile different binaries that use
different compilers.

Here's a quick example:
#######################
CC=gcc
CFLAGS=foo
LIBS=bar

serial: libshared.a serial.o
        ${CC} serial.o shared/libshared.a ${LIBS} ${IOLIBS} -o bin/serial

parallel: libshared.a parallel.o
        ${CC} parallel.o shared/libshared.a ${LIBS} -o bin/parallel 
"CFLAGS=${CFLAGS} -DPARALLEL"

libshared.a:
        cd shared; make shared

...

########
#contents of "shared/Makefile":
########
OBJS=check_err.o parseInFile.o CXXparseInFile.o

.SUFFIXES: .c .C .o

shared: ${OBJS}
        ar rcs libshared.a ${OBJS}

clean:
        rm -f *.o
        rm -f libshared.a
#######
#end contents of "shared/Makefile"
#######
#######################
end example.

So, if I type "make parallel" I want CC=mpicc (message passing
interface c-compiler) for all source files.

If I type "make serial", I want CC=gcc for all source files.

Part of the challenge is that I really want to use the default suffix
rules & I want to keep my Makefiles nice, clean & simple (I'm writing
software that will be used as a set of comprehensive tutorials--I want
it to be legible).

I have been searching for conditional statements with the target, but that
hasn't given me much luck.  The O'Reilly book "Managing Projects with
make" talks about conditional macro definitions for "many varients of
make" even though it's "not part of the standard System V make".  The
syntax looks something like
parallel:=CC=mpicc
serial:=CC=gcc
but I wasn't able to get that working properly on my system.  It wouldn't
change the value of CC from its default.

FYI I'm working on a redhat 7.2 box

Thanks!
Pete





reply via email to

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