Skip to content

Commit

Permalink
build: add mamake strict level 4 (re: 1b0a4ff, 4eaf25c, 45feaa5)
Browse files Browse the repository at this point in the history
Strict level 4 further tightens up the build system by implementing
the following changes:

1. Changes the syntax for recognising MAM variable expansions from
   ${...} to %{...}. The old sh-like ${...} form is now only
   recognised in strict level 3 and below, and is not treated
   specially in strict level 4. This allows the shell's ${...}
   syntax to be used in shell script actions without any risk of
   conflicts or confusion with MAM.

2. Disables my change from 45feaa5 that allows 'prev' to declare a
   simple file prerequisite in one line, with optional attributes,
   as an equivalent of an empty make...done block. It was confusing
   and not well designed to mix this with prev's original function:
   referencing a previously made rule.

3. Adds a 'makp' command that may now be used to declare a simple
   file prerequisite instead.

4. Gets rid of the 'implicit' attribute. It has never worked as
   documented! That functionality was simply not implemented.
   Instead, it was a simple equivalent of 'dontcare', which is
   certainly not what is wanted where 'implicit' was indicated.

src/cmd/INIT/mamake.c:
- Delete RULE_implicit symbol (the 'implicit' attribute) which,
  when used with 'make', had the same effect as RULE_dontcare.
- attributes(): Make 'implicit' attribute unavailable in strict
  level 4+; use RULE_dontcare for it otherwise.
