Aer Interpreter Source
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.

118 lines
2.8 KiB

3 years ago
3 years ago
3 years ago
  1. # Flags to pass to the compiler
  2. CFLAGS = -fPIC -Iinclude -I. -W -Wunused -Wall
  3. # Additional CFLAGS for debug build
  4. DFLAGS = -O0 -g
  5. # Addditional CFLAGS for release build
  6. RFLAGS = -O3 -s
  7. # Flags to pass to the linker
  8. LFLAGS =
  9. ##############################################
  10. ### Do not modify anything below this line ###
  11. ##############################################
  12. ifeq ($(OS),Windows_NT)
  13. PLATFORM := "Windows"
  14. else
  15. PLATFORM := $(shell uname -s)
  16. endif
  17. ifeq "$(PLATFORM)" "Darwin"
  18. CC := clang
  19. MD := mkdir -p
  20. RM := rm -rfv
  21. LIBS := -ldl -lm
  22. LFLAGS := $(LFLAGS) -Wl,--export-dynamic -rdynamic
  23. ESUFFIX :=
  24. LSUFFIX := .dylib
  25. endif
  26. ifeq "$(PLATFORM)" "FreeBSD"
  27. CC := clang
  28. MD := mkdir -p
  29. RM := rm -rfv
  30. LIBS := -lm
  31. LFLAGS := $(LFLAGS) -Wl,--export-dynamic -rdynamic
  32. ESUFFIX :=
  33. LSUFFIX := .so
  34. endif
  35. ifeq "$(PLATFORM)" "Linux"
  36. CC := gcc
  37. MD := mkdir -p
  38. RM := rm -rfv
  39. LIBS := -ldl -lm
  40. LFLAGS := $(LFLAGS) -Wl,--export-dynamic -rdynamic
  41. ESUFFIX :=
  42. LSUFFIX := .so
  43. endif
  44. ifeq "$(PLATFORM)" "OpenBSD"
  45. CC := clang
  46. MD := mkdir -p
  47. RM := rm -rfv
  48. LIBS := -lm
  49. LFLAGS := $(LFLAGS) -Wl,--export-dynamic -rdynamic
  50. ESUFFIX :=
  51. LSUFFIX := .so
  52. endif
  53. ifeq "$(PLATFORM)" "Windows"
  54. CC := gcc
  55. MD := md
  56. RM := del /F
  57. LIBS := -ldl -lm
  58. LFLAGS := $(LFLAGS) -Wl,--export-dynamic -rdynamic
  59. ESUFFIX := .exe
  60. LSUFFIX := .dll
  61. endif
  62. BINARY := psharp
  63. BUILD_DIR := build
  64. CFLAGS := $(CFLAGS) -DPH7_LIBRARY_SUFFIX=\"$(LSUFFIX)\"
  65. ENGINE_DIRS := engine/lib engine
  66. ENGINE_SRCS := $(foreach dir,$(ENGINE_DIRS),$(wildcard $(dir)/*.c))
  67. ENGINE_MAKE := $(ENGINE_SRCS:.c=.o)
  68. ENGINE_OBJS := $(addprefix $(BUILD_DIR)/,$(ENGINE_MAKE))
  69. MODULE := $(subst /,,$(subst modules/,,$(dir $(wildcard modules/*/))))
  70. SAPI := $(subst /,,$(subst sapi/,,$(dir $(wildcard sapi/*/))))
  71. .SUFFIXES:
  72. .PHONY: clean debug release style test
  73. debug: export CFLAGS := $(CFLAGS) $(DFLAGS)
  74. debug: engine sapi module
  75. release: export CFLAGS := $(CFLAGS) $(RFLAGS)
  76. release: engine sapi module
  77. engine: $(ENGINE_OBJS)
  78. module: $(MODULE)
  79. sapi: $(SAPI)
  80. $(BUILD_DIR)/%.o: %.c
  81. $(MD) $(dir $@)
  82. $(CC) $(CFLAGS) -c $< -o $@
  83. $(MODULE):
  84. $(eval MODULE_DIRS := $@)
  85. $(eval MODULE_SRCS := $(foreach dir,modules/$(MODULE_DIRS),$(wildcard $(dir)/*.c)))
  86. $(eval MODULE_MAKE := $(MODULE_SRCS:.c=.o))
  87. $(eval MODULE_OBJS := $(addprefix $(BUILD_DIR)/,$(MODULE_MAKE)))
  88. $(eval MODULE_PROG := $(MODULE_DIRS)$(LSUFFIX))
  89. $(MAKE) $(MODULE_OBJS)
  90. $(CC) -o $(BUILD_DIR)/$(MODULE_PROG) $(LFLAGS) $(LIBS) -shared $(MODULE_OBJS)
  91. $(SAPI):
  92. $(eval SAPI_DIRS := $@)
  93. $(eval SAPI_SRCS := $(foreach dir,sapi/$(SAPI_DIRS),$(wildcard $(dir)/*.c)))
  94. $(eval SAPI_MAKE := $(SAPI_SRCS:.c=.o))
  95. $(eval SAPI_OBJS := $(addprefix $(BUILD_DIR)/,$(SAPI_MAKE)))
  96. $(eval SAPI_PROG := $(subst -cli,,$(BINARY)-$(SAPI_DIRS))$(ESUFFIX))
  97. $(MAKE) $(SAPI_OBJS)
  98. $(CC) -o $(BUILD_DIR)/$(SAPI_PROG) $(LFLAGS) $(LIBS) $(ENGINE_OBJS) $(SAPI_OBJS)
  99. clean:
  100. $(RM) $(BUILD_DIR)