summaryrefslogtreecommitdiff
path: root/lang/swi-prolog-lite
diff options
context:
space:
mode:
authorhubertf <hubertf@pkgsrc.org>2004-05-20 11:09:16 +0000
committerhubertf <hubertf@pkgsrc.org>2004-05-20 11:09:16 +0000
commit703cfec78c1591ceddc5865e61b7beeb7e213833 (patch)
treeeed4c22ae00d36cc77676c59c671196a4bb76d0c /lang/swi-prolog-lite
parent963480bdeb8ed62e0b23003ea833b02eb5f7f064 (diff)
downloadpkgsrc-703cfec78c1591ceddc5865e61b7beeb7e213833.tar.gz
move over swi-prolog-lite from pkgsrc-wip
Diffstat (limited to 'lang/swi-prolog-lite')
-rw-r--r--lang/swi-prolog-lite/DESCR9
-rw-r--r--lang/swi-prolog-lite/Makefile35
-rw-r--r--lang/swi-prolog-lite/Makefile.common14
-rw-r--r--lang/swi-prolog-lite/PLIST95
-rw-r--r--lang/swi-prolog-lite/buildlink3.mk21
-rw-r--r--lang/swi-prolog-lite/distinfo13
-rw-r--r--lang/swi-prolog-lite/files/shlib.pl293
-rw-r--r--lang/swi-prolog-lite/patches/patch-aa50
-rw-r--r--lang/swi-prolog-lite/patches/patch-ab13
-rw-r--r--lang/swi-prolog-lite/patches/patch-ac13
-rw-r--r--lang/swi-prolog-lite/patches/patch-ad13
-rw-r--r--lang/swi-prolog-lite/patches/patch-ae31
-rw-r--r--lang/swi-prolog-lite/patches/patch-af22
-rw-r--r--lang/swi-prolog-lite/patches/patch-ag13
-rw-r--r--lang/swi-prolog-lite/patches/patch-ah14
-rw-r--r--lang/swi-prolog-lite/patches/patch-ai19
16 files changed, 668 insertions, 0 deletions
diff --git a/lang/swi-prolog-lite/DESCR b/lang/swi-prolog-lite/DESCR
new file mode 100644
index 00000000000..b65b42f385f
--- /dev/null
+++ b/lang/swi-prolog-lite/DESCR
@@ -0,0 +1,9 @@
+ISO/Edinburgh-style Prolog compiler. Compliant with Part 1 of the ISO
+standard for Prolog. Covers all traditional Edinburgh Prolog features
+and shares many features with Quintus and SICStus Prolog, including a
+compatible module system. Very fast compiler, garbage collection (also
+on atoms), fast and powerful C/C++ interface, autoloading,
+GNU-readline interface. SWI-Prolog supports architectures with 32-bit
+or greater (64-bit) word-length.
+
+Packages are available in the swi-prolog-packages package.
diff --git a/lang/swi-prolog-lite/Makefile b/lang/swi-prolog-lite/Makefile
new file mode 100644
index 00000000000..9d456c93016
--- /dev/null
+++ b/lang/swi-prolog-lite/Makefile
@@ -0,0 +1,35 @@
+# $NetBSD: Makefile,v 1.1.1.1 2004/05/20 11:09:16 hubertf Exp $
+
+.include "Makefile.common"
+
+PKGNAME= swi-prolog-lite-${SWIPLVERS}
+
+MAINTAINER= hubertf@NetBSD.org
+COMMENT= ISO/Edinburgh-style Prolog compiler
+
+GNU_CONFIGURE= # defined
+USE_BUILDLINK3= # defined
+USE_BUILTIN.readline= no # uses rl_event_hook() interface
+
+CONFIGURE_ENV+= PL=swi-prolog
+CONFIGURE_ARGS+= --disable-mt
+#CPPFLAGS+= -DPREFIX=\"${PREFIX}\"
+#CPPFLAGS+= -DSWIPLVERS=\"${SWIPLVERS}\"
+
+.include "../../mk/bsd.prefs.mk"
+
+.if ${MACHINE_ARCH} == alpha || ${MACHINE_ARCH} == sparc64 || \
+ ${MACHINE_ARCH} == x86_64
+PLIST_SUBST+= BITS=64
+.else
+PLIST_SUBST+= BITS=32
+.endif
+
+post-install:
+ ${INSTALL_DATA} ${FILESDIR}/shlib.pl \
+ ${PREFIX}/lib/swi-prolog-${PKGVERSION}/library/shlib.pl
+
+.include "../../devel/ncurses/buildlink3.mk"
+.include "../../devel/readline/buildlink3.mk"
+#.include "../../mk/pthread.buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/lang/swi-prolog-lite/Makefile.common b/lang/swi-prolog-lite/Makefile.common
new file mode 100644
index 00000000000..d0e2f58301b
--- /dev/null
+++ b/lang/swi-prolog-lite/Makefile.common
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile.common,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+SWIPLVERS= 5.2.13
+DISTNAME= pl-${SWIPLVERS}
+CATEGORIES= lang
+MASTER_SITES= ftp://ftp.swi.psy.uva.nl/SWI-Prolog/
+
+HOMEPAGE= http://www.swi-prolog.org/
+
+DIST_SUBDIR= swi-prolog
+DISTINFO_FILE= ${.CURDIR}/../../wip/swi-prolog-lite/distinfo
+PATCHDIR= ${.CURDIR}/../../wip/swi-prolog-lite/patches
+
+PLIST_SUBST+= APPEND_ELF=${APPEND_ELF}
diff --git a/lang/swi-prolog-lite/PLIST b/lang/swi-prolog-lite/PLIST
new file mode 100644
index 00000000000..3145c78a8e6
--- /dev/null
+++ b/lang/swi-prolog-lite/PLIST
@@ -0,0 +1,95 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+bin/plld
+bin/plrc
+bin/swi-prolog
+include/SWI-Prolog.h
+include/SWI-Stream.h
+lib/swi-prolog-${PKGVERSION}/bin/${MACHINE_ARCH}-${LOWER_OPSYS}${APPEND_ELF}/plld
+lib/swi-prolog-${PKGVERSION}/bin/${MACHINE_ARCH}-${LOWER_OPSYS}${APPEND_ELF}/plrc
+lib/swi-prolog-${PKGVERSION}/bin/${MACHINE_ARCH}-${LOWER_OPSYS}${APPEND_ELF}/swi-prolog
+lib/swi-prolog-${PKGVERSION}/bin/swipl
+lib/swi-prolog-${PKGVERSION}/boot/apply.pl
+lib/swi-prolog-${PKGVERSION}/boot/autoload.pl
+lib/swi-prolog-${PKGVERSION}/boot/bags.pl
+lib/swi-prolog-${PKGVERSION}/boot/dwim.pl
+lib/swi-prolog-${PKGVERSION}/boot/history.pl
+lib/swi-prolog-${PKGVERSION}/boot/init.pl
+lib/swi-prolog-${PKGVERSION}/boot/license.pl
+lib/swi-prolog-${PKGVERSION}/boot/load.pl
+lib/swi-prolog-${PKGVERSION}/boot/menu.pl
+lib/swi-prolog-${PKGVERSION}/boot/messages.pl
+lib/swi-prolog-${PKGVERSION}/boot/parms.pl
+lib/swi-prolog-${PKGVERSION}/boot/qlf.pl
+lib/swi-prolog-${PKGVERSION}/boot/rc.pl
+lib/swi-prolog-${PKGVERSION}/boot/sort.pl
+lib/swi-prolog-${PKGVERSION}/boot/syspred.pl
+lib/swi-prolog-${PKGVERSION}/boot/toplevel.pl
+lib/swi-prolog-${PKGVERSION}/boot/topvars.pl
+lib/swi-prolog-${PKGVERSION}/boot/writef.pl
+lib/swi-prolog-${PKGVERSION}/boot${BITS}.prc
+lib/swi-prolog-${PKGVERSION}/dotfiles/README
+lib/swi-prolog-${PKGVERSION}/dotfiles/dotplrc
+lib/swi-prolog-${PKGVERSION}/dotfiles/dotxpcerc
+lib/swi-prolog-${PKGVERSION}/dotfiles/edit
+lib/swi-prolog-${PKGVERSION}/include/SWI-Prolog.h
+lib/swi-prolog-${PKGVERSION}/include/SWI-Stream.h
+lib/swi-prolog-${PKGVERSION}/include/stub.c
+lib/swi-prolog-${PKGVERSION}/library/INDEX.pl
+@unexec rm -f %D/%F
+lib/swi-prolog-${PKGVERSION}/library/MANUAL
+lib/swi-prolog-${PKGVERSION}/library/am_match.pl
+lib/swi-prolog-${PKGVERSION}/library/backcomp.pl
+lib/swi-prolog-${PKGVERSION}/library/bim.pl
+lib/swi-prolog-${PKGVERSION}/library/check.pl
+lib/swi-prolog-${PKGVERSION}/library/checklast.pl
+lib/swi-prolog-${PKGVERSION}/library/checkselect.pl
+lib/swi-prolog-${PKGVERSION}/library/ctypes.pl
+lib/swi-prolog-${PKGVERSION}/library/debug.pl
+lib/swi-prolog-${PKGVERSION}/library/edinburgh.pl
+lib/swi-prolog-${PKGVERSION}/library/edit.pl
+lib/swi-prolog-${PKGVERSION}/library/emacs_interface.pl
+lib/swi-prolog-${PKGVERSION}/library/explain.pl
+lib/swi-prolog-${PKGVERSION}/library/files.pl
+lib/swi-prolog-${PKGVERSION}/library/gensym.pl
+lib/swi-prolog-${PKGVERSION}/library/help.pl
+lib/swi-prolog-${PKGVERSION}/library/helpidx.pl
+lib/swi-prolog-${PKGVERSION}/library/listing.pl
+lib/swi-prolog-${PKGVERSION}/library/lists.pl
+lib/swi-prolog-${PKGVERSION}/library/main.pl
+lib/swi-prolog-${PKGVERSION}/library/make.pl
+lib/swi-prolog-${PKGVERSION}/library/netscape.pl
+lib/swi-prolog-${PKGVERSION}/library/occurs.pl
+lib/swi-prolog-${PKGVERSION}/library/option.pl
+lib/swi-prolog-${PKGVERSION}/library/ordsets.pl
+lib/swi-prolog-${PKGVERSION}/library/oset.pl
+lib/swi-prolog-${PKGVERSION}/library/qpforeign.pl
+lib/swi-prolog-${PKGVERSION}/library/qsave.pl
+lib/swi-prolog-${PKGVERSION}/library/quintus.pl
+lib/swi-prolog-${PKGVERSION}/library/readln.pl
+lib/swi-prolog-${PKGVERSION}/library/readutil.pl
+lib/swi-prolog-${PKGVERSION}/library/shell.pl
+lib/swi-prolog-${PKGVERSION}/library/shlib.pl
+lib/swi-prolog-${PKGVERSION}/library/statistics.pl
+lib/swi-prolog-${PKGVERSION}/library/system.pl
+lib/swi-prolog-${PKGVERSION}/library/threadutil.pl
+lib/swi-prolog-${PKGVERSION}/library/tty.pl
+lib/swi-prolog-${PKGVERSION}/library/url.pl
+lib/swi-prolog-${PKGVERSION}/runtime/${MACHINE_ARCH}-${LOWER_OPSYS}${APPEND_ELF}/libpl.a
+lib/swi-prolog-${PKGVERSION}/swipl
+man/man1/plld.1
+man/man1/plrc.1
+man/man1/swi-prolog.1
+@dirrm lib/swi-prolog-${PKGVERSION}/runtime/${MACHINE_ARCH}-${LOWER_OPSYS}${APPEND_ELF}
+@dirrm lib/swi-prolog-${PKGVERSION}/runtime
+@exec ${MKDIR} %D/lib/swi-prolog-${PKGVERSION}/man
+@dirrm lib/swi-prolog-${PKGVERSION}/man
+@dirrm lib/swi-prolog-${PKGVERSION}/library
+@exec ${MKDIR} %D/lib/swi-prolog-${PKGVERSION}/lib/${MACHINE_ARCH}-${LOWER_OPSYS}${APPEND_ELF}
+@dirrm lib/swi-prolog-${PKGVERSION}/lib/${MACHINE_ARCH}-${LOWER_OPSYS}${APPEND_ELF}
+@dirrm lib/swi-prolog-${PKGVERSION}/lib
+@dirrm lib/swi-prolog-${PKGVERSION}/include
+@dirrm lib/swi-prolog-${PKGVERSION}/dotfiles
+@dirrm lib/swi-prolog-${PKGVERSION}/boot
+@dirrm lib/swi-prolog-${PKGVERSION}/bin/${MACHINE_ARCH}-${LOWER_OPSYS}${APPEND_ELF}
+@dirrm lib/swi-prolog-${PKGVERSION}/bin
+@dirrm lib/swi-prolog-${PKGVERSION}
diff --git a/lang/swi-prolog-lite/buildlink3.mk b/lang/swi-prolog-lite/buildlink3.mk
new file mode 100644
index 00000000000..1f782aac9f4
--- /dev/null
+++ b/lang/swi-prolog-lite/buildlink3.mk
@@ -0,0 +1,21 @@
+# $NetBSD: buildlink3.mk,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
+SWI_PROLOG_LITE_BUILDLINK3_MK:= ${SWI_PROLOG_LITE_BUILDLINK3_MK}+
+
+.if !empty(BUILDLINK_DEPTH:M+)
+BUILDLINK_DEPENDS+= swi-prolog-lite
+.endif
+
+BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Nswi-prolog-lite}
+BUILDLINK_PACKAGES+= swi-prolog-lite
+
+.if !empty(SWI_PROLOG_LITE_BUILDLINK3_MK:M+)
+BUILDLINK_DEPENDS.swi-prolog-lite+= swi-prolog-lite>=5.2.9
+BUILDLINK_PKGSRCDIR.swi-prolog-lite?= ../../lang/swi-prolog-lite
+.endif # SWI_PROLOG_LITE_BUILDLINK3_MK
+
+.include "../../devel/ncurses/buildlink3.mk"
+.include "../../devel/readline/buildlink3.mk"
+
+BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
diff --git a/lang/swi-prolog-lite/distinfo b/lang/swi-prolog-lite/distinfo
new file mode 100644
index 00000000000..fece5e2c94c
--- /dev/null
+++ b/lang/swi-prolog-lite/distinfo
@@ -0,0 +1,13 @@
+$NetBSD: distinfo,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+SHA1 (swi-prolog/pl-5.2.13.tar.gz) = 2c13a65698e0de72e84132f929f5377306c65453
+Size (swi-prolog/pl-5.2.13.tar.gz) = 7122170 bytes
+SHA1 (patch-aa) = 2b6164ed8cc4398c1e7cc2662016e202f61e51f2
+SHA1 (patch-ab) = 66576bfd1c48a9501070308b8925f1cf4ff0bb37
+SHA1 (patch-ac) = 909331edb76b5d0ce5003d86775524cd29e22a79
+SHA1 (patch-ad) = 194e2ef8d8af03e63b7398f61a705d75b14677b5
+SHA1 (patch-ae) = 41f52217706600aac46f8992b15682024b3b6b47
+SHA1 (patch-af) = 6ca56f948950cc198fe255f064cc30fb6c1a58fb
+SHA1 (patch-ag) = 77543e08081f10deb17d48e4e91f3074f1202400
+SHA1 (patch-ah) = 3bfc13a920e0f3a79e6764a9ace89032989e2c67
+SHA1 (patch-ai) = 9446bc38a0a7e02de303e68c923249b615c91833
diff --git a/lang/swi-prolog-lite/files/shlib.pl b/lang/swi-prolog-lite/files/shlib.pl
new file mode 100644
index 00000000000..e411f930914
--- /dev/null
+++ b/lang/swi-prolog-lite/files/shlib.pl
@@ -0,0 +1,293 @@
+/* $Id: shlib.pl,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+ Part of SWI-Prolog
+
+ Author: Jan Wielemaker
+ E-mail: jan@swi.psy.uva.nl
+ WWW: http://www.swi-prolog.org
+ Copyright (C): 1985-2002, University of Amsterdam
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ As a special exception, if you link this library with other files,
+ compiled with a Free Software compiler, to produce an executable, this
+ library does not by itself cause the resulting executable to be covered
+ by the GNU General Public License. This exception does not however
+ invalidate any other reasons why the executable file might be covered by
+ the GNU General Public License.
+*/
+
+:- module(shlib,
+ [ load_foreign_library/1, % :LibFile
+ load_foreign_library/2, % :LibFile, +InstallFunc
+ unload_foreign_library/1, % +LibFile
+ unload_foreign_library/2, % +LibFile, +UninstallFunc
+ current_foreign_library/2, % ?LibFile, ?Public
+ reload_foreign_libraries/0
+ ]).
+:- set_prolog_flag(generate_debug_info, false).
+
+:- module_transparent
+ load_foreign_library/1,
+ load_foreign_library/2.
+
+:- dynamic
+ loading/1, % Lib
+ error/2, % File, Error
+ foreign_predicate/2, % Lib, Pred
+ current_library/5. % Lib, Entry, Path, Module, Handle
+
+:- volatile % Do not store in state
+ loading/1,
+ error/2,
+ foreign_predicate/2,
+ current_library/5.
+
+:- ( current_prolog_flag(open_shared_object, true)
+ -> true
+ ; print_message(warning, shlib(not_supported)) % error?
+ ).
+
+
+ /*******************************
+ * DISPATCHING *
+ *******************************/
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+Windows: If libpl.dll is compiled for debugging, prefer loading <lib>D.dll
+to allow for debugging.
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+find_library(Spec, Lib) :-
+ current_prolog_flag(windows, true),
+ current_prolog_flag(kernel_compile_mode, debug),
+ libd_spec(Spec, SpecD),
+ catch(find_library2(SpecD, Lib), _, fail).
+find_library(Spec, Lib) :-
+ find_library2(Spec, Lib).
+
+find_library2(Spec, Lib) :-
+ absolute_file_name(Spec,
+ [ file_type(executable),
+ access(read),
+ file_errors(fail)
+ ], Lib), !.
+find_library2(Spec, Spec) :-
+ atom(Spec), !. % use machines finding schema
+find_library2(foreign(Spec), Spec) :-
+ atom(Spec), !. % use machines finding schema
+find_library2(Spec, _) :-
+ throw(error(existence_error(source_sink, Spec), _)).
+
+libd_spec(Name, NameD) :-
+ atomic(Name),
+ file_name_extension(Base, Ext, Name),
+ atom_concat(Base, 'D', BaseD),
+ file_name_extension(BaseD, Ext, NameD).
+libd_spec(Spec, SpecD) :-
+ compound(Spec),
+ Spec =.. [Alias,Name],
+ libd_spec(Name, NameD),
+ SpecD =.. [Alias,NameD].
+libd_spec(Spec, Spec). % delay errors
+
+base(Path, Base) :-
+ atomic(Path), !,
+ file_base_name(Path, File),
+ file_name_extension(Base, _Ext, File).
+base(Path, Base) :-
+ Path =.. [_,Arg],
+ base(Arg, Base).
+
+entry(_, Function, Function) :-
+ Function \= default(_), !.
+entry(Spec, default(FuncBase), Function) :-
+ base(Spec, Base),
+ concat_atom([FuncBase, Base], '_', Function).
+entry(_, default(Function), Function).
+
+ /*******************************
+ * (UN)LOADING *
+ *******************************/
+
+load_foreign_library(Library) :-
+ load_foreign_library(Library, default(install)).
+
+load_foreign_library(LibFileSpec, Entry) :-
+ '$strip_module'(LibFileSpec, Module, LibFile),
+ with_mutex('$foreign',
+ shlib:load_foreign_library(LibFile, Module, Entry)).
+
+load_foreign_library(LibFile, _Module, _) :-
+ current_library(LibFile, _, _, _, _), !.
+load_foreign_library(LibFile, Module, DefEntry) :-
+ retractall(error(_, _)),
+ find_library(LibFile, Path),
+ asserta(loading(LibFile)),
+ catch(Module:open_shared_object(Path, Handle), E, true),
+ ( nonvar(E)
+ -> assert(error(Path, E)),
+ fail
+ ; true
+ ), !,
+ ( ( entry(LibFile, DefEntry, Entry),
+ Module:call_shared_object_function(Handle, Entry)
+ -> true
+ ; DefEntry == default(install)
+ )
+ -> retractall(loading(LibFile)),
+ assert_shlib(LibFile, Entry, Path, Module, Handle)
+ ; retractall(loading(LibFile)),
+ close_shared_object(Handle),
+ print_message(error, shlib(LibFile, call_entry(DefEntry))),
+ fail
+ ).
+load_foreign_library(LibFile, _, _) :-
+ retractall(loading(LibFile)),
+ ( error(_Path, E)
+ -> retractall(error(_, _)),
+ throw(E)
+ ; throw(error(existence_error(foreign_library, LibFile), _))
+ ).
+
+unload_foreign_library(LibFile) :-
+ unload_foreign_library(LibFile, default(uninstall)).
+
+unload_foreign_library(LibFile, DefUninstall) :-
+ with_mutex('$foreign', do_unload(LibFile, DefUninstall)).
+
+do_unload(LibFile, DefUninstall) :-
+ current_library(LibFile, _, _, Module, Handle),
+ retractall(current_library(LibFile, _, _, _, _)),
+ ( entry(LibFile, DefUninstall, Uninstall),
+ Module:call_shared_object_function(Handle, Uninstall)
+ -> true
+ ; true
+ ),
+ abolish_foreign(LibFile),
+ close_shared_object(Handle).
+
+abolish_foreign(LibFile) :-
+ ( retract(foreign_predicate(LibFile, Module:Head)),
+ functor(Head, Name, Arity),
+ abolish(Module:Name, Arity),
+ fail
+ ; true
+ ).
+
+system:'$foreign_registered'(M, H) :-
+ ( loading(Lib)
+ -> true
+ ; Lib = '<spontaneous>'
+ ),
+ assert(foreign_predicate(Lib, M:H)).
+
+assert_shlib(File, Entry, Path, Module, Handle) :-
+ retractall(current_library(File, _, _, _, _)),
+ asserta(current_library(File, Entry, Path, Module, Handle)).
+
+
+ /*******************************
+ * ADMINISTRATION *
+ *******************************/
+
+% current_foreign_library(?File, ?Public)
+%
+% Query currently loaded shared libraries
+
+current_foreign_library(File, Public) :-
+ current_library(File, _Entry, _Path, _Module, _Handle),
+ findall(Pred, foreign_predicate(File, Pred), Public).
+
+
+ /*******************************
+ * RELOAD *
+ *******************************/
+
+% reload_foreign_libraries
+%
+% Reload all foreign libraries loaded (after restore of a state
+% craeted using qsave_program/2.
+
+reload_foreign_libraries :-
+ findall(lib(File, Entry, Module),
+ ( retract(current_library(File, Entry, _, Module, _)),
+ File \== -
+ ),
+ Libs),
+ reverse(Libs, Reversed),
+ reload_libraries(Reversed).
+
+reload_libraries([]).
+reload_libraries([lib(File, Entry, Module)|T]) :-
+ ( load_foreign_library(File, Module, Entry)
+ -> true
+ ; print_message(error, shlib(File, load_failed))
+ ),
+ reload_libraries(T).
+
+
+ /*******************************
+ * CLEANUP (WINDOWS ...) *
+ *******************************/
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+Called from Halt() in pl-os.c (if it is defined), *after* all at_halt/1
+hooks have been executed, and after dieIO(), closing and flushing all
+files has been called.
+
+On Unix, this is not very useful, and can only lead to conflicts.
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+unload_all_foreign_libraries :-
+ current_prolog_flag(unix, true), !.
+unload_all_foreign_libraries :-
+ forall(current_library(File, _, _, _, _),
+ unload_foreign(File)).
+
+% unload_foreign(+File)
+%
+% Unload the given foreign file and all `spontaneous' foreign
+% predicates created afterwards. Handling these spontaneous
+% predicates is a bit hard, as we do not know who created them and
+% on which library they depend.
+
+unload_foreign(File) :-
+ unload_foreign_library(File),
+ ( clause(foreign_predicate(Lib, M:H), true, Ref),
+ ( Lib == '<spontaneous>'
+ -> functor(H, Name, Arity),
+ abolish(M:Name, Arity),
+ erase(Ref),
+ fail
+ ; !
+ )
+ -> true
+ ; true
+ ).
+
+ /*******************************
+ * MESSAGES *
+ *******************************/
+
+:- multifile
+ prolog:message/3.
+
+prolog:message(shlib(LibFile, call_entry(DefEntry))) -->
+ [ '~w: Failed to call entry-point ~w'-[LibFile, DefEntry] ].
+prolog:message(shlib(LibFile, load_failed)) -->
+ [ '~w: Failed to load file'-[LibFile] ].
+prolog:message(shlib(not_supported)) -->
+ [ 'Emulator does not support foreign libraries' ].
diff --git a/lang/swi-prolog-lite/patches/patch-aa b/lang/swi-prolog-lite/patches/patch-aa
new file mode 100644
index 00000000000..bddd855de7b
--- /dev/null
+++ b/lang/swi-prolog-lite/patches/patch-aa
@@ -0,0 +1,50 @@
+$NetBSD: patch-aa,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+--- src/Makefile.in.orig Tue Apr 9 20:09:31 2002
++++ src/Makefile.in Wed May 1 19:41:34 2002
+@@ -63,6 +63,7 @@
+ ARCH=@ARCH@
+ INSTALL=@INSTALL@
+ INSTALL_PROGRAM=@INSTALL_PROGRAM@
++INSTALL_SCRIPT=@INSTALL_SCRIPT@
+ INSTALL_DATA=@INSTALL_DATA@
+ MKDIR=@MKDIR@
+ REL_LN=$(srcdir)/rel-ln
+@@ -71,8 +72,9 @@
+ CWFLAGS=@CWFLAGS@
+ CIFLAGS=@CIFLAGS@
+ CMFLAGS=@CMFLAGS@
+-CFLAGS= $(CWFLAGS) $(COFLAGS) $(CIFLAGS) $(CMFLAGS)
++CFLAGS+= $(CWFLAGS) $(COFLAGS) $(CIFLAGS) $(CMFLAGS)
+ LDFLAGS=@LDFLAGS@
++CPPFLAGS=@CPPFLAGS@
+
+ PLFOREIGN=@PLFOREIGN@
+
+@@ -135,7 +137,7 @@
+ plld
+
+ .c.o:
+- $(CC) -c -I. -I$(srcdir) -I$(srcdir)/rc $(CFLAGS) $< @COUTOPT@
++ $(CC) -c -I. -I$(srcdir) -I$(srcdir)/rc $(CPPFLAGS) $(CFLAGS) $< @COUTOPT@
+
+ system: $(PL)
+ startup: $(STARTUPPATH)
+@@ -242,7 +244,7 @@
+ ar x `$(CC) -print-libgcc-file-name` $@
+
+ plld: $(srcdir)/plld.c
+- $(CC) -I. -I$(srcdir) $(CFLAGS) -o $@ $(srcdir)/plld.c
++ $(CC) -I. -I$(srcdir) $(CPPFLAGS) $(CFLAGS) -o $@ $(srcdir)/plld.c
+
+ tags: $(srcdir)/TAGS
+
+@@ -322,7 +324,7 @@
+ $(INSTALL_DATA) ../dotfiles/dotplrc $(PLBASE)/dotfiles
+ $(INSTALL_DATA) ../dotfiles/dotxpcerc $(PLBASE)/dotfiles
+ $(INSTALL_DATA) ../dotfiles/README $(PLBASE)/dotfiles
+- $(INSTALL_PROGRAM) ../dotfiles/edit $(PLBASE)/dotfiles
++ $(INSTALL_SCRIPT) ../dotfiles/edit $(PLBASE)/dotfiles
+
+ iinclude::
+ cd ../include; \
diff --git a/lang/swi-prolog-lite/patches/patch-ab b/lang/swi-prolog-lite/patches/patch-ab
new file mode 100644
index 00000000000..0c36bf7d647
--- /dev/null
+++ b/lang/swi-prolog-lite/patches/patch-ab
@@ -0,0 +1,13 @@
+$NetBSD: patch-ab,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+--- src/configure.orig Tue Apr 16 10:03:45 2002
++++ src/configure Wed May 1 19:21:58 2002
+@@ -978,7 +978,7 @@
+ EXTRAOBJ=""
+ EXTRAHDR=""
+ INSTALLTARGET=dv-install
+-PL=pl
++#PL=pl
+ PLLIB=libpl.a
+ RT=""
+ PLVERSION=`cat ../VERSION`
diff --git a/lang/swi-prolog-lite/patches/patch-ac b/lang/swi-prolog-lite/patches/patch-ac
new file mode 100644
index 00000000000..80c20de0060
--- /dev/null
+++ b/lang/swi-prolog-lite/patches/patch-ac
@@ -0,0 +1,13 @@
+$NetBSD: patch-ac,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+--- packages/xpce/Makefile.in.orig Tue Apr 20 18:56:26 2004
++++ packages/xpce/Makefile.in
+@@ -4,7 +4,7 @@
+ # See also ./configure
+ ################################################################
+
+-MAKE=@MAKE@
++MAKE=gmake
+ BUILDARCH=@BUILDARCH@
+
+ all::
diff --git a/lang/swi-prolog-lite/patches/patch-ad b/lang/swi-prolog-lite/patches/patch-ad
new file mode 100644
index 00000000000..a62cab2c7c8
--- /dev/null
+++ b/lang/swi-prolog-lite/patches/patch-ad
@@ -0,0 +1,13 @@
+$NetBSD: patch-ad,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+--- packages/Makefile.in.orig Thu Oct 16 16:06:35 2003
++++ packages/Makefile.in
+@@ -33,7 +33,7 @@ CNFG=@CNFG@
+
+ # Values filled from the main SWI-Prolog configure
+
+-MAKE=@MAKE@
++MAKE=gmake
+ prefix=@prefix@
+ exec_prefix=@exec_prefix@
+ bindir=@bindir@
diff --git a/lang/swi-prolog-lite/patches/patch-ae b/lang/swi-prolog-lite/patches/patch-ae
new file mode 100644
index 00000000000..6231ca76568
--- /dev/null
+++ b/lang/swi-prolog-lite/patches/patch-ae
@@ -0,0 +1,31 @@
+$NetBSD: patch-ae,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+--- packages/xpce/pl/src/Makefile.orig 2003-10-10 12:24:18.000000000 +0200
++++ packages/xpce/pl/src/Makefile
+@@ -33,7 +33,7 @@ BINDIR= ../../$(builddir)
+ OBJDIR= ../../$(builddir)/pl
+ CONFIG= ../../$(builddir)/config.h
+
+-CPLIFLAGS= -I$(PLINCL) -I../../$(builddir) -I../../src
++CPLIFLAGS= -I$(PLINCL) -I../../$(builddir) -I../../src -I${X11BASE}/include
+ PL= pl
+ PLLD= plld -pl $(PL)
+ ITFOBJ= $(addprefix $(OBJDIR)/, interface.o link.o pcecall.o)
+@@ -114,14 +114,14 @@ $(XPCESO): $(SOITF) $(libXPCE) $(SOEXTR)
+ fi
+
+ sopce$(XPCESO):
+- LD_RUN_PATH="$(libdir):$$LD_RUN_PATH"; \
++ LD_RUN_PATH="$(libdir):${X11BASE}/lib:$$LD_RUN_PATH"; \
+ export LD_RUN_PATH; \
+ $(PLLD) -shared $(SOITF) -L$(XLIB) -L$(LIBDIR) -lXPCE -o $(XPCESO);
+ axpce$(XPCESO):
+- LD_RUN_PATH="$(libdir):$$LD_RUN_PATH"; \
++ LD_RUN_PATH="$(libdir):${X11BASE}/lib:$$LD_RUN_PATH"; \
+ export LD_RUN_PATH; \
+ $(PLLD) -shared $(SOITF) $(SOEXTR) -L$(LIBDIR) \
+- -lXPCE $(GCCLIB) -L$(XLIB) $(XLIBS) $(NETLIBS) -o $(XPCESO);
++ -lXPCE $(GCCLIB) -L$(XLIB) -Wl,-R${XLIB} -L${LOCALBASE}/lib -Wl,-R${LOCALBASE}/lib $(XLIBS) $(NETLIBS) -o $(XPCESO);
+
+ ################################################################$
+ # QLF generation
diff --git a/lang/swi-prolog-lite/patches/patch-af b/lang/swi-prolog-lite/patches/patch-af
new file mode 100644
index 00000000000..ef8500cf440
--- /dev/null
+++ b/lang/swi-prolog-lite/patches/patch-af
@@ -0,0 +1,22 @@
+$NetBSD: patch-af,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+--- packages/xpce/src/Makefile.in.orig Sat Jan 17 18:28:41 2004
++++ packages/xpce/src/Makefile.in
+@@ -88,7 +88,7 @@ NETLIBS=@NETLIBS@
+ XLIBS=@XLIBS@
+ LDFLAGS=-L$(XLIB) @LDFLAGS@
+ GCCLIB=@GCCLIB@
+-LDSOFLAGS=@LDSOFLAGS@ -L$(XLIB)
++LDSOFLAGS=@LDSOFLAGS@ -L$(XLIB) -Wl,-R${XLIB} -L${LOCALBASE}/lib -Wl,-R${LOCALBASE}/lib
+ SOEXTRAOBJ=@SOEXTRAOBJ@
+ SO=@SO@
+ VWS=@VWS@
+@@ -107,7 +107,7 @@ LIBS= $(XLIBS) $(NETLIBS) -lm
+
+ COFLAGS=@COFLAGS@
+ CWFLAGS=@CWFLAGS@
+-CIFLAGS=-I. -I$(srcdir) @CIFLAGS@
++CIFLAGS=-I. -I$(srcdir) @CIFLAGS@ -I${LOCALBASE}/include
+ CMFLAGS=@CMFLAGS@ @DEFS@
+ CFLAGS=$(CWFLAGS) $(COFLAGS) $(CIFLAGS) $(CMFLAGS)
+
diff --git a/lang/swi-prolog-lite/patches/patch-ag b/lang/swi-prolog-lite/patches/patch-ag
new file mode 100644
index 00000000000..c0d76124c87
--- /dev/null
+++ b/lang/swi-prolog-lite/patches/patch-ag
@@ -0,0 +1,13 @@
+$NetBSD: patch-ag,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+--- src/pl-incl.h.orig 2004-01-05 10:43:45.000000000 +0100
++++ src/pl-incl.h
+@@ -206,7 +206,7 @@ gcc.
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+ #ifndef __unix__
+-#if defined(_AIX) || defined(__APPLE__) || defined(__unix) || defined(__BEOS__)
++#if defined(_AIX) || defined(__APPLE__) || defined(__unix) || defined(__BEOS__) || defined(__NetBSD__)
+ #define __unix__ 1
+ #endif
+ #endif
diff --git a/lang/swi-prolog-lite/patches/patch-ah b/lang/swi-prolog-lite/patches/patch-ah
new file mode 100644
index 00000000000..37e0e8e54a6
--- /dev/null
+++ b/lang/swi-prolog-lite/patches/patch-ah
@@ -0,0 +1,14 @@
+$NetBSD: patch-ah,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+--- src/pl-xterm.c.orig Thu Apr 22 16:35:01 2004
++++ src/pl-xterm.c
+@@ -27,7 +27,8 @@
+ #endif
+
+ #include "pl-incl.h"
+-#if defined(HAVE_GRANTPT) && defined(O_PLMT)
++#if defined(HAVE_GRANTPT) && defined(O_PLMT) \
++ && !defined(__FreeBSD__) /* grantpt is borked on freebsd up to 5.2.1-rc */
+
+ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ Open an alternative xterm-console. Used to support multi-threading
diff --git a/lang/swi-prolog-lite/patches/patch-ai b/lang/swi-prolog-lite/patches/patch-ai
new file mode 100644
index 00000000000..5f41fc2d0cd
--- /dev/null
+++ b/lang/swi-prolog-lite/patches/patch-ai
@@ -0,0 +1,19 @@
+$NetBSD: patch-ai,v 1.1.1.1 2004/05/20 11:09:17 hubertf Exp $
+
+--- packages//xpce/src/unx/process.c.orig 2002-02-01 16:05:02.000000000 +0100
++++ packages//xpce/src/unx/process.c
+@@ -45,7 +45,13 @@ simulated using CreatePipe() and CreateP
+ reduced to the facility to terminate the inferior process.
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+-#ifdef __unix__
++/* that's not passed down, and pulling in src/pl-incl.h doesn't work
++ for some reason - HF */
++#ifdef __NetBSD__
++# define __unix__ 1
++#endif
++
++#if defined(__unix__)
+ #define HAVE_FORK 1
+ #define HAVE_PTYS 1
+ #define HAVE_KILL 1