[project @ 1997-01-22 08:00:38 by sof]
[ghc-hetmet.git] / ghc / lib / Makefile.libHS
1 #-----------------------------------------------------------------------------
2 # $Id: Makefile.libHS,v 1.10 1997/01/22 08:01:26 sof Exp $
3
4 TOP = ../..
5 include $(TOP)/ghc/mk/ghc.mk
6
7 # per-build options: shared with runtime system
8 include ../mk/buildflags.mk
9
10 #       ============= ADDED BY SIMON =============
11 ifeq ($(GhcWithHscBuiltViaC),YES)
12   HC = $(GHC)
13   SuffixRule_hc_o = YES
14 else
15   HaskellSuffixRules = YES
16 endif
17 include $(TOP)/mk/rules.mk
18 #       ===========================================
19
20 # Everything here *must* be compiled with the Glasgow Haskell compiler.
21 # (Hence the use of $(GHC), rather than $(HC).)
22 # The driver will give warnings if -split-objs, but that's cool...
23
24 GHCFLAGS = \
25   -recomp -cpp -fglasgow-exts -fvia-C \
26   $(HcMaxHeapFlag) $(EXTRA_HC_OPTS)
27
28 #-----------------------------------------------------------------------------
29 # Rules for building various types of objects from HS files
30
31 # Note: the $(*_flags) module-specific flags come after the $(GHC_OPTS_..) 
32 # so that things like -O can be overriden on a per-module basis.
33
34 ifeq ($(SplitObjs),YES)
35 LIB_GHC = $(GHC) $(GHCFLAGS) -split-objs $(notdir $*) -o $@ -c
36 else
37 LIB_GHC = $(GHC) $(GHCFLAGS) -o $@ -c
38 endif
39
40 ifneq ($(GhcWithHscBuiltViaC),YES)
41 %.o : %.lhs
42         $(LIB_GHC) $($*_flags) $*.lhs
43
44 %.$(suffix)_o : %.lhs
45         $(LIB_GHC) $(GHC_OPTS_$(suffix)) $($*_flags) $*.lhs
46
47 else # $(GhcWithHscBuiltViaC) == YES
48
49 %.$(suffix)_o : %.hc
50         $(LIB_GHC) $(GHC_OPTS_$(suffix)) $($*_flags) $*.hc
51 endif
52
53 #-----------------------------------------------------------------------------
54 # build the library itself...
55
56 ifeq ($(suffix), norm)
57 ARCHIVE = libHS.a                       # this one is special
58 else
59 ARCHIVE = libHS_$(suffix).a
60 endif
61
62 SRCS    = $(wildcard required/*.lhs ghc/*.lhs glaExts/*.lhs concurrent/*.lhs)
63 ifeq ($(suffix), norm)
64 LIBOBJS = $(SRCS:.lhs=.o)
65 else
66 LIBOBJS = $(SRCS:.lhs=.$(suffix)_o)
67 endif
68
69 DESTDIR = $(INSTLIBDIR_GHC)
70
71 include $(TOP)/mk/lib.mk
72
73 #-----------------------------------------------------------------------------
74 # per-module flags
75
76 # The -Onots are only because -O would not go through on
77 # a reasonably-sized machine (i.e., one I have)
78
79 ghc/PackedString_flags   = '-\#include"cbits/stgio.h"' -monly-3-regs
80 required/Directory_flags = '-\#include"cbits/stgio.h"' -monly-3-regs
81 required/System_flags    = '-\#include"cbits/stgio.h"'
82
83 #ghc/ArrBase_flags      = '-fno-implicit-prelude'
84 #ghc/IOBase_flags       = '-fno-implicit-prelude'
85 #ghc/IOHandle_flags     = '-fno-implicit-prelude'
86 #ghc/PrelBase_flags     = '-fno-implicit-prelude'
87 #ghc/PrelIO_flags       = '-fno-implicit-prelude'
88 #ghc/PrelList_flags     = '-fno-implicit-prelude'
89 #ghc/PrelNum_flags      = '-fno-implicit-prelude'
90 #ghc/PrelRead_flags     = '-fno-implicit-prelude'
91 #ghc/PrelTup_flags      = '-fno-implicit-prelude'
92 #ghc/STBase_flags       = '-fno-implicit-prelude'
93 #glaExts/Foreign_flags  = '-fno-implicit-prelude'
94 #glaExts/PackedString_flags     = '-fno-implicit-prelude'
95 #glaExts/ST_flags       = '-fno-implicit-prelude'
96 #required/Array_flags   = '-fno-implicit-prelude'
97 #required/Char_flags    = '-fno-implicit-prelude'
98 #required/IO_flags      = '-fno-implicit-prelude'
99 #required/Ix_flags      = '-fno-implicit-prelude'
100 #required/Maybe_flags   = '-fno-implicit-prelude'
101 #required/Monad_flags   = '-fno-implicit-prelude'
102 #required/Ratio_flags   = '-fno-implicit-prelude'
103
104 concurrent/Merge_flags = -iconcurrent
105 concurrent/Parallel_flags = -fglasgow-exts
106 concurrent/Concurrent_flags = -iconcurrent
107
108 #-----------------------------------------------------------------------------
109 # Depend and install stuff
110
111 # temp soln until ghcconfig.mk leaves 1.2 behind.
112 MKDEPENDHS = $(GHC) $(GHCFLAGS) -M
113
114 MKDEPENDHS_OPTS += -I$(GHC_INCLUDES)
115 MKDEPENDHS_OPTS += -irequired:ghc:hbc:glaExts:concurrent
116 MKDEPENDHS_OPTS += $(foreach way,$(filter-out norm, $(WAY_SUFFIXES)),-optdep-s -optdep$(way))
117
118 # Todo: make this a generic include of hsdepend.mk or something.
119 depend :: $(SRCS)
120         $(MKDEPENDHS) $(MKDEPENDHSFLAGS) -optdep-f -optdep.depend $(GHCFLAGS) $(SRCS)
121
122 # Copy the crucial IOBase hi file over
123 hiboot ::
124         cp ghc/IOBase.hi-boot ghc/IOBase.hi
125         cp ghc/Main.hi-boot ghc/Main.hi
126         cp ghc/GHC.hi-boot ghc/GHC.hi
127         
128 #-----------------------------------------------------------------------------
129 # install hi files
130
131 ifeq ($(suffix),norm)
132 HI_FILES = $(SRCS:.lhs=.hi)
133 else
134 HI_FILES = $(SRCS:.lhs=.$(suffix)_hi)
135 endif
136
137 install :: $(HI_FILES)
138         $(INSTALL) $(INSTDATAFLAGS) $(HI_FILES) $(INSTIMPORTSDIR_GHC)