eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

import-sources.awk (3122B)


      1 # Read the upstream source assignments, including their continuation lines.
      2 function assignment(line,    key) {
      3 	if (line !~ /^[A-Za-z_][A-Za-z_0-9]*[ \t]*[+:?]?=/)
      4 		return
      5 	key = line
      6 	sub(/[ \t]*[+:?]?=.*/, "", key)
      7 	if (key !~ /^(ell_sources|ell_headers|ell_shared|eap_sources|src_iwd_SOURCES|monitor_iwmon_SOURCES|unit_test_.*_SOURCES)$/ || key == "unit_test_client_SOURCES")
      8 		return
      9 	if (line !~ /^[A-Za-z_][A-Za-z_0-9]*[ \t]*=/ || key in values) {
     10 		print "review changed upstream assignment: " key > "/dev/stderr"
     11 		bad = 1
     12 		return
     13 	}
     14 	sub(/^[^=]*=[ \t]*/, "", line)
     15 	values[key] = line
     16 	if (key ~ /^unit_test_.*_SOURCES$/ && key != "unit_test_client_SOURCES")
     17 		tests[++ntests] = key
     18 }
     19 
     20 function emit(name, value, suffix,    n, words, i, file, count, seen) {
     21 	# All supported references are expanded explicitly. A new upstream
     22 	# reference must be reviewed instead of silently dropping its sources.
     23 	gsub(/\$\(eap_sources\)/, values["eap_sources"], value)
     24 	gsub(/\$\(builtin_sources\)/, "", value)
     25 	n = split(value, words, /[ \t]+/)
     26 	printf "%s =", name
     27 	for (i = 1; i <= n; i++) {
     28 		file = words[i]
     29 		if (file ~ /\$/) {
     30 			print "unsupported upstream source reference: " file > "/dev/stderr"
     31 			bad = 1
     32 		}
     33 		if (file !~ suffix || seen[file]++)
     34 			continue
     35 		if (name ~ /^ELL_/)
     36 			sub(/^ell\//, "$(ELL_DIR)/ell/", file)
     37 		printf " \\\n\t%s", file
     38 		count++
     39 	}
     40 	printf "\n\n"
     41 	if (!count) {
     42 		print "empty upstream source list: " name > "/dev/stderr"
     43 		bad = 1
     44 	}
     45 }
     46 
     47 {
     48 	line = line $0
     49 	if (sub(/\\[ \t]*$/, " ", line))
     50 		next
     51 	assignment(line)
     52 	line = ""
     53 }
     54 
     55 END {
     56 	print "# Imported by scripts/import-upstream; review changes when updating iwd."
     57 	print "VERSION = " version "\n"
     58 	emit("ELL_SRC", values["ell_sources"], "\\.c$")
     59 	emit("ELL_HEADERS", values["ell_headers"] " " values["ell_sources"] " " values["ell_shared"], "\\.h$")
     60 	emit("IWD_SRC", values["src_iwd_SOURCES"], "\\.c$")
     61 	emit("MONITOR_SRC", values["monitor_iwmon_SOURCES"], "\\.c$")
     62 	emit("HEADERS", values["src_iwd_SOURCES"] " " values["monitor_iwmon_SOURCES"], "\\.h$")
     63 	printf "ELL_OBJ ="
     64 	n = split(values["ell_sources"], words, /[ \t]+/)
     65 	for (i = 1; i <= n; i++) {
     66 		if (words[i] !~ /\.c$/)
     67 			continue
     68 		file = words[i]
     69 		sub(/^ell\//, "build/ell/", file)
     70 		sub(/\.c$/, ".o", file)
     71 		printf " \\\n\t%s", file
     72 		deps = deps file ": $(ELL_DIR)/" words[i] "\n"
     73 	}
     74 	print "\n\n" deps
     75 	printf "TESTS ="
     76 	for (i = 1; i <= ntests; i++) {
     77 		name = tests[i]
     78 		sub(/^unit_test_/, "unit/test-", name)
     79 		sub(/_SOURCES$/, "", name)
     80 		gsub(/_/, "-", name)
     81 		targets[i] = name
     82 		printf " \\\n\t%s", name
     83 	}
     84 	print "\n"
     85 	for (j = 1; j <= ntests; j++) {
     86 		name = tests[j]
     87 		sub(/_SOURCES$/, "_OBJ", name)
     88 		emit(name, values[tests[j]], "\\.c$")
     89 		# Convert only the emitted source variable at its point of use.
     90 		printf "%s: $(%s:.c=.o) libell.a\n", targets[j], name
     91 		printf "\t$(CC) $(LDFLAGS) -o $@ $(%s:.c=.o)", name
     92 		if (targets[j] == "unit/test-sae")
     93 			printf " -Wl,-wrap,l_ecc_supported_ike_groups"
     94 		print " libell.a $(LDLIBS)\n"
     95 		objects = objects " \\\n\t$(" name ":.c=.o)"
     96 	}
     97 	print "TEST_OBJ =" objects "\n"
     98 	if (bad || !ntests)
     99 		exit 1
    100 }