Skip to content

Commit

Permalink
build system: Mamfiles: move all attributes to 'make'
Browse files Browse the repository at this point in the history
Since they were originally generated, the Mamfiles have attributes
(such as 'dontcare', 'generated', 'virtual') appended to either
'make', or 'done', or both! They have the same effect either way
because they apply to the make...done block as a whole. So it
doesn't really matter, but it does hinder legibility. Especially
for large make...done blocks, this is a bit of a maintenance pain.

src/cmd/INIT/mamake.c:
- If MAMAKE_STRICT is set, produce a deprecation warning upon
  encountering attributes to 'done'.
- Make the strict() function more efficient by caching the
  MAMAKE_STRICT search result in a static int variable. This
  assumes 'setv MAMAKE_STRICT' is executed early, as even a
  not-found result is cached. (re: 45feaa5)
- For the 'done' command, I backported a minor change from 93v-; it
  suppresses the 'improper done command' error if the operand word
  starts with a '$'. I've no idea what that was for, but it smells
  like a workaround for some bug in nmake. There does not seem to
  be a corresponding RELEASE entry. We don't need this, so let's
  disable this in strict mode. (re: abbd9ff)

**/Mamfile:
- Move all 'done' attributes to the 'make' commands.
- Remove all 'archive' attributes; mamake ignores them.
- Remove all 'generated' attributes; they are automatically
  assigned by the 'exec' command.

src/lib/libast/Mamfile:
- Remove two unused joint.* virtual rules and incorporate their
  dependencies in place of 'prev' commands elsewhere.
  • Loading branch information
