summaryrefslogtreecommitdiffstats
path: root/config-figure-this-out-for-me.mk
blob: 8da5ff93145f14d61e87ea2f1dc47549c2f495db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# See LICENSE file for copyright and license details.
BASECONFIG !=\
	set -e; \
	if test -n "$(BASECONFIG)"; then \
		printf '%s\n' "$(BASECONFIG)"; \
	else \
		rm -f -- .config.mk.tmp; \
		(set -e; \
			sed 's/^\s*DOWNLOAD\s*=/\x23&/' < config.mk; \
			for testscript in */what-architecture-am-i-using; do \
				if test "$$testscript" = "util/what-architecture-am-i-using"; then \
					continue; \
				fi; \
				os="$$(printf '%s\n' "$$testscript" | cut -d / -f 1 | tr '[a-z]' '[A-Z]')"; \
				support="$${os}_SUPPORT"; \
				q=\'; \
				printf '%s_ != test -z "$$(%s_)" || printf %s%%s\\n%s "$$(%s)"\n' \
				       "$$support"        "$$support"      $$q  $$q      "$$support"; \
				printf '%s !=\\\n' \
				       "$$support"; \
				printf '\tif test -n "$$(%s_)"; then \\\n' \
				                        "$$support"; \
				printf '\t\tprintf '\''%%s\\n'\'' "$$(%s_)"; \\\n' \
				                                     "$$support"; \
				printf '\telse \\\n'; \
				printf '\t\tset +e; \\\n'; \
				printf '\t\t%s false >/dev/null 2>&1; \\\n' \
				           "$${testscript}"; \
				printf '\t\tif test $$$$? -lt 2; then printf %syes\\n%s; else printf %sno\\n%s; fi; \\\n' \
				                                             $$q     $$q             $$q    $$q; \
				printf '\tfi\n'; \
			done \
		) > .config.mk.tmp; \
		printf '%s\n' .config.mk.tmp; \
	fi;

include $(BASECONFIG)

DOWNLOAD !=\
	if test -n "$(DOWNLOAD)"; then printf '%s\n' "$(DOWNLOAD)"; \
	elif curl --version >/dev/null 2>&1; then printf 'curl --\n'; \
	elif wget --version >/dev/null 2>&1; then printf 'wget -O - --\n'; \
	else printf 'curl --\n'; fi

DEFAULT_OS_SUPPORT_SELECTION != :

SUPPORTED_ARCHES_ != test -z "$(SUPPORTED_ARCHES_)" || printf '%s\n' "$(SUPPORTED_ARCHES)"

SUPPORTED_ARCHES !=\
	if test -n "$(SUPPORTED_ARCHES_)"; then printf '%s\n' "$(SUPPORTED_ARCHES_)"; \
	else util/what-architecture-am-i-using true; fi

DEFAULT_OS_SUPPORT_SELECTION != printf 'no\n'

IMPORTANT_CFLAGS !=\
	printf '%s\n' $(IMPORTANT_CFLAGS) &&\
	if ! printf '%s\n' $(CC) $(CFLAGS) $(IMPORTANT_CFLAGS) | grep '^-std=c..$$' > /dev/null; then \
		sed -n 's/^.*\(-std=c..\).*$$/\1/p' < .config.mk.tmp | sed 1q; \
	fi