diff --git a/Makefile b/Makefile index 2051944..e28ae96 100644 --- a/Makefile +++ b/Makefile @@ -2,15 +2,28 @@ # Contains targets for `release', `debug', and `clean'. PROJECT=naka -DESCRIPTION="Find a file within another file" +DESCRIPTION=Find a file within another file(s) AUTHOR=Avril (Flanchan) +LICENSE=GPL3+ + +VERSION_MAJ=0 +VERSION_MIN=0 +VERSION_BF=0 +VERSION_REV=0 + +VERSION:=$(VERSION_MAJ).$(VERSION_MIN).$(VERSION_BF).$(VERSION_REV) SRC_C = $(wildcard src/*.c) $(wildcard src/tests/*.c) SRC_CXX = $(wildcard src/*.cpp) INCLUDE=include -COMMON_FLAGS+= -W -Wall -fno-strict-aliasing $(addprefix -I,$(INCLUDE)) +META_FLAGS:=-D_PROJECT_AUTHOR="\"$(AUTHOR)\"" -D_PROJECT_DESCRIPTION="\"$(DESCRIPTION)\"" -D_PROJECT_NAME="\"$(PROJECT)\"" \ + -D_PROJECT_LICENSE="\"$(LICENSE)\"" \ + -D_VERSION_MAJOR=$(VERSION_MAJ) -D_VERSION_MINOR=$(VERSION_MIN) \ + -D_VERSION_BUGFIX=$(VERSION_BF) -D_VERSION_REVISION=$(VERSION_REV) + +COMMON_FLAGS+= -W -Wall -fno-strict-aliasing $(addprefix -I,$(INCLUDE)) $(META_FLAGS) ARCH?=native OPT_FLAGS+= -fgraphite -fopenmp -floop-parallelize-all -ftree-parallelize-loops=4 \ diff --git a/include/project.h b/include/project.h new file mode 100644 index 0000000..c8b260c --- /dev/null +++ b/include/project.h @@ -0,0 +1,23 @@ +//! Re-exports Makefile defines as more usable types +#ifndef _PROJECT_H +#define _PROJECT_H + +#include "version.h" + +/// Project version, as a raw version identifier (u32). +/// Use `v_rawtoc()` to convert to `version_t`. +#define PROG_VERSION VERSION(_VERSION_MAJOR, \ + _VERSION_MINOR, \ + _VERSION_BUGFIX, \ + _VERSION_REVISION) + +/// Project name. Output binary name +#define PROG_NAME _PROJECT_NAME +/// Project description +#define PROG_DESCRIPTION _PROJECT_DESCRIPTION +/// Project authour(s) +#define PROG_AUTHOUR _PROJECT_AUTHOR +/// Project license +#define PROG_LICENSE _PROJECT_LICENSE + +#endif /* _PROJECT_H */ diff --git a/src/main.c b/src/main.c index 42c7a3e..91908e8 100644 --- a/src/main.c +++ b/src/main.c @@ -8,14 +8,9 @@ #include #include -#include +#include -// TODO: Have Makefile define these, or import them from Makefile defines. -#define PROG_NAME "naka" -#define PROG_DESCRIPTION "find a file within other file(s)" -#define PROG_AUTHOUR "Avril " -#define PROG_LICENSE "GPL3+" -#define PROG_VERSION VERSION(0,0,0,0) +#include void prog_info(FILE* out) { @@ -44,11 +39,11 @@ noreturn void usage_then_exit(int err, int argc, char** argv) int main(int argc, char** argv) { - INFO("main start"); + TRACE("main start"); usage_then_exit(0, argc, argv); - INFO("main end"); + TRACE("main end"); return 0; }