## This version of the Makefile is for compiling the examples outside the
## mysql++ source tree, using the MySQL++ library and headers installed
## into the system directories.


# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.


# --- Things you might need to change:

CXX=g++
MYSQLPP_INC_DIR=/usr/local/include/mysql++
MYSQLCLIENT_INC_DIR=/usr/local/include/mysql
CXXFLAGS=-I$(MYSQLPP_INC_DIR) -I$(MYSQLCLIENT_INC_DIR) -O2

LD=$(CXX)
LDFLAGS=-L/usr/local/lib -L/usr/local/lib/mysql -lmysqlpp -lmysqlclient


# --- No user-serviceable parts below :)

BINARIES=resetdb simple1 custom1 custom2 custom3 custom4 \
	fieldinf1 dbinfo cgi_image load_file updel

RESETDB_OBJS=resetdb.o util.o
SIMPLE1_OBJS=simple1.o util.o
CUSTOM1_OBJS=custom1.o util.o
CUSTOM2_OBJS=custom2.o util.o
CUSTOM3_OBJS=custom3.o util.o
CUSTOM4_OBJS=custom4.o util.o
FIELDINF1_OBJS=fieldinf1.o util.o
DBINFO_OBJS=dbinfo.o util.o
CGI_IMAGE_OBJS=cgi_image.o
LOAD_FILE_OBJS=load_file.o
UPDEL_OBJS=updel.o

.SUFFIXES: .cpp

.cpp.o:
	$(CXX) $(CXXFLAGS) -c $<


all: $(BINARIES)

clean:
	rm -f *.o $(BINARIES)


resetdb: $(RESETDB_OBJS)
	$(LD) $(RESETDB_OBJS) -o $@ $(LDFLAGS)

simple1: $(SIMPLE1_OBJS)
	$(LD) $(SIMPLE1_OBJS) -o $@ $(LDFLAGS)

custom1: $(CUSTOM1_OBJS)
	$(LD) $(CUSTOM1_OBJS) -o $@ $(LDFLAGS)

custom2: $(CUSTOM2_OBJS)
	$(LD) $(CUSTOM2_OBJS) -o $@ $(LDFLAGS)

custom3: $(CUSTOM3_OBJS)
	$(LD) $(CUSTOM3_OBJS) -o $@ $(LDFLAGS)

custom4: $(CUSTOM4_OBJS)
	$(LD) $(CUSTOM4_OBJS) -o $@ $(LDFLAGS)

fieldinf1: $(FIELDINF1_OBJS)
	$(LD) $(FIELDINF1_OBJS) -o $@ $(LDFLAGS)

dbinfo: $(DBINFO_OBJS)
	$(LD) $(DBINFO_OBJS) -o $@ $(LDFLAGS)

cgi_image: $(CGI_IMAGE_OBJS)
	$(LD) $(CGI_IMAGE_OBJS) -o $@ $(LDFLAGS)

load_file: $(LOAD_FILE_OBJS)
	$(LD) $(LOAD_FILE_OBJS) -o $@ $(LDFLAGS)

updel: $(UPDEL_OBJS)
	$(LD) $(UPDEL_OBJS) -o $@ $(LDFLAGS)


resetdb.o: resetdb.cpp util.h
simple1.o: simple1.cpp util.h
custom1.o: custom1.cpp util.h
custom2.o: custom2.cpp util.h
custom3.o: custom3.cpp util.h
custom4.o: custom4.cpp util.h
fieldinf1.o: fieldinf1.cpp util.h
dbinfo.o: dbinfo.cpp util.h
cgi_image.o: cgi_image.cpp
load_file.o: load_file.cpp
updel.o: updel.cpp
util.o: util.cpp util.h

