[project @ 1996-11-22 13:33:29 by simonm]
[ghc-hetmet.git] / ghc / compiler / Makefile
1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.3 1996/11/22 13:33:29 simonm 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 flags for particular modules
157
158 absCSyn/AbsCSyn_flags           = -fno-omit-reexported-instances
159 hsSyn/HsExpr_flags              = -K2m
160 hsSyn/HsSyn_flags               = -fno-omit-reexported-instances
161 main/Main_flags                 = -fvia-C
162 basicTypes/IdInfo_flags         = -K2m
163 main/CmdLineOpts_flags          = -fvia-C
164 coreSyn/AnnCoreSyn_flags        = -fno-omit-reexported-instances
165 nativeGen/PprMach_flags         = -K2m
166 parser/UgenAll_flags            = -fvia-C '-\#include"hspincl.h"'
167 parser/UgenUtil_flags           = -fvia-C '-\#include"hspincl.h"'
168 parser/U_constr_flags           = -fvia-C '-\#include"hspincl.h"'
169 parser/U_binding_flags          = -fvia-C '-\#include"hspincl.h"'
170 parser/U_pbinding_flags         = -fvia-C '-\#include"hspincl.h"'
171 parser/U_entidt_flags           = -fvia-C '-\#include"hspincl.h"'
172 parser/U_list_flags             = -fvia-C '-\#include"hspincl.h"'
173 parser/U_literal_flags          = -fvia-C '-\#include"hspincl.h"'
174 parser/U_maybe_flags            = -fvia-C '-\#include"hspincl.h"'
175 parser/U_either_flags           = -fvia-C '-\#include"hspincl.h"'
176 parser/U_qid_flags              = -fvia-C '-\#include"hspincl.h"'
177 parser/U_tree_flags             = -fvia-C '-\#include"hspincl.h"'
178 parser/U_ttype_flags            = -fvia-C '-\#include"hspincl.h"'
179 prelude/PrimOp_flags            = -K3m
180 reader/ReadPrefix_flags         = -fvia-C '-\#include"hspincl.h"'
181 rename/ParseIface_flags         = -Onot -H16m
182 rename/RnMonad_flags            = -fvia-C
183 rename/RnSource_flags           = -H12m
184 rename/RnIfaces_flags           = -H8m
185 rename/RnNames_flags            = -H12m
186 specialise/Specialise_flags     = -Onot -H12m
187 stgSyn/StgSyn_flags             = -fno-omit-reexported-instances
188 typecheck/TcMonad_flags         = -fvia-C
189 typecheck/TcGenDeriv_flags      = -H10m
190 typecheck/TcExpr_flags          = -H10m
191 utils/Argv_flags                = -fvia-C
192 utils/CharSeq_flags             = -fvia-C
193 utils/SST_flags                 = -fvia-C
194
195 #-----------------------------------------------------------------------------
196 # make depend, clean, tags and install
197
198 depend :: $(LOOPS)
199
200 MKDEPENDHSFLAGS = -f .depend -I../includes -x HsVersions.h
201 ifeq ($(GhcWithDeforester),NO)
202   MKDEPENDHSFLAGS += -DOMIT_DEFORESTER
203 endif
204
205 ifeq ($(GhcWithHscBuiltViaC),YES)
206   MKDEPENDHSFLAGS += -o .hc
207 else
208   HS_DEP_SRCS = $(SRCS) # should add $(LOOPS) ?
209   include $(TOP)/mk/hsdepend.mk
210 endif
211
212 clean ::
213         $(RM) */*.o */*.hi $(UGNC) $(UGNH) $(UGNHS)
214         $(RM) rename/ParseIface.hs
215
216 veryclean ::
217         $(RM) */*.hc
218
219 tags ::
220         @$(RM) TAGS
221         @touch TAGS
222         $(HSTAGS) -I../includes $(HSTAGSFLAGS) $(SRCS)
223
224 install ::
225         $(INSTALL) $(INSTBINFLAGS) hsc $(INSTLIBDIR_GHC)