From 96fe966928cd83f22aed388a11013b67c1a374a1 Mon Sep 17 00:00:00 2001 From: cbdev Date: Fri, 6 Dec 2019 18:58:59 +0100 Subject: Make install path for examples configurable --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 8b2d7ec..8dab638 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ OBJS = config.o backend.o plugin.o PREFIX ?= /usr PLUGIN_INSTALL = $(PREFIX)/lib/midimonster +EXAMPLES ?= $(PREFIX)/share/midimonster SYSTEM := $(shell uname -s) CFLAGS ?= -g -Wall -Wpedantic @@ -68,8 +69,8 @@ install: install -m 0755 midimonster "$(DESTDIR)$(PREFIX)/bin" install -d "$(DESTDIR)$(PLUGIN_INSTALL)" install -m 0755 backends/*.so "$(DESTDIR)$(PLUGIN_INSTALL)" - install -d "$(DESTDIR)$(PREFIX)/share/midimonster" - install -m 0644 configs/* "$(DESTDIR)$(PREFIX)/share/midimonster" + install -d "$(DESTDIR)$(EXAMPLES)" + install -m 0644 configs/* "$(DESTDIR)$(EXAMPLES)" ifdef DEFAULT_CFG install -Dm 0644 monster.cfg "$(DESTDIR)$(DEFAULT_CFG)" endif -- cgit v1.2.3 From e517dbe783e65fdd1c80f5c917f8f924e2adfe8d Mon Sep 17 00:00:00 2001 From: cbdev Date: Tue, 10 Dec 2019 23:28:02 +0100 Subject: Implement rudimentary argument parsing --- Makefile | 8 +++++++- midimonster.c | 27 ++++++++++++++++++++++++--- midimonster.h | 5 +++++ 3 files changed, 36 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 8dab638..5183fa5 100644 --- a/Makefile +++ b/Makefile @@ -5,13 +5,19 @@ PREFIX ?= /usr PLUGIN_INSTALL = $(PREFIX)/lib/midimonster EXAMPLES ?= $(PREFIX)/share/midimonster SYSTEM := $(shell uname -s) +GITVERSION = $(shell git describe) +# Default compilation CFLAGS CFLAGS ?= -g -Wall -Wpedantic +#CFLAGS += -DDEBUG # Hide all non-API symbols for export CFLAGS += -fvisibility=hidden -#CFLAGS += -DDEBUG midimonster: LDLIBS = -ldl +# Replace version string with current git-describe if possible +ifneq "$(GITVERSION)" "" +midimonster: CFLAGS += "-DMIDIMONSTER_VERSION=\"$(GITVERSION)\"" +endif # Work around strange linker passing convention differences in Linux and OSX ifeq ($(SYSTEM),Linux) diff --git a/midimonster.c b/midimonster.c index e6c0842..67614d4 100644 --- a/midimonster.c +++ b/midimonster.c @@ -223,8 +223,12 @@ static void event_free(){ } } +static void version(){ + fprintf(stderr, "MIDIMonster %s\n", MIDIMONSTER_VERSION); +} + static int usage(char* fn){ - fprintf(stderr, "MIDIMonster v0.3\n"); + version(); fprintf(stderr, "Usage:\n"); fprintf(stderr, "\t%s \n", fn); return EXIT_FAILURE; @@ -263,6 +267,21 @@ static int platform_initialize(){ return 0; } +static int args_parse(int argc, char** argv, char** cfg_file){ + size_t u; + for(u = 1; u < argc; u++){ + if(!strcmp(argv[u], "-v") || !strcmp(argv[u], "--version")){ + version(); + return 1; + } + + //if nothing else matches, it's probably the configuration file + *cfg_file = argv[u]; + } + + return 0; +} + int main(int argc, char** argv){ fd_set all_fds, read_fds; event_collection* secondary = NULL; @@ -271,8 +290,10 @@ int main(int argc, char** argv){ managed_fd* signaled_fds = NULL; int rv = EXIT_FAILURE, error, maxfd = -1; char* cfg_file = DEFAULT_CFG; - if(argc > 1){ - cfg_file = argv[1]; + + //parse commandline arguments + if(args_parse(argc, argv, &cfg_file)){ + return EXIT_FAILURE; } if(platform_initialize()){ diff --git a/midimonster.h b/midimonster.h index 5ce0c73..677eeee 100644 --- a/midimonster.h +++ b/midimonster.h @@ -5,6 +5,11 @@ #include #include +/* Core version unless set by the build process */ +#ifndef MIDIMONSTER_VERSION + #define MIDIMONSTER_VERSION "v0.3-dist" +#endif + /* API call attributes and visibilities */ #ifndef MM_API #ifdef _WIN32 -- cgit v1.2.3 From ec01135171e4a57450e0250cf08cd4d60a8ad9ee Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 11 Dec 2019 22:38:46 +0100 Subject: Fix makefile indentation --- Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5183fa5..1f6f212 100644 --- a/Makefile +++ b/Makefile @@ -71,14 +71,14 @@ run: valgrind --leak-check=full --show-leak-kinds=all ./midimonster install: - install -d "$(DESTDIR)$(PREFIX)/bin" - install -m 0755 midimonster "$(DESTDIR)$(PREFIX)/bin" - install -d "$(DESTDIR)$(PLUGIN_INSTALL)" - install -m 0755 backends/*.so "$(DESTDIR)$(PLUGIN_INSTALL)" - install -d "$(DESTDIR)$(EXAMPLES)" - install -m 0644 configs/* "$(DESTDIR)$(EXAMPLES)" + install -d "$(DESTDIR)$(PREFIX)/bin" + install -m 0755 midimonster "$(DESTDIR)$(PREFIX)/bin" + install -d "$(DESTDIR)$(PLUGIN_INSTALL)" + install -m 0755 backends/*.so "$(DESTDIR)$(PLUGIN_INSTALL)" + install -d "$(DESTDIR)$(EXAMPLES)" + install -m 0644 configs/* "$(DESTDIR)$(EXAMPLES)" ifdef DEFAULT_CFG - install -Dm 0644 monster.cfg "$(DESTDIR)$(DEFAULT_CFG)" + install -Dm 0644 monster.cfg "$(DESTDIR)$(DEFAULT_CFG)" endif sanitize: export CC = clang -- cgit v1.2.3 From e60eff52920cf063e7625344764521a791c8be3e Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 11 Dec 2019 22:41:43 +0100 Subject: Remove unnecessary quotes --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 1f6f212..75c9d0d 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ CFLAGS += -fvisibility=hidden midimonster: LDLIBS = -ldl # Replace version string with current git-describe if possible ifneq "$(GITVERSION)" "" -midimonster: CFLAGS += "-DMIDIMONSTER_VERSION=\"$(GITVERSION)\"" +midimonster: CFLAGS += -DMIDIMONSTER_VERSION=\"$(GITVERSION)\" endif # Work around strange linker passing convention differences in Linux and OSX -- cgit v1.2.3 From cedbf74db776414988621e8113f5869b29c2cb41 Mon Sep 17 00:00:00 2001 From: cbdev Date: Tue, 24 Dec 2019 00:50:05 +0100 Subject: Fix version define for Windows --- Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 75c9d0d..990aec3 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ midimonster: LDLIBS = -ldl # Replace version string with current git-describe if possible ifneq "$(GITVERSION)" "" midimonster: CFLAGS += -DMIDIMONSTER_VERSION=\"$(GITVERSION)\" +midimonster.exe: CFLAGS += -DMIDIMONSTER_VERSION=\"$(GITVERSION)\" endif # Work around strange linker passing convention differences in Linux and OSX -- cgit v1.2.3