1ALLTESTS = open_memstream funopen fopencookie gc_sections \
2	   system-cjson cjson
3MAKEFILE := $(lastword $(MAKEFILE_LIST))
4OUT :=
5
6PROGRAM-open_memstream = extern int open_memstream(); int main() { return open_memstream(); }
7PROGRAM-funopen = extern int funopen(); int main() { return funopen(); }
8PROGRAM-fopencookie = extern int fopencookie(); int main() { return fopencookie(); }
9PROGRAM-gc_sections = int main() {}
10CCFLAGS-gc_sections = -Wl,--gc-sections
11
12PROGRAM-cjson  = \#include <stdlib.h>\n
13PROGRAM-cjson += \#include <cjson/cJSON.h>\n
14PROGRAM-cjson += int main() { return cJSON_False; }
15CCFLAGS-cjson = -I$(dir $(MAKEFILE))src/cjson
16PROGRAM-system-cjson = $(PROGRAM-cjson)
17CCFLAGS-system-cjson = -lcjson
18
19sink:
20	@echo >&2 Please run from the top-level Makefile.
21
22configure: $(foreach it,$(ALLTESTS),check-$(it))
23
24check-%:
25	@echo $(subst check-,,$@)-tested := 1 $(OUT)
26	$(if $(V),,@)if printf "$($(subst check-,PROGRAM-,$@))" | \
27	    $(CC) -xc $($(subst check-,CCFLAGS-,$@)) -o /dev/null - $(if $(V),,>/dev/null 2>&1); \
28	then \
29	    echo $(subst check-,,$@)-pass := 1 $(OUT); \
30	fi
31