Skip to content

Commit

Permalink
Support source-to-object compilation in a DESTDIR
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bradking committed Jun 18, 2012
1 parent 9e807f2 commit 74aa25e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sr_unix/obj_source.c
@@ -1,3 +1,5 @@
#include "gtm_stdlib.h"
#include "gtm_string.h"
#include "mdef.h"

#include "obj_source.h"
Expand All @@ -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;
}

0 comments on commit 74aa25e

Please sign in to comment.