Hi Simon, I eventually managed to produce an executable (but see
below) with the following patches (note that the address family
enumeration below is *not* identical to freebsd):

$NetBSD$

--- ghc/lib/misc/SocketPrim.lhs Wed Sep 15 09:06:26 1999
+++ ghc/lib/misc/SocketPrim.lhs Tue Dec 14 13:00:08 1999
@@ -941,10 +941,56 @@

 #endif

+#if netbsd_TARGET_OS || netbsd_elf_TARGET_OS
+
+data Family =
+               AF_UNSPEC       -- unspecified
+      |        AF_UNIX         -- local to host (pipes, portals)
+      |        AF_INET         -- internetwork: UDP, TCP, etc.
+      |        AF_IMPLINK      -- arpanet imp addresses
+      |        AF_PUP          -- pup protocols: e.g. BSP
+      |        AF_CHAOS        -- mit CHAOS protocols
+      |        AF_NS           -- XEROX NS protocols
+      |        AF_ISO          -- ISO protocols
+--    |        AF_OSI is the same as AF_ISO
+      |        AF_ECMA         -- european computer manufacturers
+      |        AF_DATAKIT      -- datakit protocols
+      |        AF_CCITT        -- CCITT protocols, X.25 etc
+      |        AF_SNA          -- IBM SNA
+      | AF_DECnet      -- DECnet
+      | AF_DLI         -- DEC Direct data link interface
+      | AF_LAT         -- LAT
+      |        AF_HYLINK       -- NSC Hyperchannel
+      |        AF_APPLETALK    -- Apple Talk
+      |        AF_ROUTE        -- Internal Routing Protocol
+      |        AF_LINK         -- Link layer interface
+      |        Pseudo_AF_XTP   -- eXpress Transfer Protocol (no AF)
+      | AF_COIP         -- connection-oriented IP, aka ST II
+      | AF_CNT         -- Computer Network Technology
+      | Psuedo_AF_RTIP  -- Help Identify RTIP packets
+      | AF_IPX         -- Novell Internet Protocol
+      | AF_INET6       -- IPv6
+      | Pseudo_AF_PIP   -- Help Identify PIP packets
+      | AF_ISDN         -- Integrated Services Digital Network
+--    | AF_E164        is the same as AF_ISDN
+      | AF_NATM                -- native ATM access
+      | AF_ARP         -- (rev.) addr. res. prot. (RFC 826)
+      | Pseudo_AF_KEY   -- Internal key-management function
+      | Pseudo_AF_HDRCMPLT -- Used by BPF to not rewrite hdrs in iface output
+      | AF_MAX
+       deriving (Eq, Ord, Ix, Show)
+
+packFamily = index (AF_UNSPEC, AF_MAX)
+unpackFamily family = (range (AF_UNSPEC, AF_MAX))!!family
+
+#endif
+
+
 -- Alpha running OSF or a SPARC with SunOS, rather than Solaris.

 #if osf1_TARGET_OS || osf3_TARGET_OS || sunos4_TARGET_OS || hpux_TARGET_OS || \
-       aix_TARGET_OS || freebsd2_TARGET_OS || freebsd3_TARGET_OS
+       aix_TARGET_OS || freebsd2_TARGET_OS || freebsd3_TARGET_OS || \
+       netbsd_TARGET_OS || netbsd_elf_TARGET_OS
 data SocketType =
          Stream
        | Datagram
diff -u -r old/fptools/ghc/rts/MBlock.c work.i386/fptools/ghc/rts/MBlock.c
$NetBSD$

--- ghc/rts/MBlock.c    Wed Sep 15 09:06:54 1999
+++ ghc/rts/MBlock.c    Tue Dec 14 10:27:15 1999
@@ -47,6 +47,10 @@
  */
 #define ASK_FOR_MEM_AT 0x50000000

+#elif netbsd_TARGET_OS
+/* NetBSD i386 shared libs are at 0x40000000
+ */
+#define ASK_FOR_MEM_AT 0x50000000
 #elif linux_TARGET_OS
 /* Any ideas?
  */
$NetBSD$

