You are on page 1of 2

TOP = $(PWD)

SRC_DIR = $(TOP)/src/

###################################################
## ##
## OBJECTS is for source files used in both ##
## the slip and no-slip versions of the code ##
## ##
###################################################

OBJECTS = psg2d.o globals.o fourier.o solvers.o allocate.o input.o


initial_concentration.o

#####################################################
## ##
## SLIP_OBJECTS is for source files used only in ##
## the slip version of the code ##
## ##
#####################################################

SLIP_OBJECTS = ddt_slip.o cfd_slip.o

#######################################################
## ##
## NOSLIP_OBJECTS is for source files used only in ##
## the no-slip version of the code ##
## ##
#######################################################

NOSLIP_OBJECTS = ddt_noslip.o cfd_noslip.o

#######################################################
## ##
## BOUNDARY_FLAG_OBJECTS is for source files used ##
## both the slip and no-slip versions of the code, ##
## but that require a flag to be set specifying ##
## which version of the code they are being ##
## compiled for ##
## ##
#######################################################

BOUNDARY_FLAG_OBJECTS = post_process.o

PROFILE = -pg
FLAGS = -g -lm
SLIP_FLAGS = -D SLIP
NOSLIP_FLAGS = -D NOSLIP

SLAPP = psg_slip
NSAPP = psg_noslip

CC = gcc

all : slip noslip


slip : $(SLAPP)

noslip : $(NSAPP)

$(SLAPP) : $(OBJECTS) $(SLIP_OBJECTS) $(BOUNDARY_FLAG_OBJECTS)


@for file in $(subst .o,,$(BOUNDARY_FLAG_OBJECTS)); do \
cp $(SRC_DIR)/$$file\_slip.o $(SRC_DIR)/$$file.o ; \
done
cd $(SRC_DIR); \
$(CC) $(FLAGS) $^ -o $@ $(PROFILE); \
mv psg_slip $(TOP)

$(NSAPP) : $(OBJECTS) $(NOSLIP_OBJECTS) $(BOUNDARY_FLAG_OBJECTS)


@for file in $(subst .o,,$(BOUNDARY_FLAG_OBJECTS)); do \
cp $(SRC_DIR)/$$file\_noslip.o $(SRC_DIR)/$$file.o ; \
done
cd $(SRC_DIR); \
$(CC) $(FLAGS) $^ -o $@ $(PROFILE); \
mv psg_noslip $(TOP)

$(OBJECTS) :
cd $(SRC_DIR); $(CC) $(FLAGS) -c $*.c $(PROFILE)

$(SLIP_OBJECTS) :
cd $(SRC_DIR); $(CC) $(FLAGS) -c $*.c $(PROFILE)

$(NOSLIP_OBJECTS) :
cd $(SRC_DIR); $(CC) $(FLAGS) -c $*.c $(PROFILE)

$(BOUNDARY_FLAG_OBJECTS) :
cd $(SRC_DIR); $(CC) $(FLAGS) $(SLIP_FLAGS) -c $*.c $(PROFILE)
@for file in $(subst .o,,$(BOUNDARY_FLAG_OBJECTS)); do \
mv $(SRC_DIR)/$$file.o $(SRC_DIR)/$$file\_slip.o ; \
done
cd $(SRC_DIR); $(CC) $(FLAGS) $(NOSLIP_FLAGS) -c $*.c $(PROFILE)
@for file in $(subst .o,,$(BOUNDARY_FLAG_OBJECTS)); do \
mv $(SRC_DIR)/$$file.o $(SRC_DIR)/$$file\_noslip.o ; \
done

clean :
rm -f psg_slip psg_noslip *.bin *.vtr; cd $(SRC_DIR); rm -f *.o *~ core*

fresh : clean all

You might also like