mirror of
https://github.com/memtest86plus/memtest86plus.git
synced 2025-02-25 18:55:23 -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
|
# Object files
|
||||||
*.o
|
*.o
|
||||||
|
|
||||||
|
# Generated file
|
||||||
|
githash.h
|
||||||
|
|
||||||
# Binaries
|
# Binaries
|
||||||
memtest_shared
|
memtest_shared
|
||||||
memtest_shared.bin
|
memtest_shared.bin
|
||||||
@ -21,5 +24,4 @@ grub-iso
|
|||||||
html
|
html
|
||||||
latex
|
latex
|
||||||
|
|
||||||
# hash file
|
|
||||||
githash.h
|
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
AS = as -32
|
AS = as -32
|
||||||
CC = gcc
|
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 \
|
CFLAGS = -std=c11 -Wall -Wextra -Wshadow -m32 -march=i586 -fpic -fno-builtin \
|
||||||
-ffreestanding -fomit-frame-pointer -fno-stack-protector
|
-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 \
|
SYS_OBJS = system/cpuid.o \
|
||||||
system/cpuinfo.o \
|
system/cpuinfo.o \
|
||||||
@ -95,14 +103,23 @@ tests/%.o: ../tests/%.c
|
|||||||
@mkdir -p tests
|
@mkdir -p tests
|
||||||
$(CC) -c $(CFLAGS) -O3 $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
$(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
|
@mkdir -p app
|
||||||
$(CC) -c $(CFLAGS) -Os $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
$(CC) -c $(CFLAGS) -Os $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
||||||
|
|
||||||
githash.h:
|
app/githash.h: FORCE
|
||||||
echo -n '#ifndef GIT_HASH\n#define GIT_HASH "' > ../app/$@ && \
|
@mkdir -p app
|
||||||
git rev-parse HEAD | cut -c1-7 | tr -d "\n" >> ../app/$@ && \
|
@( \
|
||||||
echo '"\n#endif' >> ../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
|
# Link it statically once so I know I don't have undefined symbols and
|
||||||
# then link it dynamically so I have full relocation information.
|
# then link it dynamically so I have full relocation information.
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
AS = as -64
|
AS = as -64
|
||||||
CC = gcc
|
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 \
|
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
|
-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 \
|
SYS_OBJS = system/cpuid.o \
|
||||||
system/cpuinfo.o \
|
system/cpuinfo.o \
|
||||||
@ -94,14 +102,23 @@ tests/%.o: ../tests/%.c
|
|||||||
@mkdir -p tests
|
@mkdir -p tests
|
||||||
$(CC) -c $(CFLAGS) -O3 $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
$(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
|
@mkdir -p app
|
||||||
$(CC) -c $(CFLAGS) -Os $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
$(CC) -c $(CFLAGS) -Os $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
|
||||||
|
|
||||||
githash.h:
|
app/githash.h: FORCE
|
||||||
echo -n '#ifndef GIT_HASH\n#define GIT_HASH "' > ../app/$@ && \
|
@mkdir -p app
|
||||||
git rev-parse HEAD | cut -c1-7 | tr -d "\n" >> ../app/$@ && \
|
@( \
|
||||||
echo '"\n#endif' >> ../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
|
# Link it statically once so I know I don't have undefined symbols and
|
||||||
# then link it dynamically so I have full relocation information.
|
# then link it dynamically so I have full relocation information.
|
||||||
|
Loading…
Reference in New Issue
Block a user