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