Commit 5433fa2f authored by Alessandro Rubini's avatar Alessandro Rubini

Makefile: three fixes

I'd better set CROSS_COMPILE in the environment than change my path,
so CROSS_COMPILE is conditionally assigned.

The revision is better "git describe --dirty" than "git rev-parse". The output
is a short beautiful string like "wrpc-v2.0-13-g09a736d5"
with an optional "-dirty" trailer, to show we compiled a non-committed
change.

Finally, to execute commands we dont $(shell) at toplevel, but have
them in the build rule.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 4cb937ab
......@@ -48,7 +48,7 @@ WITH_ETHERBONE=0
# and don't touch the rest unless you know what you're doing.
CROSS_COMPILE = lm32-elf-
CROSS_COMPILE ?= lm32-elf-
OBJS_WRC = wrc_main.o \
wrc_ptp.o \
......@@ -101,15 +101,15 @@ CFLAGS= $(CFLAGS_PLATFORM) $(CFLAGS_EB) $(CFLAGS_PTPD) $(INCLUDE_DIRS) -ffunctio
LDFLAGS= $(LDFLAGS_PLATFORM) -ffunction-sections -fdata-sections -Wl,--gc-sections -Os -Iinclude
OBJS=$(OBJS_PLATFORM) $(OBJS_WRC) $(OBJS_PTPD) $(OBJS_SHELL) $(OBJS_TESTS) $(OBJS_LIB) $(OBJS_SOCKITOWM) $(OBJS_SOFTPLL) $(OBJS_DEV)
OUTPUT=wrc
REVISION=$(shell git rev-parse HEAD)
REVISION=$(shell git describe --dirty --always)
$(shell ln -sf ../boards/$(BOARD)/board.h include/board.h)
all: tools wrc
wrc: $(OBJS)
echo "const char *build_revision = \"$(REVISION)\";" > revision.c
echo "const char *build_date = __DATE__ \" \" __TIME__;" >> revision.c
ln -sf ../boards/$(BOARD)/board.h include/board.h
$(CC) $(CFLAGS) -c revision.c
$(SIZE) -t $(OBJS)
${CC} -o $(OUTPUT).elf revision.o $(OBJS) $(LDFLAGS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment