1dba5a28e5e4d49ef7e036b0099cb562085e10b8
[ghc-hetmet.git] / ghc / lib / Makefile.libHS
1 #-----------------------------------------------------------------------------
2 # $Id: Makefile.libHS,v 1.4 1997/01/06 21:10:03 simonpj 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 GHC_OPTS = \
25   -recomp -cpp -fglasgow-exts -fvia-C \
26   $(HcMaxHeapFlag) $(EXTRA_HC_OPTS)
27
28 SRCS = $(wildcard ghc/*.lhs required/*.lhs glaExts/*.lhs concurrent/*.lhs)
29 ifeq ($(suffix), norm)
30 OBJS = $(SRCS:.lhs=.o)
31 else
32 OBJS = $(SRCS:.lhs=.$(suffix)_o)
33 endif
34
35 #-----------------------------------------------------------------------------
36 # Rules for building various types of objects from HS files
37
38 # Note: the $(*_flags) module-specific flags come after the $(GHC_OPTS_..) 
39 # so that things like -O can be overriden on a per-module basis.
40
41 ifeq ($(SplitObjs),YES)
42 LIB_GHC = $(GHC) $(GHCFLAGS) -split-objs $(notdir $*) -o $@ -c
43 else
44 LIB_GHC = $(GHC) $(GHCFLAGS) -o $@ -c
45 endif
46
47 ifneq ($(GhcWithHscBuiltViaC),YES)
48 %.o : %.lhs
49         $(LIB_GHC) $($*_flags) $*.lhs
50
51 %.$(suffix)_o : %.lhs
52         $(LIB_GHC) $(GHC_OPTS_$(suffix)) $($*_flags) $*.hs
53
54 else # $(GhcWithHscBuiltViaC) == YES
55
56 %.$(suffix)_o : %.hc
57         $(LIB_GHC) $(GHC_OPTS_$(suffix)) $($*_flags) $*.hs
58 endif
59
60 #-----------------------------------------------------------------------------
61 # build the library itself...
62
63 ifeq ($(suffix), norm)
64 LIB = libHS.a                   # this one is special
65 else
66 LIB = libHS_$(suffix).a
67 endif
68
69 $(LIB) : $(OBJS)
70         @$(RM) $@
71         $(AR) $@ $^
72
73 all :: $(LIB)
74
75 clean ::
76         $(RM) $(LIB)
77         $(RM) $(OBJS)
78
79 install :: $(LIB)
80         $(INSTALL) $(INSTLIBFLAGS) $(LIB) $(INSTLIBDIR_GHC)
81         $(RANLIB) $(INSTLIBDIR_GHC)/$(LIB)
82
83 veryclean ::
84         $(RM) */*.hc */*.hi
85
86 #-----------------------------------------------------------------------------
87 # per-module flags
88
89 # The -Onots are only because -O would not go through on
90 # a reasonably-sized machine (i.e., one I have)
91
92 ghc/PackedString_flags   = '-\#include"cbits/stgio.h"' -monly-3-regs
93 required/Directory_flags = '-\#include"cbits/stgio.h"' -monly-3-regs
94 required/System_flags    = '-\#include"cbits/stgio.h"'
95
96 concurrent/Merge_flags = -iconcurrent
97 concurrent/Parallel_flags = -fglasgow-exts
98 concurrent/Concurrent_flags = -iconcurrent
99
100 #-----------------------------------------------------------------------------
101 # Depend and install stuff
102
103 MKDEPENDHS_OPTS += -I$(GHC_INCLUDES)
104 MKDEPENDHS_OPTS += -irequired:ghc:hbc:glaExts:concurrent
105 MKDEPENDHS_OPTS += $(foreach way,$(WAY_SUFFIXES),-s .$(way))
106
107 # Todo: make this a generic include of hsdepend.mk or something.
108 depend :: $(SRCS)
109         $(MKDEPENDHS) $(MKDEPENDHSFLAGS) -- $(GHCFLAGS) -- -f .depend $(SRCS)
110
111 #-----------------------------------------------------------------------------
112 # install hi files
113
114 ifeq ($(suffix),norm)
115 HI_FILES = $(SRCS:.hs=.hi)
116 else
117 HI_FILES = $(SRCS:.hs=.$(suffix)_hi)
118 endif
119
120 install :: $(HI_FILES)
121         $(INSTALL) $(INSTDATAFLAGS) $(HI_FILES) $(INSTIMPORTSDIR_GHC)