Build System Bug on Arch Linux

mwaters517 <[email protected]> Wed, 09 Sep 2020 14:36:56 +1000
Newsgroups gmane.comp.gnu.gnucap.bugs
Message-ID <[email protected]>
Hi All,

I've found a some what obscure bug in the GNU-CAP build system. I've 
figured out what the
problem is and can offer a solution that has been tested and appears to 
work. I've tested
this against the latest git repository.

As the build system proceeds it moves through each gnucap sub-directory 
(eg. gnucap/apps)
and uses "pwd" and "sed" to create the LIBPATH and MODELGEN directories. 
Unfortunately if
the current working directory contains two or more instances of the 
sub-directory name
(in my case "apps") the build breaks :

...
...
make[1]: Entering directory '/home/user/apps/geda/gnucap/git/apps'
mkdir O
mkdir: cannot create directory ‘O’: File exists
make[1]: [Makefile:31: default] Error 1 (ignored)
cat Make1 Make2 ../Make3 Make.depend >O/Makefile
(cd O; make -k)
make[2]: Entering directory '/home/user/apps/geda/gnucap/git/apps/O'
(export LD_LIBRARY_PATH=`pwd | sed 's/apps/lib/g'`; `pwd | sed 
's/apps/modelgen/g'`/gnucap-modelgen -cc ../d_mos1.model)
/bin/sh: /home/user/modelgen/geda/gnucap/git/modelgen/O/gnucap-modelgen: 
No such file or directory
...
...

In the above, the directory "apps" appears twice and so gets replaced 
twice. I've found an
incantation of "sed" where the last appearance of a string is replaced, 
which is what is
required here. Instead of using : sed 's/apps/lib/g', use : sed 
's/\(.*\)apps/\1lib/'`. I only
have a problem with the directory "apps" but it could happen in any of 
the other sub-directories
as well.

The fault occurs in the file gnucap/apps/Make1. The following shows the 
original lines commented
out and the new lines replacing them :

#LIBPATH = `pwd | sed 's/apps/lib/g'`
LIBPATH = `pwd | sed 's/\(.*\)apps/\1lib/'`
#MODELGEN = `pwd | sed 's/apps/modelgen/g'`/gnucap-modelgen
MODELGEN = `pwd | sed 's/\(.*\)apps/\1modelgen/'`/gnucap-modelgen

Incidentally, "mkdir" has the switch "-p" so that if the directory to be 
made already exist no
error message is generated.

Hope this helps. Thanks for your efforts writing gnucap.

Mike Waters