#
# default base directory for YAP installation
# (EROOT for architecture-dependent files)
#
prefix = /usr/pkg
exec_prefix = ${prefix}
ROOTDIR = $(prefix)
EROOTDIR = ${prefix}
abs_top_builddir = /tmp/pkgbuild/lang/yap/work.alpha/yap-6.3.3
#
# where the binary should be
#
BINDIR = $(EROOTDIR)/bin
#
# where YAP should look for libraries
#
LIBDIR=${exec_prefix}/lib
YAPLIBDIR=${exec_prefix}/lib/Yap
#
#
CC=gcc
CFLAGS= -fPIC -O3 -fomit-frame-pointer -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -mieee -D_FORTIFY_SOURCE=2 -I/usr/include -I/usr/pkg/include $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include
LDFLAGS=-Wl,--export-dynamic -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -L$(abs_top_builddir) -Wl,-R,$(LIBDIR)
#
#
# You shouldn't need to change what follows.
#
INSTALL=/usr/bin/install -c -o pbulk -g users
INSTALL_DATA=/usr/bin/install -c -o pbulk -g users -m 644
INSTALL_PROGRAM=/usr/bin/install -c -s -o pbulk -g users -m 755
SHELL=/bin/sh
RANLIB=ranlib
srcdir=.
SO=so
#4.1VPATH=.:./OPTYap
CWD=$(PWD)
#

OBJS=regexp.o # regcomp.o regexec.o regerror.o regfree.o
SOBJS=regexp.so  # 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  # $(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

%.so: %.o
	gcc -shared -Wl,-export-dynamic $(LDFLAGS) -o $@ $<   -L$(abs_top_builddir) -Wl,-R,$(YAPLIBDIR)

regexp.so: regexp.o # regcomp.o regerror.o regfree.o regexec.o
	gcc -shared -Wl,-export-dynamic $(LDFLAGS) -o regexp.so regexp.o   -L$(abs_top_builddir) -Wl,-R,$(YAPLIBDIR) # regcomp.o regerror.o regfree.o regexec.o 

regcomp.so: regcomp.o # regfree.o
	gcc -shared -Wl,-export-dynamic $(LDFLAGS) -o regcomp.so regcomp.o # regfree.o  -L$(abs_top_builddir) -Wl,-R,$(YAPLIBDIR)

regerror.so: regerror.o
	gcc -shared -Wl,-export-dynamic $(LDFLAGS) -o regerror.so regerror.o  -L$(abs_top_builddir) -Wl,-R,$(YAPLIBDIR)

regfree.so: regfree.o
	gcc -shared -Wl,-export-dynamic $(LDFLAGS) -o regfree.so regfree.o  -L$(abs_top_builddir) -Wl,-R,$(YAPLIBDIR)

regexec.so: regexec.o
	gcc -shared -Wl,-export-dynamic $(LDFLAGS) -o regexec.so regexec.o  -L$(abs_top_builddir) -Wl,-R,$(YAPLIBDIR)

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

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

