problematic 64bit test
[libfirm] / ir / be / test / Makefile
1 #
2 #
3 #
4 RM   = rm -f
5 CAT  = cat
6 ECHO = echo
7 XCC ?= ~/local/bin/eccp
8 XCC_GOOD = gcc -malign-double -S
9
10
11 #
12 # generated files
13 #
14 LOG = run.log
15 ERR = compile.errors
16 ECNT = .errors
17 GCNT = .good
18 TESTERR = .compile.err.log
19 TESTSUC = .compile.suc.log
20
21 # maximum running time for a testprogram in seconds (default 5min)
22 maxtime ?= 300
23
24 #
25 # C-Generic backend:
26 # define extension and additional includes
27 #
28 #EXT = c.c
29 #INC = -I$(HOME)/cvs/be/C_GENERIC
30
31 #
32 # MMIX backend
33 #
34 #EXT = mms
35 #INC =
36
37 #
38 # ia32 backend
39 #
40 EXT = s
41 INC =
42
43 SRC   = apfel.c          Doit.c           LongLong.c     Switcher.c \
44         Args.c           Empty.c          mul.c            Test.c \
45         Arrays.c         EmptyFor.c       optest.c         Thilo.c \
46         Field.c          Pdg.c            trivial_add.c \
47         BinaryOpTest.c   Float.c          Queens.c         trivial_div.c \
48         BreakTest.c      ForTest.c        QuickSort.c      trivial_empty.c \
49         ByteTest.c       gcd.c            RegallocBug.c    trivial_extern_add.c \
50         CallingTest.c    GlobalCseTest.c  Return.c         trivial_max.c \
51         callref.c        Hanoi.c          SieveBits.c      trivial_sum_upto.c \
52         HeapSort.c       Sieve.c          trivial_two_times.c \
53         CondExpr.c       HelloWorld.c     SimpleExpr.c     While.c \
54         IfExpr.c         Strings.c        ContinueTest.c   XXEndless.c \
55         d.c              Int.c            struct.c \
56         DeclTest.c       Label.c          structtest.c \
57         Do.c             Local.c          Swap.c           ll_call.c \
58         MergeSort.c      Or.c             while-printf.c   multidim-array.c \
59         fehler1.c        fehler3.c        fehler4.c \
60         fehler5.c        fehler6.c        fehler7.c        fehler8.c \
61         fehler9.c        fehler10.c       fehler11.c       fehler12.c  \
62         simd1.c          simd2.c          enum.c           max.c \
63         use_uninit_ptr.c func_arg.c       ns.c             array_type.c \
64         sparam.c         wrong_cmp.c      nested_loops.c   alloca.c \
65         nested_loops2.c  truth.c          iabs.c           stmt_expr.c \
66         dblstruct.c      tailrec.c        types.c          types2.c \
67         nullnode.c       bf_store.c       duffs.c          bf_init.c \
68         bf_localinit.c   switch_test.c    rotate.c         biggest_prime.c \
69         DivBug.c         strenght_red.c   divtest.c        pbqp_RedN.c \
70         cmp.c
71
72
73
74 ##################################
75 ###### causes endless loop: ######
76 ##################################
77
78
79 ASM_SRC = $(SRC:.c=.$(EXT))
80 TARGETS = $(ASM_SRC:.$(EXT)=)
81 LOGS    = $(ASM_SRC:.$(EXT)=.log)
82
83 .PHONY: run clean good good_i all
84 .SUFFIXES: .$(EXT)
85
86 all:
87         @echo "compile   == run your backend"
88         @echo "build     == assemble files (on target platform)"
89         @echo "compare   == run the executeables and compare with GOOD results"
90         @echo "good      == copy the log files into GOOD repository"
91         @echo "run       == make the combined test (only for ia-32)"
92         @echo "clean     == removes cores and logs"
93         @echo "realclean == removes all generated files"
94         @echo "test      == try to compile, used by automatic tests"
95
96
97 #
98 # how to assemble "something"
99 #
100 %:      %.$(EXT)
101         @$(ECHO) gcc $(INC) -o $@ $<
102         @gcc $(INC) -o $@ $< || gcc -o $@ error.c
103
104 #
105 # how to compile a C file into "something"
106 #
107 %.c.c:  %.c
108         @$(ECHO) $(XCC) $<
109         @$(XCC) $< >/dev/null 2>error || (mv core* $<.core ; $(ECHO) -e "\n$<: corefile $<.core" >> $(ERR) && $(CAT) error >> $(ERR) && $(ECHO) "int main(void) { printf(\"$<\\n  Compile failed!\\n\"); }" > $@)
110         @if [ -f $@ ]; then $(RM) error ; else $(ECHO) "int main(void) { printf(\"$<\\n  Compile produced empty file!\\n\"); }" > $@ ;  $(CAT) error >> $(ERR) ; fi
111
112 %.s:    %.c
113         @$(ECHO) $(XCC) $<
114         @$(XCC) $< >/dev/null 2>error || (mv core* $<.core ; $(ECHO) -e "\n$<: corefile $<.core" >> $(ERR) && $(CAT) error >> $(ERR) && $(ECHO) "int main(void) { printf(\"$<\\n  Compile failed!\\n\"); }" > $@.c.c && gcc -S $@.c.c -o $@ && rm $@.c.c )
115         @if [ -f $@ ]; then $(RM) error ; else $(ECHO) "int main(void) { printf(\"$<\\n  Compile produced empty file!\\n\"); }" > $@.c.c ; gcc -S $@.c.c -o $@; rm $@.c.c ;  $(CAT) error >> $(ERR) ; fi
116
117
118 #
119 # how to create an mmix emulator executable from a .mms assembler file (for gas)
120 #
121 %:      %.mms
122         mmix-gcc -xassembler $< -o $@
123
124 #
125 # how to create a default executable from an .s assembler file (for gas)
126 #
127 %:      %.c.c
128         gcc -malign-double -g -lm $< -o $@ || true
129
130 #
131 # how to create a default executable from an .s assembler file (for gas)
132 #
133 %:      %.s
134         gcc -g -lm $< -o $@ || true
135
136 #
137 # how to create a file from a target
138 #
139 %.log:  %
140         @echo "running: $^"
141         @ulimit -St $(maxtime); ./$^ > $@ || \
142         if [ "$$?" = "152" ]; then echo "$^: Process killed (CPU time limit exceeded)"; tail -1000 $@ > $@.tmp; mv $@.tmp $@; fi || \
143         true
144
145 $(TARGETS):     $(ASM_SRC)
146
147 compile: clean $(ASM_SRC)
148
149 build: $(TARGETS)
150
151 run:    error.c $(TARGETS)
152         @$(RM) $(LOG)
153         @$(ECHO) -e "\nRunning..."
154         @for i in $(TARGETS); do ./$$i | tee -a $(LOG) | tee $$i.log ; done
155         @if [ -s $(ERR) ]; then $(ECHO) -e "\nThere were compile errors, see $(LOG)"; fi
156         @$(ECHO) -e "\nError reports:" >> $(LOG)
157         -@$(CAT) $(ERR) >> $(LOG)
158         @$(RM) $(ERR)
159         @$(ECHO) "For run log, see file $(LOG)"
160
161 error.c:
162         @$(ECHO) "main() { printf(\"GCC compile errors!\n\"); }" > $@
163
164 clean:
165         $(RM) *.stat *.ilp *.ra *.ra.res *.pstat *.vcg *.$(EXT) *.o core* $(TARGETS) .error.c *.errlog $(TESTERR) $(TESTSUC) error $(ERR) .comp.log
166
167 realclean:      clean
168         $(RM) $(LOG) $(RUN) $(ERR) $(ECNT) $(GCNT) *.core *.log GOOD/*.good
169
170 runonly:        $(TARGETS)
171         @for i in $(TARGETS); do ./$$i ; done
172
173 good_i: $(LOGS)
174         @for i in $(TARGETS); do mv $$i.log GOOD/$$i.good ; done
175
176 good:
177         $(MAKE) XCC="$(XCC_GOOD)" realclean good_i
178
179 compare: $(LOGS)
180         echo > $(ECNT)
181         echo > $(GCNT)
182 #       @for i in $(TARGETS); do diff -u1 $$i.log GOOD/$$i.good | less ; done
183         @for i in $(TARGETS); do echo $$i >> $(GCNT); diff -u1 $$i.log GOOD/$$i.good || echo $$i >> $(ECNT) ; done
184         @diff -u $(ECNT) $(GCNT) || true
185         @echo "############# Number of Differences #############"
186         @wc -w $(ECNT)
187         @echo "############# Total number of Tests #############"
188         @wc -w $(GCNT)
189         @echo "############# Detailed list of failures #########"
190         @$(RM) $(ECNT) $(GCNT)
191
192 test: clean
193         for i in $(SRC); do \
194                 $(ECHO) $(XCC) $$i; \
195                 $(XCC) $$i &> $$i.errlog; \
196                 if [ $$? -ne 0 ]; then \
197                         $(ECHO) -e "Compilation of $$i failed: \n" >> $(TESTERR); \
198                         $(CAT) $$i.errlog >> $(TESTERR); \
199                         $(ECHO) -e "\n--------------------------------------------------------------------------------------\n" >> $(TESTERR); \
200                 else \
201                         $(ECHO) "Compilation of $$i successful." >> $(TESTSUC); \
202                 fi \
203         done
204
205 xml1:
206         for i in *.c.xml ; do ~/CRS/firmxml/test/inout $$i $$i.xml ; done
207
208 xml2:
209         for i in *.c.xml.xml ; do ~/CRS/firmxml/test/inout $$i $$i.xml ; done
210
211 xml3:
212         for i in *.c.xml.xml.xml ; do ~/CRS/firmxml/test/inout $$i $$i.xml ; done