McDutchie committed Jan 28, 2024
1 parent 0ce5e16 commit fbf8f42
Show file tree
Hide file tree
Showing 10 changed files with 1,189 additions and 1,187 deletions.
12 changes: 6 additions & 6 deletions src/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ note * Mamfiles are processed by mamake (src/cmd/INIT/mamake.c); we added
note * indentation to improve readability. The language is documented in
note * src/cmd/INIT/README-mamake.md.
note *
make test
make test_announce
make test virtual
make test_announce virtual
exec - : testing KornShell $KSH_VERSION :
done test_announce virtual
done test_announce
make install
make all
make all virtual
exec - ${MAMAKE} -r '*/*' ${MAMAKEARGS}
done all virtual
done all
done install virtual
done test virtual
done test
112 changes: 56 additions & 56 deletions src/cmd/INIT/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,98 +17,98 @@ setv LDFLAGS
note *
note * initialization for all packages
note *
make install
make install virtual
make iffe
prev iffe.sh
exec - ${STDCP} iffe.sh iffe
exec - test -w iffe -a -x iffe || ${STDCHMOD} u+w,+x iffe
done iffe generated
done iffe
make mktest
prev mktest.sh
exec - ${STDCP} mktest.sh mktest
exec - test -w mktest -a -x mktest || ${STDCHMOD} u+w,+x mktest
done mktest generated
done mktest
make package
prev package.sh
exec - ${STDCP} package.sh package
exec - test -w package -a -x package || ${STDCHMOD} u+w,+x package
done package generated
done package
make regress
prev regress.sh
exec - ${STDCP} regress.sh regress
exec - test -w regress -a -x regress || ${STDCHMOD} u+w,+x regress
done regress generated
done regress
make crossexec
prev crossexec.sh
exec - ${STDCP} crossexec.sh crossexec
exec - test -w crossexec -a -x crossexec || ${STDCHMOD} u+w,+x crossexec
done crossexec generated
done crossexec
make mkreq
prev mkreq.sh
exec - ${STDCP} mkreq.sh mkreq
exec - test -w mkreq -a -x mkreq || ${STDCHMOD} u+w,+x mkreq
done mkreq generated
done mkreq
make mkreq-maplib
prev mkreq-maplib.sh
exec - ${STDCP} mkreq-maplib.sh mkreq-maplib
exec - test -w mkreq-maplib -a -x mkreq-maplib || ${STDCHMOD} u+w,+x mkreq-maplib
done mkreq-maplib generated
done mkreq-maplib
make mprobe
prev mprobe.sh
exec - ${STDCP} mprobe.sh mprobe
exec - test -w mprobe -a -x mprobe || ${STDCHMOD} u+w,+x mprobe
done mprobe generated
done mprobe
make probe
make probe.sh
prev C+probe
prev make.probe
exec - ${STDCAT} C+probe make.probe > probe.sh
done probe.sh generated
done probe.sh
exec - ${STDCP} probe.sh probe
exec - test -w probe -a -x probe || ${STDCHMOD} u+w,+x probe
done probe generated
done probe
make ${INSTALLROOT}/bin
exec - mkdir -p ${INSTALLROOT}/bin
done ${INSTALLROOT}/bin generated
done ${INSTALLROOT}/bin
make ${INSTALLROOT}/bin/iffe
prev iffe
exec - ${STDCP} -f iffe ${INSTALLROOT}/bin/iffe
done ${INSTALLROOT}/bin/iffe generated
done ${INSTALLROOT}/bin/iffe
make ${INSTALLROOT}/bin/mkreq
prev mkreq
exec - ${STDCP} -f mkreq ${INSTALLROOT}/bin/mkreq
done ${INSTALLROOT}/bin/mkreq generated
done ${INSTALLROOT}/bin/mkreq
make ${INSTALLROOT}/bin/mktest
prev mktest
exec - ${STDCP} -f mktest ${INSTALLROOT}/bin/mktest
done ${INSTALLROOT}/bin/mktest generated
done ${INSTALLROOT}/bin/mktest
make ${INSTALLROOT}/bin/package
prev package
exec - ${STDCP} -f package ${INSTALLROOT}/bin/package
done ${INSTALLROOT}/bin/package generated
done ${INSTALLROOT}/bin/package
make ${INSTALLROOT}/bin/regress
prev regress
exec - ${STDCP} -f regress ${INSTALLROOT}/bin/regress
done ${INSTALLROOT}/bin/regress generated
done ${INSTALLROOT}/bin/regress
make ${PACKAGEROOT}/bin
exec - mkdir -p ${PACKAGEROOT}/bin
done ${PACKAGEROOT}/bin generated
done ${PACKAGEROOT}/bin
make ${PACKAGEROOT}/bin/package
prev package
exec - ${STDCP} -f package ${PACKAGEROOT}/bin/package
done ${PACKAGEROOT}/bin/package generated
done ${PACKAGEROOT}/bin/package
make ${INSTALLROOT}/bin/crossexec
prev crossexec
exec - ${STDCP} -f crossexec ${INSTALLROOT}/bin/crossexec
done ${INSTALLROOT}/bin/crossexec generated
done ${INSTALLROOT}/bin/crossexec
make ${INSTALLROOT}/bin/proto
note *
note * proto(1) has been removed, but install a backward compatibility stub
note * that allows old Mamfiles containing proto commands to keep working.
note *
prev proto.sh
exec - ${STDCP} proto.sh ${INSTALLROOT}/bin/proto && ${STDCHMOD} u+w,+x ${INSTALLROOT}/bin/proto
done ${INSTALLROOT}/bin/proto generated
done ${INSTALLROOT}/bin/proto
note *
note * ksh93 function search on PATH
note * ksh93 builtin command library -lcmd
Expand Down Expand Up @@ -245,44 +245,44 @@ make install
exec - echo "$h$N$p$N$f$N$l$u" > ${INSTALLROOT}/bin/.paths ;;
exec - esac
exec - fi
done ${INSTALLROOT}/bin/.paths generated
done ${INSTALLROOT}/bin/.paths
note *
note * probe initialization
note *
make ${INSTALLROOT}/lib/probe/C
exec - mkdir -p ${INSTALLROOT}/lib/probe/C
done ${INSTALLROOT}/lib/probe/C generated
done ${INSTALLROOT}/lib/probe/C
make ${INSTALLROOT}/lib/probe/C/probe
prev C+probe
exec - ${STDCP} -f C+probe ${INSTALLROOT}/lib/probe/C/probe
done ${INSTALLROOT}/lib/probe/C/probe generated
done ${INSTALLROOT}/lib/probe/C/probe
make ${INSTALLROOT}/lib/probe/C/make
exec - mkdir -p ${INSTALLROOT}/lib/probe/C/make
done ${INSTALLROOT}/lib/probe/C/make generated
done ${INSTALLROOT}/lib/probe/C/make
make ${INSTALLROOT}/lib/probe/C/pp
exec - mkdir -p ${INSTALLROOT}/lib/probe/C/pp
done ${INSTALLROOT}/lib/probe/C/pp generated
done ${INSTALLROOT}/lib/probe/C/pp
make ${INSTALLROOT}/lib/probe/C/mam
exec - mkdir -p ${INSTALLROOT}/lib/probe/C/mam
done ${INSTALLROOT}/lib/probe/C/mam generated
done ${INSTALLROOT}/lib/probe/C/mam
make ${INSTALLROOT}/lib/probe/C/mam/probe
prev mprobe
exec - ${STDCP} -f mprobe ${INSTALLROOT}/lib/probe/C/mam/probe
done ${INSTALLROOT}/lib/probe/C/mam/probe generated
done ${INSTALLROOT}/lib/probe/C/mam/probe
make ${INSTALLROOT}/lib/probe/C/mam/mprobe
prev mprobe
exec - ${STDCP} -f mprobe ${INSTALLROOT}/lib/probe/C/mam/mprobe
done ${INSTALLROOT}/lib/probe/C/mam/mprobe generated
done ${INSTALLROOT}/lib/probe/C/mam/mprobe
make ${INSTALLROOT}/lib/probe/C/make/probe
prev probe
exec - ${STDCP} -f probe ${INSTALLROOT}/lib/probe/C/make/probe
done ${INSTALLROOT}/lib/probe/C/make/probe generated
done ${INSTALLROOT}/lib/probe/C/make/probe
make ${INSTALLROOT}/include/ast
exec - mkdir -p ${INSTALLROOT}/include/ast
done ${INSTALLROOT}/include/ast generated
done ${INSTALLROOT}/include/ast
make ${INSTALLROOT}/lib/lib
exec - mkdir -p ${INSTALLROOT}/lib/lib
done ${INSTALLROOT}/lib/lib generated
done ${INSTALLROOT}/lib/lib
note *
note * check if -ldl is required
note *
Expand All @@ -297,9 +297,9 @@ make install
prev dl.c
prev mkreq-maplib
exec - mkreq-maplib ${CC} : dl : dl.c : dl
done dl.req generated
done dl.req
exec - ${STDCP} -f dl.req ${INSTALLROOT}/lib/lib/dl
done ${INSTALLROOT}/lib/lib/dl generated
done ${INSTALLROOT}/lib/lib/dl
note *
note * requiring these is a botch
note *
Expand All @@ -308,18 +308,18 @@ make install
prev iconv.c
prev mkreq-maplib
exec - mkreq-maplib ${CC} : iconv : iconv.c : iconv
done iconv.req generated
done iconv.req
exec - ${STDCP} -f iconv.req ${INSTALLROOT}/lib/lib/iconv
done ${INSTALLROOT}/lib/lib/iconv generated
done ${INSTALLROOT}/lib/lib/iconv
make ${INSTALLROOT}/lib/lib/w
make w.req
prev w.c
prev w2.c
prev mkreq-maplib
exec - mkreq-maplib ${CC} : w : w.c w2.c : w
done w.req generated
done w.req
exec - ${STDCP} -f w.req ${INSTALLROOT}/lib/lib/w
done ${INSTALLROOT}/lib/lib/w generated
done ${INSTALLROOT}/lib/lib/w
note *
note * miscellaneous -l* checks
note *
Expand All @@ -328,9 +328,9 @@ make install
prev intl.c
prev mkreq-maplib
exec - mkreq-maplib ${CC} : intl : intl.c : intl
done intl.req generated
done intl.req
exec - ${STDCP} -f intl.req ${INSTALLROOT}/lib/lib/intl
done ${INSTALLROOT}/lib/lib/intl generated
done ${INSTALLROOT}/lib/lib/intl
make ${INSTALLROOT}/lib/lib/m
make m.req
prev m.c
Expand All @@ -341,17 +341,17 @@ make install
prev m6.c
prev mkreq-maplib
exec - mkreq-maplib ${CC} : m : m.c m2.c m3.c m4.c m5.c m6.c : m
done m.req generated
done m.req
exec - ${STDCP} -f m.req ${INSTALLROOT}/lib/lib/m
done ${INSTALLROOT}/lib/lib/m generated
done ${INSTALLROOT}/lib/lib/m
make ${INSTALLROOT}/lib/lib/nsl
make nsl.req
prev nsl.c
prev mkreq-maplib
exec - mkreq-maplib ${CC} : nsl : nsl.c : nsl
done nsl.req generated
done nsl.req
exec - ${STDCP} -f nsl.req ${INSTALLROOT}/lib/lib/nsl
done ${INSTALLROOT}/lib/lib/nsl generated
done ${INSTALLROOT}/lib/lib/nsl
note *
note * what was sco smoking
note * almost all of gethost* are in -lnsl except gethostbyname which
Expand All @@ -364,9 +364,9 @@ make install
prev nsl.c
prev mkreq-maplib
exec - mkreq-maplib ${CC} : socket : socket.c nsl.c : socket
done socket.req generated
done socket.req
exec - ${STDCP} -f socket.req ${INSTALLROOT}/lib/lib/socket
done ${INSTALLROOT}/lib/lib/socket generated
done ${INSTALLROOT}/lib/lib/socket
note *
note * more substance abuse
note * gdbm's ndbm "compatibility" doesn't supply <ndbm.h>, instead supplies
Expand All @@ -387,23 +387,23 @@ make install
prev gdbm2.c
prev mkreq-maplib
exec - mkreq-maplib ${CC} : dbm : db.c gdbm.c gdbm1.c gdbm2.c : db gdbm_compat gdbm ndbm dbm
done dbm.req generated
done dbm.req
exec - ${STDCP} -f dbm.req ${INSTALLROOT}/lib/lib/dbm
done ${INSTALLROOT}/lib/lib/dbm generated
done install virtual
make test
make test.iffe
done ${INSTALLROOT}/lib/lib/dbm
done install
make test dontcare virtual
make test.iffe virtual
prev iffe.tst
exec - regress iffe.tst iffe
done test.iffe virtual
make test.mamake
done test.iffe
make test.mamake virtual
make mamake.tst
prev mamake.rt
exec - if test mamake.rt -nt mamake.tst
exec - then "$SHELL" "$INSTALLROOT/bin/mktest" --style=regress mamake.rt > mamake.tst
exec - fi
done mamake.tst generated
done mamake.tst
exec - : testing mamake as built by package.sh :
exec - regress mamake.tst mamake
done test.mamake virtual
done test dontcare virtual
done test.mamake
done test
13 changes: 9 additions & 4 deletions src/cmd/INIT/README-mamake.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ whereas `mamake` is simple and portable, and offers all the same flexibility.

