From c74ada5fa42de4947eb0d65886f21528b8e65be7 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sat, 6 Jul 2019 12:01:35 +0200 Subject: [PATCH] Makefile: Setting VERSION from the environment if set, else default back to old behavior of VERSION composition. Using the environment variable USE_SYSTEM_LIBS to devendor all unnecessarily static libraries (curl, glew, jansson, speexdsp, libzip, openssl, rtaudio, rtmidi) and using pkg-config to retrieve the location of the ones already dynamically linked (alsa, gtk+-2.0, jack, x11). compile.mk: Exporting CFLAGS of glew, jansson, libcurl, libzip, openssl, rtaudio, rtmidi and speexdsp (using pkg-config) to FLAGS (which will be used in CFLAGS and CXXFLAGS). dep.mk: Exporting CFLAGS of glew, jansson, libcurl, libzip, openssel, rtaudio, rtmidi and speexdsp (using pkg-config) to DEP_FLAGS (which will be used in CLFAGS and CXXFLAGS of the dependencies). dep/Makefile: When using USE_SYSTEM_LIBS, shrinking the statically linked libraries down to the vendored glfw3 (which is in use because of one single, not upstreamed, custom function). This eliminates the vendored glew, speexdsp, openssl, curl, libzip, zlib, rtaudio, rtmidi and only leaves the vendored glfw, nanovg, nanosvgg, oui-blendish, osdialog and pffft. Makefile: Removing VERSION hardcoding (per release). src/main.cpp: Removing call to glfwGetOpenedFilename() (which is a hacky addition to gflw only for macOS: https://github.com/AndrewBelt/glfw/pull/1 ). Makefile, dep.mk, dep/Makefile: Devendoring gflw, if USE_SYSTEM_LIBS is used. dep/Makefile: Making sure to create the dep/include directory, before copying files to it. Removing dead code. --- Makefile | 11 +++++++- compile.mk | 4 +++ dep.mk | 4 +++ dep/Makefile | 57 +++++++++++++++++++++++++++++----------- src/app/ModuleWidget.cpp | 2 +- 5 files changed, 60 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index bd1d631a..2108cd5c 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ RACK_DIR ?= . -# VERSION := 1.dev.$(shell git rev-parse --short HEAD) VERSION := 1.1.6 +ifeq ($(strip $(VERSION)),) +VERSION := 1.dev.$(shell git rev-parse --short HEAD) +endif + FLAGS += -DVERSION=$(VERSION) FLAGS += -Iinclude -Idep/include @@ -20,10 +23,16 @@ ifdef ARCH_LIN SOURCES += dep/osdialog/osdialog_gtk2.c build/dep/osdialog/osdialog_gtk2.c.o: FLAGS += $(shell pkg-config --cflags gtk+-2.0) +ifneq ($(USE_SYSTEM_LIBS),true) LDFLAGS += -rdynamic \ dep/lib/libGLEW.a dep/lib/libglfw3.a dep/lib/libjansson.a dep/lib/libcurl.a dep/lib/libssl.a dep/lib/libcrypto.a dep/lib/libzip.a dep/lib/libz.a dep/lib/libspeexdsp.a dep/lib/libsamplerate.a dep/lib/librtmidi.a dep/lib/librtaudio.a \ -lpthread -lGL -ldl -lX11 -lasound -ljack \ $(shell pkg-config --libs gtk+-2.0) +else + LDFLAGS += -rdynamic \ + -lpthread -ldl \ + $(shell pkg-config --libs alsa glew glfw3 gtk+-2.0 jack jansson libcurl libzip zlib openssl rtaudio rtmidi speexdsp x11) +endif TARGET := Rack endif diff --git a/compile.mk b/compile.mk index 96ea4b8d..0febe00c 100644 --- a/compile.mk +++ b/compile.mk @@ -18,6 +18,10 @@ FLAGS += -Wall -Wextra -Wno-unused-parameter # C++ standard CXXFLAGS += -std=c++11 +ifeq ($(USE_SYSTEM_LIBS),true) +FLAGS += $(shell pkg-config --cflags glew jansson libcurl libzip openssl rtaudio rtmidi speexdsp) +endif + # Architecture-independent flags ifdef ARCH_LIN FLAGS += -DARCH_LIN diff --git a/dep.mk b/dep.mk index bad90ec7..b0eb59d6 100644 --- a/dep.mk +++ b/dep.mk @@ -7,6 +7,10 @@ DEP_PATH := $(abspath $(DEP_LOCAL)) DEP_FLAGS += -g -O3 -march=nocona +ifeq ($(USE_SYSTEM_LIBS),true) +DEP_FLAGS += $(shell pkg-config --cflags glew glfw3 jansson libcurl libzip openssl rtaudio rtmidi speexdsp) +endif + ifeq ($(ARCH), mac) DEP_MAC_SDK_FLAGS := -mmacosx-version-min=10.7 DEP_FLAGS += $(DEP_MAC_SDK_FLAGS) -stdlib=libc++ diff --git a/dep/Makefile b/dep/Makefile index 4ce54ad5..ed9381bb 100755 --- a/dep/Makefile +++ b/dep/Makefile @@ -6,6 +6,7 @@ RACK_DIR ?= .. include $(RACK_DIR)/arch.mk +ifneq ($(USE_SYSTEM_LIBS),true) ifdef ARCH_LIN glew = lib/libGLEW.a glfw = lib/libglfw3.a @@ -48,27 +49,29 @@ ifdef ARCH_WIN rtaudio = lib/librtaudio.a endif +else + +ifdef ARCH_MAC + glfw = lib/libglfw3.a +endif + +ifdef ARCH_WIN + glfw = lib/libglfw3.a +endif + +endif + nanovg = include/nanovg.h nanosvg = include/nanosvg.h oui-blendish = include/blendish.h osdialog = include/osdialog.h pffft = include/pffft.h -DEPS += $(glew) -DEPS += $(glfw) -DEPS += $(jansson) -DEPS += $(libcurl) -DEPS += $(libzip) -DEPS += $(libspeexdsp) -DEPS += $(libsamplerate) -DEPS += $(rtmidi) -DEPS += $(rtaudio) -DEPS += $(nanovg) -DEPS += $(nanosvg) -DEPS += $(oui-blendish) -DEPS += $(osdialog) -DEPS += $(pffft) - +ifneq ($(USE_SYSTEM_LIBS),true) +DEPS += $(glew) $(glfw) $(jansson) $(libspeexdsp) $(libcurl) $(libzip) $(rtmidi) $(rtaudio) $(nanovg) $(nanosvg) $(oui-blendish) $(osdialog) $(pffft) +else +DEPS += $(nanovg) $(nanosvg) $(oui-blendish) $(osdialog) $(pffft) +endif DEP_LOCAL := . include $(RACK_DIR)/dep.mk @@ -76,6 +79,7 @@ include $(RACK_DIR)/dep.mk # Targets +ifneq ($(USE_SYSTEM_LIBS),true) glew-2.1.0: $(WGET) "https://github.com/nigels-com/glew/releases/download/glew-2.1.0/glew-2.1.0.tgz" $(SHA256) glew-2.1.0.tgz 04de91e7e6763039bc11940095cd9c7f880baba82196a7765f727ac05a993c95 @@ -222,17 +226,31 @@ $(rtaudio): rtaudio cd rtaudio/build && $(CMAKE) $(RTAUDIO_FLAGS) .. $(MAKE) -C rtaudio/build $(MAKE) -C rtaudio/build install +else +ifndef ARCH_LIN +$(glfw): glfw + cd glfw && mkdir -p build + cd glfw/build && $(CMAKE) .. \ + -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF + $(MAKE) -C glfw/build + $(MAKE) -C glfw/build install +endif +endif $(nanovg): $(wildcard nanovg/src/*.h) nanovg/example/stb_image_write.h + mkdir -p include cp $^ include/ $(nanosvg): $(wildcard nanosvg/src/*.h) + mkdir -p include cp $^ include/ $(oui-blendish): $(wildcard oui-blendish/*.h) + mkdir -p include cp $^ include/ $(osdialog): $(wildcard osdialog/*.h) + mkdir -p include cp $^ include/ jpommier-pffft-29e4f76ac53b: @@ -242,11 +260,18 @@ jpommier-pffft-29e4f76ac53b: rm 29e4f76ac53b.zip $(pffft): jpommier-pffft-29e4f76ac53b + mkdir -p include cp jpommier-pffft-29e4f76ac53b/*.h include/ # Helpers -src: glew-2.1.0 glfw jansson-2.12 speexdsp-SpeexDSP-1.2rc3 openssl-1.1.1d curl-7.66.0 libzip-1.5.2 zlib-1.2.11 rtmidi-4.0.0 rtaudio nanovg nanosvg oui-blendish osdialog jpommier-pffft-29e4f76ac53b +ifneq ($(USE_SYSTEM_LIBS),true) +SRC = glew-2.1.0 glfw jansson-2.12 speexdsp-SpeexDSP-1.2rc3 openssl-1.1.1b curl-7.66.0 libzip-1.5.2 zlib-1.2.11 rtmidi-4.0.0 rtaudio nanovg nanosvg oui-blendish osdialog jpommier-pffft-29e4f76ac53b +else +SRC = nanovg nanosvg oui-blendish osdialog jpommier-pffft-29e4f76ac53b +endif + +src: $(SRC) clean: git clean -fdx diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index 998ac245..4a525e31 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -845,4 +845,4 @@ void ModuleWidget::createContextMenu() { } // namespace app -} // namespace rack \ No newline at end of file +} // namespace rack