Mail Archives: geda-user/2023/03/30/03:02:22
--==_Exmh_1680158467_3450--
This is a multipart MIME message.
--==_Exmh_1680158467_3450
Content-Type: text/plain
Peter Stuge:
> karl AT aspodata DOT se [via geda-user AT delorie DOT com] wrote:
> > What sch2pcb wants is to find common.m4 and the footprint files.
> > But how?
> >
> > 1, the dirname trick:
> > $(dirname $(dirname $(which pcb)))/share/pcb
> > followed by m4, pcblib-newlib alt. newlib depending of what
> > we are looking for
>
> This isn't a good choice at all since it makes assumptions about how
> pcb was compiled - specifically that there is a fixed relationship
> between the pcb binary path and the library path.
Well, there seems there is one, at least per default:
$ cd <git>/pcb
$ grep -B1 BINDIR_TO_PCBLIBDIR config.h
/* Relative path from bindir to pcblibdir */
#define BINDIR_TO_PCBLIBDIR "../share/pcb"
$
which can be changed with
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
./configure --datarootdir=/opt
gives:
/* Relative path from bindir to pcblibdir */
#define BINDIR_TO_PCBLIBDIR "../../../opt/pcb"
> > 2, convince pcb devs. to add some cmdline option like
> > $ pcb --libpath
> > /usr/local/share/pcb
>
> This is by far the best!
Attached patch gives me (on stdout, without X required):
$ pcb --show-libdir
/home/local/bin/../share/pcb
$
> karl AT aspodata DOT se [via geda-user AT delorie DOT com] wrote:
> > pcb already have:
> > boxA:
> > $ pcb --show-defaults 2>&1 | grep lib-command-dir
> > lib-command-dir "/home/local/bin/../share/pcb"
> >
> > boxB:
> > $ pcb --show-defaults 2>&1 | grep lib-command-dir
> > lib-command-dir "/usr/bin/../share/pcb"
>
> Perfect! Great find.
>
> karl AT aspodata DOT se [via geda-user AT delorie DOT com] wrote:
> > > But unfortunately, pcb depends on X beeing available:
> > > $ pcb --show-defaults
> > > Error: Can't open display:
> >
> > "pcb -x ps --show-defaults" solves that.
>
> Okay - attached is a C snippet to grab the string.
The problem is that -x ps might be disabled with
./configure --with-exporters= --with-printer=
so we cannot rely on any exporter to be available at all
and we have to accept that X has to be up and running to
probe the value for unpatched pcb.
Regards,
/Karl Hammar
--==_Exmh_1680158467_3450
Content-Type: text/plain; charset="utf-8" ; name="patch"
Content-Description: patch
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="patch"
diff --git a/src/main.c b/src/main.c
index a4646a39..38644d93 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1685,6 +1685,13 @@ print_version ()
exit (0);
}
=
+static void
+print_libdir ()
+{
+ printf ("%s\n", pcblibdir);
+ exit (0);
+}
+
/* ---------------------------------------------------------------------=
-
* Figure out the canonical name of the executed program
* and fix up the defaults for various paths
@@ -2035,6 +2042,8 @@ main (int argc, char *argv[])
usage ();
if (argc > 1 && strcmp (argv[1], "-V") =3D=3D 0)
print_version ();
+ if (argc > 1 && strcmp (argv[1], "--show-libdir") =3D=3D 0)
+ print_libdir ();
/* Export pcb from command line if requested. */
if (argc > 1 && strcmp (argv[1], "-p") =3D=3D 0)
{
- Raw text -