[project @ 1996-11-21 16:45:53 by simonm]
[ghc-hetmet.git] / ghc / lib / Makefile.libHS
1 #-----------------------------------------------------------------------------
2 # $Id: Makefile.libHS,v 1.2 1996/11/21 16:47:42 simonm 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 # Everything here *must* be compiled with the Glasgow Haskell compiler.
11 # (Hence the use of $(GHC), rather than $(HC).)
12 # The driver will give warnings if -split-objs, but that's cool...
13
14 GHC_OPTS = \
15   -recomp -cpp -dcore-lint -irequired -fusing-ghc-internals -fvia-C \
16   $(HcMaxHeapFlag) $(EXTRA_HC_OPTS)
17
18 SRCS = $(wildcard prelude/*.hs required/*.hs concurrent/*.hs)
19 OBJS = $(SRCS:.hs=.$(suffix)_o)
20
21 #-----------------------------------------------------------------------------
22 # Rules for building various types of objects from HS files
23
24 # Note: the $(*_flags) module-specific flags come after the $(GHC_OPTS_..) 
25 # so that things like -O can be overriden on a per-module basis.
26
27 ifeq ($(SplitObjs),YES)
28 LIB_GHC = $(GHC) $(GHCFLAGS) -split-objs $(notdir $*) -o $@ -c
29 else
30 LIB_GHC = $(GHC) $(GHCFLAGS) -o $@ -c
31 endif
32
33 ifneq ($(GhcWithHscBuiltViaC),YES)
34 %.o : %.hs
35         $(LIB_GHC) $($*_flags) $*.hs
36
37 %.$(suffix)_o : %.hs
38         $(LIB_GHC) $(GHC_OPTS_$(suffix)) $($*_flags) $*.hs
39
40 else # $(GhcWithHscBuiltViaC) == YES
41
42 %.$(suffix)_o : %.hc
43         $(LIB_GHC) $(GHC_OPTS_$(suffix)) $($*_flags) $*.hs
44 endif
45
46 #-----------------------------------------------------------------------------
47 # build the library itself...
48
49 ifeq ($(suffix), norm)
50 LIB = libHS.a                   # this one is special
51 else
52 LIB = libHS_$(suffix).a
53 endif
54
55 $(LIB) : $(OBJS)
56         @$(RM) $@
57         $(AR) $@ $^
58
59 all :: $(LIB)
60
61 clean ::
62         $(RM) $(LIB)
63         $(RM) $(OBJS)
64
65 install :: $(LIB)
66         $(INSTALL) $(INSTLIBFLAGS) $(LIB) $(INSTLIBDIR_GHC)
67         $(RANLIB) $(INSTLIBDIR_GHC)/$(LIB)
68
69 veryclean ::
70         $(RM) */*.hc */*.hi
71
72 #-----------------------------------------------------------------------------
73 # per-module flags
74
75 # The -Onots are only because -O would not go through on
76 # a reasonably-sized machine (i.e., one I have)
77
78 prelude/Prelude_flags = \
79    -iprelude -fglasgow-exts -fcompiling-ghc-internals Prelude \
80    -fno-implicit-prelude '-\#include"cbits/stgio.h"' -H18m -Onot
81 prelude/GHCbase_flags = \
82   -iprelude -fglasgow-exts -fcompiling-ghc-internals GHCbase \
83   '-\#include"cbits/stgio.h"' -H20m -monly-2-regs -Onot
84 prelude/GHCerr_flags = \
85   -iprelude -fglasgow-exts -fcompiling-ghc-internals GHCerr -H12m -Onot
86 prelude/GHCps_flags = \
87   -iprelude -fglasgow-exts '-\#include"cbits/stgio.h"' -monly-3-regs -Onot
88 prelude/GHCio_flags = \
89   -iprelude -fglasgow-exts '-\#include"cbits/stgio.h"' -Onot
90 prelude/GHCmain_flags = -iprelude -fglasgow-exts
91 prelude/PreludeGlaST_flags = -iprelude -fglasgow-exts
92
93 required/Array_flags = -fglasgow-exts -iprelude -Onot
94 required/Directory_flags = \
95   -fglasgow-exts '-\#include"cbits/stgio.h"' -monly-3-regs
96 required/IO_flags = -fglasgow-exts '-\#include"cbits/stgio.h"'
97 required/Ix_flags = -fglasgow-exts
98 required/System_flags = -fglasgow-exts '-\#include"cbits/stgio.h"'
99
100 concurrent/Merge_flags = -iconcurrent
101 concurrent/Parallel_flags = -fglasgow-exts
102 concurrent/Concurrent_flags = -iconcurrent
103
104 #-----------------------------------------------------------------------------
105 # Depend and install stuff
106
107 MKDEPENDHS_OPTS += -I$(GHC_INCLUDES)
108 MKDEPENDHS_OPTS += -irequired:prelude:ghc:hbc:glaExts:concurrent
109 MKDEPENDHS_OPTS += $(foreach way,$(WAY_SUFFIXES),-s .$(way))
110
111 # Todo: make this a generic include of hsdepend.mk or something.
112 depend :: $(SRCS)
113         $(MKDEPENDHS) $(MKDEPENDHSFLAGS) -- $(GHCFLAGS) -- -f .depend $(SRCS)
114
115 #-----------------------------------------------------------------------------
116 # install hi files
117
118 ifeq ($(suffix),norm)
119 HI_FILES = $(SRCS:.hs=.hi)
120 else
121 HI_FILES = $(SRCS:.hs=.$(suffix)_hi)
122 endif
123
124 install :: $(HI_FILES)
125         $(INSTALL) $(INSTDATAFLAGS) $(HI_FILES) $(INSTIMPORTSDIR_GHC)