aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rw-r--r--main.c9
2 files changed, 16 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 03205f0..ff57fd7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,6 @@
+PROGRAM_NAME=diff-dd
+PROGRAM_VERSION=1.0
+
CC=gcc
CFLAGS=-Wall
EXEC_NAME=diff-dd
@@ -5,10 +8,14 @@ EXEC_NAME=diff-dd
SOURCES=*.c
HEADERS=*.h
-all: $(SOURCES) $(HEADERS)
+all: $(SOURCES) $(HEADERS) program_info_header
$(CC) $(CFLAGS) -o $(EXEC_NAME) $(SOURCES)
+program_info_header:
+ echo "#define PROGRAM_NAME_STR \"$(PROGRAM_NAME)\"" >program_info.h
+ echo "#define PROGRAM_VERSION_STR \"$(PROGRAM_VERSION)\"" >>program_info.h
+
.PHONY: clean
clean:
- rm -f *.o *~ $(EXEC_NAME)
+ rm -f *.o *~ $(EXEC_NAME) program_info.h
diff --git a/main.c b/main.c
index 6968710..ea94921 100644
--- a/main.c
+++ b/main.c
@@ -11,11 +11,16 @@
#include "print.h"
#include "resources.h"
+/* This header file is automatically generated at build time from the Makefile
+ */
+#include "program_info.h"
+
void
usage(int exit_code)
{
- printf("Usage: diff-dd [-s SECTOR_SIZE] [-b BUFFER_SIZE] [INFILE] REFFILE "
- " OUTFILE\n");
+ printf("Usage: %s [-s SECTOR_SIZE] [-b BUFFER_SIZE] [INFILE] REFFILE "
+ "OUTFILE\n",
+ PROGRAM_NAME_STR);
exit(exit_code);
}