#
# Copyright (C) 2006 TeleConcept Multimedia N.V.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 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 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.
#

CC=gcc
#CFLAGS=-g -pedantic -Wall -Werror -O2 -fno-strict-aliasing
CFLAGS=-g -pedantic -Wall -Werror -fno-strict-aliasing
LDFLAGS=-Wl,-zmuldefs
MYSQLFLAGS=$(shell mysql_config --cflags)
MYSQLINCLUDES=$(shell mysql_config --cflags)
NDBINCLUDES=$(shell mysql_config --include)/ndb $(shell mysql_config --include)/ndb/mgmapi $(shell mysql_config --include )/storage/ndb/mgmapi $(shell mysql_config --include)/storage/ndb
MYSQLLIBS=$(shell mysql_config --libs_r) -lndbclient -lstdc++ -lmystrings -lmysys
NETSNMPLIBS=$(shell net-snmp-config --agent-libs)
AGENTOBJ=common.o \
         dbtable.o \
         engines.o \
         engines_ndbcluster.o \
         main.o \
         processtable.o \
         status.o \
         system.o

.SUFFIXES:      .o .c

%.o:	%.c %.h
	$(CC) $(CFLAGS) $(MYSQLINCLUDES) $(NDBINCLUDES) $(NETSNMPINCLUDES) -c -o $@ $<

all:	mysql_agent

mysql_agent:	$(AGENTOBJ) $(AGENTOBJ:.o=.h)
	$(CC) $(LDFLAGS) $(AGENTOBJ) $(NETSNMPLIBS) $(MYSQLLIBS) -o $@

clean:
	rm -f $(AGENTOBJ)
	rm -f mysql_agent
