You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
3.9KB

  1. #!/usr/bin/make -f
  2. # Makefile for Cardinal #
  3. # --------------------- #
  4. # Created by falkTX
  5. #
  6. DEP_PATH = $(abspath ../src/Rack/dep)
  7. # --------------------------------------------------------------
  8. # Import base definitions
  9. USE_NANOVG_FBO = true
  10. USE_RGBA = true
  11. include ../dpf/Makefile.base.mk
  12. # --------------------------------------------------------------
  13. # override VCV arch.mk stuff so we can build more architectures
  14. ifeq ($(CPU_ARM),true)
  15. ARCH_NAME = arm
  16. MACHINE = i686-bring-forth-the-rack
  17. else ifeq ($(CPU_ARM64),true)
  18. ARCH_NAME = arm64
  19. MACHINE = x86_64-bring-forth-the-rack
  20. else ifeq ($(CPU_AARCH64),true)
  21. ARCH_NAME = aarch64
  22. MACHINE = x86_64-bring-forth-the-rack
  23. else
  24. MACHINE = $(TARGET_MACHINE)
  25. endif
  26. ifneq ($(MACOS_OR_WINDOWS),true)
  27. MACHINE_SUFFIX = -linux
  28. endif
  29. # --------------------------------------------------------------
  30. # Fix up cmake
  31. SPACE =
  32. SPACE +=
  33. CMAKE = cmake
  34. CMAKE += -DCMAKE_INSTALL_LIBDIR=lib
  35. CMAKE += -DCMAKE_INSTALL_PREFIX='$(DEP_PATH)'
  36. CMAKE += -DBUILD_SHARED_LIBS=OFF
  37. # make sure macOS target matches ours
  38. ifneq (,$(findstring -arch$(SPACE),$(CXXFLAGS)))
  39. CMAKE += -DCMAKE_OSX_ARCHITECTURES='$(subst $(SPACE),;,$(subst -arch=,,$(filter -arch=%,$(subst -arch$(SPACE),-arch=,$(CXXFLAGS)))))'
  40. endif
  41. ifneq (,$(findstring -mmacosx-version-min=,$(CXXFLAGS)))
  42. CMAKE += -DCMAKE_OSX_DEPLOYMENT_TARGET=$(subst -mmacosx-version-min=,,$(filter -mmacosx-version-min=%,$(CXXFLAGS)))
  43. endif
  44. # make sure debug/release matches
  45. ifeq ($(DEBUG),true)
  46. CMAKE += -DCMAKE_BUILD_TYPE=Debug
  47. else
  48. CMAKE += -DCMAKE_BUILD_TYPE=Release
  49. endif
  50. # fix cross-compilation for windows
  51. ifeq ($(WINDOWS),true)
  52. CMAKE += -G 'Unix Makefiles'
  53. CMAKE += -DCMAKE_RC_COMPILER=$(subst gcc,windres,$(CC))
  54. CMAKE += -DCMAKE_SYSTEM_NAME=Windows
  55. endif
  56. # --------------------------------------------------------------
  57. # Fix up configure
  58. CONFIGURE = ./configure
  59. CONFIGURE += --prefix="$(DEP_PATH)"
  60. CONFIGURE += --host=$(TARGET_MACHINE)
  61. CONFIGURE += --enable-static
  62. CONFIGURE += --disable-shared
  63. # NOTE libsamplerate wants to link against alsa, so we disable that
  64. CONFIGURE += --disable-alsa
  65. # NOTE speex fails to build when neon is enabled, so we disable that
  66. CONFIGURE += --disable-neon
  67. # NOTE libsamplerate fails with invalid host, so we force ac_cv_host
  68. CONFIGURE += ac_cv_host=$(TARGET_MACHINE)
  69. # --------------------------------------------------------------
  70. # VCV internal dependencies target
  71. $(DEP_PATH)/lib/%.a:
  72. $(MAKE) \
  73. ARCH_NAME=$(ARCH_NAME) \
  74. CFLAGS="$(BUILD_C_FLAGS)" \
  75. CXXFLAGS="$(BUILD_CXX_FLAGS)" \
  76. LDFLAGS="$(LINK_FLAGS)" \
  77. CMAKE="$(CMAKE)" \
  78. CONFIGURE="$(CONFIGURE)" \
  79. DEP_FLAGS="$(BASE_FLAGS)" \
  80. DEP_MAC_SDK_FLAGS= \
  81. MACHINE=$(MACHINE)$(MACHINE_SUFFIX) \
  82. -C $(DEP_PATH) lib/$*.a
  83. $(DEP_PATH)/lib/libarchive.a: $(DEP_PATH)/lib/libzstd.a
  84. $(DEP_PATH)/lib/libarchive_static.a: $(DEP_PATH)/lib/libzstd.a
  85. ifeq ($(MACOS),true)
  86. # zstd cmake is borked, see https://github.com/facebook/zstd/issues/1401
  87. $(DEP_PATH)/lib/libzstd.a: $(DEP_PATH)/zstd-1.4.5/.stamp-patched
  88. $(DEP_PATH)/zstd-1.4.5/.stamp-patched:
  89. $(MAKE) -C $(DEP_PATH) zstd-1.4.5
  90. sed -i -e "56,66d" $(DEP_PATH)/zstd-1.4.5/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake
  91. touch $@
  92. endif
  93. # --------------------------------------------------------------
  94. # Build targets
  95. TARGETS += $(DEP_PATH)/lib/libjansson.a
  96. TARGETS += $(DEP_PATH)/lib/libsamplerate.a
  97. TARGETS += $(DEP_PATH)/lib/libspeexdsp.a
  98. ifeq ($(WINDOWS),true)
  99. TARGETS += $(DEP_PATH)/lib/libarchive_static.a
  100. else
  101. TARGETS += $(DEP_PATH)/lib/libarchive.a
  102. endif
  103. TARGETS += $(DEP_PATH)/lib/libzstd.a
  104. all: $(TARGETS)
  105. clean:
  106. rm -f $(TARGETS)
  107. rm -rf $(DEP_PATH)/bin
  108. rm -rf $(DEP_PATH)/include
  109. rm -rf $(DEP_PATH)/lib
  110. rm -rf $(DEP_PATH)/share
  111. rm -rf $(DEP_PATH)/jansson-2.12
  112. rm -rf $(DEP_PATH)/libarchive-3.4.3
  113. rm -rf $(DEP_PATH)/libsamplerate-0.1.9
  114. rm -rf $(DEP_PATH)/speexdsp-SpeexDSP-1.2rc3
  115. rm -rf $(DEP_PATH)/zstd-1.4.5
  116. # --------------------------------------------------------------