mirror of
https://github.com/memtest86plus/memtest86plus.git
synced 2024-11-27 01:50:20 -06:00
Better githash.h generation on Makefile from @martinwhitaker
This commit is contained in:
parent
1afcd08951
commit
8f0437c579
6
.gitignore
vendored
6
.gitignore
vendored
@ -7,6 +7,9 @@
|
||||
# Object files
|
||||
*.o
|
||||
|
||||
# Generated file
|
||||
githash.h
|
||||
|
||||
# Binaries
|
||||
memtest_shared
|
||||
memtest_shared.bin
|
||||
@ -21,5 +24,4 @@ grub-iso
|
||||
html
|
||||
latex
|
||||
|
||||
# hash file
|
||||
githash.h
|
||||
|
||||
|
@ -1,10 +1,18 @@
|
||||
AS = as -32
|
||||
CC = gcc
|
||||
|
||||
GIT = git
|
||||
|
||||
ifeq ($(GIT),none)
|
||||
GIT_AVAILABLE = false
|
||||
else
|
||||
GIT_AVAILABLE = true
|
||||
endif
|
||||
|
||||
CFLAGS = -std=c11 -Wall -Wextra -Wshadow -m32 -march=i586 -fpic -fno-builtin \
|
||||
-ffreestanding -fomit-frame-pointer -fno-stack-protector
|
||||
|
||||
INC_DIRS = -I../boot -I../system -I../lib -I../tests -I../app
|
||||
INC_DIRS = -I../boot -I../system -I../lib -I../tests -I../app -Iapp
|
||||
|
||||
SYS_OBJS = system/cpuid.o \
|
||||
system/cpuinfo.o \
|
||||
@ -95,14 +103,23 @@ tests/%.o: ../tests/%.c
|
||||
@mkdir -p tests
|
||||
$(CC) -c $(CFLAGS) -O3 $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
||||
|
||||
app/%.o: ../app/%.c githash.h
|
||||
app/%.o: ../app/%.c app/githash.h
|
||||
@mkdir -p app
|
||||
$(CC) -c $(CFLAGS) -Os $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
||||
|
||||
githash.h:
|
||||
echo -n '#ifndef GIT_HASH\n#define GIT_HASH "' > ../app/$@ && \
|
||||
git rev-parse HEAD | cut -c1-7 | tr -d "\n" >> ../app/$@ && \
|
||||
echo '"\n#endif' >> ../app/$@
|
||||
app/githash.h: FORCE
|
||||
@mkdir -p app
|
||||
@( \
|
||||
if $(GIT_AVAILABLE) && test -d ../.git ; then \
|
||||
hash=`git rev-parse HEAD | cut -c1-7`; \
|
||||
else \
|
||||
hash="unknown"; \
|
||||
fi; \
|
||||
define=`echo "#define GIT_HASH \"$$hash\""`; \
|
||||
echo $$define | diff - $@ > /dev/null 2>&1 || echo $$define > $@; \
|
||||
)
|
||||
|
||||
FORCE:
|
||||
|
||||
# Link it statically once so I know I don't have undefined symbols and
|
||||
# then link it dynamically so I have full relocation information.
|
||||
|
@ -1,10 +1,18 @@
|
||||
AS = as -64
|
||||
CC = gcc
|
||||
|
||||
GIT = git
|
||||
|
||||
ifeq ($(GIT),none)
|
||||
GIT_AVAILABLE = false
|
||||
else
|
||||
GIT_AVAILABLE = true
|
||||
endif
|
||||
|
||||
CFLAGS = -std=c11 -Wall -Wextra -Wshadow -m64 -march=x86-64 -mno-mmx -mno-sse -mno-sse2 \
|
||||
-fpic -fno-builtin -ffreestanding -fomit-frame-pointer -fno-stack-protector
|
||||
|
||||
INC_DIRS = -I../boot -I../system -I../lib -I../tests -I../app
|
||||
INC_DIRS = -I../boot -I../system -I../lib -I../tests -I../app -Iapp
|
||||
|
||||
SYS_OBJS = system/cpuid.o \
|
||||
system/cpuinfo.o \
|
||||
@ -94,14 +102,23 @@ tests/%.o: ../tests/%.c
|
||||
@mkdir -p tests
|
||||
$(CC) -c $(CFLAGS) -O3 $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
||||
|
||||
app/%.o: ../app/%.c githash.h
|
||||
app/%.o: ../app/%.c app/githash.h
|
||||
@mkdir -p app
|
||||
$(CC) -c $(CFLAGS) -Os $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
||||
|
||||
githash.h:
|
||||
echo -n '#ifndef GIT_HASH\n#define GIT_HASH "' > ../app/$@ && \
|
||||
git rev-parse HEAD | cut -c1-7 | tr -d "\n" >> ../app/$@ && \
|
||||
echo '"\n#endif' >> ../app/$@
|
||||
app/githash.h: FORCE
|
||||
@mkdir -p app
|
||||
@( \
|
||||
if $(GIT_AVAILABLE) && test -d ../.git ; then \
|
||||
hash=`git rev-parse HEAD | cut -c1-7`; \
|
||||
else \
|
||||
hash="unknown"; \
|
||||
fi; \
|
||||
define=`echo "#define GIT_HASH \"$$hash\""`; \
|
||||
echo $$define | diff - $@ > /dev/null 2>&1 || echo $$define > $@; \
|
||||
)
|
||||
|
||||
FORCE:
|
||||
|
||||
# Link it statically once so I know I don't have undefined symbols and
|
||||
# then link it dynamically so I have full relocation information.
|
||||
|
Loading…
Reference in New Issue
Block a user