1.3. Practical examples

The version of ASDF which is shipped with ECL has been further customized to allow building all the binary files mentioned in Table 1.1. The procedure to do this is documented in a detailed and formal manual page for asdf:make-build. However, since practice is the best teacher, we will show a couple of examples of how to use this function before moving into the formal specification.

In /ecl/examples/asdf you will find a very simple example that can be built in different forms. The example is built around a system definition file that depends on two sources, file1.lisp and file2.lisp:

(defsystem #:example
    :serial t
    :components ((:file "file1")
		 (:file "file2")))

We can built these files into a single FASL file, as shown below. Notice how there is a single file with the name *.fas, but there are two object files generated from their respective sources, file1.o, file2.o.

> (require 'asdf)
;;; Loading #P"/home/jlr/lib/ecl/asdf.fas"
("ASDF")
> (asdf:make-build :example :type :fasl)
...
NIL
> (directory "*.o")
(#P"/home/jlr/src/ecls-new/examples/asdf/file2.o"
 #P"/home/jlr/src/ecls-new/examples/asdf/file1.o")
> (directory "*.fas")
(#P"/home/jlr/src/ecls-new/examples/asdf/example.fas")
> (load "example.fas")
;;; Loading "/home/jlr/src/ecls-new/examples/asdf/example.fas"
======================================================================
We are now executing FILE1.LSP
TEST-FUNCTION has been created
We are now executing FILE2.LSP
Calling TEST-FUNCTION in FILE2.LSP
1 + 1 is equal to 2
Finished
======================================================================
"/home/jlr/src/ecls-new/examples/asdf/example.fas"

The previous sources may be combined into a single program, as shown below. Notice that we choose to execute ext:quit right after all compiled files have run. If you do not supply this parameter, example will jump to the lisp toplevel right after that.

> (asdf:make-build :example :type :program
                   :epilogue-code '(ext:quit 0))
NIL
> (ext:system "./example")
======================================================================
We are now executing FILE1.LSP
TEST-FUNCTION has been created
We are now executing FILE2.LSP
Calling TEST-FUNCTION in FILE2.LSP
1 + 1 is equal to 2
Finished
======================================================================