[Slackbuilds-users] how can i define data_dir in makefile?

Matteo Bernardini matteo.bernardini at gmail.com
Tue Aug 21 18:20:14 UTC 2018


Fernando, when you are asking for help you should put a link to the
sources that you are trying to build, if it's not clear which ones:
are they these?

https://github.com/zombieCraig/ICSim

if they are I just cloned it here and run a simple command

$  grep -r DATA_DIR
controls.c:#ifndef DATA_DIR
controls.c:#define DATA_DIR "./data/"
controls.c:#define DEFAULT_CAN_TRAFFIC DATA_DIR "sample-can.log"
controls.c:  if(strlen(DATA_DIR) + strlen(fname) > 255) return NULL;
controls.c:  strncpy(data_file, DATA_DIR, 255);
icsim.c:#ifndef DATA_DIR
icsim.c:#define DATA_DIR "./data/"  // Needs trailing slash
icsim.c:  if(strlen(DATA_DIR) + strlen(fname) > 255) return NULL;
icsim.c:  strncpy(data_file, DATA_DIR, 255);
icsim.c:  if(stat(DATA_DIR, &dirstat) == -1) {
icsim.c:        printf("ERROR: DATA_DIR not found.  Define in make
file or run in src dir\n");

the Makefile is this

CC=gcc
CFLAGS=-I/usr/include/SDL2
LDFLAGS=-lSDL2 -lSDL2_image

all: icsim controls

icsim: icsim.o lib.o
        $(CC) $(CFLAGS) -o icsim icsim.c lib.o $(LDFLAGS)

controls: controls.o
        $(CC) $(CFLAGS) -o controls controls.c $(LDFLAGS)

lib.o:
        $(CC) lib.c

clean:
        rm -rf icsim controls icsim.o controls.o

this is a very basic software still in a very early stage.

if you want to build using your CFLAGS and adding a DATA_DIR you
should edit the Makefile before building usind sed, adding a line like
this

DATA_DIR=/usr/share/icsim

after the LDFLAGS one in the Makefile and modifying the CFLAGS one
adding $SLKCFLAGS (expanded).


More information about the SlackBuilds-users mailing list