DISTRHO Plugin Framework
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.

128 lines
3.4KB

  1. #!/usr/bin/make -f
  2. # Makefile for dgl #
  3. # ---------------- #
  4. # Created by falkTX
  5. #
  6. AR ?= ar
  7. CC ?= gcc
  8. CXX ?= g++
  9. # --------------------------------------------------------------
  10. # Fallback to Linux if no other OS defined
  11. ifneq ($(HAIKU),true)
  12. ifneq ($(MACOS),true)
  13. ifneq ($(WIN32),true)
  14. LINUX=true
  15. endif
  16. endif
  17. endif
  18. # --------------------------------------------------------------
  19. # Set build and link flags
  20. BASE_FLAGS = -Wall -Wextra -pipe -MD -MP
  21. BASE_OPTS = -O2 -mtune=generic -msse -msse2 -fdata-sections -ffunction-sections
  22. ifeq ($(MACOS),true)
  23. # MacOS linker flags
  24. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
  25. else
  26. # Common linker flags
  27. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  28. endif
  29. ifeq ($(RASPPI),true)
  30. # Raspberry-Pi optimization flags
  31. BASE_OPTS = -O2 -march=armv6 -mfpu=vfp -mfloat-abi=hard
  32. LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  33. endif
  34. ifneq ($(NOOPT),true)
  35. # No optimization flags
  36. BASE_OPTS = -O2 -fdata-sections -ffunction-sections
  37. endif
  38. ifneq ($(WIN32),true)
  39. # not needed for Windows
  40. BASE_FLAGS += -fPIC -DPIC
  41. endif
  42. ifeq ($(DEBUG),true)
  43. BASE_FLAGS += -DDEBUG -O0 -g
  44. LINK_OPTS =
  45. else
  46. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  47. CXXFLAGS += -fvisibility-inlines-hidden
  48. endif
  49. BUILD_C_FLAGS = $(BASE_FLAGS) -std=c99 $(CFLAGS)
  50. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=c++11 $(CXXFLAGS) $(CPPFLAGS)
  51. ifeq ($(MACOS),true)
  52. # 'no-undefined' is always enabled
  53. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  54. else
  55. # Specify 'no-undefined'
  56. LINK_FLAGS = $(LINK_OPTS) -Wl,--no-undefined $(LDFLAGS)
  57. endif
  58. ifeq ($(MACOS_OLD),true)
  59. # No C++11 support
  60. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) $(CPPFLAGS)
  61. endif
  62. # --------------------------------------------------------------
  63. # Strict test build
  64. ifeq ($(TESTBUILD),true)
  65. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings
  66. BASE_FLAGS += -Wpointer-arith -Wabi -Winit-self -Wuninitialized -Wstrict-overflow=5
  67. # BASE_FLAGS += -Wfloat-equal
  68. ifeq ($(CC),clang)
  69. BASE_FLAGS += -Wdocumentation -Wdocumentation-unknown-command
  70. BASE_FLAGS += -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-exit-time-destructors -Wno-float-equal
  71. else
  72. BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations
  73. endif
  74. ifneq ($(MACOS),true)
  75. BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
  76. ifneq ($(CC),clang)
  77. BASE_FLAGS += -Wlogical-op
  78. endif
  79. endif
  80. CFLAGS += -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
  81. CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual
  82. endif
  83. # --------------------------------------------------------------
  84. # Check for required libs
  85. ifeq ($(LINUX),true)
  86. ifneq ($(shell pkg-config --exists gl && echo true),true)
  87. $(error OpenGL missing, cannot continue)
  88. endif
  89. ifneq ($(shell pkg-config --exists x11 && echo true),true)
  90. $(error X11 missing, cannot continue)
  91. endif
  92. endif
  93. # --------------------------------------------------------------
  94. # Set libs stuff
  95. ifeq ($(LINUX),true)
  96. DGL_FLAGS = $(shell pkg-config --cflags gl x11)
  97. DGL_LIBS = $(shell pkg-config --libs gl x11)
  98. endif
  99. ifeq ($(MACOS),true)
  100. DGL_LIBS = -framework OpenGL -framework Cocoa
  101. endif
  102. ifeq ($(WIN32),true)
  103. DGL_LIBS = -lopengl32 -lgdi32
  104. endif
  105. # --------------------------------------------------------------