#
# default base directory for YAP installation
# (EROOT for architecture-dependent files)
#
#
# 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
MPI_CC=mpicc
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
#

OBJS=yaprl.o range_list.o
SOBJS=yap_rl.so

#in some systems we just create a single object, in others we need to
# create a libray
all: $(SOBJS)

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

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

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

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

install: all
	@if test "$(SOBJS)" = "no"; then echo ""; else $(INSTALL_PROGRAM) $(SOBJS) $(DESTDIR)$(YAPLIBDIR); fi

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

no:
	@echo "YAP RL module not compiled."

