dagargo / elektroid

Sample and MIDI device manager
https://dagargo.github.io/elektroid/
GNU General Public License v3.0
215 stars 29 forks source link

GUI-less build? #42

Closed ryanlaws closed 2 years ago

ryanlaws commented 2 years ago

How could I go about building this without a GUI? I'm using it on a "headless" Raspbian-based machine (monome norns) which does not have GTK installed. I could install it but it will add 175MB to my install for code I'm not going to use. I have 0 use for the GUI in this particular environment.

If this isn't supported and is too much trouble, that's OK - I just wanted to check if there were some configuration tweaks or CLI flags I could add to the build to skip this without digging into the code and modifying things.

Thank you!

dagargo commented 2 years ago

It's an interesting question.

It is indeed possible to do what you want but you still need a few libraries.

If you replace the content at the beginning of src/Makefile.am with the code below and run autoreconf you could build elektroid-cli only.

elektroid_CFLAGS = -I$(top_srcdir)/src `$(PKG_CONFIG) --cflags alsa gtk+-3.0 libpulse libpulse-mainloop-glib zlib json-glib-1.0` $(SNDFILE_CFLAGS) $(SAMPLERATE_CFLAGS)
elektroid_cli_CFLAGS = -I$(top_srcdir)/src `$(PKG_CONFIG) --cflags alsa glib-2.0 zlib` $(SNDFILE_CFLAGS) $(SAMPLERATE_CFLAGS)
elektroid_LDFLAGS = `$(PKG_CONFIG) --libs alsa gtk+-3.0 libpulse libpulse-mainloop-glib zlib json-glib-1.0` $(SNDFILE_LIBS) $(SAMPLERATE_LIBS)
elektroid_cli_LDFLAGS = `$(PKG_CONFIG) --libs alsa glib-2.0 zlib` $(SNDFILE_LIBS) $(SAMPLERATE_LIBS)

You'll still need to change this in the same file this line.

bin_PROGRAMS = elektroid-cli

Although elektroid-cli can do a lot of things just works at a lower level than elektroid and thus it does not provide exactly the same functionalities because it was intended as a testing and automation tool. So keep this in mind.

My idea was to make it work only with basic objects and not zip files that are a collection of resources. But I'm questioning this now.

Let me know if the above works for you because I want to push this code as it treats compiler flags for elektroid and elektroid-cli differently and better.

ryanlaws commented 2 years ago

Thank you so much for your reply and for considering this option! I am still getting stuck on GTK with those flags but it's highly likely I did not implement them correctly:

https://github.com/ryanlaws/elektroid/commit/9caf829a4581b2db8d18e8be176a5ca6b5a6893a

Please see the commit to see what I did. Please also note I also changed the ALSA version requirement in src/Makefile.am from 1.1.8 to 1.1.3 which may not work - I'm not sure if I can put 1.1.8 on this system, but I wanted to try it "the easy way" before I tried updating the ALSA version on the system.

Here's the error I get from configure:

checking for ALSA... yes
checking for GTK... no
configure: error: Package requirements (gtk+-3.0) were not met:

No package 'gtk+-3.0' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables GTK_CFLAGS
and GTK_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

I apologize if anything I'm doing here is stupid! I have not done much with C and I have done nothing with make or autoreconf, so it is very likely I am making some silly mistakes.

dagargo commented 2 years ago

This weekend I'll try to run Elektroid on an older Debian version with ALSA 1.1.3. If all works well, I'll downgrade the required version.

The reason is just that Elektroid development started with 1.1.8 being used. So I have never tried.

I'll come back to you.

dagargo commented 2 years ago

Just a couple of things.

  1. Modify configure.ac and src/Makefile.am.
$ git diff
diff --git a/configure.ac b/configure.ac
index ce94b7c..ec464c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,5 +42,7 @@ AC_CHECK_HEADERS([unistd.h limits.h zlib.h])
 # Checks for library functions.
 AC_FUNC_MALLOC

