diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..3b18466 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,27 @@ +OBJECTS = main.o +TARGET = hello + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(CC) -o $@ $^ + +main.o: | new_header +main.o: version.h + +new_header: + @sed -e "s//$$(git describe)/g" \ + version.h.tmp + @if diff -q version.h.tmp version.h > /dev/null 2>&1; \ + then \ + rm version.h.tmp; \ + else \ + echo "version.h.in => version.h" ; \ + mv version.h.tmp version.h;\ + fi + +clean: + rm -f $(TARGET) $(OBJECTS) version.h + +.PHONY: all clean + diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..05b8086 --- /dev/null +++ b/src/main.c @@ -0,0 +1,8 @@ +#include "version.h" +#include + +int main(){ + printf("Hello, world. \n"); + printf("version: %s. \n", _VERSION); + return 0; +} diff --git a/src/version.h b/src/version.h new file mode 100644 index 0000000..6eadb96 --- /dev/null +++ b/src/version.h @@ -0,0 +1,6 @@ +#ifndef HELLO_WORLD_VERSION_H +#define HELLO_WORLD_VERSION_H + +#define _VERSION "old_practise" + +#endif