gprolog install-links Makefile rule

Keri Harris <[email protected]> Sat, 10 Jul 2021 13:53:39 +0200
Newsgroups gmane.comp.gnu.prolog.bugs
Message-ID <[email protected]>
--=-Cw6oYMF7NIdUvAv32vUy
Content-Type: multipart/alternative; boundary="=-LCT+RWvcgf/2a4ZCSMO8"


--=-LCT+RWvcgf/2a4ZCSMO8
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit

Hi

I ran into a couple of issues when installing gprolog-1.5.0:

1. the wildcard character ("*") is not expanded when linking binaries.

Links in $(INSTALL_DIR)/bin are created as:

    $(LN_S) $(INSTALL_DIR)/bin/* .

make won't expand *. (See the pitfalls of using wildcards in make [1]).
For example, installing gprolog on Gentoo Linux via a controlled
sandbox:

   (cd /var/tmp/portage/dev-lang/gprolog-1.5.0/image//usr/bin ; ln -s
-f /var/tmp/portage/dev-lang/gprolog-1.5.0/image//usr/lib64/gprolog-
1.5.0/bin/* .);
   ...
   * QA Notice: Symbolic link /usr/bin/* points to /usr/lib64/gprolog-
1.5.0/bin/* which does not exist
   >>> /usr/bin/* -> /usr/lib64/gprolog-1.5.0/bin/*


Instead the "wildcard" make function can be used for this purpose:

    $(LN_S) $(wildcard $(INSTALL_DIR)/bin/*) .

Another alternative is to use:

    for i in $(BIN_FILES); do $(LN_S) $(INSTALL_DIR)/bin/$$i .; done

2. the install-links rule may run too early

The rule refers to $(INSTALL_DIR)/bin/*. During a parallel make
install-links may run at the same time as install-system, leading to
$(wildcard $(INSTALL_DIR)/bin/*) being partially expanded or even
expanded to nothing. For example:

    (cd /var/tmp/portage/dev-lang/gprolog-1.5.0/image//usr/bin ; ln -s
-f  .);
    ...
    ln: ./.: cannot overwrite directory
    make: *** [Makefile:88: install-links] Error 1

I've attached the patch I'm using on Gentoo Linux.


Thanks

Keri

[1] 
https://www.gnu.org/software/make/manual/html_node/Wildcard-Pitfall.html#Wildcard-Pitfall


--=-LCT+RWvcgf/2a4ZCSMO8
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<html dir=3D"ltr"><head></head><body style=3D"text-align:left; direction:lt=
r;"><div>Hi</div><div><br></div><div>I ran into a couple of issues when ins=
talling gprolog-1.5.0:<br><br>1. the wildcard character ("*") is not expand=
ed when linking binaries.</div><div><br></div><div>Links in $(INSTALL_DIR)/=
bin are created as:</div><div><br></div><div>&nbsp; &nbsp; $(LN_S) $(INSTAL=
L_DIR)/bin/* .</div><div><br></div><div>make won't expand *. (See the pitfa=
lls of using wildcards in make [1]). For example, installing gprolog on Gen=
too Linux via a controlled sandbox:</div><div><br></div><div>&nbsp; &nbsp;(=
cd /var/tmp/portage/dev-lang/gprolog-1.5.0/image//usr/bin ; ln -s -f /var/t=
mp/portage/dev-lang/gprolog-1.5.0/image//usr/lib64/gprolog-1.5.0/bin/* .);<=
/div><div>&nbsp; &nbsp;...</div><div>&nbsp; &nbsp;* QA Notice: Symbolic lin=
k /usr/bin/* points to /usr/lib64/gprolog-1.5.0/bin/* which does not exist<=
/div><div>&nbsp; &nbsp;&gt;&gt;&gt; /usr/bin/* -&gt; /usr/lib64/gprolog-1.5=
.0/bin/*</div><div></div><div><br></div><div>Instead the "wildcard" make fu=
nction can be used for this purpose:</div><div><br></div><div>&nbsp; &nbsp;=
 $(LN_S) $(wildcard $(INSTALL_DIR)/bin/*) .</div><div><br></div><div>Anothe=
r alternative is to use:<br><br>&nbsp; &nbsp; for i in $(BIN_FILES); do $(L=
N_S) $(INSTALL_DIR)/bin/$$i .; done</div><div><br></div><div>2. the install=
-links rule may run too early</div><div><br></div><div>The rule refers to $=
(INSTALL_DIR)/bin/*. During a parallel make install-links may run at the sa=
me time as install-system, leading to $(wildcard $(INSTALL_DIR)/bin/*) bein=
g partially expanded or even expanded to nothing. For example:</div><div><b=
r></div><div>&nbsp; &nbsp; (cd /var/tmp/portage/dev-lang/gprolog-1.5.0/imag=
e//usr/bin ; ln -s -f &nbsp;.);</div><div>&nbsp; &nbsp; ...</div><div>&nbsp=
; &nbsp; ln: ./.: cannot overwrite directory</div><div>&nbsp; &nbsp; make: =
*** [Makefile:88: install-links] Error 1</div><div><br></div><div>I've atta=
ched the patch I'm using on Gentoo Linux.</div><div><br></div><div><br></di=
v><div>Thanks</div><div><br></div><div>Keri</div><div><br></div><div>[1]&nb=
sp;<a href=3D"https://www.gnu.org/software/make/manual/html_node/Wildcard-P=
itfall.html#Wildcard-Pitfall">https://www.gnu.org/software/make/manual/html=
_node/Wildcard-Pitfall.html#Wildcard-Pitfall</a></div><div><div></div></div=
></body></html>

--=-LCT+RWvcgf/2a4ZCSMO8--

--=-Cw6oYMF7NIdUvAv32vUy
Content-Disposition: attachment; filename="gprolog-1.5.0-links.patch"
Content-Type: text/x-patch; name="gprolog-1.5.0-links.patch"; charset="UTF-8"
Content-Transfer-Encoding: base64

LS0tIGdwcm9sb2ctMS41LjAub3JpZy9zcmMvTWFrZWZpbGUuaW4JMjAyMS0wNy0wNyAxNjowNjox
Ni4wMDAwMDAwMDAgLTAwMDAKKysrIGdwcm9sb2ctMS41LjAvc3JjL01ha2VmaWxlLmluCTIwMjEt
MDctMTAgMTE6MzA6MjkuMTMwMzcwOTk2IC0wMDAwCkBAIC04NCwxMCArODQsMTAgQEAKIAogIyAt
LS0gTGlua3MgLS0tICMKIAotaW5zdGFsbC1saW5rczogdW5pbnN0YWxsLWxpbmtzCitpbnN0YWxs
LWxpbmtzOiBpbnN0YWxsLXN5c3RlbSB1bmluc3RhbGwtbGlua3MKIAlpZiB0ZXN0ICQoTElOS1Nf
RElSKSAhPSBub25lOyB0aGVuIFwKIAkgICAuL21raW5zdGFsbGRpcnMgJChMSU5LU19ESVIpOyBc
Ci0JICAgKGNkICQoTElOS1NfRElSKSA7ICQoTE5fUykgJChJTlNUQUxMX0RJUikvYmluLyogLik7
IFwKKwkgICAoY2QgJChMSU5LU19ESVIpIDsgJChMTl9TKSAkKHdpbGRjYXJkICQoSU5TVEFMTF9E
SVIpL2Jpbi8qKSAuKTsgXAogCWZpCiAKIHVuaW5zdGFsbC1saW5rczoK


--=-Cw6oYMF7NIdUvAv32vUy--