automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setup for a project with autotools so resulting executables can see


From: Jamil Egdemir
Subject: Re: Setup for a project with autotools so resulting executables can see required binary files?
Date: Sun, 15 Mar 2015 12:10:26 -0400

Simon and Diego,  

Your assistance was most helpful.  Just to follow up I am posting my
modifications to the code I was working on in case anyone else has the
same question:

To allegro-learning/src/Makefile.am:

stargatedir = $(datadir)/stargate
stargate_DATA = stargate.bmp
stargate_SOURCES = stargate.c
stargate_CFLAGS = $(ALLEGRO_CFLAGS) -DPKGDATADIR=\"$(stargatedir)\"
stargate_LDFLAGS = $(ALLEGRO_LIBS) 

To stargate.c I added the following:

#include <stdio.h>

// for nice string concatenation:
#define Sasprintf(write_to,  ...) {           \
    char *tmp_string_for_extend = (write_to); \
    asprintf(&(write_to), __VA_ARGS__);       \
    free(tmp_string_for_extend);              \
}

char* addImageBaseDir(char* filename) {
  char *abspath = NULL;
  Sasprintf(abspath, PKGDATADIR);
  Sasprintf(abspath, "%s%s%s", abspath, "/", "stargate.bmp");
  return abspath;
}

and now I replace the original,

stargate = load_bitmap("stargate.bmp", NULL);

with,

stargate = load_bitmap(addImageBaseDir("stargate.bmp"), NULL)

and building with autotools now works just fine.  All the files land in
the proper location and through the macro the paths are available to the
code.  

Thanks again!
Jamil






reply via email to

[Prev in Thread] Current Thread [Next in Thread]