MAPLIB.mk 1006 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 require -lGi1 ... -lGin
  10. * otherwise -lL is not required and maps to "no library required"
  11. */
  12. ":MAPLIB:" : .MAKE .OPERATOR
  13. local L P
  14. L := $(<:B:O=1)
  15. if ! ( P = "$(<:B:O>1)" )
  16. P := $(L)
  17. end
  18. $(LIBDIR)/lib/$(L) :INSTALL: $(L).req
  19. eval
  20. $(L).req : (CC) $$(>)
  21. set -
  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 2>&1
  29. then $$(CC) -o $$(<:B:S=.exe) $i > /dev/null 2>&1 || {
  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