#
# default base directory for YAP installation
# (EROOT for architecture-dependent files)
#
prefix = @prefix@
exec_prefix = @exec_prefix@
ROOTDIR = $(prefix)
EROOTDIR = @exec_prefix@
abs_top_builddir = @abs_top_builddir@
#
# where the binary should be
#
BINDIR = $(EROOTDIR)/bin
#
# where YAP should look for libraries
#
LIBDIR=@libdir@
YAPLIBDIR=@libdir@/Yap
#
#
CC=@CC@
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include
LDFLAGS=@LDFLAGS@
#
#
# You shouldn't need to change what follows.
#
INSTALL=@INSTALL@
INSTALL_DATA=@INSTALL_DATA@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
SHELL=/bin/sh
RANLIB=@RANLIB@
srcdir=@srcdir@
SO=@SO@
#4.1VPATH=@srcdir@:@srcdir@/OPTYap
CWD=$(PWD)
#

OBJS=regexp.o @NO_BUILTIN_REGEXP@ regcomp.o regexec.o regerror.o regfree.o
SOBJS=regexp.@SO@  @NO_BUILTIN_REGEXP@ regcomp.@SO@ regexec.@SO@ regerror.@SO@ regfree.@SO@ 

#in some systems we just create a single object, in others we need to
# create a libray

all: $(SOBJS)

regexp.o: $(srcdir)/regexp.c  @NO_BUILTIN_REGEXP@ $(srcdir)/regex2.h  $(srcdir)/engine.c
	$(CC) -c $(CFLAGS) $(srcdir)/regexp.c -o regexp.o

regcomp.o: $(srcdir)/regcomp.c $(srcdir)/regex2.h
	$(CC) -c $(CFLAGS) $(srcdir)/regcomp.c -o regcomp.o

regerror.o: $(srcdir)/regerror.c
	$(CC) -c $(CFLAGS) $(srcdir)/regerror.c -o regerror.o

regfree.o: $(srcdir)/regfree.c $(srcdir)/regex2.h
	$(CC) -c $(CFLAGS) $(srcdir)/regfree.c -o regfree.o

regexec.o: $(srcdir)/regexec.c
	$(CC) -c $(CFLAGS) $(srcdir)/regexec.c -o regexec.o

@DO_SECOND_LD@%.@SO@: %.o
@DO_SECOND_LD@	@SHLIB_LD@ $(LDFLAGS) -o $@ $<  @EXTRA_LIBS_FOR_DLLS@

@DO_SECOND_LD@regexp.@SO@: regexp.o @MERGE_DLL_OBJS@ regcomp.o regerror.o regfree.o regexec.o
@DO_SECOND_LD@	@SHLIB_LD@ $(LDFLAGS) -o regexp.@SO@ regexp.o  @EXTRA_LIBS_FOR_DLLS@ @MERGE_DLL_OBJS@ regcomp.o regerror.o regfree.o regexec.o 

@DO_SECOND_LD@regcomp.@SO@: regcomp.o @MERGE_DLL_OBJS@ regfree.o
@DO_SECOND_LD@	@SHLIB_LD@ $(LDFLAGS) -o regcomp.@SO@ regcomp.o @MERGE_DLL_OBJS@ regfree.o @EXTRA_LIBS_FOR_DLLS@

@DO_SECOND_LD@regerror.@SO@: regerror.o
@DO_SECOND_LD@	@SHLIB_LD@ $(LDFLAGS) -o regerror.@SO@ regerror.o @EXTRA_LIBS_FOR_DLLS@

@DO_SECOND_LD@regfree.@SO@: regfree.o
@DO_SECOND_LD@	@SHLIB_LD@ $(LDFLAGS) -o regfree.@SO@ regfree.o @EXTRA_LIBS_FOR_DLLS@

@DO_SECOND_LD@regexec.@SO@: regexec.o
@DO_SECOND_LD@	@SHLIB_LD@ $(LDFLAGS) -o regexec.@SO@ regexec.o @EXTRA_LIBS_FOR_DLLS@

install: all
	$(INSTALL_PROGRAM) $(SOBJS) $(DESTDIR)$(YAPLIBDIR)

clean:
	rm -f *.o *~ $(OBJS) $(SOBJS) *.BAK