Compared to the 2012-08-01 AT&T distribution,
ksh 93u+m made a few changes to `mamake` that make it easier to maintain Mamfiles by hand:
* If the `MAMAKE_STRICT` variable is set before any other mamake command is executed,
some backward incompatible changes are activated to facilitate maintainability.
* All Mamfiles have been indented for legibility. (See `bin/Mamfile_indent` in the distribution.)
* Indentation and word separators may use any whitespace (e.g. tabs), not only spaces.
* Unrecognized commands and rule attributes throw an error instead of being silently ignored.
* Fixed some crashing bugs and memory leaks.
* The `prev` command may now be used without a prior `make`...`done` to declare a simple
prerequisite, provided the `MAMAKE_STRICT` variable is set.
* The `notrace` attribute was added to disable xtrace for a rule's shell action.
* If `MAMAKE_STRICT` is set, appending attributes to the `done` command
produces a deprecation warning; please append them to `make` instead.

In addition, the following two simple shell scripts are now provided to aid
in maintaining and modernising Mamfiles:
Expand Down Expand Up @@ -61,7 +65,7 @@ For historical reasons, `info` and `meta` are also ignored.
### Rules ###

`make` *rule* [ *attribute* ... ]
`done` *rule* [ *attribute* ... ]
`done` *rule*

