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.

133 lines
3.6KB

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