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.

113 lines
2.6 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 = -Wl,--export-dynamic -rdynamic
  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. ESUFFIX :=
  23. LSUFFIX := .dylib
  24. endif
  25. ifeq "$(PLATFORM)" "FreeBSD"
  26. CC := clang
  27. MD := mkdir -p
  28. RM := rm -rfv
  29. LIBS := -lm
  30. ESUFFIX :=
  31. LSUFFIX := .so
  32. endif
  33. ifeq "$(PLATFORM)" "Linux"
  34. CC := gcc
  35. MD := mkdir -p
  36. RM := rm -rfv
  37. LIBS := -ldl -lm
  38. ESUFFIX :=
  39. LSUFFIX := .so
  40. endif
  41. ifeq "$(PLATFORM)" "OpenBSD"
  42. CC := clang
  43. MD := mkdir -p
  44. RM := rm -rfv
  45. LIBS := -lm
  46. ESUFFIX :=
  47. LSUFFIX := .so
  48. endif
  49. ifeq "$(PLATFORM)" "Windows"
  50. CC := gcc
  51. MD := md
  52. RM := del /F
  53. LIBS := -ldl -lm
  54. ESUFFIX := .exe
  55. LSUFFIX := .dll
  56. endif
  57. BINARY := psharp
  58. BUILD_DIR := build
  59. CFLAGS := $(CFLAGS) -DPH7_LIBRARY_SUFFIX=\"$(LSUFFIX)\"
  60. ENGINE_DIRS := engine/lib engine
  61. ENGINE_SRCS := $(foreach dir,$(ENGINE_DIRS),$(wildcard $(dir)/*.c))
  62. ENGINE_MAKE := $(ENGINE_SRCS:.c=.o)
  63. ENGINE_OBJS := $(addprefix $(BUILD_DIR)/,$(ENGINE_MAKE))
  64. MODULE := $(subst /,,$(subst modules/,,$(dir $(wildcard modules/*/))))
  65. SAPI := $(subst /,,$(subst sapi/,,$(dir $(wildcard sapi/*/))))
  66. .SUFFIXES:
  67. .PHONY: clean debug release style test
  68. debug: export CFLAGS := $(CFLAGS) $(DFLAGS)
  69. debug: engine sapi module
  70. release: export CFLAGS := $(CFLAGS) $(RFLAGS)
  71. release: engine sapi module
  72. engine: $(ENGINE_OBJS)
  73. module: $(MODULE)
  74. sapi: $(SAPI)
  75. $(BUILD_DIR)/%.o: %.c
  76. $(MD) $(dir $@)
  77. $(CC) $(CFLAGS) -c $< -o $@
  78. $(MODULE):
  79. $(eval MODULE_DIRS := $@)
  80. $(eval MODULE_SRCS := $(foreach dir,modules/$(MODULE_DIRS),$(wildcard $(dir)/*.c)))
  81. $(eval MODULE_MAKE := $(MODULE_SRCS:.c=.o))
  82. $(eval MODULE_OBJS := $(addprefix $(BUILD_DIR)/,$(MODULE_MAKE)))
  83. $(eval MODULE_PROG := $(MODULE_DIRS)$(LSUFFIX))
  84. $(MAKE) $(MODULE_OBJS)
  85. $(CC) -o $(BUILD_DIR)/$(MODULE_PROG) $(LFLAGS) $(LIBS) -shared $(MODULE_OBJS)
  86. $(SAPI):
  87. $(eval SAPI_DIRS := $@)
  88. $(eval SAPI_SRCS := $(foreach dir,sapi/$(SAPI_DIRS),$(wildcard $(dir)/*.c)))
  89. $(eval SAPI_MAKE := $(SAPI_SRCS:.c=.o))
  90. $(eval SAPI_OBJS := $(addprefix $(BUILD_DIR)/,$(SAPI_MAKE)))
  91. $(eval SAPI_PROG := $(subst -cli,,$(BINARY)-$(SAPI_DIRS))$(ESUFFIX))
  92. $(MAKE) $(SAPI_OBJS)
  93. $(CC) -o $(BUILD_DIR)/$(SAPI_PROG) $(LFLAGS) $(LIBS) $(ENGINE_OBJS) $(SAPI_OBJS)
  94. clean:
  95. $(RM) $(BUILD_DIR)