diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-09-26 15:29:59 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-09-26 15:29:59 +0200 |
commit | f3f471c65a8c1a16b203c4240a5e5ea1e09205ba (patch) | |
tree | 3305f0622973846a32cccabe388adcf427c417d3 | |
parent | 80739758ca113e3f205b14e047ab77f12a559df0 (diff) | |
download | glutte-o-matic-f3f471c65a8c1a16b203c4240a5e5ea1e09205ba.tar.gz glutte-o-matic-f3f471c65a8c1a16b203c4240a5e5ea1e09205ba.tar.bz2 glutte-o-matic-f3f471c65a8c1a16b203c4240a5e5ea1e09205ba.zip |
Improve vc.c generation
-rw-r--r-- | src/common/src/Core/main.c | 2 | ||||
-rw-r--r-- | src/glutt-o-logique/Makefile | 20 | ||||
-rw-r--r-- | src/glutt-o-logique/vc.c | 30 | ||||
-rw-r--r-- | src/simulator/Makefile | 18 |
4 files changed, 61 insertions, 9 deletions
diff --git a/src/common/src/Core/main.c b/src/common/src/Core/main.c index c70d0ff..df736c5 100644 --- a/src/common/src/Core/main.c +++ b/src/common/src/Core/main.c @@ -94,7 +94,7 @@ int main(void) { init(); delay_init(); usart_init(); - usart_debug_puts("\r\n******* glutt-o-matique version " GIT_VERSION " *******\r\n"); + usart_debug("\r\n******* glutt-o-matique version %s *******\r\n", vc_get_version()); #ifndef SIMULATOR diff --git a/src/glutt-o-logique/Makefile b/src/glutt-o-logique/Makefile index ddfd4fd..0febb9c 100644 --- a/src/glutt-o-logique/Makefile +++ b/src/glutt-o-logique/Makefile @@ -14,8 +14,8 @@ BINDIR=bin SRCDIR=. ASOURCES=$(shell find -L $(SRCDIR) -name '*.s') -CSOURCES+=$(shell find -L $(SRCDIR) -name '*.c') -HEADERS=$(shell find -L $(SRCDIR) -name '*.h') +CSOURCES+=$(shell find -L $(SRCDIR) -name '*.c' -not -name 'vc.c') +HEADERS=$(shell find -L $(SRCDIR) -name '*.h' -not -name 'vc.h') COMMON_DIR=../common COMMON_SOURCE_LIST=$(shell cat ../common/sourcelist.txt) @@ -29,6 +29,8 @@ INCLUDES=$(INC:%=-I%) OBJECTS=$(CSOURCES:%.c=obj/%.o) OBJECTS+=$(ASOURCES:%.s=obj/%.o) +OBJECTS+=obj/vc.o + # Define output files ELF & IHEX BINELF=outp.elf BINHEX=outp.hex @@ -124,13 +126,18 @@ $(BINDIR)/$(BINHEX): $(BINDIR)/$(BINELF) @echo "[CP] $@" @echo "[:)] Happiness :)" -$(BINDIR)/$(BINELF): vc.h $(OBJECTS) +$(BINDIR)/$(BINELF): $(OBJECTS) @$(CC) $(LDFLAGS) $(OBJECTS) -o $@ -lm - @echo "[CC] $@" + @echo "[LINK] $@" @$(SIZE) $(BINDIR)/$(BINELF) dir_guard=@mkdir -p $(@D) +obj/vc.o: vc.c vc.h $(HEADERS) + $(dir_guard) + @echo "[CC] version information vc.c" + @$(CC) $(CFLAGS) vc.c -o obj/vc.o + obj/%.o: %.c $(HEADERS) $(dir_guard) @echo "[CC] $<" @@ -141,13 +148,16 @@ obj/%.o: %.s $(HEADERS) @echo [AS] $< @$(CC) $(CFLAGS) $< -o $@ +.PHONY: vc.h vc.h: ../../.git/logs/HEAD @echo "// This file is generated by Makefile." > vc.h @echo "// Do not edit this file!" >> vc.h + @echo "const char* vc_get_version(void);" >> vc.h + @echo >> vc.h @git log -1 --format="format:#define GIT_VERSION \"%h\"" >> vc.h @echo >> vc.h @echo >> vc.h - @echo [EC] vc.h + @echo [GEN] vc.h clean: @rm -f $(OBJECTS) $(BINDIR)/$(BINELF) $(BINDIR)/$(BINHEX) diff --git a/src/glutt-o-logique/vc.c b/src/glutt-o-logique/vc.c new file mode 100644 index 0000000..253ab2d --- /dev/null +++ b/src/glutt-o-logique/vc.c @@ -0,0 +1,30 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Matthias P. Braendli, Maximilien Cuony + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. +*/ + +#include "vc.h" + +const char* vc_get_version() +{ + return GIT_VERSION; +} diff --git a/src/simulator/Makefile b/src/simulator/Makefile index ba2cc92..407e3c2 100644 --- a/src/simulator/Makefile +++ b/src/simulator/Makefile @@ -36,7 +36,7 @@ COMMON_SOURCE_LIST=$(shell cat ../common/sourcelist.txt) C_FILES+=$(COMMON_SOURCE_LIST:%.c=../common/%.c) # Main Object -SRC_SOURCES+=$(shell find -L src/ -name '*.c') +SRC_SOURCES+=$(shell find -L src/ -name '*.c' -not -name 'vc.c') C_FILES += $(SRC_SOURCES) # Include Paths @@ -48,6 +48,7 @@ INCLUDES += -I$(SRCROOT) # Generate OBJS names OBJS = $(patsubst %.c,%.o,$(C_FILES)) +OBJS += src/Core/vc.o ######## C Flags ######## @@ -101,6 +102,15 @@ _OBJS = $(patsubst %,$(ODIR)/%,$(OBJS)) dir_guard=@mkdir -p $(@D) +$(ODIR)/src/Core/vc.o: src/Core/vc.c vc.h + $(dir_guard) + @echo "[CC] version information vc.c" +ifeq ($(verbose),1) + $(CC) $(CFLAGS) src/Core/vc.c -c -o $(ODIR)/src/Core/vc.o +else + @$(CC) $(CFLAGS) src/Core/vc.c -c -o $(ODIR)/src/Core/vc.o +endif + $(ODIR)/%.o: %.c $(dir_guard) # If verbose, print gcc execution, else hide @@ -112,14 +122,16 @@ else @$(CC) $(CFLAGS) -c -o $@ $< endif - +.PHONY: vc.h vc.h: ../../.git/logs/HEAD @echo "// This file is generated by Makefile." > vc.h @echo "// Do not edit this file!" >> vc.h + @echo "const char* vc_get_version(void);" >> vc.h + @echo >> vc.h @git log -1 --format="format:#define GIT_VERSION \"%h\"" >> vc.h @echo >> vc.h @echo >> vc.h - @echo [EC] vc.h + @echo [GEN] vc.h FreeRTOS-Sim: $(_OBJS) @echo "[LK] $@" |