1ALLTESTS = open_memstream funopen fopencookie gc_sections \ 2 system-cjson cjson freestanding 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 11PROGRAM-freestanding = \#if !defined(__STDC_HOSTED__) || __STDC_HOSTED__-0 == 1\n 12PROGRAM-freestanding += \#error Hosted implementation\n 13PROGRAM-freestanding += \#endif\n 14PROGRAM-freestanding += int main() {} 15CCFLAGS-freestanding = $(CFLAGS) 16 17PROGRAM-cjson = \#include <stdlib.h>\n 18PROGRAM-cjson += \#include <cjson/cJSON.h>\n 19PROGRAM-cjson += int main() { return cJSON_False; } 20CCFLAGS-cjson = -I$(dir $(MAKEFILE))src 21PROGRAM-system-cjson = $(PROGRAM-cjson) 22CCFLAGS-system-cjson = -I$(LOCALBASE)/include -L$(LOCALBASE)/lib -lcjson 23 24sink: 25 @echo >&2 Please run from the top-level Makefile. 26 27configure: $(foreach it,$(ALLTESTS),check-$(it)) 28 29check-%: 30 @echo $(subst check-,,$@)-tested := 1 $(OUT) 31 $(if $(V),,@)if printf "$($(subst check-,PROGRAM-,$@))" | \ 32 $(CC) -xc $($(subst check-,CCFLAGS-,$@)) -o /dev/null - $(if $(V),,>/dev/null 2>&1); \ 33 then \ 34 echo $(subst check-,,$@)-pass := 1 $(OUT); \ 35 fi 36