modernc.org/ccgo/v3@v3.16.14/lib/testdata/tcc-0.9.27/tests/tests2/Makefile (about)

     1  TOP = ../..
     2  include $(TOP)/Makefile
     3  SRC = $(TOPSRC)/tests/tests2
     4  VPATH = $(SRC)
     5  
     6  TESTS = $(patsubst %.c,%.test,$(sort $(notdir $(wildcard $(SRC)/*.c))))
     7  
     8  # some tests do not pass on all platforms, remove them for now
     9  SKIP = 34_array_assignment.test # array assignment is not in C standard
    10  ifeq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
    11   SKIP += 22_floating_point.test
    12  endif
    13  ifdef CONFIG_OSX
    14   SKIP += 40_stdio.test 42_function_pointer.test
    15   FLAGS += -w
    16  endif
    17  ifeq ($(ARCH),x86_64)
    18   SKIP += 73_arm64.test
    19  endif
    20  ifeq (,$(filter i386,$(ARCH)))
    21   SKIP += 98_al_ax_extend.test 99_fastcall.test
    22  endif
    23  ifeq (,$(filter i386 x86_64,$(ARCH)))
    24   SKIP += 85_asm-outside-function.test
    25  endif
    26  ifeq (-$(findstring gcc,$(CC))-,--)
    27   SKIP += $(patsubst %.expect,%.test,$(GEN-ALWAYS))
    28  endif
    29  ifeq (-$(CONFIG_WIN32)-$(CONFIG_i386)$(CONFIG_arm)-,--yes-)
    30   SKIP += 95_bitfields%.test # type_align is different on 32bit-non-windows
    31  endif
    32  
    33  # Some tests might need arguments
    34  ARGS =
    35  31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5
    36  46_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' $(SRC)/46_grep.c
    37  
    38  # And some tests don't test the right thing with -run
    39  NORUN =
    40  42_function_pointer.test : NORUN = true
    41  
    42  # Some tests might need different flags
    43  FLAGS =
    44  76_dollars_in_identifiers.test : FLAGS += -fdollars-in-identifiers
    45  
    46  # These tests run several snippets from the same file one by one
    47  60_errors_and_warnings.test : FLAGS += -dt
    48  96_nodata_wanted.test : FLAGS += -dt
    49  
    50  # Always generate certain .expects (don't put these in the GIT),
    51  GEN-ALWAYS =
    52  # GEN-ALWAYS += 95_bitfields.expect # does not work
    53  
    54  # using the ms compiler for the really ms-compatible bitfields
    55  95_bitfields_ms.test : GEN = $(GEN-MSC)
    56  
    57  # Filter source directory in warnings/errors (out-of-tree builds)
    58  FILTER = 2>&1 | sed 's,$(SRC)/,,g'
    59  # Filter some always-warning
    60  ifeq (-$(findstring arm,$(ARCH))-,-arm-)
    61  FILTER += 2>&1 | grep -v 'warning: soft float ABI currently not supported'
    62  endif
    63  
    64  all test tests2.all: $(filter-out $(SKIP),$(TESTS)) ;
    65  
    66  %.test: %.c %.expect
    67  	@echo Test: $*...
    68  	@$(if $(NORUN),$(T1),$(T2)) $(if $(NODIFF),,$(T3))
    69  
    70  T1 = $(TCC) $(FLAGS) $< -o a.exe && ./a.exe $(ARGS)
    71  T2 = $(TCC) $(FLAGS) -run $< $(ARGS)
    72  T3 = $(FILTER) >$*.output 2>&1 || true \
    73       && diff -Nbu $(filter %.expect,$^) $*.output \
    74       && rm -f $*.output $(filter $*.expect,$(GEN-ALWAYS))
    75  
    76  # run single test and update .expect file, e.g. "make tests2.37+"
    77  tests2.%+:
    78  	@$(MAKE) $(call F2,$(call F1,$*)) --no-print-directory
    79  
    80  # just run tcc to see the output, e.g. "make tests2.37-"
    81  tests2.%-:
    82  	@$(MAKE) $(call F1,$*) NODIFF=true --no-print-directory
    83  
    84  # run single test, e.g. "make tests2.37"
    85  tests2.%:
    86  	@$(MAKE) $(call F1,$*) --no-print-directory
    87  
    88  F1 = $(or $(filter $1_%,$(TESTS)),$1_???.test)
    89  F2 = $1 UPDATE="$(patsubst %.test,%.expect,$1)"
    90  
    91  # automatically generate .expect files with gcc:
    92  %.expect :
    93  	@echo Generating: $@
    94  	@$(call GEN,$(SRC)/$*.c) $(FILTER) >$@ 2>&1
    95  	@rm -f *.exe *.obj *.pdb
    96  
    97  # using TCC for .expect if -dt in FLAGS
    98  GEN = $(if $(filter -dt,$(FLAGS)),$(GEN-TCC),$(GEN-CC))
    99  GEN-CC = $(CC) -w -std=gnu99 $(FLAGS) $1 -o a.exe && ./a.exe $(ARGS)
   100  GEN-TCC = $(TCC) $(FLAGS) -run $1 $(ARGS)
   101  GEN-MSC = $(MS-CC) $1 && ./$(basename $@).exe
   102  MS-CC = cl
   103  
   104  # tell make not to delete
   105  .PRECIOUS: %.expect
   106  
   107  # force .expect generation for these files
   108  $(sort $(GEN-ALWAYS) $(UPDATE)) : force
   109  force:
   110  
   111  clean:
   112  	rm -f fred.txt *.output a.exe $(GEN-ALWAYS)