Unix pseudo-executables

The following still works, although the new C-ification technique (see directories pl2c, dynpl2c) can now create true one-file standalones.

It
is possible to create (as in the past) a small runtime application from <file> or <file>.pl as follows:

  ?-make_appl(<file>).

Note:
the file must contain a clause

   main(X):-...

That's
where execution starts. BinProlog's shell (the precompiled wam.bp) file is nothing but such an application which starts with a toplevel loop i.e. something like:

   main(X):-toplevel(X).

Deliver
the appropriate wam ru or ru.exe file (the Prolog engine) with your application. The user must type:

$ ru newappl.bp

to
start it.

As
a new feature, you can override this behaviour by simple defining a predicate main/0 which then becomes the new starting point.

You can also generate (on UNIX systems) stand-alone executables that dynamically start the emulator (thanks to Peter Reintjes for suggesting this). You can do something like:

?- make_executable_unix_appl('./ru','progs/hello.pl','hello').

Then
you can run it directly from the unix prompt:

$ hello

The
code of this primitive is at the end of the file co.pl.

Again, we recommend using the C-ification technique which can already speed up most applications and in the future will generate very fast code competitive with native code compilers.

You
can bootstrap the compiler, after modifying the *.pl files by:

  ?- boot.
  ?- make.

or, similarly for any other project having a top *.pro file:

  ?-make(ProjectFile).
  ?-make(ProjectFile,Module).

or

  ?-cmake(ProjectFile).
  ?-cmake(ProjectFile,Module).

if you intend to generate C-code and possibly hide non-public predicates inside a module.

This
allows to integrate your preferences and extensions written in Prolog to the BinProlog kernel.

Make
sure you keep a copy the original wam.bp in a safe place, in case things go wrong when you type ?-boot.