##################################################################
############### acedb: R.Durbin and J.Thierry-Mieg ##############
############### wmake/truemake,  Jan-12-1992       ##############
#################################################################

#################################################################
# Before running the make command
# setenv ACEDB_MACHINE to indicate one of the predefined
# Machine dependant option files, or write your own.
# These files are called  $(ACEDB_SRC)/wmake/$(ACEDB_MACHINE)_DEF
#
# They define 4 names:
#    NAME, CC, LIBS, OPTIONS
# CC is the compiler and its specific flags (cc, gcc, xlc ...)
# LIBS the corresponding libraries (-lm gcc-gnulib ...)
# NAME and OPTIONS must be selected as follows
#################################################################

### pick NAME from among this list.
### NAME is used in the source code to conform to the
### target machine. It is used mostly in wh/mystdlib.h,
### wh/mydirent.h but also in a few awkward places, for example
### wh/array.h redefines the stack Macros in a particular way to
### please the xlc compiler of the IBM.
### If you port to a new machine, please let us know.

# SUN    Tested for Sun Sparc 1 and 1+ and on SUN3/80
# DEC    Tested on DecStation 3100 and 5000 
#	(on Dec stations add in wh a link to /usr/include/mit/X11)
# NEXT   Tested on a Next used as client.
# SGI    Tested on 2 Silicon Graphics, model unknown.
# ALLIANT  Alliant partly tested, pb with vsprintf().
# IBM   Compiled on IBM-rios, but not linked, they only have X11-R3. 
#
#	On Next and Alliant we use the cc compiler, not gcc.
#       On ibm rios we use xlc.
#       This choice is made by the $(ACEDB_MACHINE)_DEF file.
# 
#       On SGI and Alliant our 2 steps make does not properly works,
#       so on those ACEDB_MACHINEs:
#       do the following by hand:
#	setenv ACEDB_MACHINE SGI or ALLIANT
#       mkdir database ; mkdir bin
#       cp w*/*.c bin
#       cp wmake/truemake bin/makefile
#       cd bin ; make all

#### On the SUN pick any number of the following options #######
##### On other machines, only -DBIBLIO has been tested

# -DIPC       Semaphore for multi users (only tested on sparc)
# -DWCS       Communication with WCS program of Schatz et al.
# -DBIBLIO    Biblio model dependent display
# -DCHRONO    Integrated profiler
# -DREADONLY  Unlinks all database modifications (under tests)

#################################################################
#################################################################
# add in DISP_OBJS your own display codes, 
# in CALCUL_OBJS your algorithms
# link your displays in wspec/quovadis.wrm
#################################################################

DISP_OBJS =  pmapdisp.o gmapdisp.o fmapdisp.o \
	biblio.o griddisp.o geldisp.o cmapdisp.o
CALCUL_OBJS = correl.o topology.o defcpt.o dnacpt.o  \
		regression.o alignmaps.o gmapcpt.o # pmapcpt.o
OTHER_OBJS = embl.o  # nmer.o

#################################################################
################## Graphic Libraries ############################
#################################################################
# In principle the following X libraries can be found using:

Xt_LIBS = -lXaw -lXt -lXmu -lXext -lX11
SUNWIEW_LIBS = -lsuntool -lsunwindow -lpixrect

# On badly configurated machines, you may redefine these libraries
# in a more precise way in your $(ACEDB_MACHINE)_DEF file

#################################################################
########## Machine dependent compiler modification ##############
############# Are included from an external file ################
#### This is equivalent to, but more portable than $($(CC)) #####
### Edit these rules to adapt the makefile to a new machine #####
#################################################################

include ../wmake/$(ACEDB_MACHINE)_DEF

# Note that you can keep different DEF files for the same machine
# setting  various compiler  options

#################################################################
#################################################################
# In principle you should not have to edit the rest of this file
#################################################################
#################################################################

FREE_OBJS = freesubs.o messubs.o arraysub.o help.o filsubs.o \
	heap.o timesubs.o
#			# CLEAN_OBJS is for smaller  programs
CLEAN_OBJS = freesubs.o arraysub.o messclean.o	filclean.o timesubs.o 
INTERACTIVE_OBJS = display.o parse.o chrono.o \
		newkey.o menu.o keyset.o

GRAPH_OBJS = graphcon.o graphsub.o graphps.o graphint.o
SUN_OBJS = graphsun.o prstatic.o sunsubs.o
Xt_OBJS =  graphxt.o graphxlib.o xtsubs.o 
WCS_OBJS =  wcscom.o wcomm.o 

ACE_OBJS = bibace.o acesubs.o stockace.o pmapace.o \
            sgmapace.o raw2ace.o genelistace.o data2.o\
            emblace.o wbgace.o homonym.o  \
	    acediff.o 

