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.

129 lines
3.5KB

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