aboutsummaryrefslogtreecommitdiff
path: root/m4/open-axiom-deps.m4
blob: 595c6da3fd92545cd562e90dd4cbba7be6d7b31e (plain)
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
# Resolve dependencies between *.boot, *.lisp, *.clisp
# and other OpenAxiom source files within the given directory.
# Dependencies will be written (appended) to the makefile:
#
#   OA_RESOLVE_DEPENDENCIES(directory, makefile)
#
# Example:
#
#   OA_RESOLVE_DEPENDENCIES([src/boot/strap], [Makefile])
#
# -----------------------------
AC_DEFUN([OA_RESOLVE_DEPENDENCIES],
[ AC_MSG_CHECKING([dependencies in $1])
  for f in $1/*.clisp $1/*.lisp $1/*.boot
  do
    AS_IF([test -f "$f"],
          [AS_CASE(["$f"],
              [*.boot],  [OA_EXTRACT_BOOT([/^import @<:@^ @:>@+$/], [/^import /], [/$/], [$1], ["$f"]) >> $2],
              [*.clisp], [OA_EXTRACT_LISP([/\((IMPORT-MODULE|import-module) "/], [/"\)/], [$1], ["$f"]) >> $2],
              [*.lisp],  [OA_EXTRACT_LISP([/\((IMPORT-MODULE|import-module) "/], [/"\)/], [$1], ["$f"]) >> $2])])
  done
  AC_MSG_RESULT([done])])

AC_DEFUN([OA_EXTRACT_LISP], [OA_EXTRACT([$1], [$1], [$2], [$3], [$4])])
AC_DEFUN([OA_EXTRACT_BOOT], [OA_EXTRACT([$1], [$2], [$3], [$4], [$5])])

AC_DEFUN([OA_EXTRACT],
[$AWK 'BEGIN {t=ARGV@<:@1@:>@; sub(/\.@<:@^.@:>@+$/,".$(FASLEXT)",t)} $1 {gsub ($2, "$4/"); gsub($3, ".$(FASLEXT)"); gsub(/_-/, "-"); r=r " " @S|@0} END {printf("%s:%s\n", t, r)}' $5])