- substitute():
  - Add %{ as the default prefix for MAM variable expansions. This
    is done regardless of strict level. The character combination
    %{ has never appeared in any Mamfile up to now, so there are no
    backward compatibility conerns, and this way, the new prefix
    can be used internally without complications.
  - Disable %{ at strict < 4.
  - For %{, disable special handling of ':', '=' and '['; these
    were just hacks to mitigate conflicts with sh/ksh syntax.
  - For %{, make it an error to expand an undefined variable when
    one of the two special expansion syntaxes is not used.
- make(): Add makp command. For backward compatibility with
  previous strict levels, it shares it code with prev, so the same
  block (somewhat refactored) continues to have both functions.
- Change internal expansions to use %{ instead of ${.

src/cmd/INIT/mkdeps.sh:
- Use %{ instead of ${ in generated dependencies.
- No longer emit the broken implicit attribute.
- For brevity, do not repeat rule name in 'done'.

**/Mamfile:
- Adapt to the new strict level 4, applying some slight refactoring
  where necessary. (The new strict level exposed one remaining
  dependency bug, in the generation of lc.h in libast/Mamfile,
  previously masked by the fact that 'implicit' was 'dontcare').
  • Loading branch information
McDutchie committed Jul 25, 2024
1 parent 1fbdab8 commit f5d5318
Show file tree
Hide file tree
Showing 13 changed files with 1,615 additions and 1,560 deletions.
10 changes: 5 additions & 5 deletions src/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ note * This build script is in an extended Make Abstract Machine (MAM)
note * language. Documentation is at: src/cmd/INIT/README-mamake.md
note *

setv MAMAKE_STRICT 3
setv MAMAKE_STRICT 4

make install virtual
make all virtual
exec - ${MAMAKE} -r '*/*' ${MAMAKEARGS}
exec - %{MAMAKE} -r '*/*' %{MAMAKEARGS}
done
make announce_build_done virtual notrace
prev cmd/ksh93/ksh
exec - ${<} -c 'print "# KornShell $KSH_VERSION"'
makp cmd/ksh93/ksh
exec - %{<} -c 'print "# KornShell $KSH_VERSION"'
exec - echo "# Type 'bin/package use' to try it out"
done
done

make test virtual
exec - : testing KornShell $KSH_VERSION :
exec - ${MAMAKE} -r '*/*' ${MAMAKEARGS}
exec - %{MAMAKE} -r '*/*' %{MAMAKEARGS}
done
142 changes: 74 additions & 68 deletions src/cmd/INIT/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ note * This build script is in an extended Make Abstract Machine (MAM)
note * language. Documentation is at: src/cmd/INIT/README-mamake.md
note *

setv MAMAKE_STRICT 3
setv MAMAKE_STRICT 4
setv INSTALLROOT ../../..
setv CC cc

Expand All @@ -13,55 +13,61 @@ note *

make install virtual
loop DIR bin include/ast lib/lib lib/probe/C/make lib/probe/C/pp lib/probe/C/mam
make ${INSTALLROOT}/${DIR}
exec - mkdir -p ${@}
make %{INSTALLROOT}/%{DIR}
exec - mkdir -p %{@}
done
done

note *
note * install helper scripts
note *

make probe.sh
prev C+probe
prev make.probe
exec - cat ${^} > ${@}
done
loop SCRIPT probe iffe mktest regress crossexec mkreq mkreq-maplib mprobe proto dylink mkdeps
make ${INSTALLROOT}/bin/${SCRIPT}
make ${SCRIPT}
prev ${@}.sh
exec - cp ${<} ${@} && chmod u+w,+x ${@}
make %{INSTALLROOT}/bin/probe
make probe
make probe.sh
makp C+probe
makp make.probe
exec - cat %{^} > %{@}
done
exec - cp -f ${<} ${@}
exec - cp %{<} %{@} && chmod u+w,+x %{@}
done
exec - cp -f %{<} %{@}
done
make ${INSTALLROOT}/bin/mamprobe
loop SCRIPT iffe mktest regress crossexec mkreq mkreq-maplib mprobe proto dylink mkdeps
make %{INSTALLROOT}/bin/%{SCRIPT}
make %{SCRIPT}
makp %{@}.sh
exec - cp %{<} %{@} && chmod u+w,+x %{@}
done
exec - cp -f %{<} %{@}
done
done
make %{INSTALLROOT}/bin/mamprobe
note * the probe.sh dependency is needed for mamake to redo the probe when C+probe or make.probe is edited
prev probe.sh
prev mamprobe.sh
exec - cp ${<} ${@} && chmod u+w,+x ${@}
makp mamprobe.sh
exec - cp %{<} %{@} && chmod u+w,+x %{@}
done

note *
note * probe initialization
note *

make ${INSTALLROOT}/lib/probe/C/probe
make %{INSTALLROOT}/lib/probe/C/probe
prev C+probe
exec - cp -f ${<} ${@}
exec - cp -f %{<} %{@}
done
make ${INSTALLROOT}/lib/probe/C/mam/probe
make %{INSTALLROOT}/lib/probe/C/mam/probe
prev mprobe
exec - cp -f ${<} ${@}
exec - cp -f %{<} %{@}
done
make ${INSTALLROOT}/lib/probe/C/mam/mprobe
make %{INSTALLROOT}/lib/probe/C/mam/mprobe
prev mprobe
exec - cp -f ${<} ${@}
exec - cp -f %{<} %{@}
done
make ${INSTALLROOT}/lib/probe/C/make/probe
make %{INSTALLROOT}/lib/probe/C/make/probe
prev probe
exec - cp -f ${<} ${@}
exec - cp -f %{<} %{@}
done
note *
note * check if -ldl is required
Expand All @@ -72,80 +78,80 @@ make install virtual
note * (3) dynamic progs built on irix 5.* and using -ldl fail
note * at runtime on irix 6.* because -ldl is not there
note *
make ${INSTALLROOT}/lib/lib/dl
make %{INSTALLROOT}/lib/lib/dl
make dl.req
prev dl.c
exec - mkreq-maplib ${CC} : dl : ${^} : dl
makp dl.c
exec - mkreq-maplib %{CC} : dl : %{^} : dl
prev mkreq-maplib
done
exec - cp -f ${<} ${@}
exec - cp -f %{<} %{@}
done
note *
note * requiring these is a botch
note *
make ${INSTALLROOT}/lib/lib/iconv
make %{INSTALLROOT}/lib/lib/iconv
make iconv.req
prev iconv.c
exec - mkreq-maplib ${CC} : iconv : ${^} : iconv
makp iconv.c
exec - mkreq-maplib %{CC} : iconv : %{^} : iconv
prev mkreq-maplib
done
exec - cp -f ${<} ${@}
exec - cp -f %{<} %{@}
done
make ${INSTALLROOT}/lib/lib/w
make %{INSTALLROOT}/lib/lib/w
make w.req
prev w.c
prev w2.c
exec - mkreq-maplib ${CC} : w : ${^} : w
makp w.c
makp w2.c
exec - mkreq-maplib %{CC} : w : %{^} : w
prev mkreq-maplib
done
exec - cp -f ${<} ${@}
exec - cp -f %{<} %{@}
done
note *
note * miscellaneous -l* checks
note *
make ${INSTALLROOT}/lib/lib/intl
make %{INSTALLROOT}/lib/lib/intl
make intl.req
prev intl.c
exec - mkreq-maplib ${CC} : intl : ${^} : intl
makp intl.c
exec - mkreq-maplib %{CC} : intl : %{^} : intl
prev mkreq-maplib
done
exec - cp -f ${<} ${@}
exec - cp -f %{<} %{@}
done
make ${INSTALLROOT}/lib/lib/m
make %{INSTALLROOT}/lib/lib/m
make m.req
prev m.c
prev m2.c
prev m3.c
prev m4.c
prev m5.c
prev m6.c
exec - mkreq-maplib ${CC} : m : ${^} : m
makp m.c
makp m2.c
makp m3.c
makp m4.c
makp m5.c
makp m6.c
exec - mkreq-maplib %{CC} : m : %{^} : m
prev mkreq-maplib
done
exec - cp -f ${<} ${@}
exec - cp -f %{<} %{@}
done
make ${INSTALLROOT}/lib/lib/nsl
make %{INSTALLROOT}/lib/lib/nsl
make nsl.req
prev nsl.c
exec - mkreq-maplib ${CC} : nsl : ${^} : nsl
makp nsl.c
exec - mkreq-maplib %{CC} : nsl : %{^} : nsl
prev mkreq-maplib
done
exec - cp -f ${<} ${@}
exec - cp -f %{<} %{@}
done
note *
note * what was sco smoking
note * almost all of gethost* are in -lnsl except gethostbyname which
note * is in -lsocket which isn't needed to resolve socket() but seems
note * to do the -lnsl job
note *
make ${INSTALLROOT}/lib/lib/socket
make %{INSTALLROOT}/lib/lib/socket
make socket.req
prev socket.c
makp socket.c
prev nsl.c
exec - mkreq-maplib ${CC} : socket : ${^} : socket
exec - mkreq-maplib %{CC} : socket : %{^} : socket
prev mkreq-maplib
done
exec - cp -f ${<} ${@}
exec - cp -f %{<} %{@}
done
note *
note * more substance abuse
Expand All @@ -159,26 +165,26 @@ make install virtual
note *
note * at least the -l* buck stops here
note *
make ${INSTALLROOT}/lib/lib/dbm
make %{INSTALLROOT}/lib/lib/dbm
make dbm.req
prev db.c
prev gdbm.c
prev gdbm1.c
prev gdbm2.c
exec - mkreq-maplib ${CC} : dbm : ${^} : db gdbm_compat gdbm ndbm dbm
makp db.c
makp gdbm.c
makp gdbm1.c
makp gdbm2.c
exec - mkreq-maplib %{CC} : dbm : %{^} : db gdbm_compat gdbm ndbm dbm
prev mkreq-maplib
done
exec - cp -f ${<} ${@}
exec - cp -f %{<} %{@}
done
done install

make test dontcare virtual
make test.iffe virtual
prev iffe.tst
makp iffe.tst
exec - regress iffe.tst iffe
done
make test.mamake virtual
prev mamake.tst
makp mamake.tst
exec - : testing non-libast mamake at $PWD/mamake :
exec - regress mamake.tst mamake
done
Expand Down
Loading

0 comments on commit f5d5318

Please sign in to comment.