#!/bin/bash

# This requires that "dessy.pkg" has been added properly.
# I.e. update the paths in the file, then do 
#         ghc-pkg -a < dessy.pkg


ghc --make Dessy -fglasgow-exts +RTS -tstderr
# Make a lot of .o files.

# Make a big .o file for use by GHCi.
ld -r -o dessy.o [A-Z]*.o
# GHCi loads that automatically with the package.

# But when the sources (or .o's) are in its search path (including .),
# it loads them all independently...


# Make an .a file for later use by GHC.
rm libdessy.a
ar qscv libdessy.a dessy.o
# GHC uses it by passing -ldessy to gcc.  That's simple!


# Earlier I did it like this, which produces exactly the same .o,
# and a slightly larger .a.
#    rm dessy.o
#    rm libdessy.a
#    ar qscv libdessy.a *.o
#    ld -r -o dessy.o -whole-archive -ldessy -L.
# (This was because I learned about "ar" before I learned about "ld
# -r".)  Of course the above is more obvious, if one knows...

