################################################################
# Shared makefile for packages.
################################################################

# This file must provide the following macros:
#
#   * PLLIBDIR
#   Base directory holding the Prolog library.  Some packages
#   may create subdirectories.
#   * SOLIBDIR
#   Directory holding shared objects/DLLs for the target architecture.
#   * PKGDOCDIR
#   Directory for storing the documentation.  Packages typically
#   create subdirectories
#   * PKGEXDIR
#   Directory where a package stores example code.  Packages typically
#   create subdirectories
#   * SO
#   Extension used for shared objects.  E.g., .so, .dylib, .dll, ...

PLBASE=/usr/pkg
PLARCH=alpha-netbsd
PLINCL=$(PLBASE)/include
PLLIBDIR=$(PLBASE)/share/Yap
SOLIBDIR=${exec_prefix}/lib/Yap
PKGDOCDIR=$(PLBASE)/share/doc/Yap/packages
PKGEXDIR=$(PLBASE)/share/doc/Yap/packages/examples
XPCEBASE=$(PLBASE)/xpce

#
# YAP internal stuff
#
ROOTDIR = $(prefix)
EROOTDIR = ${prefix}
BINDIR = $(EROOTDIR)/bin
LIBDIR=${exec_prefix}/lib
YAPLIBDIR=${exec_prefix}/lib/Yap
SHAREDIR=$(ROOTDIR)/share/Yap
abs_top_builddir=/tmp/pkgbuild/lang/yap/work.alpha/yap-6.3.3
PL=LD_LIBRARY_PATH=$(DESTDIR)$(LIBDIR):$(DESTDIR)$(YAPLIBDIR): YAPSHAREDIR=$(DESTDIR)$(SHAREDIR) YAPLIBDIR=$(DESTDIR)$(YAPLIBDIR) $(DESTDIR)$(BINDIR)/yap $(DESTDIR)$(YAPLIBDIR)/startup.yss

CC=gcc
LD=gcc -shared -Wl,-export-dynamic
SO=so
COFLAGS=$(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../.. -I$(srcdir)/../../include -I$(srcdir)/../../os -I/usr/include -I/usr/pkg/include -I/usr/pkg/include
CWFLAGS=
CMFLAGS=-fPIC -O3 -fomit-frame-pointer -Wall -Wstrict-prototypes -Wmissing-prototypes -O2 -mieee -D_FORTIFY_SOURCE=2 -I/usr/include -I/usr/pkg/include 
CIFLAGS=
CFLAGS=$(COFLAGS) $(CWFLAGS) $(CMFLAGS) $(CIFLAGS) $(PKGCFLAGS) -DHAVE_CONFIG_H

LDSOFLAGS=-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)
LDFLAGS=$(PKGLDFLAGS)

LIBPLEMBED= -L$(abs_top_builddir) -Wl,-R,$(YAPLIBDIR) -lpthread
LIBPLSO= -L$(abs_top_builddir) -Wl,-R,$(YAPLIBDIR) -lpthread

MKINDEX=(cd $(srcdir) ; $(PL) -f none -g make -t halt)

.txt.tex:
	$(PUBLICPL)  -L $(SHAREDIR)/doc_latex -g "doc_latex('$*.txt','$*.tex',[stand_alone(false)]),halt" -t "halt(1)"


PUBLICPL=$(PL)
PLTOTEX=$(PUBLICPL) -q -l $(srcdir)/pltotex -g pltotex --

#
# find out how to generate .o files from $(scrdir)
#
%.o: $(srcdir)/%.c
		$(CC) -c $(CFLAGS) $< -o $@

