Skip to content
Snippets Groups Projects
Commit 4bfe4a9d authored by Anjan Chanda's avatar Anjan Chanda
Browse files

show version info

parent 2f840318
Branches
No related tags found
No related merge requests found
Pipeline #197096 passed
......@@ -11,3 +11,4 @@ src/tags
src/mapcontroller
.configured_*
.pkgdir
version.h
......@@ -4,8 +4,12 @@ CFLAGS+=-I. -Iutils -D_GNU_SOURCE
CFLAGS+= -g -Wall
ifeq (,$(findstring EASYMESH_VERSION,$(CFLAGS)))
$(info 'EASYMESH_VERSION is not set. Build for 6')
$(info EASYMESH_VERSION is not set. Build for 6)
EASYMESH_VERSION=6
CFLAGS+=-DEASYMESH_VERSION=6
else
EASYMESH_VERSION=$(patsubst -DEASYMESH_VERSION=%,%,$(filter -DEASYMESH_VERSION=%,$(CFLAGS)))
$(info EASYMESH_VERSION passed is $(EASYMESH_VERSION))
endif
OBJS = \
......@@ -47,13 +51,24 @@ plugin_sofile = $(wildcard $(d)/*.so)
plugin_files = $(foreach d, $(plugin_subdirs), $(plugin_sofile))
HOOKS = pre-commit
.PHONY: all check clean plugins FORCE
.PHONY: all version.h check clean plugins FORCE
all: $(EXECS) plugins
all: version $(EXECS) plugins
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
version.h:
@(\
[ command -v git > /dev/null 2>&1 ] || { \
h=$(shell git rev-parse --short=8 HEAD); \
}; \
echo "const char *verstring = \"6.0\";" > $@; \
echo "const char *githash = \"$$h\";" >> $@; \
)
version: version.h
mapcontroller: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
......
......@@ -9,16 +9,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdint.h>
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "version.h"
#include "utils/debug.h"
#include "utils/utils.h"
......@@ -42,14 +44,19 @@ void usage(char *prog)
fprintf(stderr, " -v, debug verbosity; more 'v's mean more verbose\n");
fprintf(stderr, " -l, log to syslog\n");
fprintf(stderr, " -d, debug mode; i.e. don't daemonize\n");
fprintf(stderr, " -m, in debug mode trace alloc/free calls\n");
fprintf(stderr, " -p <pidfile> pid file path\n");
fprintf(stderr, " -o <file>, log to file\n");
fprintf(stderr, " -f, treat above file as fifo\n");
fprintf(stderr, " -w, wait for externall trigger\n");
fprintf(stderr, " -w, wait for external trigger\n");
fprintf(stderr, "\n");
}
static void print_version(void)
{
fprintf(stdout, "%s: %s-g%s\n", PROG_NAME, verstring, githash);
fprintf(stdout, "%s: EASYMESH_VERSION %d\n", PROG_NAME, EASYMESH_VERSION);
}
int main(int argc, char **argv)
{
struct log_options lopts = {
......@@ -59,10 +66,29 @@ int main(int argc, char **argv)
.level = DEFAULT_LOGLEVEL,
.features = LOG_FEATURE_ALL,
};
static struct option lgopts[] = {
{ "version", 0, 0, 0 },
{ "help", 0, 0, 0 },
{ 0, 0, 0, 0 },
};
int lidx = 0;
int ch;
while ((ch = getopt(argc, argv, "hlfdvws:o:p:")) != -1) {
while ((ch = getopt_long(argc, argv, "hlfdvws:o:p:", lgopts, &lidx)) != -1) {
switch (ch) {
case 0:
switch (lidx) {
case 0:
print_version();
exit(0);
case 1:
usage(argv[0]);
exit(0);
default:
break;
}
break;
case 's':
ubus_socket = optarg;
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment