aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile10
-rw-r--r--src/opendeco-cli.c24
2 files changed, 33 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 6ac73b0..00461f7 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,8 @@ OBJ_BIN = src/opendeco.o src/opendeco-cli.o src/opendeco-conf.o src/deco.o src/o
OBJ_LIB = src/deco.o src/output.o src/schedule.o
OBJ_TST = test/opendeco_test.o test/deco_test.o src/deco.o minunit/minunit.o
+LICENSES = minunit/LICENSE.h toml/LICENSE.h
+
DEPS = $(shell find -type f -name "*.dep")
all: opendeco opendeco_test libopendeco.a
@@ -45,15 +47,21 @@ opendeco_test: $(OBJ_TST)
libopendeco.a: $(OBJ_LIB)
@ar rs libopendeco.a $(OBJ_LIB)
-%.o: %.c
+%.o: %.c # override the built-in default recipe
+%.o: %.c $(LICENSES)
@echo " CC $@"
@mkdir -p .dep/$(dir $@)
@$(CC) $(CFLAGS) -MD -MF .dep/$@.dep -o $@ -c $<
+%LICENSE.h: %LICENSE
+ @echo " XXD $@"
+ @xxd -i $< > $@
+
clean:
rm -f $(OBJ_BIN)
rm -f $(OBJ_LIB)
rm -f $(OBJ_TST)
+ rm -f $(LICENSES)
rm -f opendeco
rm -f opendeco_test
rm -f libopendeco.a
diff --git a/src/opendeco-cli.c b/src/opendeco-cli.c
index 8fb0ebd..f9f510e 100644
--- a/src/opendeco-cli.c
+++ b/src/opendeco-cli.c
@@ -3,9 +3,22 @@
#include <argp.h>
#include <stdlib.h>
#include <string.h>
+#include <wchar.h>
#include "opendeco-cli.h"
+#include "toml/LICENSE.h"
+#include "minunit/LICENSE.h"
+
+#define print_xxd_arr(name, arrname) \
+ do { \
+ wprintf(L"--------\n\n"); \
+ wprintf(L"License for: %s\n\n", name); \
+ for (int i = 0; i < arrname##_len; i++) \
+ putwchar(arrname[i]); \
+ wprintf(L"\n"); \
+ } while (0)
+
static char args_doc[] = "";
static char doc[] = "Implementation of Buhlmann ZH-L16 with Gradient Factors:"
"\vExamples:\n\n"
@@ -33,9 +46,17 @@ static struct argp_option options[] = {
{"showtravel", 'T', 0, 0, "Show travel segments in deco plan", 11},
{0, 0, 0, 0, "Informational options:", 0 },
+ {"licenses", -1, 0, 0, "Show third-party licenses", 0 },
{0, 0, 0, 0, 0, 0 }
};
+static void print_licenses()
+{
+ wprintf(L"THIRD-PARTY LICENSES:\n\n");
+ print_xxd_arr("cktan/tomlc99", toml_LICENSE);
+ print_xxd_arr("siu/minunit", minunit_LICENSE);
+}
+
static error_t parse_opt(int key, char *arg, struct argp_state *state)
{
struct arguments *arguments = state->input;
@@ -83,6 +104,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
case 'T':
arguments->SHOW_TRAVEL = 1;
break;
+ case -1:
+ print_licenses();
+ exit(ARGP_ERR_UNKNOWN);
case ARGP_KEY_END:
if (arguments->depth < 0 || arguments->time < 0) {
argp_state_help(state, stderr, ARGP_HELP_USAGE);