--- ghc/driver/ghc-asm.lprl     Wed Sep 15 09:05:45 1999
+++ ghc/driver/ghc-asm.lprl     Tue Dec 14 22:09:04 1999
@@ -104,7 +104,7 @@
     $T_HDR_direct   = "\t.SPACE \$TEXT\$\n\t.SUBSPA \$CODE\$\n\t\.align 4\n";

     #--------------------------------------------------------#
-    } elsif ( $TargetPlatform =~ 
/^i386-.*-(linuxaout|freebsd2|nextstep3|cygwin32|mingw32)$/ ) {
+    } elsif ( $TargetPlatform =~ 
+/^i386-.*-(linuxaout|freebsd2|netbsd|nextstep3|cygwin32|mingw32)$/ ) {
                                # NeXT added but not tested. CaS

     $T_STABBY      = 1; # 1 iff .stab things (usually if a.out format)
@@ -135,12 +135,12 @@
     $T_HDR_direct   = "\.text\n\t\.align 2,0x90\n";

     #--------------------------------------------------------#
-    } elsif ( $TargetPlatform =~ /^i386-.*-(solaris2|linux|freebsd3)$/ ) {
+    } elsif ( $TargetPlatform =~ /^i386-.*-(solaris2|linux|freebsd3|netbsd_elf)$/ ) {

     $T_STABBY      = 0; # 1 iff .stab things (usually if a.out format)
     $T_US          = ''; # _ if symbols have an underscore on the front
     $T_PRE_APP     = # regexp that says what comes before APP/NO_APP
-                     ($TargetPlatform =~ /-(linux|freebsd3)$/) ? '#' : '/' ;
+                     ($TargetPlatform =~ /-(linux|freebsd3|netbsd_elf)$/) ? '#' : '/' 
+;
     $T_CONST_LBL    = '^\.LC(\d+):$'; # regexp for what such a lbl looks like
     $T_POST_LBL            = ':';
     $T_X86_PRE_LLBL_PAT = '\.L';
@@ -150,7 +150,7 @@
     $T_MOVE_DIRVS   = 
'^(\s*(\.(p2)?align\s+\d+(,0x90)?|\.globl\s+\S+|\.text|\.data|\.section\s+.*|\.type\s+.*|\.Lfe.*\n\t\.size\s+.*|\.size\s+.*|\.ident.*)\n)';
     $T_COPY_DIRVS   = '\.(globl)';

-    if ( $TargetPlatform =~ /freebsd3/ ) {
+    if ( $TargetPlatform =~ /freebsd3|netbsd_elf/ ) {
         $T_hsc_cc_PAT   = '\.ascii.*\)(hsc|cc) (.*)\\\\11"\n\t\.ascii\s+"(.*)\\\\0"';
     } else {
         $T_hsc_cc_PAT   = '\.string.*\)(hsc|cc) (.*)\\\\t(.*)"';

and:

GhcLibHcOpts = -O -split-objs -odir $*
SRC_HAPPY_OPTS += -c
GhcLibWays=
GhcLibsWithReadline = YES
SRC_HC_OPTS += -L/usr/pkg/lib -I/usr/pkg/include

as build.mk

however compiling:

main = "better dead than imperative"

produces:

foo.hs:1:
    Couldn't match `IO t' against `[Char]'
        Expected type: IO t
        Inferred type: [Char]
    When checking that `main' has the required type

Compilation had errors

explicit use of module Main (as used in nfib) seems to work, however.

compiling Say.hs (from hugs), produces:

proff@suburbia:/pkg/share/hugs/demos$ ghc Say.hs

Say.hs:44: Variable not in scope: `isUpper'

Say.hs:45: Variable not in scope: `isLower'

Say.hs:46: Variable not in scope: `isSpace'

Say.hs:47: Variable not in scope: `isDigit'

Compilation had errors

root@suburbia:/pkg/share/hugs/demos# ghc Literate.lhs

Literate.lhs:50: Variable not in scope: `isSpace'

Compilation had errors

root@suburbia:/pkg/share/hugs/demos# ghc Stack.hs
Stack.hs:5: parse error on input `in'

Compilation had errors

some of the other demos seem happy though.

Cheers,
Julian.

-- 
Stefan Kahrs in [Kah96] discusses the
   notion of completeness--programs which never go wrong can be
   type-checked--which complements Milner's notion of
   soundness--type-checked programs never go wrong [Mil78].

Reply via email to