Skip to content

Commit

Permalink
build system: relink ksh/shcomp if libraries change (re: 4eaf25c)
Browse files Browse the repository at this point in the history
When libast.a changed, ksh or shcomp were not getting relinked. To
make that happen, we have to repeat the 'bind -lshell' command,
which acts like 'prev' not just for libshell.a but also for all its
previously built dependencies from other directories.

Similarly, libcmd.a needed an extra 'bind -lsum' to re-extract
libsum.o and re-generated libcmd.a when libsum.a changes.

This commit also removes a few superflous 'prev' commands from some
Mamfiles and updates README-mamake.md with more complete info about
the effect of the 'bind' command.
  • Loading branch information
McDutchie committed Feb 27, 2024
1 parent c633714 commit a9a8586
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
15 changes: 10 additions & 5 deletions src/cmd/INIT/README-mamake.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,17 @@ causes a MAM variable `mam_lib`*libraryname* to be defined (see **MAM variables*
The variable will contain either the compiler argument for linking to the library *libraryname*
(either the `-l`*libraryname* flag, or the full path in case of a static library)
or, if the `dontcare` attribute is specified, possibly the empty string.
Any library dependencies are also included (see below).
This can be used both for AST libraries shipped with the distribution and for system libraries.
If the library file is found in the distribution,
its time stamp is checked and the current target is marked as outdated if it is newer.

The effect of `bind` is global, not scoped; it takes effect for all commands
physically following it, regardless of `make``done` nesting level.
For each corresponding *.a library archive dependency built previously,
its time stamp is checked and the current target is marked as outdated if it is
newer, as if a `prev` had been executed for it.

The variable set by `bind` is global, but the marking of the target as
outdated applies to the current rule only, so it may be necessary to
repeat a `bind` command when statically linking executables that depend
on a library, otherwise they may not be relinked when the library changes.
The `mam_lib`*libraryname* variable will not be regenerated when repeating a `bind`.

There is also a mechanism to communicate library dependency information across Mamfiles and `mamake` invocations.
If a file named *libraryname*`.req` in the current directory
Expand Down
5 changes: 2 additions & 3 deletions src/cmd/ksh93/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ make install virtual
shim - }

make ksh
prev libshell.a
bind -lshell
make pmain.o
prev sh/pmain.c
exec - ${compile} ${<}
Expand All @@ -1204,7 +1204,7 @@ make install virtual
done ksh

make shcomp
prev libshell.a
bind -lshell
make shcomp.o
prev sh/shcomp.c
exec - ${compile} ${<}
Expand All @@ -1216,7 +1216,6 @@ make install virtual
note * Pre-install
note *

prev libshell.a
loop DIR bin include/ast lib/lib man/man1 man/man3 fun etc
make ${INSTALLROOT}/${DIR}
exec - mkdir -p ${@}
Expand Down
2 changes: 0 additions & 2 deletions src/lib/libast/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -4931,8 +4931,6 @@ make install virtual
note * pre-install libast in $INSTALLROOT
note *

prev libast.a

note * ensure preinstallation directories exist
loop DIR include/ast lib/lib lib/file man/man3
make ${INSTALLROOT}/${DIR}
Expand Down
1 change: 1 addition & 0 deletions src/lib/libcmd/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ make install virtual
done
done
make sumlib.o
bind -lsum
exec - set -- ${mam_libsum}
exec - ${AR} x "$1" sumlib.o
done
Expand Down
1 change: 0 additions & 1 deletion src/lib/libsum/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ make install virtual
note * pre-install
note *

prev libsum.a
loop DIR ${INSTALLROOT}/lib/lib ${PACKAGE_ast_INCLUDE}
make ${DIR}
exec - mkdir -p ${@}
Expand Down

0 comments on commit a9a8586

Please sign in to comment.