MAIN_OBJS = wormmain.o  session.o status.o picksubs.o model.o\
            mainpick.o  dump.o update.o 
READ_ONLY_OBJS = objcacheRO.o bssubsRO.o querymain.o  ROsession.o
BASE_OBJS = lexsubs.o disksubs.o blocksub.o objcache.o keysetdump.o
B_OBJS    = asubs.o bsubs.o bstree.o bstools.o bssubs.o bsdumps.o dnasubs.o
GENERIC_DISPLAY_OBJS  = plot.o acdbtest.o treedisp.o ksetdisp.o \
	querydisp.o external.o longtext.o
NON_GRAPHIC_OBJS = dumpnogr.o helpnongraphic.o 

WORM_OBJS  = $(FREE_OBJS) $(GRAPH_OBJS) $(INTERACTIVE_OBJS) \
	$(MAIN_OBJS) $(BASE_OBJS) $(B_OBJS) \
	 $(GENERIC_DISPLAY_OBJS) \
	$(DISP_OBJS) $(CALCUL_OBJS) queryexe.o $(OTHER_OBJS)

QUERY_OBJS  =  $(CLEAN_OBJS) \
	$(READ_ONLY_OBJS) \
	queryexe.o picksubs.o \
	bstools.o \
	lexsubs.o keyset.o \
	blocksub.o disksubs.o asubs.o bstree.o bsubs.o bsdumps.o keysetdump.o

SERVER_OBJS  = $(CLEAN_OBJS) \
	$(B_OBJS) 

FRONTAL_OBJS  = $(FREE_OBJS) $(GRAPH_OBJS) $(INTERACTIVE_OBJS) \
	$(MAIN_OBJS) $(BASE_OBJS) $(B_OBJS) \
	$(GENERIC_DISPLAY_OBJS) $(DISP_OBJS) $(CALCUL_OBJS) 

##################### 
 
W1_SOURCES = $(FREE_OBJS:.o=.c)  $(INTERACTIVE_OBJS:.o=.c) \
	filclean.c messclean.c 
W2_SOURCES = $(GRAPH_OBJS:.o=.c) $(SUN_OBJS:.o=.c) $(Xt_OBJS:.o=.c) \
	graphtest.c 
W3_SOURCES = $(WCS_OBJS:.o=.c) $(NETWORK_OBJS:.o=.c)
W4_SOURCES = $(MAIN_OBJS:.o=.c) $(READ_ONLY_OBJS:.o=.c) queryexe.c 
W5_SOURCES = $(BASE_OBJS:.o=.c)
W6_SOURCES = $(B_OBJS:.o=.c) $(GENERIC_DISPLAY_OBJS:.o=.c)
W7_SOURCES = $(DISP_OBJS:.o=.c) 
W8_SOURCES = $(CALCUL_OBJS:.o=.c)
W9_SOURCES = $(OTHER_OBJS:.o=.c)
WNG_SOURCES = $(NON_GRAPHIC_OBJS:.o=.c)

WACE_SOURCES = $(ACE_OBJS:.o=.c)  

########## Compiler and library options
 
IDIR = -I../wh -I../wspec -I../wnongraphic \
	-I/usr/include -I/usr/kvm/sys \
	-I/usr/include/mit/X11 \
	-I/usr/local/lib/gcc-include

######## CC, LIBS, NAME, OPTIONS are defined in $(ACEDB_MACHINE)_DEF

CCFLAGS =   ## to undefine any rubbish
GCFLAGS =   ## to undefine any rubbish

CC = $(COMPILER) $(IDIR) $(OPTIONS) -D$(NAME) 
# Note that COMPILE.c is not recognized on the Next
COMPILE.c = $(COMPILER) $(IDIR) $(OPTIONS) -D$(NAME) -c 

###############################
 
.KEEP_STATE:
all :  xace  # sunace tace  homonym  aceserver acefrontal  ace   acediff

$(W1_SOURCES) : ../w1/$@
	cp ../w1/$@ .
$(W2_SOURCES) : ../w2/$@
	cp ../w2/$@ .
$(W3_SOURCES) : ../w3/$@
	cp ../w3/$@ .
$(W4_SOURCES) : ../w4/$@
	cp ../w4/$@ .
$(W5_SOURCES) : ../w5/$@
	cp ../w5/$@ .
$(W6_SOURCES) : ../w6/$@
	cp ../w6/$@ .
$(W7_SOURCES) : ../w7/$@
	cp ../w7/$@ .
$(W8_SOURCES) : ../w8/$@
	cp ../w8/$@ .
$(W9_SOURCES) : ../w9/$@
	cp ../w9/$@ .
$(WNG_SOURCES) : ../wnongraphic/$@
	cp ../wnongraphic/$@ .

$(WACE_SOURCES) : ../wace/$@
	cp ../wace/$@ .
 
