mirror of
https://github.com/Lekensteyn/ltunify.git
synced 2025-12-09 02:03:22 +00:00
ltunify: Add --version (-V) option, use git version if possible
This commit is contained in:
9
Makefile
9
Makefile
@@ -9,6 +9,13 @@ udevrulesdir ?= /etc/udev/rules.d
|
|||||||
|
|
||||||
udevrule = 42-logitech-unify-permissions.rules
|
udevrule = 42-logitech-unify-permissions.rules
|
||||||
|
|
||||||
|
PACKAGE_VERSION ?= $(shell git describe --dirty 2>/dev/null | sed s/^v//)
|
||||||
|
ifeq (PACKAGE_VERSION, "")
|
||||||
|
LTUNIFY_DEFINES :=
|
||||||
|
else
|
||||||
|
LTUNIFY_DEFINES := -DPACKAGE_VERSION=\"$(PACKAGE_VERSION)\"
|
||||||
|
endif
|
||||||
|
|
||||||
%: %.c
|
%: %.c
|
||||||
$(CC) $(CFLAGS) -o $(OUTDIR)$@ $<
|
$(CC) $(CFLAGS) -o $(OUTDIR)$@ $<
|
||||||
|
|
||||||
@@ -17,7 +24,7 @@ all: ltunify read-dev-usbmon
|
|||||||
read-dev-usbmon: read-dev-usbmon.c hidraw.c
|
read-dev-usbmon: read-dev-usbmon.c hidraw.c
|
||||||
|
|
||||||
ltunify: ltunify.c hidpp20.c
|
ltunify: ltunify.c hidpp20.c
|
||||||
$(CC) $(CFLAGS) -o $(OUTDIR)$@ $< -lrt
|
$(CC) $(CFLAGS) -o $(OUTDIR)$@ $< -lrt $(LTUNIFY_DEFINES)
|
||||||
|
|
||||||
.PHONY: all clean install-home install install-udevrule uninstall
|
.PHONY: all clean install-home install install-udevrule uninstall
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
23
ltunify.c
23
ltunify.c
@@ -1010,6 +1010,13 @@ void get_device_names(int fd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_version(void) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Logitech Unifying tool version " PACKAGE_VERSION "\n"
|
||||||
|
"Copyright (C) 2013 Peter Wu <lekensteyn@gmail.com>\n");
|
||||||
|
}
|
||||||
|
|
||||||
void print_all_devices(void) {
|
void print_all_devices(void) {
|
||||||
unsigned i;
|
unsigned i;
|
||||||
puts("Connected devices:");
|
puts("Connected devices:");
|
||||||
@@ -1025,9 +1032,10 @@ void print_all_devices(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void print_usage(const char *program_name) {
|
static void print_usage(const char *program_name) {
|
||||||
fprintf(stderr, "Usage: %s [options] cmd [cmd options]\n"
|
fprintf(stderr, "Usage: %s [options] cmd [cmd options]\n",
|
||||||
"Logitech Unifying tool version %s\n"
|
program_name);
|
||||||
"Copyright (C) 2013 Peter Wu <lekensteyn@gmail.com>\n"
|
print_version();
|
||||||
|
fprintf(stderr,
|
||||||
"\n"
|
"\n"
|
||||||
"Generic options:\n"
|
"Generic options:\n"
|
||||||
" -d, --device path Bypass detection, specify custom hidraw device.\n"
|
" -d, --device path Bypass detection, specify custom hidraw device.\n"
|
||||||
@@ -1043,8 +1051,7 @@ static void print_usage(const char *program_name) {
|
|||||||
" receiver-info - Show information about the receiver\n"
|
" receiver-info - Show information about the receiver\n"
|
||||||
"In the above lines, \"idx\" refers to the device number shown in the\n"
|
"In the above lines, \"idx\" refers to the device number shown in the\n"
|
||||||
" first column of the list command (between 1 and 6). Alternatively, you\n"
|
" first column of the list command (between 1 and 6). Alternatively, you\n"
|
||||||
" can use the following names (case-insensitive):\n"
|
" can use the following names (case-insensitive):\n");
|
||||||
, program_name, PACKAGE_VERSION);
|
|
||||||
print_device_types();
|
print_device_types();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1067,12 +1074,13 @@ static int validate_args(int argc, char **argv, char ***argsp, char **hidraw_pat
|
|||||||
struct option longopts[] = {
|
struct option longopts[] = {
|
||||||
{ "device", 1, NULL, 'd' },
|
{ "device", 1, NULL, 'd' },
|
||||||
{ "help", 0, NULL, 'h' },
|
{ "help", 0, NULL, 'h' },
|
||||||
|
{ "version", 0, NULL, 'V' },
|
||||||
{ 0, 0, 0, 0 },
|
{ 0, 0, 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
*argsp = NULL;
|
*argsp = NULL;
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "+Dd:h", longopts, NULL)) != -1) {
|
while ((opt = getopt_long(argc, argv, "+Dd:hV", longopts, NULL)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'D':
|
case 'D':
|
||||||
debug_enabled = true;
|
debug_enabled = true;
|
||||||
@@ -1080,6 +1088,9 @@ static int validate_args(int argc, char **argv, char ***argsp, char **hidraw_pat
|
|||||||
case 'd':
|
case 'd':
|
||||||
*hidraw_path = optarg;
|
*hidraw_path = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'V':
|
||||||
|
print_version();
|
||||||
|
return 0;
|
||||||
case 'h':
|
case 'h':
|
||||||
print_usage(*argv);
|
print_usage(*argv);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user