A `make`...`done` block defines the target rule named *rule* using the other commands described here.
Unless the `virtual` attribute is used, *rule* names the pathname of the file generated or referenced by the rule.
Expand All @@ -82,8 +86,9 @@ dependencies of its own, it may even be empty; this has the effect of merely
declaring a dependency on a prerequisite file, such as a source code file that
comes with the distribution or a file generated by a previously run Mamfile.

One or more *attribute*s may be specified by appending them to the `make` command
or to the `done` command; they have the same effect either way.
One or more *attribute*s may be specified by appending them to the `make` command.
(They may also be appended to the `done` command; the effect is the same either way.
This is deprecated and produces a warning if the `MAMAKE_STRICT` variable is defined.)
**Attributes apply to the current rule only and do not propagate down to nested rules.**
The following *attribute*s are available:
* `archive`: Ignored.
Expand All @@ -92,7 +97,7 @@ The following *attribute*s are available:
If the file exists then its last-modified timestamp is checked and propagated,
otherwise it is silently ignored.
* `generated`: Marks rules that produce output files generated by a shell action.
The `exec` command implicitly assigns this attribute, but it is customary to specify it regardless.
The `exec` command implicitly assigns this attribute.
* `ignore`: The timestamp associated with *rule* is ignored in dependency resolution.
* `implicit`: Marks the current rule as an implicit prerequisite of the enclosing parent rule.
An implicit prerequisite can make the parent rule out of date without triggering the parent action.
Expand Down
Loading

0 comments on commit fbf8f42

Please sign in to comment.