tcc -MD: drop system includes and duplicates
[tinycc.git] / tests / tests2 / Makefile
blob13b8c60d93134c8d408db5211eb2d446023677ad
1 TOP = ../..
2 include $(TOP)/Makefile
3 SRC = $(TOPSRC)/tests/tests2
4 VPATH = $(SRC)
6 TESTS = $(patsubst %.c,%.test,\
7 $(sort $(notdir $(wildcard $(SRC)/??_*.c)))\
8 $(sort $(notdir $(wildcard $(SRC)/???_*.c))))
10 # some tests do not pass on all platforms, remove them for now
11 SKIP = 34_array_assignment.test # array assignment is not in C standard
12 ifeq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
13 SKIP += 22_floating_point.test
14 endif
15 ifdef CONFIG_OSX
16 SKIP += 40_stdio.test 42_function_pointer.test
17 FLAGS += -w
18 endif
19 ifeq ($(ARCH),x86_64)
20 SKIP += 73_arm64.test
21 endif
22 ifeq (,$(filter i386,$(ARCH)))
23 SKIP += 98_al_ax_extend.test 99_fastcall.test
24 endif
25 ifeq (,$(filter i386 x86_64,$(ARCH)))
26 SKIP += 85_asm-outside-function.test # x86 asm
27 SKIP += 113_btdll.test # dll support needed
28 endif
29 ifeq (,$(filter i386 x86_64 arm arm64 riscv64,$(ARCH)))
30 SKIP += 112_backtrace.test
31 SKIP += 114_bound_signal.test
32 SKIP += 115_bound_setjmp.test
33 SKIP += 116_bound_setjmp2.test
34 endif
35 ifeq (-$(CONFIG_musl)-,-yes-)
36 SKIP += 112_backtrace.test
37 endif
38 ifeq (-$(findstring gcc,$(CC))-,--)
39 SKIP += $(patsubst %.expect,%.test,$(GEN-ALWAYS))
40 endif
41 ifeq (-$(CONFIG_WIN32)-$(CONFIG_i386)$(CONFIG_arm)-,--yes-)
42 SKIP += 95_bitfields%.test # type_align is different on 32bit-non-windows
43 endif
44 ifeq (-$(CONFIG_WIN32)-,-yes-)
45 SKIP += 106_pthread.test # No pthread support
46 endif
47 ifneq (-$(CONFIG_WIN32)-$(findstring $(GCC_MAJOR),3 4)-,---)
48 SKIP += 114_bound_signal.test # not on windows or older linuxes
49 endif
51 # Some tests might need arguments
52 ARGS =
53 31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5
54 46_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' $(SRC)/46_grep.c
56 # And some tests don't test the right thing with -run
57 NORUN =
58 42_function_pointer.test : NORUN = true
60 # Some tests might need different flags
61 FLAGS =
62 76_dollars_in_identifiers.test : FLAGS += -fdollars-in-identifiers
64 # These tests run several snippets from the same file one by one
65 60_errors_and_warnings.test : FLAGS += -dt
66 96_nodata_wanted.test : FLAGS += -dt
68 # Always generate certain .expects (don't put these in the GIT),
69 GEN-ALWAYS =
70 # GEN-ALWAYS += 95_bitfields.expect # does not work
72 # using the ms compiler for the really ms-compatible bitfields
73 95_bitfields_ms.test : GEN = $(GEN-MSC)
75 # this test compiles/links two files:
76 104_inline.test : FLAGS += $(subst 104,104+,$1)
77 104_inline.test : GEN = $(GEN-TCC)
79 # this test needs pthread
80 106_pthread.test: FLAGS += -pthread
81 106_pthread.test: NORUN = true
83 # constructor/destructor
84 108_constructor.test: NORUN = true
86 112_backtrace.test: FLAGS += -dt -b
87 112_backtrace.test 113_btdll.test: FILTER += \
88 -e 's;[0-9A-Fa-fx]\{5,\};........;g' \
89 -e 's;0x[0-9A-Fa-f]\+;0x?;g'
91 # this test creates two DLLs and an EXE
92 113_btdll.test: NORUN = true
93 113_btdll.test: FLAGS += \
94 -bt $1 -shared -D DLL=1 -o a1$(DLLSUF) && $(TCC) \
95 -bt $1 -shared -D DLL=2 -o a2$(DLLSUF) && $(TCC) \
96 -bt a1$(DLLSUF) a2$(DLLSUF) -Wl,-rpath=.
98 114_bound_signal.test: FLAGS += -b
99 115_bound_setjmp.test: FLAGS += -b
100 116_bound_setjmp2.test: FLAGS += -b
102 # Filter source directory in warnings/errors (out-of-tree builds)
103 FILTER = 2>&1 | sed -e 's,$(SRC)/,,g'
105 all test tests2.all: $(filter-out $(SKIP),$(TESTS))
106 @$(MAKE) clean --no-print-directory -s
108 %.test: %.c %.expect
109 @echo Test: $*...
110 @$(call T1,$<) $(T3)
112 T1 = $(TCC) $(FLAGS) $(T2) $(ARGS)
113 T2 = $(if $(NORUN),$1 -o a.exe && ./a.exe,-run $1)
114 T3 = $(FILTER) >$*.output 2>&1 || true \
115 && diff -Nbu $(filter %.expect,$^) $*.output \
116 && rm -f $*.output $(filter $*.expect,$(GEN-ALWAYS))
118 # run single test and update .expect file, e.g. "make tests2.37+"
119 tests2.%+:
120 @$(MAKE) $(call F2,$(call F1,$*)) --no-print-directory
122 # just run tcc to see the output, e.g. "make tests2.37-"
123 tests2.%-:
124 @$(MAKE) $(call F1,$*) T3= --no-print-directory
126 # run single test, e.g. "make tests2.37"
127 tests2.%:
128 @$(MAKE) $(call F1,$*) --no-print-directory
130 F1 = $(or $(filter $1_%,$(TESTS)),$1_???.test)
131 F2 = $1 UPDATE="$(patsubst %.test,%.expect,$1)"
133 # automatically generate .expect files with gcc:
134 %.expect :
135 @echo Generating: $@
136 @$(call GEN,$(SRC)/$*.c) $(FILTER) >$@ 2>&1
137 @rm -f *.exe *.obj *.pdb
139 # using TCC for .expect if -dt in FLAGS
140 GEN = $(if $(filter -dt -bt -b,$(FLAGS)),$(GEN-TCC),$(GEN-CC))
141 GEN-CC = $(CC) -w -std=gnu99 $(FLAGS) $1 -o a.exe && ./a.exe $(ARGS)
142 GEN-TCC = $(T1)
143 GEN-MSC = $(MS-CC) $1 && ./$(basename $@).exe
144 MS-CC = cl
146 # tell make not to delete
147 .PRECIOUS: %.expect
149 # force .expect generation for these files
150 $(sort $(GEN-ALWAYS) $(UPDATE)) : force
151 force:
153 clean :
154 rm -f fred.txt *.output a.exe *.dll *.so *.def $(GEN-ALWAYS)