# -*- Makefile -*-

#
# 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
#
TARGETS=	prism.so
LIBDIR=${exec_prefix}/lib
YAPLIBDIR=${exec_prefix}/lib/Yap
YAP_EXTRAS= -DCOROUTINING=1 -DCUT_C=1 -DRATIONAL_TREES=1 -DDEPTH_LIMIT=1 -DTABLING=1 -D_YAP_NOT_INSTALLED_=1  -D__YAP_PROLOG__=1
#
#
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 -I$(srcdir)/../../../../H -I$(srcdir)/../../../../library/dialect/bprolog/fli
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)
#
RM=rm -f

##----------------------------------------------------------------------

ifeq ($(PROCTYPE),mp)
SUBDIRS += $(MP_DIR)
OBJS    += $(MP_OBJS)
endif

##----------------------------------------------------------------------

include $(srcdir)/makefiles/Makefile.files
S=/
O=o

SOBJS=prism.so

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

all: $(SOBJS)

core/%.o: $(srcdir)/core/%.c
	$(CC) -c $(CFLAGS) $< -o $@

up/%.o: $(srcdir)/up/%.c
	$(CC) -c $(CFLAGS) $< -o $@

mp/%.o: $(srcdir)/mp/%.c
	$(CC) -c $(CFLAGS) $< -o $@

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

all: $(TARGETS)

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

clean: clean_subdirs
	$(RM) $(TARGET)

clean_subdirs:
	for i in $(SUBDIRS); do                     \
	  $(RM) $$i/*.o;                            \
	done

##----------------------------------------------------------------------

.PHONY: all install clean $(SUBDIRS)

##----------------------------------------------------------------------
