1/*
2 * normalize local -l* library conventions
3 *
4 * L [ [ G11 ... G1n ] ... [ Gg1 ... Ggn ] ] :MAPLIB: T1.c ... Tn.c
5 *
6 * if Giji not specified then G11 == L
7 * the first Ti.c that compiles/links with group -lGi1 ... -lGin
8 * but does not compile/link with no libraries maps
9 * -lL to to require -lGi1 ... -lGin
10 * otherwise -lL is not required and maps to "no library required"
11 */
12
13":MAPLIB:" : .MAKE .OPERATOR
14	local L P
15	L := $(<:B:O=1)
16	if ! ( P = "$(<:B:O>1)" )
17		P := $(L)
18	end
19	$(LIBDIR)/lib/$(L) :INSTALL: $(L).req
20	eval
21	$(L).req : (CC) $$(>)
22		r='-'
23		for i in $$(*)
24		do	if	$$(CC) -c $i > /dev/null
25			then	g=
26				for p in $(P) -
27				do	case $p in
28					-)	if	$$(CC) -o $$(<:B:S=.exe) $i $g > /dev/null
29						then	$$(CC) -o $$(<:B:S=.exe) $i > /dev/null || {
30								r="$g"
31								break 2
32							}
33						fi
34						g=
35						;;
36					*)	g="$g -l$p"
37						;;
38					esac
39				done
40			fi
41		done 2>/dev/null
42		echo " $r" > $$(<)
43		rm -f $$(<:B:S=.exe) $$(*:B:S=$$(CC.SUFFIX.OBJECT))
44	end
45