Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install dependencies using vcpkg #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Convert Makefile to use vcpkg
sourcefrog committed Jan 2, 2025
commit e84afb54daafe9115d68afc745547b1a6b243b4a
48 changes: 27 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
# If RACK_DIR is not defined when calling the Makefile, default to two levels above
RACK_DIR ?= ../..

# Must include the VCV plugin Makefile framework
include $(RACK_DIR)/arch.mk

# Assume that `vcpkg install` has run so the dependencies from `vcpkg.json` are available
# under `vcpkg_installed` in the source dir.

PKGCONFIG= pkg-config
PACKAGES= libusb-1.0 librtlsdr

# Map VCVRack's arch.mk to vcpkg's triplet
ifeq ($(ARCH_OS), lin)
TRIPLET := $(ARCH_CPU)-linux
else ifeq ($(ARCH_OS), mac)
TRIPLET := $(ARCH_CPU)-osx
else ifeq ($(ARCH_OS), win)
TRIPLET := $(ARCH_CPU)-windows
else
$(error Unrecognized OS "$(ARCH_OS)")
endif

PKG_CONFIG_PATH = $(abspath vcpkg_installed)/$(TRIPLET)/lib/pkgconfig
PKGCONFIG := $(abspath vcpkg_installed)/$(TRIPLET)/tools/pkgconf/pkgconf --with-path=$(PKG_CONFIG_PATH)

# FLAGS will be passed to both the C and C++ compiler
FLAGS += $(shell $(PKGCONFIG) --cflags $(PACKAGES))
FLAGS += $(shell $(PKGCONFIG) --cflags $(PACKAGES))
CFLAGS +=
CXXFLAGS +=
LDFLAGS += $(shell $(PKGCONFIG) --libs $(PACKAGES))

# Add .cpp and .c files to the build
SOURCES = $(wildcard src/*.cpp src/*.c src/*/*.cpp src/*/*.c)

# Must include the VCV plugin Makefile framework
include $(RACK_DIR)/arch.mk

# Careful about linking to libraries, since you can't assume much about the user's environment and library search path.
# Static libraries are fine.
ifeq ($(ARCH), lin)
# WARNING: static compilation is broken on Linux
LDFLAGS +=$(shell $(PKGCONFIG) --libs $(PACKAGES))
endif

ifeq ($(ARCH), mac)
LDFLAGS +=$(shell $(PKGCONFIG) --variable=libdir libusb-1.0)/libusb-1.0.a
LDFLAGS +=$(shell $(PKGCONFIG) --variable=libdir librtlsdr)/librtlsdr.a
endif

ifeq ($(ARCH), win)
LDFLAGS +=$(shell $(PKGCONFIG) --variable=libdir librtlsdr)/librtlsdr_static.a
LDFLAGS +=$(shell $(PKGCONFIG) --variable=libdir libusb-1.0)/libusb-1.0.a
endif

DISTRIBUTABLES += $(wildcard LICENSE*) res

# Include the VCV Rack plugin Makefile framework
include $(RACK_DIR)/plugin.mk

.PHONY: vcpkg

vcpkg:
vcpkg install --no-print-usage
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -5,3 +5,13 @@ A voltage-controlled FM radio tuner for [VCVRack](https://vcvrack.com) supportin
[Downloads](https://vcvrack.com/plugins.html#RTL_SDR)

[![Build Status](https://travis-ci.org/WIZARDISHUNGRY/vcvrack-rtlsdr.svg?branch=master)](https://travis-ci.org/WIZARDISHUNGRY/vcvrack-rtlsdr)

## Build

Building a package requires the VCVRack source tree. You can either check out this module inside the `plugins` directory, or build with an explicit path like

make RACK_DIR=$HOME/src/vcvrack

This branch can use [vcpkg](https://learn.microsoft.com/en-us/vcpkg/) to fetch dependencies, and requires that `vcpkg` already be installed. Before building, run

make vcpkg