+To add another system library, you'll need to augment the
+Supported_syslibs variable with name and info on your addition
+to the syslib family. The info bit consist of the following:
+
+ - interface file directory
+ see the misc or posix entry for how to distinguish
+ between using installed and build tree directories.
+
+ - directory location of archives
+
+ - location of (way-independent) C support libs.
+ not all libraries need this - if you don't, just
+ give the empty string.
+ - list of syslibs you depend on.
+
+ - additional ghc command line flags that should be used.
+ - additional C compiler command line flags that should be used.
+ - link
+
+
+\begin{code}
+
+# Hash to keep track of
+%Syslibs_added = ();
+
+sub add_syslib {
+ local($syslib) = @_;
+
+ # Lifting this out of this sub brings it out of scope - why??
+ %Supported_syslibs =
+ ( lang,
+ [ # where to slurp interface files from
+ ( $INSTALLING
+ ? "$InstLibDirGhc/imports/lang"
+ : "$TopPwd/hslibs/lang:$TopPwd/hslibs/lang/monads"
+ )
+ , # where to find the archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/lang"
+ )
+ , # where to find the cbits archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/lang/cbits"
+ )
+ , '' # Syslib dependencies
+ , '' # extra ghc opts
+ , '' # extra cc opts
+ , '' # extra ld opts
+ ],
+
+ concurrent,
+ [ # where to slurp interface files from
+ ( $INSTALLING
+ ? "$InstLibDirGhc/imports/concurrent"
+ : "$TopPwd/hslibs/concurrent"
+ )
+ , # where to find the archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/concurrent"
+ )
+ , '' # where to find the cbits archive to use when linking
+ , '' # Syslib dependencies
+ , '' # extra ghc opts
+ , '' # extra cc opts
+ , '' # extra ld opts
+ ],
+
+ data,
+ [ # where to slurp interface files from
+ ( $INSTALLING
+ ? "$InstLibDirGhc/imports/data"
+ : "$TopPwd/hslibs/data:$TopPwd/hslibs/data/edison:$TopPwd/hslibs/data/edison/Assoc:$TopPwd/hslibs/data/edison/Coll:$TopPwd/hslibs/data/edison/Seq"
+ )
+ , # where to find the archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/data"
+ )
+ , '' # where to find the cbits archive to use when linking
+ , '' # Syslib dependencies
+ , '' # extra ghc opts
+ , '' # extra cc opts
+ , '' # extra ld opts
+ ],
+
+ net,
+ [ # where to slurp interface files from
+ ( $INSTALLING
+ ? "$InstLibDirGhc/imports/net"
+ : "$TopPwd/hslibs/net"
+ )
+ , # where to find the archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/net"
+ )
+ , # where to find the cbits archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/net/cbits"
+ )
+ , 'lang text' # Syslib dependencies
+ , '' # extra ghc opts
+ , '' # extra cc opts
+ , ( $TargetPlatform =~ /-solaris2$/ ? '-lnsl -lsocket' : '')
+ ],
+
+ posix,
+ [ # where to slurp interface files from
+ ( $INSTALLING
+ ? "$InstLibDirGhc/imports/posix"
+ : "$TopPwd/hslibs/posix"
+ )
+ , # where to find the archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/posix"
+ )
+ , # where to find the cbits archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/posix/cbits"
+ )
+ , 'lang' # Syslib dependencies
+ , '' # extra ghc opts
+ , '' # extra cc opts
+ , '' # extra ld opts
+ ],
+
+ text,
+ [ # where to slurp interface files from
+ ( $INSTALLING
+ ? "$InstLibDirGhc/imports/text"
+ : "$TopPwd/hslibs/text:$TopPwd/hslibs/text/html"
+ )
+ , # where to find the archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/text"
+ )
+ , # where to find the cbits archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/text/cbits"
+ )
+ , 'lang' # Syslib dependencies
+ , '' # extra ghc opts
+ , '' # extra cc opts
+ , '' # extra ld opts
+ ],
+
+ util,
+ [ # where to slurp interface files from
+ ( $INSTALLING
+ ? "$InstLibDirGhc/imports/util"
+ : "$TopPwd/hslibs/util"
+ )
+ , # where to find the archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/util"
+ )
+ , # where to find the cbits archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/util/cbits"
+ )
+ , 'lang concurrent' # Syslib dependencies
+ , '' # extra ghc opts
+ , '' # extra cc opts
+ , '' # extra ld opts
+ ],
+
+ win32,
+ [ # where to slurp interface files from
+ ( $INSTALLING
+ ? "$InstLibDirGhc/imports/win32"
+ : "$TopPwd/hslibs/win32/src"
+ )
+ , # where to find the archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hslibs/win32/src"
+ )
+ , ''
+ , 'lang' # Syslib dependencies
+ , '' # extra ghc opts
+ , '' # extra cc opts
+ , '-luser32 -lgdi32' # extra ld opts
+ ],
+
+ com,
+ [ # where to slurp interface files from
+ ( $INSTALLING
+ ? "$InstLibDirGhc/imports/com"
+ : "$TopPwd/hdirect/lib"
+ )
+ , # where to find the archive to use when linking
+ ( $INSTALLING
+ ? "$InstLibDirGhc"
+ : "$TopPwd/hdirect/lib"
+ )
+ , ''
+ , 'lang' # Syslib dependencies
+ , '' # extra ghc opts
+ , '' # extra cc opts
+ , '-luser32 -lole32 -loleaut32 -ladvapi32'
+ # extra ld opts
+ ]
+ );
+
+ # check if it's supported..
+
+ if ( !exists $Supported_syslibs{$syslib} ) {
+ print STDERR "$Pgm: no such system library (-syslib): $syslib\n";
+ $Status++;
+ return;
+ }
+
+ # This check is here to avoid syslib loops from
+ # spoiling the party. A side-effect of it is that
+ # it disallows multiple mentions of a syslib on a command-line,
+ # explicit *and* implicit ones (i.e., "-syslib lang -syslib misc"
+ # is not equal to "-syslib lang -syslib misc -syslib lang",
+ # which it needs to be)
+ #
+ # Since our current collection of syslibs don't have any
+ # loops, this test is disabled.
+ #
+ # ToDo: loop avoidance scheme when the need arises
+ #
+ #return if ( exists $Syslibs_added{$syslib} );
+
+ $Syslibs_added{$syslib} = 1;
+
+ local ($hi_dirs, $lib_dir, $lib_cbits_dir,
+ $syslib_deps, $syslib_ghc_opts,
+ $syslib_cc_opts, $syslib_ld_opts) = @{ $Supported_syslibs{$syslib} };
+
+ foreach(split(':',$hi_dirs)) {
+ unshift(@SysImport_dir, $_);
+ }
+ push(@SysLibrary_dir, $lib_dir);
+ push(@SysLibrary_dir, $lib_cbits_dir) if ( $lib_cbits_dir ne '');
+
+ push(@SysLibrary, "-lHS$syslib");
+ push(@SysLibrary, "-lHS${syslib}_cbits") if ( $lib_cbits_dir ne '');
+ push(@SysLibrary, $syslib_ld_opts) if ($syslib_ld_opts ne '');
+
+ # Add on any extra dependencies.
+ foreach $lib (split(' ',$syslib_deps)) {
+ &add_syslib($lib);
+ }
+}
+\end{code}
+