wine_wrapper.mk 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. ifeq ($(MPT_PROGRESS_FILE),)
  2. MPT_PROGRESS_FILE:=/dev/null
  3. endif
  4. ifeq ($(MPT_WINEGCC_LANG),)
  5. MPT_WINEGCC_LANG:=CPLUSPLUS
  6. endif
  7. ifneq ($(words $(MAKECMDGOALS)),1)
  8. .DEFAULT_GOAL = all
  9. %:
  10. @$(MAKE) $@ --no-print-directory -rRf $(firstword $(MAKEFILE_LIST))
  11. else
  12. ifndef PROGRESS
  13. T := $(shell $(MAKE) $(MAKECMDGOALS) --no-print-directory -nrRf $(firstword $(MAKEFILE_LIST)) PROGRESS="COUNTTHIS" | grep -c "COUNTTHIS")
  14. N := x
  15. C = $(words $N)$(eval N := x $N)
  16. D = $(words $N)$(eval N := $N)
  17. PROGRESS = @echo "`expr \( $C '-' 1 \) '*' 100 / $T`" >$(MPT_PROGRESS_FILE)
  18. PROGRESS_ECHO = @echo "[`printf %3s \`expr \( $D '-' 1 \) '*' 100 / $T\``%]"
  19. endif
  20. PROGRESS_ECHO ?= echo
  21. V?=2
  22. INFO ?= @echo
  23. SILENT ?= @
  24. VERYSILENT ?= @
  25. ifeq ($(V),6)
  26. INFO = @true
  27. SILENT =
  28. VERYSILENT =
  29. endif
  30. ifeq ($(V),5)
  31. INFO = @true
  32. SILENT =
  33. VERYSILENT =
  34. endif
  35. ifeq ($(V),4)
  36. INFO = @true
  37. SILENT =
  38. VERYSILENT = @
  39. endif
  40. ifeq ($(V),3)
  41. INFO = @$(PROGRESS_ECHO)
  42. SILENT = @
  43. VERYSILENT = @
  44. endif
  45. ifeq ($(V),2)
  46. INFO = @$(PROGRESS_ECHO)
  47. SILENT = @
  48. VERYSILENT = @
  49. endif
  50. ifeq ($(V),1)
  51. INFO = @true
  52. SILENT = @
  53. VERYSILENT = @
  54. endif
  55. ifeq ($(V),0)
  56. INFO = @true
  57. SILENT = @
  58. VERYSILENT = @
  59. endif
  60. ifeq ($(MPT_ARCH_BITS),)
  61. MPT_ARCH_TARGET:=
  62. else
  63. MPT_ARCH_TARGET:=-m$(MPT_ARCH_BITS)
  64. endif
  65. CPPFLAGS += $(MPT_ARCH_TARGET) -DMPT_WINEGCC -Icommon
  66. CXXFLAGS += $(MPT_ARCH_TARGET) -std=gnu++17 -fpermissive -fPIC -fvisibility=hidden
  67. CFLAGS += $(MPT_ARCH_TARGET) -std=gnu99 -fPIC -fvisibility=hidden
  68. LDFLAGS += $(MPT_ARCH_TARGET)
  69. LDLIBS += -lm
  70. ARFLAGS +=
  71. CXXFLAGS += -Os -ffast-math
  72. CFLAGS += -Os -ffast-math -fno-strict-aliasing
  73. CXXFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align
  74. CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align
  75. #ifeq ($(shell command -v ccache 2>/dev/null 1>/dev/null && echo yes),yes)
  76. CCACHE=ccache
  77. #else
  78. CCACHE=
  79. #endif
  80. .PHONY: all
  81. all: openmpt_wine_wrapper.dll
  82. openmpt_wine_wrapper.dll: openmpt_wine_wrapper.dll.so
  83. $(PROGRESS)
  84. $(INFO) Copying $@ ...
  85. $(VERYSILENT)cp openmpt_wine_wrapper.dll.so openmpt_wine_wrapper.dll
  86. ifeq ($(MPT_WINEGCC_LANG),CPLUSPLUS)
  87. openmpt_wine_wrapper.dll.so: openmpt_wine_wrapper.o build/wine/wine_wrapper.spec libopenmpt_native_support.so
  88. $(PROGRESS)
  89. $(INFO) Linking $@ ...
  90. $(SILENT)$(WINEGXX) -shared $(CPPFLAGS) -DMPT_BUILD_WINESUPPORT_WRAPPER $(CXXFLAGS) $(LDFLAGS) "-Wl,-rpath,$(MPT_WINE_SEARCHPATH)" build/wine/wine_wrapper.spec openmpt_wine_wrapper.o -L. -lopenmpt_native_support $(LOADLIBS) $(LDLIBS) -o openmpt_wine_wrapper.dll.so
  91. openmpt_wine_wrapper.o: mptrack/wine/WineWrapper.cpp
  92. $(PROGRESS)
  93. $(INFO) Compiling $@ ...
  94. $(SILENT)$(CCACHE) $(WINEGXX) -c $(CPPFLAGS) -DMPT_BUILD_WINESUPPORT_WRAPPER $(CXXFLAGS) mptrack/wine/WineWrapper.cpp -o openmpt_wine_wrapper.o
  95. endif
  96. ifeq ($(MPT_WINEGCC_LANG),C)
  97. openmpt_wine_wrapper.dll.so: openmpt_wine_wrapper.o build/wine/wine_wrapper.spec libopenmpt_native_support.so
  98. $(PROGRESS)
  99. $(INFO) Linking $@ ...
  100. $(SILENT)$(WINEGXX) -shared $(CPPFLAGS) -DMPT_BUILD_WINESUPPORT_WRAPPER $(CFLAGS) $(LDFLAGS) "-Wl,-rpath,$(MPT_WINE_SEARCHPATH)" build/wine/wine_wrapper.spec openmpt_wine_wrapper.o -L. -lopenmpt_native_support $(LOADLIBS) $(LDLIBS) -o openmpt_wine_wrapper.dll.so
  101. openmpt_wine_wrapper.o: mptrack/wine/WineWrapper.c
  102. $(PROGRESS)
  103. $(INFO) Compiling $@ ...
  104. $(SILENT)$(CCACHE) $(WINEGXX) -c $(CPPFLAGS) -DMPT_BUILD_WINESUPPORT_WRAPPER $(CFLAGS) mptrack/wine/WineWrapper.c -o openmpt_wine_wrapper.o
  105. endif
  106. endif