neurobin / shc

Shell script compiler
https://neurobin.org/projects/softwares/unix/shc/
GNU General Public License v3.0
2k stars 338 forks source link

strip should be configurable #124

Closed embetrix closed 3 years ago

embetrix commented 3 years ago

when cross-compiling a script, strip does not recognise cross binary format :

strip: Unable to recognise the format of the input file test/test.bash.x

strip program should be in the same way configurable as CC via STRIP environment variable and not hard coded :

https://github.com/neurobin/shc/blob/master/src/shc.c#L1312

for example :

diff --git a/src/shc.c b/src/shc.c
index 7b73d85..ea75959 100644
--- a/src/shc.c
+++ b/src/shc.c
@@ -94,6 +94,7 @@ static const char * help[] = {
 "    Environment variables used:",
 "    Name    Default  Usage",
 "    CC      cc       C compiler command",
+"    STRIP   strip    Strip command",
 "    CFLAGS  <none>   C compiler flags",
 "    LDFLAGS <none>   Linker flags",
 "",
@@ -1309,7 +1310,10 @@ file2=strcat(file2,".x");
        if (verbose) fprintf(stderr, "%s: %s\n", my_name, cmd);
        if (system(cmd))
                return -1;
-       sprintf(cmd, "strip %s", file2);
+       char* strip = getenv("STRIP");
+       if (!strip)
+               strip = "strip";
+       sprintf(cmd, "%s %s", strip, file2);
        if (verbose) fprintf(stderr, "%s: %s\n", my_name, cmd);
        if (system(cmd))
                fprintf(stderr, "%s: never mind\n", my_name);