First question---what exactly are you attempting to do? It's hard to see
what you want from your examples----the sample code hardcodes a script, so
are you trying to avoid having the user know the script to run? Are you
trying to make a stand alone executable? Knowing more context about what
you are trying to do will help.
What I am looking to do is take a lua app that uses various rocks and custom code and make it a self contained app that can be run on a new machine without saying ("now install X, Y, Z ...."). My current solution works well on macos and arm based linux (RPI) but is falling flat on X86 based linux
I know that there are various solutions that others have come up with but found that they are either (1) old and only work with 5.1, (2) platform specific, (3) no longer actually works, but most of all (4) undocumented workflow. So in the grand tradition I am reinventing another wheel. All I have to do is create a folder, drop a main.lua file into it as the root of the application, add other custom files and run the build script that will collect all the lua and .so dependencies and compile the C to run the app. It then gets zipped up and when unpacked on a machine without lua will run the application without issue
Unfortunately my C is rather rusty so I'm building this with the aid of google at the moment which is why you might be asking yourself "why is he doing this?"
Anyhow thanks for the pointers. Once I get off work I will try them out