flamewing / asl-releases

Improved/bugfixed version of Alfred Arnold's The Macro Assembler AS
http://john.ccac.rwth-aachen.de:8000/as/
GNU General Public License v2.0
20 stars 2 forks source link

Using custom directories in Makefile.def results in binaries unable to find libraries #21

Closed biggestsonicfan closed 6 months ago

biggestsonicfan commented 3 years ago

Using a Makefile.def with the following configuration

BINDIR = ./build/bin
INCDIR = ./build/include/asl
MANDIR = ./build/man
LIBDIR = ./build/lib/asl
DOCDIR = ./build/doc/asl

Results in the binary folder not being able to find the LIBDIR. I'm not quite able to understand where the executable binary is trying to look and would prefer if the executable understood where they should be looking at compile time.

flamewing commented 3 years ago

I think that this particular issue is due to using relative paths in the makefile; this will cause AS to look for LIBDIR starting on the cwd when you execute it. I will take a look at the search path later, but if I remember correctly, there is an environment variable you can set, or you can put the msg files together with the executable, or you can place them on LIBDIR, or you can place them on the path.

I think I would still like to make as recognize the relative LIBDIR path and try it relative to the base path of the executable to make things easier.

biggestsonicfan commented 3 years ago

Ah yeah, I used a full path and it worked. Moving the "build" folder as a whole, however, broke the link so the program isn't looking in the correct directory (how could it lol) so the application isn't so much portable as it can be compiled for use in a specific place.

I'm preferring not to "install" the program, but if this is a limitation perhaps that might be for the best to go ahead and install it.

flamewing commented 3 years ago

I confirmed the search order of the msg files to be this:

  1. Current working directory (usually not what you want);
  2. The executable path;
  3. The directory specified by AS_MSGPATH environment variable;
  4. Search in all locations in PATH environment variable;
  5. If the executable was found through PATH environment variable, tries that path replacing "bin" by "lib";
  6. The path specified in LIBDIR specified in the makefile

So the easiest solution would be to make LIBDIR equal to BINDIR and then you can move the build dir anywhere you want without issues. LIBDIR is used only for the msg files anyway.

Now that I am thinking about it, I think I might just change the msg-generating executable to generate a c file for instead of the msg files and include it directly on the executable. This will slightly increase the executable sizes but will speed up loading times, and will make portable binaries easier because it is just moving the executables around.

biggestsonicfan commented 6 months ago

I don't think we're going to see much traction on this issue, so closing.