[project @ 1999-03-01 14:58:56 by sewardj]
[ghc-hetmet.git] / ghc / interpreter / Makefile
1
2 # ----------------------------------------------------------------------------- #
3 # $Id: Makefile,v 1.5 1999/03/01 14:58:56 sewardj Exp $                         #
4 # ----------------------------------------------------------------------------- #
5
6 TOP = ../..
7 include $(TOP)/mk/boilerplate.mk
8
9 GHC_DIR = $(TOP)/ghc
10 RTS_DIR = $(TOP)/ghc/rts
11
12 # --------------------------------------------------------------------- #
13 # interpreter and relevant .a/.so files                                 #
14 # --------------------------------------------------------------------- #
15
16 YACC = bison -y
17 %.c: %.y
18         -$(YACC) $<
19         mv y.tab.c $@
20
21
22 HS_SRCS =
23
24 Y_SRCS = parser.y
25 C_SRCS = link.c type.c static.c storage.c derive.c input.c compiler.c subst.c \
26      translate.c codegen.c lift.c free.c stgSubst.c optimise.c output.c   \
27      hugs.c dynamic.c stg.c
28
29 SRC_CC_OPTS = -g -I$(GHC_DIR)/includes -I$(GHC_DIR)/rts -D__HUGS__ -Wall -Wstrict-prototypes -D_POSIX_C_SOURCE
30
31 GHC_LIBS_NEEDED = $(TOP)/ghc/rts/libHSrts.a $(TOP)/ghc/rts/gmp/libgmp.a
32 GHC_DYN_CBITS_DIR = $(TOP)/ghc/lib/std/cbits
33 GHC_DYN_CBITS = $(GHC_DYN_CBITS_DIR)/libHS_cbits.so
34
35 ###all :: parser.c $(GHC_LIBS_NEEDED) $(GHC_DYN_CBITS) hugs Prelude.hs
36 all :: parser.c $(GHC_LIBS_NEEDED) $(GHC_DYN_CBITS) hugs
37
38 ### EXTREMELY hacky
39 hugs: $(C_OBJS) ../rts/Assembler.o ../rts/Disassembler.o ../rts/Evaluator.o ../rts/ForeignCall.o \
40                 ../rts/Printer.o
41         $(CC) -o $@ $(CC_OPTS) $^ $(GHC_LIBS_NEEDED) -lbfd -liberty -ldl -lm
42
43 $(GHC_DYN_CBITS):
44 ###     (cd $(GHC_DYN_CBITS_DIR); make EXTRA_CC_OPTS="-fpic -optc-g" ; gcc -shared -o libHS_cbits.so *.o)
45         (cd $(GHC_DYN_CBITS_DIR); rm -f *.o ; gcc -I../../../includes -fPIC -g -Wall -c *.c ; gcc -shared -o libHS_cbits.so *.o)
46         cp -f $(GHC_DYN_CBITS) .
47
48 $(TOP)/ghc/rts/libHSrts.a:
49         (cd $(TOP)/ghc/rts ; make clean ; make)
50 $(TOP)/ghc/rts/gmp/libgmp.a:
51         (cd $(TOP)/ghc/rts/gmp ; make clean ; make)
52
53 cleanish:
54         /bin/rm *.o
55
56 snapshot:
57         /bin/rm -f snapshot.tar
58         tar cvf snapshot.tar Makefile Prelude.hs *.[chy] *-ORIG-* \
59              ../rts/Assembler.c ../rts/Evaluator.c ../rts/Disassembler.c \
60              ../rts/ForeignCall.c ../rts/Printer.c \
61              ../includes/options.h ../includes/Assembler.h nHandle.c \
62              ../includes/Assembler.h ../rts/Bytecodes.h
63
64 # --------------------------------------------------------------------- #
65 # Prelude                                                               #
66 # --------------------------------------------------------------------- #
67
68 # HPPFLAGS += "-DBEGIN_FOR_HUGS={-"
69 # HPPFLAGS += "-DEND_FOR_HUGS=-}"
70
71 CPPFLAGS        += -I$(GHC_DIR)/includes 
72 CPPFLAGS        += -D__HUGS__ 
73 HPP = gcc -E -P -traditional -xc -DSTD_PRELUDE=0 $(HPPFLAGS) $(CPPFLAGS) -Iprelude -Ilibrary -I.
74 UNLIT = ../utils/unlit/unlit
75
76 # we cleanup by deleting adjacent blank lines - which just happen to be the
77 # only duplicate adjacent lines in all the files we process
78 CLEANUP = uniq
79
80 # Fiendishly cunning this: 
81 # o PreludeBuiltin.hs contains the BODY of the libraries it requires.
82 # o All the other libraries just contain the HEAD of the file.
83 Prelude.hs      : $(wildcard prelude/*.hs) $(wildcard library/*.hs) $(wildcard ../lib/*/*.lhs)
84         echo Building PreludeBuiltin
85         $(HPP) ../lib/std/PrelHandle.lhs     | $(UNLIT) - PrelHandle.unlit
86         $(HPP) ../lib/std/PrelIOBase.lhs     | $(UNLIT) - PrelIOBase.unlit
87         $(HPP) ../lib/std/PrelException.lhs  | $(UNLIT) - PrelException.unlit
88         $(HPP) ../lib/std/PrelDynamic.lhs    | $(UNLIT) - PrelDynamic.unlit
89         $(HPP) -DBODY ../lib/std/IO.lhs      | $(UNLIT) - IO.unlit
90         $(HPP) -DHEAD ../lib/std/IO.lhs      | $(UNLIT) - IO.hs
91         $(HPP) -DBODY prelude/Prelude.hs     | $(CLEANUP) > PreludeBuiltin.hs
92         $(HPP) -DHEAD prelude/Prelude.hs     | $(CLEANUP) > Prelude.hs
93         $(HPP) -DHEAD library/Array.hs       | $(CLEANUP) > Array.hs      
94         $(HPP) -DHEAD library/Char.hs        | $(CLEANUP) > Char.hs             
95         $(HPP) -DHEAD library/Ix.hs          | $(CLEANUP) > Ix.hs               
96         $(HPP) -DHEAD library/List.hs        | $(CLEANUP) > List.hs             
97         $(HPP) -DHEAD library/Maybe.hs       | $(CLEANUP) > Maybe.hs            
98         $(HPP) -DHEAD library/Numeric.hs     | $(CLEANUP) > Numeric.hs    
99         $(HPP) -DHEAD library/Ratio.hs       | $(CLEANUP) > Ratio.hs      
100         $(HPP) -DHEAD library/UnicodePrims.hs| $(CLEANUP) > UnicodePrims.hs      
101         $(HPP) -DHEAD prelude/PreludeIO.hs   | $(CLEANUP) > PreludeIO.hs  
102         $(HPP) -DHEAD prelude/PreludeList.hs | $(CLEANUP) > PreludeList.hs
103         $(HPP) -DHEAD prelude/PreludeText.hs | $(CLEANUP) > PreludeText.hs      
104         $(HPP) -DHEAD prelude/PrelConc.hs    | $(CLEANUP) > PrelConc.hs
105         echo "Building standard libraries"
106         $(HPP) library/Complex.hs       > Complex.hs            
107         $(HPP) library/Monad.hs         > Monad.hs      
108         $(HPP) ../lib/std/System.lhs    > System.lhs  
109         $(HPP) ../lib/std/Directory.lhs > Directory.lhs         
110         $(HPP) ../lib/std/Locale.lhs    > Locale.lhs  
111         $(HPP) ../lib/std/Random.lhs    > Random.lhs  
112         $(HPP) ../lib/std/CPUTime.lhs   > CPUTime.lhs  
113         $(HPP) ../lib/std/Time.lhs      > Time.lhs  
114         echo "And some standard libraries which ain't done yet"
115         # $(HPP) library/IO.hs            > IO.hs               
116         #
117         echo "Building Hugs-GHC libraries"
118         $(HPP) ../lib/exts/ST.lhs        > ST.lhs     
119         $(HPP) ../lib/misc/Pretty.lhs    > Pretty.lhs     
120         $(HPP) ../lib/exts/IOExts.lhs    > IOExts.lhs     
121         $(HPP) ../lib/exts/NumExts.lhs   > NumExts.lhs     
122         $(HPP) ../lib/exts/Dynamic.lhs   > Dynamic.lhs     
123         $(HPP) ../lib/exts/Bits.lhs      > Bits.lhs     
124         $(HPP) ../lib/exts/Exception.lhs > Exception.lhs     
125         $(HPP) library/Int.hs     > Int.hs     
126         $(HPP) library/Word.hs    > Word.hs     
127         $(HPP) ../lib/exts/Addr.lhs    > Addr.lhs     
128         $(HPP) ../lib/concurrent/Channel.lhs    > Channel.lhs    
129         $(HPP) ../lib/concurrent/ChannelVar.lhs > ChannelVar.lhs 
130         $(HPP) ../lib/concurrent/Concurrent.lhs > Concurrent.lhs 
131         $(HPP) ../lib/concurrent/Merge.lhs      > Merge.lhs      
132         $(HPP) ../lib/concurrent/SampleVar.lhs  > SampleVar.lhs 
133         $(HPP) ../lib/concurrent/Semaphore.lhs  > Semaphore.lhs 
134         echo "And some libraries which ain't converted yet"
135         # $(HPP) ../lib/exts/Foreign.lhs          > Foreign.lhs 
136         #
137         # $(HPP) ../lib/concurrent/Parallel.lhs   > Parallel.lhs   
138
139 prelclean:
140         $(RM) Array.hs           Dynamic.lhs        NumExts.lhs        Pretty.lhs
141         $(RM) Bits.lhs           Exception.lhs      Numeric.hs         Ratio.hs
142         $(RM) Channel.lhs        IOExts.lhs         PrelConc.hs        ST.lhs
143         $(RM) ChannelVar.lhs     Ix.hs              Prelude.hs         SampleVar.lhs
144         $(RM) Char.hs            List.hs            PreludeBuiltin.hs  Semaphore.lhs
145         $(RM) Complex.hs         Maybe.hs           PreludeIO.hs       System.lhs
146         $(RM) Concurrent.lhs     Merge.lhs          PreludeList.hs     UnicodePrims.hs
147         $(RM) Directory.lhs      Monad.hs           PreludeText.hs
148         $(RM) Locale.lhs Int.hs IO.hs Addr.lhs Time.lhs Word.hs
149         $(RM) *.unlit
150
151
152 # --------------------------------------------------------------------- #
153 # Testing                                                               #
154 # --------------------------------------------------------------------- #
155
156 check :: all
157         ./test/runtests test/static/*.hs
158         ./test/runtests test/typechecker/*.hs
159         ./test/runtests test/runtime/*.hs
160         ./test/runtests test/std/*.hs
161         ./test/runtests test/exts/*.hs
162
163 checkrun: all
164         ./test/runtests test/runtime/*.hs
165         ./test/runtests test/std/*.hs
166         ./test/runtests test/exts/*.hs
167
168 # --------------------------------------------------------------------- #
169 # Cleanery & misc                                                       #
170 # --------------------------------------------------------------------- #
171
172 CLEAN_FILES += hugs libHS_cbits.so $(GHC_DYN_CBITS) $(GHC_DYN_CBITS_DIR)/*.o 
173 CLEAN_FILES += $(TOP)/ghc/rts/libHSrts.a $(TOP)/ghc/rts/*.o
174 CLEAN_FILES += $(TOP)/ghc/rts/gmp/libgmp.a  $(TOP)/ghc/rts/gmp/*.o $(TOP)/ghc/rts/gmp/*/*.o
175 CLEAN_FILES += parser.c
176
177 INSTALL_LIBEXECS = hugs
178
179 ###clean :: prelclean
180
181 depend :: $(LOOPS) $(SRCS_UGNHS)
182
183
184 include $(TOP)/mk/target.mk
185
186