# Makefile for
#  fastcap - capacitance calculation program
#  busgen - bus crossing input file generator
#  capgen - || plate capacitor input file generator
#  cubegen - cubic capacitor input file generator
#  pipedgen - parallelepiped input file generator
#  pyragen - pyramid input file generator

# assumed places for unaliased executables - must be same in all Makefile.*
SHELL = /bin/sh
AWK = awk
RM = /bin/rm

MAKETYPE = 4
# normally overidden by master Makefile
TYPE = other

INCL = .
IO = .
DIR = .
MUL = .
ALC = .
COM = .
GEN = .
BIN = ../bin
TOP = ..

OBJS = $(MUL)/mulGlobal.o $(MUL)/mulSetup.o $(MUL)/mulMats.o $(MUL)/mulDo.o \
$(IO)/mulDisplay.o $(MUL)/mulMulti.o \
$(MUL)/mulLocal.o $(DIR)/direct.o $(DIR)/calcp.o $(MUL)/fastcap.o \
$(DIR)/blkDirect.o $(ALC)/uglyalloc.o \
$(IO)/patran.o $(IO)/quickif.o $(MUL)/electric.o \
$(IO)/input.o $(IO)/psMatDisplay.o $(MUL)/capsolve.o $(IO)/savemat_mod.o \
$(IO)/zbufInOut.o $(IO)/zbuf2fastcap.o $(IO)/zbufProj.o $(IO)/zbufSort.o

SRCS = $(MUL)/mulGlobal.c $(MUL)/mulSetup.c $(MUL)/mulMats.c $(MUL)/mulDo.c \
$(IO)/mulDisplay.c $(MUL)/mulMulti.c \
$(MUL)/mulLocal.c $(DIR)/direct.c $(DIR)/calcp.c $(MUL)/fastcap.c \
$(DIR)/blkDirect.c $(ALC)/uglyalloc.c \
$(IO)/patran.c $(IO)/quickif.c $(MUL)/electric.c \
$(IO)/input.c $(IO)/psMatDisplay.c $(MUL)/capsolve.c $(IO)/savemat_mod.c \
$(IO)/zbufInOut.c $(IO)/zbuf2fastcap.c $(IO)/zbufProj.c $(IO)/zbufSort.c

OBJSB = $(GEN)/busgen.o $(GEN)/disrect.o $(COM)/epsilon.o
SRCSB = $(GEN)/busgen.c $(GEN)/disrect.c $(COM)/epsilon.c

OBJSP = $(GEN)/pltcapgen.o $(GEN)/disrect.o $(COM)/epsilon.o
SRCSP = $(GEN)/pltcapgen.c $(GEN)/disrect.c $(COM)/epsilon.c

OBJSC = $(GEN)/cubegen.o $(GEN)/disrect.o $(COM)/epsilon.o
SRCSC = $(GEN)/cubegen.c $(GEN)/disrect.c $(COM)/epsilon.c

OBJST = $(GEN)/teragen.o $(GEN)/disrect.o $(GEN)/distri.o $(COM)/epsilon.o
SRCST = $(GEN)/teragen.c $(GEN)/disrect.c $(GEN)/distri.c $(COM)/epsilon.c

OBJSI = $(GEN)/pipedgen.o $(GEN)/disrect.o $(COM)/epsilon.o
SRCSI = $(GEN)/pipedgen.c $(GEN)/disrect.c $(COM)/epsilon.c

LIBS = -lm

# These compile flags are needed to account for differences in the
#  resource usage system call used to get CPU time and memory use data
#  - also used to select the correct CC macro definition for AIX machines
#
# for generic machine use (timers not supported)
#CFLAGS = -O -DOTHER
# for most machines running 4.2/3 use (only necessary if timers are needed)
CFLAGS = -O -DFOUR
# for most machines running System V use (only necessary if timers are needed)
#CFLAGS = -O -DFIVE
# for IBM AIX systems use
#CC = xlc

default:
	@echo Please specify what to make:
	@echo "  fastcap - capacitance calculation program"
	@echo "  busgen - bus crossing input file generator"
	@echo "  capgen - || plate capacitor input file generator"
	@echo "  cubegen - cubic capacitor input file generator"
	@echo "  pyragen - pyramid capacitor input file generator"
	@echo "  pipedgen - parallelepiped capacitor input file generator"
	@echo "  all - all of the above"

fastcap: $(OBJS)
	$(CC) -o fastcap $(CFLAGS) $(OBJS) $(LIBS)
	mv fastcap $(BIN)/fastcap

busgen: $(OBJSB)
	$(CC) -o busgen $(CFLAGS) $(OBJSB) $(LIBS)
	mv busgen $(BIN)/busgen

capgen: $(OBJSP)
	$(CC) -o capgen $(CFLAGS) $(OBJSP) $(LIBS)
	mv capgen $(BIN)/capgen

cubegen: $(OBJSC)
	$(CC) -o cubegen $(CFLAGS) $(OBJSC) $(LIBS)
	mv cubegen $(BIN)/cubegen

pyragen: $(OBJST)
	$(CC) -o pyragen $(CFLAGS) $(OBJST) $(LIBS)
	mv pyragen $(BIN)/pyragen

pipedgen: $(OBJSI)
	$(CC) -o pipedgen $(CFLAGS) $(OBJSI) $(LIBS)
	mv pipedgen $(BIN)/pipedgen

all : fastcap busgen capgen cubegen pyragen pipedgen

setmake:
	@$(SHELL) setmake.sh $(AWK) $(TYPE) $(TOP) $(RM)
clean:
	$(RM) -f *.o

$(OBJS) : $(INCL)/mulStruct.h $(INCL)/mulGlobal.h $(INCL)/patran.h \
$(INCL)/resusage.h Makefile
$(SRCS) : $(INCL)/mulStruct.h $(INCL)/mulGlobal.h $(INCL)/patran.h \
$(INCL)/resusage.h Makefile
$(IO)/quickif.c $(IO)/quickif.o : $(IO)/quickif.h Makefile
