include ../../Makefile.site

GOAL   = libripup.a 

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

OTHERS = 

REQUIRES = rpsl util Core

#LIBS 	 = $(REQUIRES:%=-Lsrc/%) -L../../lib -L/opt/package/mysql/lib/mysql $(REQUIRES:%=-l%) -lmysqlclient -lsocket -lnsl -lglib -lriper -lripau 

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

SHELL           = /bin/sh
CC              = gcc
CXX             = c++
BISON           = bison -y
FLEX            = flex
LD              = c++

DEFINES  = -DHAVE_CONFIG_H -DHAVE_STRTOK_R
CFFLAGS   = -gstabs+ $(CFLAGS)
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) $(CFFLAGS) $(DEFINES) $(INCDIRS) $<

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

.SUFFIXES: .cc

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

src:
	cd src; $(MAKE); cd ..


$(GOAL): $(OBJS) dolibs
	ar -r ../../lib/libripup.a $(OBJS) 

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

clean:
	rm -f core *.o *~ *.y.cc *.y.hh *.l.cc *.l.hh *.tk.cc $(GOAL)
	cd src; $(MAKE) clean

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

# make dependencies
depend:	${SRCS}
	$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) $(INCDIRS) $^ >makedep
	echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	cp Makefile Makefile.bak
	ed - Makefile < eddep
	rm eddep makedep
	echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
	echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
	echo '# see make depend above' >> Makefile

# DO NOT DELETE THIS LINE
UP_util.o: UP_util.cc dbupdate.h src/rpsl/rpsl/object.hh \
 src/Core/util/List.hh src/Core/util/Buffer.hh src/util/debug.hh \
 src/rpsl/rpsl/rpsl_attr.hh src/rpsl/rpsl/rptype.hh \
 src/rpsl/rpsl/regexp.hh src/rpsl/gnu/SetOfSymID.hh \
 src/rpsl/gnu/SymID.VHSet.h src/rpsl/gnu/SymID.Set.h \
 src/rpsl/gnu/Pix.h src/rpsl/gnu/SymID.defs.h src/rpsl/gnu/std.h \
 src/rpsl/rpsl/rangelist.hh src/rpsl/rpsl/symbols.hh \
 src/Core/util/Allocator.hh src/Core/util/xstring.h \
 src/rpsl/rpsl/prefix.hh src/rpsl/rpsl/rpsl_item.hh \
 src/rpsl/rpsl/rpsl_policy.hh src/rpsl/rpsl/rpsl_filter.hh \
 src/rpsl/gnu/prefixranges.hh src/rpsl/gnu/PrefixRange.XPlex.h \
 src/rpsl/gnu/PrefixRange.Plex.h src/rpsl/gnu/PrefixRange.defs.h \
 src/Core/util/rusage.hh src/util/trace.hh src/util/Argv.hh \
 src/util/version.hh src/rpsl/rpsl/schema.hh ../er/erroutines.h \
 ../er/er_facilities.h ../er/er_ER_errors.h ../ip/er_IP_errors.h \
 ../rx/er_RX_errors.h er_UP_errors.h ../ut/er_UT_errors.h \
 ../wh/er_WH_errors.h ../../include/er_RP_errors.h \
 ../../include/er_QI_errors.h ../../include/er_QC_errors.h \
 ../../include/er_PW_errors.h ../../include/er_SK_errors.h \
 ../../include/er_TH_errors.h ../au/AU_util.h
# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend above
