include ../../Makefile.site
GOAL   = dbupdate 

OBJS   = dbupdate.o
SRCS   = dbupdate.cc
HFILES = er_UP_errors.h  update_upper.h 

OTHERS = 

REQUIRES = rpsl Core util

LIBS 	 = $(REQUIRES:%=-L../../modules/up/src/%) $(REQUIRES:%=-l%) -lmysqlclient -lsocket -lnsl -lglib -lriper  -lripup -lripau -lripak -lripca -lripnt -lripmm -lrippa $(LFLAGS)

# directories
srcdir		= ../../modules/up/src/
top_srcdir	= ../../modules/up
INCDIRS         = -I$(srcdir) -I. -I$(top_srcdir)/src -I.. -I$(top_srcdir)/src/Core -I$(top_srcdir)/src/rpsl $(INCLUDES)
# programs

SHELL           = /bin/sh
RANLIB          = :
CC              = gcc
CXX             = c++ -g
BISON           = bison -y
FLEX            = flex
LD              = c++
PERL            = @PERL_PATH@
INSTALL         = ../.././install-sh -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA    = ${INSTALL} -m 644

# The default location for installation.
prefix      = /usr/local
exec_prefix = ${prefix}
bindir      = ${exec_prefix}/bin
mandir      = ${prefix}/man
man1dir     = $(mandir)/man1
man8dir     = $(mandir)/man8

DEFINES  = -DHAVE_CONFIG_H -DHAVE_STRSEP
CFLAGS   = -gstabs+
CPPFLAGS = 
LDFLAGS  = 
CXXFLAGS = -gstabs+ -frtti

default: all

# Implicit rules
%.y.cc %.y.hh: %.y
	@echo Compiling: `basename $<`
	$(BISON) -d -p `basename $< .y` $<
	mv y.tab.c $<.cc
	mv y.tab.h $<.hh

%.l.cc: %.l
	@echo Compiling: `basename $<`
	$(FLEX) -P`basename $< .l` $<
	mv lex.`basename $< .l`.c $<.cc

.c.o:
	$(CC)  -c $(CPPFLAGS) $(CFLAGS) $(DEFINES) $(INCDIRS) $<

.cc.o: 
	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) $(INCDIRS) $<

.SUFFIXES: .cc

#
# No need to make changes below
#
all: $(GOAL) 

$(GOAL): $(OBJS)
#$(GOAL): $(OBJS) dolibs
	$(LD) $(CFLAGS) -o $(GOAL) $(OBJS) $(LIBS)

dolibs:
	@ for f in $(REQUIRES); do cd src/$$f; $(MAKE) $(MFLAGS); done

clean:
	rm -f core *.o *~ $(GOAL)

mostlyclean:
	rm -f core *.o *~ *.y.cc *.y.hh *.l.cc *.l.hh *.tk.cc

