#Open Babel Makefile

prefix        = /usr/local
exec_prefix   = ${prefix}
pkgdatadir    = ${prefix}/share/openbabel

CC            = gcc
CXX	      = g++

CFLAGS        = -g -O2
CXXFLAGS      = -g -O2 
DEFS          = -DDATADIR=\"${pkgdatadir}\" 
INCS          = -I$(builddir)
LIBS	      = 
LIBFLAGS      = -DLIBRARY

LINKER	      = $(CXX)
LDFLAGS       = 

RM            = rm -f
INSTALL	      = /usr/bin/install -c
MKDIRS        = $(top_srcdir)/mkinstalldirs
AR	      = /usr/local/bin/ar
RANLIB	      = ranlib

srcdir        = .

top_srcdir    = ..
top_builddir  = /usr/src/xdrawchem-1.5.2
builddir      = /usr/src/xdrawchem-1.5.2/openbabel

DEST	      = ${exec_prefix}/bin

MAIN	      = main.o

DATAFILES     = aromatic.txt atomtyp.txt element.txt extable.txt \
		resdata.txt types.txt phmodel.txt 

DATAINCS      = aromatic.h atomtyp.h element.h extable.h \
	        phmodeldata.h resdata.h types.h

HDRS	      = math/vector3.h math/matrix3x3.h aromatic.h atomtyp.h base.h binary.h \
		bitgrid.h bitvec.h chiral.h chains.h cwrap.h \
		data.h element.h extable.h fileformat.h grid.h \
		matrix.h mol.h molchrg.h molvector.h oeifstream.h \
		obutil.h parsmart.h patty.h phmodel.h phmodeldata.h \
		resdata.h ring.h rotor.h smi.h typer.h types.h version.h \
		chains.h generic.h oberror.h

OBJS	      =	alchemy.o binary.o typer.o atom.o base.o bitvec.o \
		bitgrid.o bond.o \
		chains.o data.o molvector.o matrix.o\
		chiral.o grid.o mdl.o mol.o mol2.o molchrg.o \
		obutil.o parsmi.o parsmart.o patty.o \
		ring.o rotor.o smi.o tokenst.o math/vector3.o math/matrix3x3.o pdb.o ccc.o \
		mmod.o rand.o box.o balst.o bgf.o cacao.o cache.o chdrw.o \
		csr.o cssr.o feat.o fh.o gromos96.o cwrap.o \
		ghemical.o xyz.o fileformat.o gamess.o hin.o \
		qchem.o tinker.o unichem.o mpqc.o phmodel.o car.o xed.o \
		jaguar.o amber.o generic.o residue.o \
		dmol.o report.o nwchem.o mopac.o gaussian.o c3d.o viewmol.o \
		cml.o oberror.o

PROGRAM	      = babel

LIBRARY       = libopenbabel.a

EXTRA_DIST    = bin2hex.pl

MAKEFILE      = Makefile

$(PROGRAM):     $(MAIN) $(LIBRARY)
		$(LINKER) $(LDFLAGS) -o  $(PROGRAM) $(MAIN) $(LIBRARY) $(LIBS)

$(LIBRARY):	$(DATAINCS) $(OBJS)
		$(AR) -r $(LIBRARY) $(OBJS)
		$(RANLIB) $(LIBRARY)

all:		$(DATAINCS) $(LIBRARY) $(PROGRAM)

test:		check
check:		$(PROGRAM)

clean:;		$(RM) $(OBJS) $(MAIN) $(PROGRAM) $(LIBRARY) 
distclean:	clean
		$(RM) version.h Makefile

install:	$(PROGRAM)
		$(MKDIRS) $(DEST)
		$(INSTALL) $(PROGRAM) $(DEST)
		$(MKDIRS) $(pkgdatadir)
		(cd $(srcdir); $(INSTALL) -m644 $(DATAFILES) $(pkgdatadir))

print:;		$(PRINT) $(HDRS) $(SRCS)

program:        $(PROGRAM)

dist:		distclean

# Generated include files (default data tables)
aromatic.h:	bin2hex.pl aromatic.txt
		(cd $(srcdir); ./bin2hex.pl aromatic.txt AromaticData >aromatic.h)

atomtyp.h:	bin2hex.pl atomtyp.txt
		(cd $(srcdir); ./bin2hex.pl atomtyp.txt AtomTypeData >atomtyp.h)

element.h:	bin2hex.pl element.txt
		(cd $(srcdir); ./bin2hex.pl element.txt ElementData >element.h)

extable.h:	bin2hex.pl extable.txt
		(cd $(srcdir); ./bin2hex.pl extable.txt ExtensionTableData >extable.h)

phmodeldata.h:	bin2hex.pl phmodel.txt
		(cd $(srcdir); ./bin2hex.pl phmodel.txt PhModelData PHMODELDATA >phmodeldata.h)

resdata.h:	bin2hex.pl resdata.txt
		(cd $(srcdir); ./bin2hex.pl resdata.txt ResidueData >resdata.h)

types.h:	bin2hex.pl types.txt
		(cd $(srcdir); ./bin2hex.pl types.txt TypesData >types.h)

# Update the Makefile if the Makefile.in or configure script changes
Makefile:	Makefile.in
		(cd ..; ./config.status)

.SUFFIXES:	.cpp
.cpp.o:
		$(CXX) $(CXXFLAGS) $(DEFS) $(INCS) -c $< -o $@
