dcf06812d84ac72e73f04c077c5e2f47f1cb3162
[ghc-hetmet.git] / ghc / compiler / Makefile
1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.7 1997/01/17 00:32:23 simonpj Exp $
3
4 TOP = ../..
5 FlexSuffixRules = YES
6 YaccSuffixRules = YES
7 SuffixRule_WantStdOnes = NO
8 include $(TOP)/ghc/mk/ghc.mk
9
10 # Problem: don't know whether GhcWithHscBuiltViaC until now, so we have
11 # to re-include rules.mk to get the correct suffix rules.
12
13 FlexSuffixRules =
14 YaccSuffixRules =
15 ifeq ($(GhcWithHscBuiltViaC),YES)
16   HC = $(GHC)
17   SuffixRule_hc_o = YES
18 else
19   HaskellSuffixRules = YES
20 endif
21 include $(TOP)/mk/rules.mk
22
23 #-----------------------------------------------------------------------------
24 # make libhsp.a
25
26 YFLAGS = -d -v
27 CFLAGS = -Iparser -I. -IcodeGen
28 ARCHIVE = libhsp.a
29 DESTDIR =  $(INSTLIBDIR_GHC)
30 UGN = $(wildcard parser/*.ugn)
31 UGNC = $(patsubst %.ugn, %.c, $(UGN))
32 UGNH = $(patsubst %.ugn, %.h, $(UGN))
33 UGNHS = $(patsubst parser/%.ugn, parser/U_%.hs, $(UGN))
34 LIBOBJS = \
35   $(patsubst %.c, %.o, $(UGNC)) parser/hslexer.o parser/hsparser.tab.o \
36   parser/id.o parser/infix.o parser/syntax.o parser/type2context.o \
37   parser/util.o
38
39 parser/%.h parser/%.c parser/U_%.hs : parser/%.ugn
40         @$(RM) $@ parser/$*.hs parser/U_$*.hs parser/$*.h
41         $(UGEN) $< || $(RM) parser/$*.h parser/$*.hs
42         @$(MV) -f parser/$*.hs parser/U_$*.hs
43         @chmod 444 parser/$*.h parser/U_$*.hs
44
45 parser/%.o : parser/%.c $(UGNH)
46         @$(RM) $@
47         $(CC) $(CFLAGS) -c $< -o $@
48
49 clean ::
50         $(RM) parser/hslexer.c parser/hsparser.tab.h parser/hsparser.tab.c
51
52 parser/hslexer.o : parser/hslexer.c parser/hsparser.tab.h
53
54 include $(TOP)/mk/lib.mk
55
56 #-----------------------------------------------------------------------------
57
58 ifeq ($(IncludeTestDirsInBuild),YES)
59   SUBDIRS = tests
60 endif
61
62 ifeq ($(Ghc2_0),YES)
63   %.hi : %_1_3.lhi
64         $(RM) $@
65         $(GHC_UNLIT) $<  $@ || ( $(RM) $@ && exit 1 )
66         @chmod 444 $@
67 else
68   %.hi : %.lhi
69         $(RM) $@
70         $(GHC_UNLIT) $<  $@ || ( $(RM) $@ && exit 1 )
71         @chmod 444 $@
72 endif
73
74 DIRS = \
75   utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
76   specialise simplCore stranal stgSyn simplStg codeGen absCSyn main \
77   reader profiling parser
78
79 # -----------------------------------------------------------------------------
80 # optional directories
81
82 ifeq ($(GhcWithDeforester),YES)
83   DIRS += deforest
84 endif
85
86 ifeq ($(GhcWithNativeCodeGen),YES)
87   DIRS += nativeGen
88 else
89   ifeq ($(GhcWithHscBuiltViaC),YES)
90     # If building via C, we *assume* that it is the distributed C files,
91     # which do not have a native-code generator in them
92   else
93     DIRS += nativeGen
94   endif
95 endif
96
97 # -----------------------------------------------------------------------------
98 # wildcard to get the lists of sources/objects
99
100 INCLUDEDIRS = $(foreach dir,$(DIRS),-i$(dir))
101 SRCS = \
102   $(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs)) \
103   $(UGNHS) rename/ParseIface.hs \
104   main/LoopHack.hc
105
106 # LoopHack.lhc is an SLPJ addition to fix a profiling problem.  See comments
107 # inside it.
108
109 LOOPS = $(patsubst %.lhi, %.hi, $(wildcard */*.lhi))
110 HCS = $(patsubst %.hs, %.hc, $(patsubst %.lhs, %.hc, $(SRCS)))
111 OBJS = \
112   $(patsubst %.hc, %.o, $(HCS)) rename/ParseIface.o \
113   parser/hsclink.o parser/hschooks.o libhsp.a \
114   main/LoopHack.o
115
116 main/LoopHack.hc : main/LoopHack.lhc
117         $(RM) $@
118         $(GHC_UNLIT) $<  $@ || ( $(RM) $@ && exit 1 )
119         @chmod 444 $@
120
121 main/LoopHack.o : main/LoopHack.hc
122         $(HC) -v -c $(HC_OPTS) $<  
123
124 # -----------------------------------------------------------------------------
125 # options for the Haskell compiler
126
127 MAKEFLAGS += --no-builtin-rules
128
129 HC_OPTS += \
130   -cpp $(HcMaxHeapFlag) $(HcMaxStackFlag) -fhaskell-1.3 \
131   -fglasgow-exts -DCOMPILING_GHC -Rghc-timing -I. -IcodeGen \
132   -InativeGen -Iparser $(INCLUDEDIRS)
133
134 # expect 12 shift/reduce conflicts and 0 reduce/reduce conflicts
135
136 ifeq ($(GhcWithHscDebug),YES)
137   HC_OPTS += -DDEBUG
138   CFLAGS += -DDEBUG
139 endif
140
141 ifneq ($(Ghc2_0),YES)
142   HC_OPTS += -fomit-derived-read -fomit-reexported-instances
143 endif
144
145 ifeq ($(GhcWithHscOptimised),YES)
146   HC_OPTS += -O -fshow-import-specs
147 endif
148
149 ifeq ($(GhcWithDeforester),NO)
150   HC_OPTS += -DOMIT_DEFORESTER
151 endif
152
153 # ----------------------------------------------------------------------------
154
155 all :: hsc libhsp.a
156
157 hsc : $(OBJS)
158 #       $(HC) -no-link-chk "-pgml time /projects/pacsoft/ghc/src/pureatria/purelink-1.2.2-solaris2/purelink gcc" $(HC_OPTS) $(EXTRA_HC_OPTS) -o $@ $^
159         $(HC) -no-link-chk "-pgml time gcc -B/projects/unsupported/gnu/sparc-sunos5/bin/g" $(HC_OPTS)  $(EXTRA_HC_OPTS) -o $@ $^
160 #       $(HC) -no-link-chk "-pgml time gcc" $(HC_OPTS)  $(EXTRA_HC_OPTS) -o $@ $^
161
162 parser/hschooks.o : parser/hschooks.c
163         @$(RM) $@
164         $(HC) -c -o $@ $(HCFLAGS) parser/hschooks.c
165
166 rename/ParseIface.hs : rename/ParseIface.y
167         @$(RM) rename/ParseIface.hs rename/ParseIface.hinfo
168         happy +RTS -K2m -H10m -RTS -g rename/ParseIface.y
169         @chmod 444 rename/ParseIface.hs
170
171 # ----------------------------------------------------------------------------
172 # Special extra dependencies for yukky ugen stuff
173
174 hspincl.h : $(UGNH)
175 parser/UgenAll.o : parser/hspincl.h
176 parser/UgenUtil.o : parser/hspincl.h
177 parser/U_constr.o : parser/hspincl.h
178 parser/U_binding.o : parser/hspincl.h
179 parser/U_pbinding.o : parser/hspincl.h
180 parser/U_entidt.o : parser/hspincl.h
181 parser/U_list.o : parser/hspincl.h
182 parser/U_literal.o : parser/hspincl.h
183 parser/U_maybe.o : parser/hspincl.h
184 parser/U_either.o : parser/hspincl.h
185 parser/U_qid.o : parser/hspincl.h
186 parser/U_tree.o : parser/hspincl.h
187 parser/U_ttype.o : parser/hspincl.h
188 reader/ReadPrefix.o : parser/hspincl.h
189
190 # ----------------------------------------------------------------------------
191 # Special flags for particular modules
192
193 absCSyn/AbsCSyn_flags           = -fno-omit-reexported-instances
194 hsSyn/HsExpr_flags              = -K2m
195 hsSyn/HsSyn_flags               = -fno-omit-reexported-instances
196 main/Main_flags                 = -fvia-C
197 basicTypes/IdInfo_flags         = -K2m
198 main/CmdLineOpts_flags          = -fvia-C
199 coreSyn/AnnCoreSyn_flags        = -fno-omit-reexported-instances
200 nativeGen/PprMach_flags         = -K2m
201 parser/UgenAll_flags            = -fvia-C '-\#include"hspincl.h"'
202 parser/UgenUtil_flags           = -fvia-C '-\#include"hspincl.h"'
203 parser/U_constr_flags           = -fvia-C '-\#include"hspincl.h"'
204 parser/U_binding_flags          = -fvia-C '-\#include"hspincl.h"'
205 parser/U_pbinding_flags         = -fvia-C '-\#include"hspincl.h"'
206 parser/U_entidt_flags           = -fvia-C '-\#include"hspincl.h"'
207 parser/U_list_flags             = -fvia-C '-\#include"hspincl.h"'
208 parser/U_literal_flags          = -fvia-C '-\#include"hspincl.h"'
209 parser/U_maybe_flags            = -fvia-C '-\#include"hspincl.h"'
210 parser/U_either_flags           = -fvia-C '-\#include"hspincl.h"'
211 parser/U_qid_flags              = -fvia-C '-\#include"hspincl.h"'
212 parser/U_tree_flags             = -fvia-C '-\#include"hspincl.h"'
213 parser/U_ttype_flags            = -fvia-C '-\#include"hspincl.h"'
214 prelude/PrimOp_flags            = -K3m
215 reader/ReadPrefix_flags         = -fvia-C '-\#include"hspincl.h"'
216 rename/ParseIface_flags         = -Onot -H16m
217 rename/RnMonad_flags            = -fvia-C
218 rename/RnSource_flags           = -H12m
219 rename/RnIfaces_flags           = -H8m
220 rename/RnNames_flags            = -H12m
221 specialise/Specialise_flags     = -Onot -H12m
222 stgSyn/StgSyn_flags             = -fno-omit-reexported-instances
223 typecheck/TcMonad_flags         = -fvia-C
224 typecheck/TcGenDeriv_flags      = -H10m
225 typecheck/TcExpr_flags          = -H10m
226 utils/Argv_flags                = -fvia-C
227 utils/CharSeq_flags             = -fvia-C
228 utils/SST_flags                 = -fvia-C
229
230 #-----------------------------------------------------------------------------
231 # make depend, clean, tags and install
232
233 depend :: $(LOOPS)
234
235 MKDEPENDHSFLAGS = -f .depend -I../includes -x HsVersions.h
236 ifeq ($(GhcWithDeforester),NO)
237   MKDEPENDHSFLAGS += -DOMIT_DEFORESTER
238 endif
239
240 ifeq ($(GhcWithHscBuiltViaC),YES)
241   MKDEPENDHSFLAGS += -o .hc
242 else
243   HS_DEP_SRCS = $(SRCS) # should add $(LOOPS) ?
244   include $(TOP)/mk/hsdepend.mk
245 endif
246
247 clean ::
248         $(RM) */*.o */*.hi $(UGNC) $(UGNH) $(UGNHS)
249         $(RM) rename/ParseIface.hs
250
251 veryclean ::
252         $(RM) */*.hc
253
254 tags ::
255         @$(RM) TAGS
256         @touch TAGS
257         $(HSTAGS) -I../includes $(HSTAGSFLAGS) $(SRCS)
258
259 install ::
260         $(INSTALL) $(INSTBINFLAGS) hsc $(INSTLIBDIR_GHC)