From dbda7e15b0d9d45db55f3b90510e4181e7388fa6 Mon Sep 17 00:00:00 2001 From: mhrooz Date: Sun, 18 Aug 2024 23:13:18 +0200 Subject: [PATCH] Hello world initilized --- src/Makefile | 27 +++++++++++++++++++++++++++ src/main.c | 8 ++++++++ src/version.h | 6 ++++++ 3 files changed, 41 insertions(+) create mode 100644 src/Makefile create mode 100644 src/main.c create mode 100644 src/version.h 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