Missing file/headers
metrodango opened this issue · 6 comments
A simple make shows some missing headers/file:
[Thu Sep 05 11:20:42] $ make
python darmgen.py
python darmgen.py
python darmgen.py
python darmgen.py
python darmgen.py
python darmgen.py
gcc -std=c99 -Wall -O2 -s -Wextra -o darm.o -c darm.c -fPIC
gcc -std=c99 -Wall -O2 -s -Wextra -o armv7.o -c armv7.c -fPIC
In file included from darm.c:34:0:
darm.h:33:23: fatal error: armv7-tbl.h: No such file or directoryIn file included from armv7.c:33:0:
darm.h:33:23: fatal error: armv7-tbl.h: No such file or directory
compilation terminated.
compilation terminated.
make: *** [darm.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [armv7.o] Error 1
All right after trying again, it would appear that the files are created afterwards.
After investigation, the main cause is that I was running make with the -j8 flag (compilation across 8 processes).
it does work fine when the flag is set back to -j1 (single process).
It might be worth adding this to the doc.
Thanks for your feedback. Let me improve the Makefile a bit so this issue doesn't occur again.
(It's probably because make doesn't know which files are created by calling python darmgen.py
.)
Hmm, I'm not sure whether it's trivial to change this.. Because darmgen.py
creates several files, and make -j8
wants to make these files in parallel, thus it creates several python darmgen.py
processes.
I guess I could have darmgen.py
generate only one of the files at a time - it's not like it matters too much with regards to time it takes to compile, and it should fix said issues with -j8
.
If I'll do it, I'll notify through this issue, otherwise just compile using -j1
. It's only a couple of source files anyway.
Thanks for your bug report though! Let me know if you stumble upon anything else.
This one works for me:
AR = ar
CC = gcc
CFLAGS = -std=c99 -Wall -O2 -s -Wextra
INCLIBS = -I. -L. -ldarm
# I am not sure that the distinction is relevant here,
# as this Makefile won't work on Windows platforms (dlls extensions)
ifneq ($(OS),Windows_NT)
PIC_FLAGS = -fPIC
TESTSBIN = tests/tests
ELFDARMBIN = utils/elfdarm
else
TESTSBIN = tests/tests.exe
ELFDARMBIN = utils/elfdarm.exe
endif
TOOLS = $(TESTSBIN) $(ELFDARMBIN)
SHAREDLIB = libdarm.so
STATICLIB = libdarm.a
GENCODEHEADERS = darm-tbl.h armv7-tbl.h thumb-tbl.h
GENCODESRC = darm-tbl.c armv7-tbl.c thumb-tbl.c
GENCODEOBJ = $(GENCODESRC:.c=.o)
SRC = armv7.c darm.c thumb.c thumb2.c
OBJ = $(SRC:.c=.o)
TEMPSTUFF = $(SHAREDLIB) $(STATICLIB) $(TOOLS) $(GENCODEHEADERS) $(GENCODESRC) $(GENCODEOBJ) $(OBJ)
all: libdarm tools
rebuild: clean all
script-darmgen:
python darmgen.py
$(GENCODEOBJ): script-darmgen
$(CC) $(CFLAGS) $(PIC_FLAGS) -c $*.c
$(OBJ): script-darmgen
$(CC) $(CFLAGS) $(PIC_FLAGS) -c $*.c
libdarm: $(OBJ) $(GENCODEOBJ)
$(CC) -shared $(CFLAGS) -o $(SHAREDLIB) $(GENCODEOBJ) $(OBJ)
$(AR) cr $(STATICLIB) $(GENCODEOBJ) $(OBJ)
$(TOOLS):libdarm
$(CC) $(CFLAGS) -o $@ $@.c $(INCLIBS)
tools: $(TOOLS)
default: all
test: all
./tests/tests.exe
clean:
rm -f $(TEMPSTUFF)
Or even shorter
AR = ar
CC = gcc
CFLAGS = -std=c99 -Wall -O2 -s -Wextra
INCLIBS = -I. -L. -ldarm
# I am not sure that the distinction is relevant here,
# as this Makefile won't work on Windows platforms (dlls extensions)
ifneq ($(OS),Windows_NT)
PIC_FLAGS = -fPIC
TESTSBIN = tests/tests
ELFDARMBIN = utils/elfdarm
else
TESTSBIN = tests/tests.exe
ELFDARMBIN = utils/elfdarm.exe
endif
TOOLS = $(TESTSBIN) $(ELFDARMBIN)
LIBRARY = libdarm
SHAREDLIB = $(LIBRARY).so
STATICLIB = $(LIBRARY).a
GENCODESRC = darm-tbl.c armv7-tbl.c thumb-tbl.c
GENCODEHEADERS = $(GENCODESRC:.c=.h)
SRC = armv7.c darm.c thumb.c thumb2.c
OBJ = $(SRC:.c=.o) $(GENCODESRC:.c=.o)
GENSTUFF = $(SHAREDLIB) $(STATICLIB) $(TOOLS) $(GENCODEHEADERS) $(GENCODESRC) $(OBJ)
all: libdarm tools
rebuild: clean all
script-darmgen:
python darmgen.py
$(OBJ): script-darmgen
$(CC) $(CFLAGS) $(PIC_FLAGS) -c $*.c
libdarm: $(OBJ)
$(CC) -shared $(CFLAGS) -o $(SHAREDLIB) $(OBJ)
$(AR) cr $(STATICLIB) $(OBJ)
$(TOOLS):libdarm
$(CC) $(CFLAGS) -o $@ $@.c $(INCLIBS)
tools: $(TOOLS)
default: all
test: all
./$(TESTSBIN)
clean:
rm -f $(GENSTUFF)