+AM_CONDITIONAL([CLI_ONLY], [test "${CLI_ONLY}" == yes])
+
 AC_CONFIG_FILES([Makefile src/Makefile res/Makefile test/Makefile po/Makefile.in po/Makefile man/Makefile])
 AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index b8e442a..d4cf4b4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,7 +4,12 @@ AM_CFLAGS = -I$(top_srcdir)/src `$(PKG_CONFIG) --cflags alsa gtk+-3.0 libpulse l
 elektroid_LDFLAGS = `$(PKG_CONFIG) --libs alsa gtk+-3.0 libpulse libpulse-mainloop-glib zlib json-glib-1.0` $(SNDFILE_LIBS) $(SAMPLERATE_LIBS)
 elektroid_cli_LDFLAGS = `$(PKG_CONFIG) --libs alsa glib-2.0 zlib` $(SNDFILE_LIBS) $(SAMPLERATE_LIBS)

+if CLI_ONLY
+bin_PROGRAMS = elektroid-cli
+else
 bin_PROGRAMS = elektroid elektroid-cli
+endif
+
 elektroid_SOURCES = audio.c audio.h browser.c browser.h connector.c connector.h elektroid.c sample.c sample.h utils.c utils.h notifier.c notifier.h local.c local.h config.c config.h
 elektroid_cli_SOURCES = connector.c connector.h elektroid-cli.c sample.c sample.h utils.c utils.h
  1. Run configure depending on what we want. Just running ./configure will prepare everything to compile both binaries. The command below, will just prepare it for elektroid-cli.
$ ./configure CLI_ONLY=yes
  1. Compile as usual.
dagargo commented 2 years ago

I've changed my mind regarding elektroid-cli.

It's gonna mimmic 100% what you can achieve with the GUI. The code is in the raw_fs branch but it will be hopefully merged in the master during the following week as you know because your involvement in #38.

I'm closing this as both of your requests are applied.

Feel free to reopen if needed.

ryanlaws commented 2 years ago

Thank you so much! I apologize for not looking at this over the weekend. I have more time today.

ryanlaws commented 2 years ago
$ ./configure CLI_ONLY=yes
  1. Compile as usual.

I'm still getting this error when building this way:

configure: error: Package requirements (gtk+-3.0) were not met:

No package 'gtk+-3.0' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables GTK_CFLAGS
and GTK_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
ryanlaws commented 2 years ago

I don't really know autoconf at all, but I have opened #43 in hopes of resolving this, so please read it closely with a critical eye before merging. Note that it targets the raw_fs branch rather than master. It does seem to work on my machine for the ./configure step.

This was based on: https://www.gnu.org/software/automake/manual/html_node/Usage-of-Conditionals.html https://autotools.io/pkgconfig/pkg_check_modules.html

Note also that I had to install libpulse-dev. If this is a required dependency, it's not a problem for me - it was a small package and I didn't run into any issues installing it.

However, I am now getting this issue on make:

Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-3.0' found
Package json-glib-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `json-glib-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'json-glib-1.0' found
In file included from audio.c:22:0:
audio.h:21:18: fatal error: glib.h: No such file or directory
 #include <glib.h>
                  ^
compilation terminated.
Makefile:485: recipe for target 'elektroid-audio.o' failed
make[2]: *** [elektroid-audio.o] Error 1
make[2]: Leaving directory '/home/we/src/elektroid/src'
Makefile:430: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/we/src/elektroid'
Makefile:362: recipe for target 'all' failed
make: *** [all] Error 2

So maybe that doesn't completely fix the GTK issue.

dagargo commented 2 years ago

Let's fix first the building in #43 and then we'll address this.

It's not working on a Debian 9 yet because of a syntax error in the libraries but the generated Makefiles look right to me.

dagargo commented 2 years ago

After fixing the build in #43, looks like everything is working now.

I consider this solved but in case of any issues regarding the compilation reopen this.