X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com Message-ID: <20230330032511.12329.qmail@stuge.se> Date: Thu, 30 Mar 2023 03:25:11 +0000 From: "Peter Stuge (peter AT stuge DOT se) [via geda-user AT delorie DOT com]" To: geda-user AT delorie DOT com Subject: Re: [geda-user] lepton-sch2pcb: wrong ${prefix} for pcb MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="sm4nu43k4a2Rpi4c" Content-Disposition: inline In-Reply-To: <20230328193724.BDEE785E55FD@turkos.aspodata.se> <20230328063554 DOT 7EFAE85E4E5E AT turkos DOT aspodata DOT se> <20230323224044 DOT A6DA6849765A AT turkos DOT aspodata DOT se> Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk --sm4nu43k4a2Rpi4c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Karl, 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. > 3, test /usr /usr/local etc. for share/pcb/m4/common.m4 etc. This would be better than 1 but much worse than 2. > 2, convince pcb devs. to add some cmdline option like > $ pcb --libpath > /usr/local/share/pcb This is by far the best! 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. //Peter --sm4nu43k4a2Rpi4c Content-Type: text/x-c; charset=us-ascii Content-Disposition: attachment; filename="pcblib.c" #define _POSIX_C_SOURCE 2 /* popen pclose */ #define _XOPEN_SOURCE 500 /* realpath */ #include #include #include #include #include #include int main(int argc, char *argv[]) { int ret = EXIT_FAILURE; FILE *p; char buf[64 + PATH_MAX], *libdir, real_dir[PATH_MAX]; size_t n; p = popen("pcb -x ps --show-defaults 2>&1", "r"); if (NULL == p) { perror("popen"); exit(EXIT_FAILURE); } while (fgets(buf, sizeof buf, p)) { if (strncmp(buf, "lib-command-dir ", 16)) continue; libdir = buf + 16; if ('"' == libdir[0]) libdir++; n = strlen(libdir); while (n > 0 && strchr("\r\n\t ", libdir[n - 1])) libdir[--n] = 0; if (n > 0 && '"' == libdir[n - 1]) libdir[--n] = 0; printf("libdir '%s'\n", libdir); if (NULL == realpath(libdir, real_dir)) { perror("realpath"); continue; } printf("real dir '%s'\n", real_dir); ret = EXIT_SUCCESS; } pclose(p); return ret; } --sm4nu43k4a2Rpi4c--