[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / rts / adr
1 ################################################################
2 # Start of Makefile
3 ################################################################
4
5 # This rule goes first to make it the default choice
6 default         :: test
7
8 CC = gcc
9
10 CPPFLAGS += -I../includes 
11 CPPFLAGS += -D__HUGS__ 
12
13 CFLAGS  += -Wall 
14 CFLAGS  += -W
15 CFLAGS  += -Wno-unused 
16 CFLAGS  += -Wstrict-prototypes 
17 CFLAGS  += -Wmissing-prototypes 
18 CFLAGS  += -Wmissing-declarations
19 #CFLAGS += -Wredundant-decls 
20 #CFLAGS += -Wnested-externs
21 #CFLAGS += -Wshadow
22 CFLAGS  += -Winline
23 CFLAGS  += -Waggregate-return
24 CFLAGS  += -Wpointer-arith
25 CFLAGS  += -Wbad-function-cast
26 #CFLAGS += -Wcast-qual
27 #CFLAGS += -Wcast-align
28 #CFLAGS += -Wconversion
29
30 #CFLAGS += -ggdb3 -O0    # debug with gdb, minimal confusion
31 #CFLAGS += -pg -O2       # Profile with gprof
32 #CFLAGS += -pg -g        # Profile more with gprof
33 #CFLAGS += -pg -g -a     # Profile basic blocks with gprof (disnae work)
34 #CFLAGS += -O2 -g        # Run it - but put a little debugging help in
35 CFLAGS += -g -DDEBUG
36 #CFLAGS += -O6           # Just run it
37
38 C_FILES         = $(wildcard *.c)
39 S_FILES         = $(wildcard *.S)
40 HC_FILES        = $(wildcard *.hc)
41
42 LIBOBJS         += $(patsubst %.c,%.o,$(C_FILES))
43 LIBOBJS         += $(patsubst %.S,%.o,$(S_FILES))
44 LIBOBJS         += $(patsubst %.hc,%.o,$(HC_FILES))
45
46 LIBRARY = libHSrts.a
47
48 %.o     : %.c
49         @echo Compiling $<
50         @$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
51 %.o     : %.S
52         @echo Compiling $<
53         @$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
54 %.o     : %.hc
55         @echo Compiling $<
56         @ $(CC) $(CFLAGS) $(CPPFLAGS) -xc -c $< -o $@
57
58 # We can build an archive
59 $(LIBRARY):     $(LIBOBJS)
60         rm -f $@
61         ar clqs $@ $^
62
63 # Or we can build a shared library
64 # (The shared library is nicer because it's linked with all the libs
65 #  that the rts depends on.  But it has the problem that the bfd code
66 #  can't see the symbols defined in the library - though that may be easy
67 #  to fix.)
68 $(LIBRARY:.a=.so):      $(LIBOBJS)
69         rm -f $@
70         $(CC) -shared $^ -L$(HOME)/lib -lm -lbfd -liberty -o $@ 
71
72 clean::
73         $(RM) *.o *.a *.so
74 veryclean :: clean
75 tags:
76         etags ../*/*.{c,h,hc,S}
77
78 ################################################################
79 # Floppy disk for me to take home at night
80 ################################################################
81
82 # We avoid using zip because we're fed up being bitten by the
83 # default=non-recursive bug
84
85 GHC_DIR  = fptools/ghc
86 TEST_DIR = $(GHC_DIR)/tests/rts
87 RTS_DIR  = $(GHC_DIR)/rts
88 LIB_DIR  = $(GHC_DIR)/lib
89 GMP_DIR  = $(GHC_DIR)/rts/gmp
90 INC_DIR  = $(GHC_DIR)/includes
91 HUGS_DIR = $(GHC_DIR)/interpreter
92
93 TARFILES += $(GHC_DIR)/CVS
94
95 TARFILES += $(INC_DIR)/*.h
96 TARFILES += $(INC_DIR)/CVS
97
98 TARFILES += $(RTS_DIR)/*.{c,h,hc,S} 
99 TARFILES += $(RTS_DIR)/comments
100 TARFILES += $(RTS_DIR)/adr 
101 TARFILES += $(RTS_DIR)/CVS 
102
103 TARFILES += $(TEST_DIR)/Makefile
104 TARFILES += $(TEST_DIR)/.gdbinit
105 TARFILES += $(TEST_DIR)/*.{c,h}
106 TARFILES += $(TEST_DIR)/CVS
107
108 TARFILES += $(GMP_DIR)
109
110 TARFILES += $(LIB_DIR)/*/CVS
111 TARFILES += $(LIB_DIR)/*/*.{lhs,hi-boot}
112 TARFILES += $(LIB_DIR)/*/cbits/*.{c,h}
113
114 TARFILES += $(HUGS_DIR)
115
116 tarfile:        
117         cd ../../../$(GMP_DIR) && make clean
118         cd ../../../$(HUGS_DIR) && make clean
119         cd ../../..; tar zcvf rts.tgz $(TARFILES)
120         ls -l ../../../rts.tgz
121         echo todo: add unlit to tarfile
122
123 floppy:         tarfile
124                 mount /mnt/floppy
125                 - cp ../../../rts.tgz /mnt/floppy
126                 umount /mnt/floppy
127
128 ################################################################
129 # Dependencies
130 ################################################################
131
132 DEP_FILES       += $(C_FILES:.c=.d)
133 DEP_FILES       += $(S_FILES:.S=.d)
134 DEP_FILES       += $(HC_FILES:.hc=.d)
135
136 include $(DEP_FILES)
137
138 #Copied from the gmake manual - builds a dependency file for every C file
139 %.d             : %.c
140                 @echo "Making dependency file $@"
141                 @$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< \
142                  | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@ \
143                  ; [ -s $@ ] || rm -f $@'
144 %.d             : %.S
145                 @echo "Making dependency file $@"
146                 @$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< \
147                  | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@ \
148                  ; [ -s $@ ] || rm -f $@'
149 %.d             : %.hc
150                  @echo "Making dependency file $@"
151                  @$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) -xc $< \
152                   | sed '\''s/\($*\)\.hc\.o[ :]*/\1.o $@ : /g'\'' > $@ \
153                   ; [ -s $@ ] || rm -f $@'
154
155 veryclean:: 
156         $(RM) $(DEP_FILES)
157
158 ################################################################
159 # End of Makefile
160 ################################################################