From 3a3960a7f46033ffd922c0ae8fa25385b3af4984 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 21 Mar 2018 04:50:09 -0400 Subject: [PATCH] Require RACK_DIR, VERSION, and SLUG in Makefile, refactor dep build system --- Makefile | 2 +- compile.mk | 11 ++++++++--- dep.mk | 27 +++++++++++++++++++++++++++ dep/Makefile | 39 +++++++-------------------------------- plugin.mk | 15 +++++++++------ 5 files changed, 52 insertions(+), 42 deletions(-) create mode 100644 dep.mk diff --git a/Makefile b/Makefile index 99a4c56f..f0171115 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ +RACK_DIR ?= . VERSION = master -RACK_DIR = . FLAGS += \ -Iinclude \ diff --git a/compile.mk b/compile.mk index f2f8b812..4479af85 100644 --- a/compile.mk +++ b/compile.mk @@ -1,16 +1,21 @@ -ifdef VERSION - FLAGS += -DVERSION=$(VERSION) +ifndef RACK_DIR +$(error RACK_DIR is not defined in Makefile) +endif + +ifndef VERSION +$(error VERSION is not defined in Makefile) endif -RACK_DIR ?= . include $(RACK_DIR)/arch.mk +FLAGS += -DVERSION=$(VERSION) # Generate dependency files alongside the object files FLAGS += -MMD -MP FLAGS += -g # Optimization FLAGS += -O3 -march=nocona -ffast-math -fno-finite-math-only FLAGS += -Wall -Wextra -Wno-unused-parameter + ifneq ($(ARCH), mac) CXXFLAGS += -Wsuggest-override endif diff --git a/dep.mk b/dep.mk new file mode 100644 index 00000000..cfe09c48 --- /dev/null +++ b/dep.mk @@ -0,0 +1,27 @@ +include $(RACK_DIR)/arch.mk + +LOCAL ?= . +FLAGS += -g -O3 -march=nocona + +ifeq ($(ARCH), mac) + FLAGS += -mmacosx-version-min=10.7 -stdlib=libc++ + LDFLAGS += -mmacosx-version-min=10.7 -stdlib=libc++ +endif + +CFLAGS += $(FLAGS) +CXXFLAGS += $(FLAGS) +export CFLAGS +export CXXFLAGS +export LDFLAGS + +# Commands +WGET := curl -OL +UNTAR := tar xf +UNZIP := unzip +MAKE := make +CONFIGURE := ./configure --prefix="$(realpath $(LOCAL))" +ifeq ($(ARCH), win) + CMAKE := cmake -G 'MSYS Makefiles' +else + CMAKE := cmake +endif diff --git a/dep/Makefile b/dep/Makefile index 5fe02eab..34e349e2 100755 --- a/dep/Makefile +++ b/dep/Makefile @@ -1,31 +1,6 @@ -LOCAL = $(shell pwd) +RACK_DIR ?= .. -# Arch-specifics -include ../arch.mk - -FLAGS += -g -O3 -march=nocona - -ifeq ($(ARCH),mac) - FLAGS += -mmacosx-version-min=10.7 -stdlib=libc++ - LDFLAGS += -mmacosx-version-min=10.7 -stdlib=libc++ -endif - -CFLAGS += $(FLAGS) -CXXFLAGS += $(FLAGS) -export CFLAGS -export CXXFLAGS -export LDFLAGS - - -# Commands -WGET = curl -OL -UNTAR = tar xf -UNZIP = unzip -ifeq ($(ARCH),win) - CMAKE = cmake -G 'MSYS Makefiles' -else - CMAKE = cmake -endif +include $(RACK_DIR)/dep.mk # Libraries ifeq ($(ARCH),lin) @@ -96,14 +71,14 @@ $(glfw): $(jansson): $(WGET) http://www.digip.org/jansson/releases/jansson-2.10.tar.gz $(UNTAR) jansson-2.10.tar.gz - cd jansson-2.10 && ./configure --prefix="$(LOCAL)" + cd jansson-2.10 && $(CONFIGURE) $(MAKE) -C jansson-2.10 $(MAKE) -C jansson-2.10 install $(libspeexdsp): $(WGET) https://vcvrack.com/downloads/dep/speexdsp-SpeexDSP-1.2rc3.tgz $(UNTAR) speexdsp-SpeexDSP-1.2rc3.tgz - cd speexdsp-SpeexDSP-1.2rc3 && ./configure --prefix="$(LOCAL)" + cd speexdsp-SpeexDSP-1.2rc3 && $(CONFIGURE) $(MAKE) -C speexdsp-SpeexDSP-1.2rc3 $(MAKE) -C speexdsp-SpeexDSP-1.2rc3 install @@ -117,7 +92,7 @@ $(openssl): $(libcurl): $(openssl) $(WGET) https://github.com/curl/curl/releases/download/curl-7_56_0/curl-7.56.0.tar.gz $(UNTAR) curl-7.56.0.tar.gz - cd curl-7.56.0 && ./configure --prefix="$(LOCAL)" \ + cd curl-7.56.0 && $(CONFIGURE) \ --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-manual \ --without-zlib --without-libpsl --without-libmetalink --without-libssh2 --without-librtmp --without-winidn --without-libidn2 --without-nghttp2 \ --without-ca-bundle --with-ca-fallback --with-ssl="$(LOCAL)" @@ -127,14 +102,14 @@ $(libcurl): $(openssl) $(libzip): $(WGET) https://nih.at/libzip/libzip-1.2.0.tar.gz $(UNTAR) libzip-1.2.0.tar.gz - cd libzip-1.2.0 && ./configure --prefix="$(LOCAL)" + cd libzip-1.2.0 && $(CONFIGURE) $(MAKE) -C libzip-1.2.0 $(MAKE) -C libzip-1.2.0 install $(rtmidi): $(WGET) https://vcvrack.com/downloads/dep/rtmidi.tgz $(UNTAR) rtmidi.tgz - cd rtmidi && ./configure --prefix="$(LOCAL)" + cd rtmidi && $(CONFIGURE) $(MAKE) -C rtmidi $(MAKE) -C rtmidi install diff --git a/plugin.mk b/plugin.mk index 37776dfc..61903990 100644 --- a/plugin.mk +++ b/plugin.mk @@ -1,12 +1,15 @@ -RACK_DIR ?= ../.. - -FLAGS += -fPIC \ - -I$(RACK_DIR)/include -I$(RACK_DIR)/dep/include +ifndef RACK_DIR +$(error RACK_DIR is not defined in Makefile) +endif -ifdef SLUG - FLAGS += -DSLUG=$(SLUG) +ifndef SLUG +$(error SLUG is not defined in Makefile) endif +FLAGS += -DSLUG=$(SLUG) +FLAGS += -fPIC +FLAGS += -I$(RACK_DIR)/include -I$(RACK_DIR)/dep/include + include $(RACK_DIR)/arch.mk