diff --git a/Makefile b/Makefile index 736d271..96c941d 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,9 @@ obj = $(src:.c=.o) # Build type parameter ifeq ($(BUILD),debug) - CFLAGS_BUILD = -O0 -ggdb -Wall #-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls + CFLAGS_BUILD = -O0 -ggdb -Wall GLAD_GEN = c-debug STRIP_CMD = $(info Skipping `strip` for debug builds) -# ASAN = -lasan else CFLAGS_BUILD = -O2 -Wstringop-overflow=0 GLAD_GEN = c @@ -25,6 +24,10 @@ ifndef INSTALL endif endif +ifndef EXECDIR + EXECDIR = /usr/bin/ +endif + # Install type parameter ifeq ($(INSTALL),standalone) @@ -33,10 +36,12 @@ endif ifeq ($(INSTALL),unix) CFLAGS_INSTALL = -DGLAVA_UNIX - ifdef XDG_CONFIG_DIRS - SHADER_DIR = $(firstword $(subst :, ,$(XDG_CONFIG_DIRS)))/glava - else - SHADER_DIR = etc/xdg/glava + ifndef SHADERDIR + ifdef XDG_CONFIG_DIRS + SHADERDIR = /$(firstword $(subst :, ,$(XDG_CONFIG_DIRS)))/glava/ + else + SHADERDIR = /etc/xdg/glava/ + endif endif endif @@ -52,7 +57,9 @@ endif ifeq ($(INSTALL),osx) CFLAGS_INSTALL = -DGLAVA_OSX - SHADER_DIR = Library/glava + ifndef SHADERDIR + SHADERDIR = /Library/glava + endif endif LDFLAGS += $(ASAN) -lpulse -lpulse-simple -pthread $(LDFLAGS_GLFW) -ldl -lm -lX11 -lXext $(LDFLAGS_GLX) @@ -64,30 +71,38 @@ ifeq ($(GLAVA_VERSION),\"\") GLAVA_VERSION = \"unknown\" endif +ifdef DESTDIR + DESTDIR += / +endif + GLAD_INSTALL_DIR = glad -GLAD_SRCFILE = ./glad/src/glad.c +GLAD_SRCFILE = glad.c GLAD_ARGS = --generator=$(GLAD_GEN) --extensions=GL_EXT_framebuffer_multisample,GL_EXT_texture_filter_anisotropic -CFLAGS_COMMON = -I glad/include -DGLAVA_VERSION="$(GLAVA_VERSION)" +CFLAGS_COMMON = -DGLAVA_VERSION="$(GLAVA_VERSION)" -DSHADER_INSTALL_PATH="\"$(SHADERDIR)\"" CFLAGS_USE = $(CFLAGS_COMMON) $(CFLAGS_GLX) $(CFLAGS_GLFW) $(CFLAGS_BUILD) $(CFLAGS_INSTALL) $(CFLAGS) # Store relevant variables that may change depending on the environment or user input -STATE = $(BUILD),$(INSTALL),$(ENABLE_GLFW),$(DISABLE_GLX),$(PYTHON),$(CC),$(CFLAGS_USE) +STATE = $(BUILD),$(INSTALL),$(PREFIX),$(ENABLE_GLFW),$(DISABLE_GLX),$(PYTHON),$(CC),$(CFLAGS_USE) # Only update the file if the contents changed, `make` just looks at the timestamp $(shell if [[ ! -e build_state ]]; then touch build_state; fi) $(shell if [ '$(STATE)' != "`cat build_state`" ]; then echo '$(STATE)' > build_state; fi) all: glava -%.o: %.c glad.o build_state - $(CC) $(CFLAGS_USE) -o $@ -c $(firstword $<) +%.o: %.c build_state + @$(CC) $(CFLAGS_USE) -o $@ -c $(firstword $<) + @echo "CC $@" glava: $(obj) - $(CC) -o glava $(obj) glad.o $(LDFLAGS) + @$(CC) -o glava $(obj) $(LDFLAGS) + @echo "CC glava" $(STRIP_CMD) -glad.o: build_state - cd $(GLAD_INSTALL_DIR) && $(PYTHON) -m glad $(GLAD_ARGS) --out-path=. - $(CC) $(CFLAGS_USE) -o glad.o $(GLAD_SRCFILE) -c +.PHONY: glad +glad: build_state + @cd $(GLAD_INSTALL_DIR) && $(PYTHON) -m glad $(GLAD_ARGS) --local-files --out-path=. + @cp glad/*.h . + @cp glad/glad.c . # Empty build state goal, used to force some of the above rules to re-run if `build_state` was updated build_state: ; @@ -96,14 +111,17 @@ build_state: ; clean: rm -f $(obj) glava glad.o build_state +EXECTARGET = $(shell readlink -m "$(DESTDIR)$(EXECDIR)/glava") +SHADERTARGET = $(shell readlink -m "$(DESTDIR)$(SHADERDIR)") + .PHONY: install install: - install -Dm755 glava "$(DESTDIR)/usr/bin/glava" - install -d "$(DESTDIR)/$(SHADER_DIR)" - cp -Rv shaders/* "$(DESTDIR)/$(SHADER_DIR)" + install -Dm755 glava $(EXECTARGET) + install -d $(SHADERTARGET) + cp -Rv shaders/* $(SHADERTARGET) .PHONY: uninstall uninstall: - rm /usr/bin/glava - rm -rf $(SHADER_DIR)/glava + rm $(EXECTARGET) + rm -rf $(SHADERTARGET) diff --git a/README.md b/README.md index 247bc21..18db58f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ **Compiling** (Or use the Arch Linux [`glava` package](https://www.archlinux.org/packages/community/x86_64/glava/), or the [`glava-git` AUR package](https://aur.archlinux.org/packages/glava-git/))**:** ```bash -$ git clone --recursive https://github.com/wacossusca34/glava +$ git clone https://github.com/wacossusca34/glava $ cd glava $ CFLAGS="-march=native" make $ sudo make install @@ -23,8 +23,6 @@ You can pass `BUILD=debug` to the makefile for debug builds of both glad and gla **Additional compile time requirements:** -- glad (included as a submodule) -- python (required to generate bindings with glad) - GCC (this program uses GNU C features) **Optional requirements:** @@ -72,7 +70,7 @@ Note that some WMs listed without issues have specific overrides when using the ## Licensing -GLava is licensed under the terms of the GPLv3. GLava includes some (heavily modified) source code that originated from [cava](https://github.com/karlstav/cava), which was initially provided under the MIT license. The source files that originated from cava are the following: +GLava is licensed under the terms of the GPLv3, with the exemption of `khrplatform.h`, which is licensed under the terms in its header. GLava includes some (heavily modified) source code that originated from [cava](https://github.com/karlstav/cava), which was initially provided under the MIT license. The source files that originated from cava are the following: - `[cava]/input/fifo.c -> [glava]/fifo.c` - `[cava]/input/fifo.h -> [glava]/fifo.h` diff --git a/glava.c b/glava.c index eff84f3..88052a7 100644 --- a/glava.c +++ b/glava.c @@ -55,11 +55,15 @@ #define SHADER_USER_PATH "userconf" /* FHS compliant systems */ #elif defined(__unix__) || defined(GLAVA_UNIX) +#ifndef SHADER_INSTALL_PATH #define SHADER_INSTALL_PATH "/etc/xdg/glava" +#endif #define SHADER_USER_PATH FORMAT("%s/glava", ENV("XDG_CONFIG_HOME", "%s/.config", ENV("HOME", "/home"))) /* OSX */ #elif (defined(__APPLE__) && defined(__MACH__)) || defined(GLAVA_OSX) +#ifndef SHADER_INSTALL_PATH #define SHADER_INSTALL_PATH "/Library/glava" +#endif #define SHADER_USER_PATH FORMAT("%s/Library/Preferences/glava", ENV("HOME", "/")) #else #error "Unsupported target system" diff --git a/glx_wcb.c b/glx_wcb.c index 0016732..b233641 100644 --- a/glx_wcb.c +++ b/glx_wcb.c @@ -20,7 +20,7 @@ #include #include -#include +#include "glad.h" #include "render.h" #include "xwin.h" diff --git a/render.c b/render.c index f5c4951..1c57951 100644 --- a/render.c +++ b/render.c @@ -13,7 +13,7 @@ #include #include -#include +#include "glad.h" #include "render.h" #include "xwin.h" diff --git a/xwin.c b/xwin.c index 8c900ca..c9cd5b8 100644 --- a/xwin.c +++ b/xwin.c @@ -19,7 +19,7 @@ #include #include -#include +#include "glad.h" #define GLAVA_RDX11 #include "render.h"