Support source-to-object compilation in a DESTDIR
If environment variable 'gtm_destdir' is set, treat it as a prefix to be removed from any source file paths contained inside it. This will allow sources to be compiled in a DESTDIR for packaging such that the object files will find their sources in the final install prefix after distribution.
This commit is contained in:
parent
9e807f2434
commit
74aa25e075
|
@ -1,3 +1,5 @@
|
|||
#include "gtm_stdlib.h"
|
||||
#include "gtm_string.h"
|
||||
#include "mdef.h"
|
||||
|
||||
#include "obj_source.h"
|
||||
|
@ -8,5 +10,16 @@ GBLREF unsigned short source_name_len;
|
|||
struct obj_source get_obj_source(void)
|
||||
{
|
||||
struct obj_source sn = {source_file_name, source_name_len};
|
||||
char* gtm_destdir = getenv("gtm_destdir");
|
||||
if(gtm_destdir)
|
||||
{
|
||||
/* Strip the destdir prefix from sources inside it. */
|
||||
size_t const ddlen = strlen(gtm_destdir);
|
||||
if(strncmp(sn.name, gtm_destdir, ddlen) == 0)
|
||||
{
|
||||
sn.name += ddlen;
|
||||
sn.len -= ddlen;
|
||||
}
|
||||
}
|
||||
return sn;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue