fpcmkcfg and replacable parameters lazarus / 62-General ---------------------------------------------------------------------- dbannon · 2024-10-30 10:25 The FPC config file made by fpcmkcfg (in 3.2.4 RC1 and others) has version specific information in it, unnecessarily I believe. As I need to swap compilers around from time to time and expect to so until a new FPC release is made, I need my config to work with various versions of FPC. But a typical line in the fpc.cfg (from fpcmkcfg) looks like - Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -Fu/home/dbannon/bin/FPC/fpc-3.2.4/units/$fpctarget # but should, IMHO be like this - -Fu/home/dbannon/bin/FPC/fpc-$fpcversion/units/$fpctarget The macro, $fpcversion is listed by fpcmkcfg and seems to have been working for some time. But I cannot find a way to use it, a user error (?) any suggestions please ?  Its not particularly difficult to edit the file with sed but it seems silly that it is necessary. Incidentally, my command line looks like this - Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $> fpcmkcfg -d basepath="$HOME"/bin/FPC/fpc-3.2.4 > ~/.fpc.cfg Davo ---------------------------------------------------------------------- TRon · 2024-10-30 10:36 The issue you are facing is due to the fact that the terminal gives special meaning to a dollar sign. So the option needs to be escaped. I am not entirely sure if this also works on/for the command-line but it does work inside a script. Code: [Select]fpcmkcfg -d "basepath=/somewhere/somehow/\$fpcversion" ---------------------------------------------------------------------- MarkMLl · 2024-10-30 10:54 I'm pretty sure that a hardcoded version is an error, my (Linux) systems all have $fpcversion. The one thing I'd add to what TRon's said is that if you're having problems with quoting you might find it easier to write your setup script using Perl rather than shell, since by and large that will give you far more control. I've wrestled with this sort of thing in the past (I think it was in the context of writing scripts to control a SCSI-connected tape changer) and while it worked in the end I concluded 90% of the way through that shell was quite simply the wrong tool for the job. MarkMLl ---------------------------------------------------------------------- marcov · 2024-10-30 10:58 Quote from: TRon on October 30, 2024, 11:36:38 amThe issue you are facing is due to the fact that the terminal gives special meaning to a dollar sign. So the option needs to be escaped. I am not entirely sure if this also works on/for the command-line but it does work inside a script. Code: [Select]fpcmkcfg -d "basepath=/somewhere/somehow/\$fpcversion" (btw: afaik the FPC installer script that calls this, specifies bash in the shebang, so if that kind of escaping is for other shells...) ---------------------------------------------------------------------- TRon · 2024-10-30 11:01 Quote from: marcov on October 30, 2024, 11:58:33 am(btw: afaik the FPC installer script that calls this, specifies bash in the shebang, so if that kind of escaping is for other shells...) True, but I am/was more or less guessing that dbannon uses bash. @MarkMLI: fpcmkcfg used to contain several 'default' templates (not sure if that is still the case) and you can at least provide a (custom) default template if you happen to have one. ---------------------------------------------------------------------- dbannon · 2024-10-30 11:53 Thanks folks but I think I am not communicating here, the problem I mention can be replicated with pure command line entries.  No scripts, no passed envvars, no use of a $ in any command. Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i dbannon@dell:~$ fpcmkcfg -d basepath=/home/dbannon/bin/FPC/fpc-3.2.4 | grep Fu...-Fu/home/dbannon/bin/FPC/fpc-3.2.4/units/$fpctarget- Fu/home/dbannon/bin/FPC/fpc-3.2.4/units/$fpctarget/*... (Removed most lines for brevity, they all contain the "3.2.4" version number) Are other people not seeing this ?  Thats interesting ... Davo ---------------------------------------------------------------------- TRon · 2024-10-30 11:57 Sorry dbannon but in that case I either am daft or still not fully grasp what you meant. Quote$fpcmkcfg -d basepath=/home/dbannon/bin/FPC/fpc-3.2.4 The basepath option is provided including the 3.2.4 numbers so it will store that literally in the generated configuration file. apologies for any miscommunication in advance. edit Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $fpcmkcfg -d "basepath=/somewhere/somehow/\$fpcversion" | grep Fu-Fu/somewhere/s omehow/$fpcversion/units/$fpctarget/$fpcsubarch-$fpcmemorymodel-Fu/som ewhere/somehow/$fpcversion/units/$fpctarget/$fpcsubarch- $fpcmemorymodel/*- Fu/somewhere/somehow/$fpcversion/units/$fpctarget/$fpcsubarch- $fpcmemorymodel/rtl-Fu/somewhere/somehow/$fpcversion/units/$fpctarget- Fu/somewhere/somehow/$fpcversion/units/$fpctarget/*- Fu/somewhere/somehow/$fpcversion/units/$fpctarget/rtl-Fu/somewhere/som ehow/$fpcversion/units/$fpctarget/httpd13/- Fu/somewhere/somehow/$fpcversion/units/$fpctarget/httpd20- Fu/somewhere/somehow/$fpcversion/units/$fpctarget/httpd22- Fu~/.fppkg/lib/fpc/$fpcversion/units/$FPCTARGET/*  vs Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpcmkcfg -d "basepath=/somewhere/somehow/fpc-3.2.4" | grep Fu-Fu/somewhere/somehow /fpc-3.2.4/units/$fpctarget/$fpcsubarch-$fpcmemorymodel-Fu/somewhere/s omehow/fpc-3.2.4/units/$fpctarget/$fpcsubarch-$fpcmemorymodel/*- Fu/somewhere/somehow/fpc-3.2.4/units/$fpctarget/$fpcsubarch- $fpcmemorymodel/rtl-Fu/somewhere/somehow/fpc-3.2.4/units/$fpctarget-Fu /somewhere/somehow/fpc-3.2.4/units/$fpctarget/*- Fu/somewhere/somehow/fpc-3.2.4/units/$fpctarget/rtl-Fu/somewhere/someh ow/fpc-3.2.4/units/$fpctarget/httpd13/-Fu/somewhere/somehow/fpc- 3.2.4/units/$fpctarget/httpd20-Fu/somewhere/somehow/fpc- 3.2.4/units/$fpctarget/httpd22- Fu~/.fppkg/lib/fpc/$fpcversion/units/$FPCTARGET/* ---------------------------------------------------------------------- MarkMLl · 2024-10-30 11:58 I've seen embedded numbers like that once, years ago, and I think it was associated with a target which was "work in progress". MarkMLl ---------------------------------------------------------------------- dbannon · 2024-10-30 12:15 No, you are all correct and I should have read TRon's post more carefully. Yep, putting in a variable, already containing the true path, works eexactly as I expected it too ! Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $> export fpcversion="fpc-3.2.4"$> fpcmkcfg -d basepath=/home/dbannon/bin/FPC/\$fpcversion | grep Fu...-Fu/home/dbannon/bin/FPC/$fpcversion/units/$fpctarget- Fu/home/dbannon/bin/FPC/$fpcversion/units/$fpctarget/* Sorry for the noise ! Davo ---------------------------------------------------------------------- TRon · 2024-10-30 12:21 Quote from: dbannon on October 30, 2024, 01:15:28 pmYep, putting in a variable, already containing the true path, works eexactly as I expected it too ! Well, actually... if the aim is to have a environment variable substituted (at compile time) inside fpc.cfg (from my own config file): Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -d "basepath=\$fpc_root_directory\$/\$fpcversion" Note the envar enclosed between dollar signs If the aim is to replace when/while creating the cfg file then $name_of_envar (just like $HOME) should be enough., e.g. Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -d "basepath=/somewhere/$name_of_envar/somehow"  combined: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -d "basepath=/\$somewhere\$/$some_envar/somehow/\$fpcversion" - $somewhere$ will be replaced at compile time with envar somewhere (if it exist, else empty) - some_envar is replaced at creation time when making the config file - $fpcversion will be replaced by the compiler's version number at compile time