# must compile prstatic with cc because pixrect macros are non-ANSI - YUCK!
prstatic.o : prstatic.c
	cc -c prstatic.c -o prstatic.o

#### main program ##########################
 
sunace : $(WORM_OBJS) $(SUN_OBJS)
	cc -o sunace $(WORM_OBJS) $(SUN_OBJS) $(SUNWIEW_LIBS) $(LIBS)
	chmod 4755 sunace

 ## Do not setuid for textace is readonly and may fork subshells
tace : $(QUERY_OBJS) $(NON_GRAPHIC_OBJS)
	cc  $(BSTATIC) -o  tace $(QUERY_OBJS)  $(NON_GRAPHIC_OBJS) $(LIBS)
	chmod 755 tace  

xace : $(WORM_OBJS) $(Xt_OBJS) $(WCS_OBJS)
	$(CC)  $(BSTATIC) -o xace $(WORM_OBJS) $(Xt_OBJS) $(WCS_OBJS) \
	$(Xt_LIBS) $(LIBS)
	chmod 4755 xace

# replace cc by cc -Bstatic before compiling the distribution files
# i.e.   cc  -Bstatic -o xace...

#### distributed programs ################

aceserver : $(SERVER_OBJS)
	cc -o aceserver $(SERVER_OBJS)
	chmod 4755 aceserver

acefrontal : $(FRONTAL_OBJS) $(Xt_OBJS) $(WCS_OBJS)
	cc -o acefrontal $(FRONTAL_OBJS) $(Xt_OBJS) $(WCS_OBJS) \
	$(Xt_LIBS) $(LIBS)
	chmod 4755 acefrontal

#### graphics test programs ################

graphxtclean.o: graphxt.c
	$(COMPILER) $(IDIR) $(OPTIONS) -D$(NAME) -c -DNO_WCS \
	-o graphxtclean.o graphxt.c

GTEST_OBJS = graphtest.o $(GRAPH_OBJS) $(FREE_OBJS)
xtest : $(GTEST_OBJS) graphxtclean.o graphxlib.o xtsubs.o
	cc -o xtest $(GTEST_OBJS)  graphxtclean.o graphxlib.o \
	xtsubs.o $(Xt_LIBS) $(LIBS)

suntest : $(GTEST_OBJS) $(SUN_OBJS)
	cc -o suntest $(GTEST_OBJS) $(SUN_OBJS) $(SUNVIEW_LIBS) $(LIBS)

#### conversion programs ###################

ace :  stockace pmapace   emblace\
	genelistace  wbgace homonym

ACE_OBJS = acesubs.o $(CLEAN_OBJS)

ACE_LIBS = $(LIBS)
BIBACE_OBJS  =  bibace.o $(ACE_OBJS) 
bibace :  $(BIBACE_OBJS)
	cc -o bibace $(BIBACE_OBJS) $(ACE_LIBS)

STKACE_OBJS  =  stockace.o $(ACE_OBJS) 
stockace :  $(STKACE_OBJS)
	cc -o stockace $(STKACE_OBJS) $(ACE_LIBS)

PMAPACE_OBJS  =  pmapace.o $(CLEAN_OBJS) 
pmapace :  $(PMAPACE_OBJS)
	cc -o pmapace $(PMAPACE_OBJS) $(ACE_LIBS)
 
RAW2ACE_OBJS  =  raw2ace.o $(ACE_OBJS) 
raw2ace :  $(RAW2ACE_OBJS)
	cc -o raw2ace $(RAW2ACE_OBJS) $(ACE_LIBS)

DATA2_OBJS  =  data2.o  $(ACE_OBJS) 
data2 :  $(DATA2ACE_OBJS) 
	cc -o data2  $(DATA2_OBJS) $(ACE_LIBS)

GENELISTACE_OBJS  =  genelistace.o $(ACE_OBJS) 
genelistace :  $(GENELISTACE_OBJS)
	cc -o genelistace $(GENELISTACE_OBJS) $(ACE_LIBS)

WBGACE_OBJS  =  wbgace.o $(ACE_OBJS)
wbgace :  $(WBGACE_OBJS)
	cc -o wbgace $(WBGACE_OBJS) $(ACE_LIBS)

HOMONYM_OBJS  =  homonym.o $(CLEAN_OBJS)
homonym :  $(HOMONYM_OBJS)
	cc -o homonym $(HOMONYM_OBJS) $(ACE_LIBS)

emblace :  emblace.o
	cc -o emblace emblace.o $(ACE_LIBS)

DIFF_OBJS = acediff.o messclean.o arraysub.o freesubs.o	timesubs.o
acediff : $(DIFF_OBJS)
	cc $(BSTATIC) -o acediff $(DIFF_OBJS) $(ACE_LIBS)

###########################################################
########### end of the acedb truemake file ################
###########################################################


