[project @ 1996-12-18 18:42:48 by dnt]
[ghc-hetmet.git] / ghc / compiler / Makefile
1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.4 1996/12/18 18:42:48 dnt 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
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 LOOPS = $(patsubst %.lhi, %.hi, $(wildcard */*.lhi))
105 HCS = $(patsubst %.hs, %.hc, $(patsubst %.lhs, %.hc, $(SRCS)))
106 OBJS = \
107   $(patsubst %.hc, %.o, $(HCS)) rename/ParseIface.o \
108   parser/hsclink.o parser/hschooks.o libhsp.a
109
110 # -----------------------------------------------------------------------------
111 # options for the Haskell compiler
112
113 MAKEFLAGS += --no-builtin-rules
114
115 HC_OPTS += \
116   -cpp $(HcMaxHeapFlag) $(HcMaxStackFlag) -fhaskell-1.3 \
117   -fglasgow-exts -DCOMPILING_GHC -Rghc-timing -I. -IcodeGen \
118   -InativeGen -Iparser $(INCLUDEDIRS)
119
120 # expect 12 shift/reduce conflicts and 0 reduce/reduce conflicts
121
122 ifeq ($(GhcWithHscDebug),YES)
123   HC_OPTS += -DDEBUG
124   CFLAGS += -DDEBUG
125 endif
126
127 ifneq ($(Ghc2_0),YES)
128   HC_OPTS += -fomit-derived-read -fomit-reexported-instances
129 endif
130
131 ifeq ($(GhcWithHscOptimised),YES)
132   HC_OPTS += -O -fshow-import-specs
133 endif
134
135 ifeq ($(GhcWithDeforester),NO)
136   HC_OPTS += -DOMIT_DEFORESTER
137 endif
138
139 # ----------------------------------------------------------------------------
140
141 all :: hsc libhsp.a
142
143 hsc : $(OBJS)
144         $(HC) $(HC_OPTS) -o $@ $^
145
146 parser/hschooks.o : parser/hschooks.c
147         @$(RM) $@
148         $(HC) -c -o $@ $(HCFLAGS) parser/hschooks.c
149
150 rename/ParseIface.hs : rename/ParseIface.y
151         @$(RM) rename/ParseIface.hs rename/ParseIface.hinfo
152         happy -g rename/ParseIface.y
153         @chmod 444 rename/ParseIface.hs
154
155 # ----------------------------------------------------------------------------
156 # Special extra dependencies for yukky ugen stuff
157
158 hspincl.h : $(UGNH)
159 parser/UgenAll.o : parser/hspincl.h
160 parser/UgenUtil.o : parser/hspincl.h
161 parser/U_constr.o : parser/hspincl.h
162 parser/U_binding.o : parser/hspincl.h
163 parser/U_pbinding.o : parser/hspincl.h
164 parser/U_entidt.o : parser/hspincl.h
165 parser/U_list.o : parser/hspincl.h
166 parser/U_literal.o : parser/hspincl.h
167 parser/U_maybe.o : parser/hspincl.h
168 parser/U_either.o : parser/hspincl.h
169 parser/U_qid.o : parser/hspincl.h
170 parser/U_tree.o : parser/hspincl.h
171 parser/U_ttype.o : parser/hspincl.h
172 reader/ReadPrefix.o : parser/hspincl.h
173
174 # ----------------------------------------------------------------------------
175 # Special flags for particular modules
176
177 absCSyn/AbsCSyn_flags           = -fno-omit-reexported-instances
178 hsSyn/HsExpr_flags              = -K2m
179 hsSyn/HsSyn_flags               = -fno-omit-reexported-instances
180 main/Main_flags                 = -fvia-C
181 basicTypes/IdInfo_flags         = -K2m
182 main/CmdLineOpts_flags          = -fvia-C
183 coreSyn/AnnCoreSyn_flags        = -fno-omit-reexported-instances
184 nativeGen/PprMach_flags         = -K2m
185 parser/UgenAll_flags            = -fvia-C '-\#include"hspincl.h"'
186 parser/UgenUtil_flags           = -fvia-C '-\#include"hspincl.h"'
187 parser/U_constr_flags           = -fvia-C '-\#include"hspincl.h"'
188 parser/U_binding_flags          = -fvia-C '-\#include"hspincl.h"'
189 parser/U_pbinding_flags         = -fvia-C '-\#include"hspincl.h"'
190 parser/U_entidt_flags           = -fvia-C '-\#include"hspincl.h"'
191 parser/U_list_flags             = -fvia-C '-\#include"hspincl.h"'
192 parser/U_literal_flags          = -fvia-C '-\#include"hspincl.h"'
193 parser/U_maybe_flags            = -fvia-C '-\#include"hspincl.h"'
194 parser/U_either_flags           = -fvia-C '-\#include"hspincl.h"'
195 parser/U_qid_flags              = -fvia-C '-\#include"hspincl.h"'
196 parser/U_tree_flags             = -fvia-C '-\#include"hspincl.h"'
197 parser/U_ttype_flags            = -fvia-C '-\#include"hspincl.h"'
198 prelude/PrimOp_flags            = -K3m
199 reader/ReadPrefix_flags         = -fvia-C '-\#include"hspincl.h"'
200 rename/ParseIface_flags         = -Onot -H16m
201 rename/RnMonad_flags            = -fvia-C
202 rename/RnSource_flags           = -H12m
203 rename/RnIfaces_flags           = -H8m
204 rename/RnNames_flags            = -H12m
205 specialise/Specialise_flags     = -Onot -H12m
206 stgSyn/StgSyn_flags             = -fno-omit-reexported-instances
207 typecheck/TcMonad_flags         = -fvia-C
208 typecheck/TcGenDeriv_flags      = -H10m
209 typecheck/TcExpr_flags          = -H10m
210 utils/Argv_flags                = -fvia-C
211 utils/CharSeq_flags             = -fvia-C
212 utils/SST_flags                 = -fvia-C
213
214 #-----------------------------------------------------------------------------
215 # make depend, clean, tags and install
216
217 depend :: $(LOOPS)
218
219 MKDEPENDHSFLAGS = -f .depend -I../includes -x HsVersions.h
220 ifeq ($(GhcWithDeforester),NO)
221   MKDEPENDHSFLAGS += -DOMIT_DEFORESTER
222 endif
223
224 ifeq ($(GhcWithHscBuiltViaC),YES)
225   MKDEPENDHSFLAGS += -o .hc
226 else
227   HS_DEP_SRCS = $(SRCS) # should add $(LOOPS) ?
228   include $(TOP)/mk/hsdepend.mk
229 endif
230
231 clean ::
232         $(RM) */*.o */*.hi $(UGNC) $(UGNH) $(UGNHS)
233         $(RM) rename/ParseIface.hs
234
235 veryclean ::
236         $(RM) */*.hc
237
238 tags ::
239         @$(RM) TAGS
240         @touch TAGS
241         $(HSTAGS) -I../includes $(HSTAGSFLAGS) $(SRCS)
242
243 install ::
244         $(INSTALL) $(INSTBINFLAGS) hsc $(INSTLIBDIR_GHC)