La simu multi-agents qui repeint une image, mais en c++ Boilerplate pompé ici : https://github.com/andrew-r-king/sfml-vscode-boilerplate
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. .SUFFIXES:
  2. SUFFIXES =
  3. .SUFFIXES: .c .cpp .h .hpp .rc .res .inl .o .d .asm
  4. #==============================================================================
  5. MAKEFLAGS += --no-print-directory
  6. #==============================================================================
  7. SHELL := /bin/sh
  8. # Build platform
  9. PLATFORM?=linux
  10. # Build description (Primarily uses Debug/Release)
  11. BUILD?=Release
  12. _BUILDL := $(shell echo $(BUILD) | tr A-Z a-z)
  13. ifeq ($(BUILD),Tests)
  14. _BUILDL := release
  15. endif
  16. # The sub-folder containing the target source files
  17. SRC_TARGET?=
  18. ifneq ($(SRC_TARGET),)
  19. _SRC_TARGET := /$(SRC_TARGET)
  20. endif
  21. # Maximum parallel jobs during build process
  22. MAX_PARALLEL_JOBS?=8
  23. # Dump assembly?
  24. DUMP_ASSEMBLY?=false
  25. # Clean output?
  26. CLEAN_OUTPUT?=true
  27. # If dll, build as a static library?
  28. BUILD_STATIC?=false
  29. # Platform specific environment variables
  30. -include env/.all.mk
  31. -include env/.$(_BUILDL).mk
  32. -include env/$(PLATFORM).all.mk
  33. -include env/$(PLATFORM).$(_BUILDL).mk
  34. # Target specific variables
  35. ifneq ($(SRC_TARGET),)
  36. -include env/$(SRC_TARGET)/.all.mk
  37. -include env/$(SRC_TARGET)/.$(_BUILDL).mk
  38. -include env/$(SRC_TARGET)/$(PLATFORM).all.mk
  39. -include env/$(SRC_TARGET)/$(PLATFORM).$(_BUILDL).mk
  40. endif
  41. #==============================================================================
  42. # File/Folder dependencies for the production build recipe (makeproduction)
  43. PRODUCTION_DEPENDENCIES?=
  44. # Extensions to exclude from production builds
  45. PRODUCTION_EXCLUDE?=
  46. # Folder location (relative or absolute) to place the production build into
  47. PRODUCTION_FOLDER?=build
  48. PRODUCTION_FOLDER_RESOURCES := $(PRODUCTION_FOLDER)
  49. #==============================================================================
  50. # Library directories (separated by spaces)
  51. LIB_DIRS := \
  52. $(LIB_DIRS ) \
  53. $(_SFML)/lib
  54. INCLUDE_DIRS := \
  55. $(INCLUDE_DIRS) \
  56. lib/Environment
  57. # Link libraries (separated by spaces)
  58. LINK_LIBRARIES?=
  59. # Precompiled header filename (no extension)
  60. # This file will be excluded from Rebuild, but if the bin/(build) directory is removed, it will be as well.
  61. PRECOMPILED_HEADER?=
  62. # Build-specific preprocessor macros
  63. BUILD_MACROS?=
  64. # Build-specific compiler flags to be appended to the final build step (with prefix)
  65. BUILD_FLAGS?=
  66. # Build dependencies to copy into the bin/(build) folder - example: openal32.dll
  67. BUILD_DEPENDENCIES?=
  68. # NAME should always be passed as an argument from tasks.json as the root folder name, but uses a fallback of "game.exe"
  69. # This is used for the output filename (game.exe)
  70. NAME?=game.exe
  71. #==============================================================================
  72. # The source file directory
  73. SRC_DIR := src$(_SRC_TARGET)
  74. LIB_DIR := lib
  75. # Project .cpp or .rc files (relative to $(SRC_DIR) directory)
  76. SOURCE_FILES := $(patsubst $(SRC_DIR)/%,%,$(shell find $(SRC_DIR) -name '*.cpp' -o -name '*.c' -o -name '*.cc' -o -name '*.rc'))
  77. # Project subdirectories within $(SRC_DIR)/ that contain source files
  78. PROJECT_DIRS := $(patsubst $(SRC_DIR)/%,%,$(shell find $(SRC_DIR) -mindepth 1 -maxdepth 99 -type d))
  79. # Add prefixes to the above variables
  80. _INCLUDE_DIRS := $(patsubst %,-I%,$(SRC_DIR)/ $(LIB_DIR)/ $(INCLUDE_DIRS))
  81. _BUILD_MACROS := $(BUILD_MACROS:%=-D%)
  82. _LINK_LIBRARIES := $(LINK_LIBRARIES:%=-l%)
  83. #==============================================================================
  84. # Unit Testing
  85. TEST_DIR :=
  86. ifeq ($(BUILD),Tests)
  87. TEST_DIR := test
  88. SOURCE_FILES := $(SOURCE_FILES:Main.cpp=)
  89. SOURCE_FILES := $(patsubst $(TEST_DIR)/%,.$(TEST_DIR)/%,$(shell find $(TEST_DIR) -name '*.cpp' -o -name '*.c' -o -name '*.cc' -o -name '*.rc')) $(SOURCE_FILES)
  90. _INCLUDE_DIRS := $(patsubst %,-I%,$(TEST_DIR)/) $(_INCLUDE_DIRS)
  91. PROJECT_DIRS := .$(TEST_DIR) $(PROJECT_DIRS)
  92. BUILD_FLAGS := $(BUILD_FLAGS:-mwindows=)
  93. endif
  94. #==============================================================================
  95. # Linux Specific
  96. PRODUCTION_LINUX_ICON?=icon
  97. # The full working directory
  98. ifeq ($(PLATFORM),linux)
  99. _LINUX_GREP_CWD := $(shell echo $(CURDIR) | sed 's/\//\\\//g')
  100. endif
  101. #==============================================================================
  102. # MacOS Specific
  103. PRODUCTION_MACOS_ICON?=icon
  104. PRODUCTION_MACOS_BUNDLE_COMPANY?=developer
  105. PRODUCTION_MACOS_BUNDLE_DISPLAY_NAME?=App
  106. PRODUCTION_MACOS_BUNDLE_NAME?=App
  107. PRODUCTION_MACOS_MAKE_DMG?=true
  108. PRODUCTION_MACOS_BACKGROUND?=dmg-background
  109. ifeq ($(PLATFORM),osx)
  110. PRODUCTION_MACOS_BUNDLE_COMPANY := '$(PRODUCTION_MACOS_BUNDLE_COMPANY)'
  111. PRODUCTION_MACOS_BUNDLE_DISPLAY_NAME := '$(PRODUCTION_MACOS_BUNDLE_DISPLAY_NAME)'
  112. PRODUCTION_MACOS_BUNDLE_NAME := '$(PRODUCTION_MACOS_BUNDLE_NAME)'
  113. PRODUCTION_FOLDER_MACOS := $(PRODUCTION_FOLDER)
  114. PRODUCTION_FOLDER := $(PRODUCTION_FOLDER)/$(PRODUCTION_MACOS_BUNDLE_NAME).app/Contents
  115. PRODUCTION_FOLDER_RESOURCES := $(PRODUCTION_FOLDER)/Resources
  116. PRODUCTION_DEPENDENCIES := $(PRODUCTION_DEPENDENCIES)
  117. PRODUCTION_MACOS_DYLIBS := $(PRODUCTION_MACOS_DYLIBS:%=%.dylib)
  118. MACOS_FRAMEWORKS?=CoreFoundation
  119. PRODUCTION_MACOS_FRAMEWORKS := $(PRODUCTION_MACOS_FRAMEWORKS:%=%.framework)
  120. PRODUCTION_MACOS_BACKGROUND := env/osx/$(PRODUCTION_MACOS_BACKGROUND)
  121. MACOS_FRAMEWORK_PATHS := $(MACOS_FRAMEWORK_PATHS:%=-F%)
  122. BUILD_FLAGS := $(BUILD_FLAGS) $(MACOS_FRAMEWORK_PATHS) $(MACOS_FRAMEWORKS:%=-framework %)
  123. endif
  124. #==============================================================================
  125. # Directories & Dependencies
  126. BLD_DIR := bin/$(BUILD)
  127. ifeq ($(BUILD),Tests)
  128. BLD_DIR := bin/Release
  129. endif
  130. BLD_DIR := $(BLD_DIR:%/=%)
  131. _BASENAME := $(basename $(NAME))
  132. ifeq ($(BUILD_STATIC),true)
  133. ifeq ($(suffix $(NAME)),$(filter $(suffix $(NAME)),.dll .dylib .so))
  134. ifneq ($(suffix $(NAME)),)
  135. NAME := $(_BASENAME)-s.a
  136. endif
  137. endif
  138. endif
  139. TARGET := $(BLD_DIR)/$(NAME)
  140. ifneq ($(SRC_TARGET),)
  141. LIB_DIRS := $(LIB_DIRS) $(BLD_DIR)
  142. endif
  143. _LIB_DIRS := $(LIB_DIR:%=-L%/) $(LIB_DIRS:%=-L%)
  144. _SOURCES_IF_RC := $(if $(filter windows,$(PLATFORM)),$(SOURCE_FILES),$(SOURCE_FILES:%.rc=))
  145. OBJ_DIR := $(BLD_DIR)/obj$(_SRC_TARGET)
  146. _OBJS := $(_SOURCES_IF_RC:.c=.c.o)
  147. _OBJS := $(_OBJS:.cpp=.cpp.o)
  148. _OBJS := $(_OBJS:.cc=.cc.o)
  149. _OBJS := $(_OBJS:.rc=.res)
  150. OBJS := $(_OBJS:%=$(OBJ_DIR)/%)
  151. OBJ_SUBDIRS := $(PROJECT_DIRS:%=$(OBJ_DIR)/%)
  152. DEP_DIR := $(BLD_DIR)/dep$(_SRC_TARGET)
  153. _DEPS := $(_SOURCES_IF_RC:%=%.d)
  154. DEPS := $(_DEPS:%=$(DEP_DIR)/%) $(DEP_DIR)/$(PRECOMPILED_HEADER).d
  155. DEP_SUBDIRS := $(PROJECT_DIRS:%=$(DEP_DIR)/%)
  156. _PCH_HFILE := $(shell find $(SRC_DIR) -name '$(PRECOMPILED_HEADER).hpp' -o -name '$(PRECOMPILED_HEADER).h' -o -name '$(PRECOMPILED_HEADER).hh')
  157. _PCH_HFILE := $(_PCH_HFILE:$(SRC_DIR)/%=%)
  158. _PCH_EXT := $(_PCH_HFILE:$(PRECOMPILED_HEADER).%=%)
  159. _PCH_COMPILER_EXT := $(if $(filter osx,$(PLATFORM)),p,g)ch
  160. _SYMBOLS := $(if $(filter osx,$(PLATFORM)),,$(if $(filter Release,$(BUILD)),-s,))
  161. _PCH := $(_PCH_HFILE:%=$(OBJ_DIR)/%)
  162. ifneq ($(_PCH),)
  163. _PCH_GCH := $(_PCH).$(_PCH_COMPILER_EXT)
  164. endif
  165. ifeq ($(DUMP_ASSEMBLY),true)
  166. ASM_DIR := $(BLD_DIR)/asm$(_SRC_TARGET)
  167. _ASMS := $(_OBJS:%.res=)
  168. _ASMS := $(_ASMS:.o=.o.asm)
  169. ASMS := $(_ASMS:%=$(ASM_DIR)/%)
  170. ASM_SUBDIRS := $(PROJECT_DIRS:%=$(ASM_DIR)/%)
  171. endif
  172. _DIRECTORIES := $(sort bin $(BLD_DIR) $(OBJ_DIR) $(OBJ_SUBDIRS) $(DEP_DIR) $(DEP_SUBDIRS) $(ASM_DIR) $(ASM_SUBDIRS))
  173. _CLEAN := $(filter true,$(CLEAN_OUTPUT))
  174. _TARGET_DEPS := $(_PCH_GCH) $(OBJS) $(ASMS) $(TEST_DIR)
  175. # Quiet flag
  176. _Q := $(if $(_CLEAN),@)
  177. #==============================================================================
  178. # Compiler & flags
  179. CC?=g++
  180. RC?=windres.exe
  181. CFLAGS?=-O2 -Wall -fdiagnostics-color=always
  182. CFLAGS_DEPS = -MT $@ -MMD -MP -MF $(DEP_DIR)/$*.Td
  183. CFLAGS_DEPS_T = -MT $@ -MMD -MP -MF $(DEP_DIR)/.$(TEST_DIR)/$*.Td
  184. PCH_COMPILE = $(CC) $(CFLAGS_DEPS) $(_BUILD_MACROS) $(CFLAGS) $(_INCLUDE_DIRS) -o $@ -c $<
  185. ifneq ($(_PCH),)
  186. _INCLUDE_PCH := -include $(_PCH)
  187. endif
  188. OBJ_COMPILE = $(CC) $(CFLAGS_DEPS) $(_BUILD_MACROS) $(_INCLUDE_DIRS) $(_INCLUDE_PCH) $(CFLAGS) -o $@ -c $<
  189. OBJ_COMPILE_T = $(CC) $(CFLAGS_DEPS_T) $(_BUILD_MACROS) $(_INCLUDE_DIRS) $(_INCLUDE_PCH) $(CFLAGS) -o $@ -c $<
  190. RC_COMPILE = -$(RC) -J rc -O coff --preprocessor-arg=-MT --preprocessor-arg=$@ --preprocessor-arg=-MMD --preprocessor-arg=-MP --preprocessor-arg=-MF --preprocessor-arg=$(DEP_DIR)/$*.rc.Td $(_BUILD_MACROS) $(_INCLUDE_DIRS) -i $< -o $@
  191. ifeq ($(PLATFORM),osx)
  192. ASM_COMPILE = otool -tvV $< | c++filt > $@
  193. else
  194. ASM_COMPILE = objdump -d -C -Mintel $< > $@
  195. endif
  196. POST_COMPILE = mv -f $(DEP_DIR)/$*.Td $(DEP_DIR)/$*.d && touch $@
  197. POST_COMPILE_T = mv -f $(DEP_DIR)/.$(TEST_DIR)/$*.Td $(DEP_DIR)/.$(TEST_DIR)/$*.d && touch $@
  198. POST_COMPILE_RC = mv -f $(DEP_DIR)/$*.rc.Td $(DEP_DIR)/$*.rc.d && touch $@
  199. #==============================================================================
  200. # Unicode
  201. UNI_COPY := ➦
  202. UNI_LINK := ⇛
  203. ifeq ($(PLATFORM),osx)
  204. UNI_COPY := ➦
  205. UNI_LINK := ⇛
  206. endif
  207. ifeq ($(PLATFORM),windows)
  208. UNI_COPY := \xE2\x9E\xA6
  209. UNI_LINK := \xE2\x87\x9B
  210. endif
  211. # Misc
  212. ORIGIN_FLAG := '-Wl,-R$$ORIGIN'
  213. ifeq ($(PLATFORM),osx)
  214. ORIGIN_FLAG :=
  215. endif
  216. #==============================================================================
  217. # Build Scripts
  218. all:
  219. @$(MAKE) makepch
  220. @$(MAKE) -j$(MAX_PARALLEL_JOBS) makebuild
  221. .DELETE_ON_ERROR: all
  222. rebuild: clean all
  223. .PHONY: rebuild
  224. buildprod: all makeproduction
  225. .PHONY: buildprod
  226. #==============================================================================
  227. # Functions
  228. color_blue := \033[0;34m
  229. color_purple := \033[0;35m
  230. define compile_with
  231. $(if $(_CLEAN),@printf ' $(color_blue)$($(2):$(OBJ_DIR)/%=%)\n')
  232. $(_Q)$(3) && $(4)
  233. endef
  234. define linking_with
  235. $(if $(_CLEAN),@printf '\n$(color_blue)$(UNI_LINK) Linking: $(1)')
  236. endef
  237. define build_deps
  238. $(foreach dep,$(BUILD_DEPENDENCIES),$(call copy_to,$(dep),$(BLD_DIR)))
  239. endef
  240. MKDIR := $(_Q)mkdir -p
  241. makepch: $(_PCH_GCH)
  242. @printf ''
  243. .PHONY: makepch
  244. makebuild: $(TARGET)
  245. ifeq ($(SRC_TARGET),)
  246. @printf ' $(color_blue)Target is up to date.\n'
  247. else
  248. @printf ' $(color_blue)$(NAME): Target is up to date.\n'
  249. endif
  250. .PHONY: makebuild
  251. #==============================================================================
  252. # Build Recipes
  253. $(OBJ_DIR)/%.o: $(SRC_DIR)/%
  254. $(OBJ_DIR)/%.o: $(SRC_DIR)/% $(_PCH_GCH) $(DEP_DIR)/%.d | $(_DIRECTORIES)
  255. $(call compile_with,@,<,$(OBJ_COMPILE),$(POST_COMPILE))
  256. $(OBJ_DIR)/.$(TEST_DIR)/%.o: $(TEST_DIR)/%
  257. $(OBJ_DIR)/.$(TEST_DIR)/%.o: $(TEST_DIR)/% $(_PCH_GCH) $(DEP_DIR)/.$(TEST_DIR)/%.d | $(_DIRECTORIES)
  258. $(call compile_with,@,<,$(OBJ_COMPILE_T),$(POST_COMPILE_T))
  259. $(OBJ_DIR)/%.$(_PCH_EXT).$(_PCH_COMPILER_EXT) : $(SRC_DIR)/%.$(_PCH_EXT)
  260. $(OBJ_DIR)/%.$(_PCH_EXT).$(_PCH_COMPILER_EXT) : $(SRC_DIR)/%.$(_PCH_EXT) $(DEP_DIR)/%.d | $(_DIRECTORIES)
  261. $(call compile_with,@,<,$(PCH_COMPILE),$(POST_COMPILE))
  262. $(OBJ_DIR)/%.res: $(SRC_DIR)/%.rc
  263. $(OBJ_DIR)/%.res: $(SRC_DIR)/%.rc $(DEP_DIR)/%.rc.d | $(_DIRECTORIES)
  264. $(call compile_with,@,<,$(RC_COMPILE),$(POST_COMPILE_RC))
  265. $(ASM_DIR)/%.o.asm: $(OBJ_DIR)/%.o
  266. $(if $(_CLEAN),@printf ' $(color_purple)$@\n')
  267. $(_Q)$(ASM_COMPILE)
  268. $(BLD_DIR)/lib%-s.a: $(_TARGET_DEPS)
  269. $(call linking_with,$@)
  270. -$(_Q)rm -rf $@
  271. $(_Q)ar -c -r -s $@ $(OBJS)
  272. @printf '\n'
  273. $(BLD_DIR)/$(_BASENAME).dll: $(_TARGET_DEPS)
  274. $(call linking_with,$@)
  275. -$(_Q)rm -rf $(BLD_DIR)/$(_BASENAME).def $(BLD_DIR)/$(_BASENAME).a
  276. $(_Q)$(CC) -shared -Wl,--output-def="$(BLD_DIR)/$(_BASENAME).def" -Wl,--out-implib="$(BLD_DIR)/$(_BASENAME).a" -Wl,--dll $(_LIB_DIRS) $(OBJS) -o $@ $(_SYMBOLS) $(_LINK_LIBRARIES) $(BUILD_FLAGS)
  277. @printf '\n'
  278. $(BLD_DIR)/$(_BASENAME).so: $(_TARGET_DEPS)
  279. $(call linking_with,$@)
  280. $(_Q)$(CC) -shared $(_LIB_DIRS) $(OBJS) -o $@ $(_SYMBOLS) $(_LINK_LIBRARIES) $(BUILD_FLAGS)
  281. @printf '\n'
  282. $(BLD_DIR)/$(_BASENAME).dylib: $(_TARGET_DEPS)
  283. $(call linking_with,$(BLD_DIR)/$(_BASENAME).dylib)
  284. $(_Q)$(CC) -dynamiclib -undefined suppress -flat_namespace $(_LIB_DIRS) $(OBJS) -o $@ $(_SYMBOLS) $(_LINK_LIBRARIES) $(BUILD_FLAGS)
  285. @printf '\n'
  286. $(BLD_DIR)/$(_BASENAME).exe: $(_TARGET_DEPS)
  287. $(call linking_with,$@)
  288. $(_Q)$(CC) $(_LIB_DIRS) $(_SYMBOLS) -o $@ $(ORIGIN_FLAG) $(OBJS) $(_LINK_LIBRARIES) $(BUILD_FLAGS)
  289. @printf '\n'
  290. $(call build_deps)
  291. $(BLD_DIR)/$(_BASENAME): $(_TARGET_DEPS)
  292. $(call linking_with,$@)
  293. $(_Q)$(CC) $(_LIB_DIRS) $(_SYMBOLS) -o $@ $(ORIGIN_FLAG) $(OBJS) $(_LINK_LIBRARIES) $(BUILD_FLAGS)
  294. @printf '\n'
  295. $(call build_deps)
  296. $(_DIRECTORIES):
  297. $(if $(_CLEAN),,@printf '\$(color_blue)')
  298. $(MKDIR) $@
  299. clean:
  300. $(if $(_CLEAN),@prtinf ' $(color_blue)Cleaning old build files & folders...\n\n')
  301. $(_Q)$(RM) $(TARGET) $(DEPS) $(OBJS)
  302. .PHONY: clean
  303. #==============================================================================
  304. # Production recipes
  305. rmprod:
  306. @printf '\n'
  307. -$(_Q)rm -rf $(if $(filter osx,$(PLATFORM)),$(PRODUCTION_FOLDER_MACOS),$(PRODUCTION_FOLDER))
  308. ifeq ($(PLATFORM),linux)
  309. -$(_Q)rm -rf ~/.local/share/applications/$(NAME).desktop
  310. endif
  311. .PHONY: rmprod
  312. mkdirprod:
  313. $(MKDIR) $(PRODUCTION_FOLDER)
  314. .PHONY: mkdirprod
  315. define do_copy_to_clean
  316. @printf '$(color_blue)$(UNI_COPY) Copying \"$(1)\" to \"$(CURDIR)/$(2)\"\n'
  317. $(shell cp -r $(1) $(2))
  318. endef
  319. define do_copy_to
  320. @printf '$(color_blue)cp -r $(1) $(2)\n'
  321. $(shell cp -r $(1) $(2))
  322. endef
  323. define copy_to
  324. $(if $(wildcard $(2)/$(notdir $(1))),,$(if $(_CLEAN),$(call do_copy_to_clean,$(1),$(2)),$(call do_copy_to,$(1),$(2))))
  325. endef
  326. releasetoprod: $(TARGET)
  327. ifeq ($(PLATFORM),osx)
  328. @printf ' $(color_blue)Creating the MacOS application bundle...\n'
  329. @printf '\n'
  330. $(MKDIR) $(PRODUCTION_FOLDER)/Resources $(PRODUCTION_FOLDER)/Frameworks $(PRODUCTION_FOLDER)/MacOS
  331. $(_Q)sips -s format icns env/osx/$(PRODUCTION_MACOS_ICON).png --out $(PRODUCTION_FOLDER)/Resources/$(PRODUCTION_MACOS_ICON).icns
  332. @printf '\n'
  333. $(_Q)plutil -convert binary1 env/osx/Info.plist.json -o $(PRODUCTION_FOLDER)/Info.plist
  334. $(_Q)plutil -replace CFBundleExecutable -string $(NAME) $(PRODUCTION_FOLDER)/Info.plist
  335. $(_Q)plutil -replace CFBundleName -string $(PRODUCTION_MACOS_BUNDLE_NAME) $(PRODUCTION_FOLDER)/Info.plist
  336. $(_Q)plutil -replace CFBundleIconFile -string $(PRODUCTION_MACOS_ICON) $(PRODUCTION_FOLDER)/Info.plist
  337. $(_Q)plutil -replace CFBundleDisplayName -string "$(PRODUCTION_MACOS_BUNDLE_DISPLAY_NAME)" $(PRODUCTION_FOLDER)/Info.plist
  338. $(_Q)plutil -replace CFBundleIdentifier -string com.$(PRODUCTION_MACOS_BUNDLE_DEVELOPER).$(PRODUCTION_MACOS_BUNDLE_NAME) $(PRODUCTION_FOLDER)/Info.plist
  339. $(_Q)cp $(TARGET) $(PRODUCTION_FOLDER)/MacOS
  340. $(_Q)chmod +x $(PRODUCTION_FOLDER)/MacOS/$(NAME)
  341. else ifeq ($(PLATFORM),linux)
  342. $(_Q)cp $(TARGET) $(PRODUCTION_FOLDER)
  343. $(_Q)cp env/linux/$(PRODUCTION_LINUX_ICON).png $(PRODUCTION_FOLDER)/$(PRODUCTION_LINUX_ICON).png
  344. $(_Q)cp env/linux/exec.desktop $(PRODUCTION_FOLDER)/$(NAME).desktop
  345. $(_Q)sed -i 's/^Exec=.*/Exec=$(_LINUX_GREP_CWD)\/$(PRODUCTION_FOLDER)\/$(NAME)/' $(PRODUCTION_FOLDER)/$(NAME).desktop
  346. $(_Q)sed -i 's/^Path=.*/Path=$(_LINUX_GREP_CWD)\/$(PRODUCTION_FOLDER)/' $(PRODUCTION_FOLDER)/$(NAME).desktop
  347. $(_Q)sed -i 's/^Name=.*/Name=$(PRODUCTION_LINUX_APP_NAME)/' $(PRODUCTION_FOLDER)/$(NAME).desktop
  348. $(_Q)sed -i 's/^Comment=.*/Comment=$(PRODUCTION_LINUX_APP_COMMENT)/' $(PRODUCTION_FOLDER)/$(NAME).desktop
  349. $(_Q)sed -i 's/^Icon=.*/Icon=$(_LINUX_GREP_CWD)\/$(PRODUCTION_FOLDER)\/$(PRODUCTION_LINUX_ICON).png/' $(PRODUCTION_FOLDER)/$(NAME).desktop
  350. $(_Q)chmod +x $(PRODUCTION_FOLDER)/$(NAME)
  351. $(_Q)chmod +x $(PRODUCTION_FOLDER)/$(NAME).desktop
  352. $(_Q)cp $(PRODUCTION_FOLDER)/$(NAME).desktop ~/.local/share/applications
  353. else
  354. $(_Q)cp $(TARGET) $(PRODUCTION_FOLDER)
  355. $(if $(_CLEAN),,@printf '\n')
  356. endif
  357. .PHONY: releasetoprod
  358. makeproduction: rmprod mkdirprod releasetoprod
  359. ifneq ($(PRODUCTION_DEPENDENCIES),)
  360. @printf ' $(color_blue)Adding dynamic libraries & project dependencies...\n'
  361. @printf '\n'
  362. $(foreach dep,$(PRODUCTION_DEPENDENCIES),$(call copy_to,$(dep),$(PRODUCTION_FOLDER_RESOURCES)))
  363. $(foreach excl,$(PRODUCTION_EXCLUDE),$(shell find $(PRODUCTION_FOLDER_RESOURCES) -name '$(excl)' -delete))
  364. endif
  365. ifeq ($(PLATFORM),osx)
  366. $(foreach dylib,$(PRODUCTION_MACOS_DYLIBS),$(call copy_to,$(dylib),$(PRODUCTION_FOLDER)/MacOS))
  367. $(_Q)install_name_tool -add_rpath @executable_path/../Frameworks $(PRODUCTION_FOLDER)/MacOS/$(NAME)
  368. $(_Q)install_name_tool -add_rpath @loader_path/.. $(PRODUCTION_FOLDER)/MacOS/$(NAME)
  369. $(foreach dylib,$(PRODUCTION_MACOS_DYLIBS),$(shell install_name_tool -change @rpath/$(notdir $(dylib)) @rpath/MacOS/$(notdir $(dylib)) $(PRODUCTION_FOLDER)/MacOS/$(NAME)))
  370. $(foreach dylib,$(PRODUCTION_MACOS_DYLIBS),$(shell install_name_tool -change $(notdir $(dylib)) @rpath/MacOS/$(notdir $(dylib)) $(PRODUCTION_FOLDER)/MacOS/$(NAME)))
  371. $(foreach dylib,$(PRODUCTION_MACOS_DYLIBS),$(shell install_name_tool -change $(dylib) @rpath/MacOS/$(notdir $(dylib)) $(PRODUCTION_FOLDER)/MacOS/$(NAME)))
  372. $(foreach framework,$(PRODUCTION_MACOS_FRAMEWORKS),$(call copy_to,$(framework),$(PRODUCTION_FOLDER)/Frameworks))
  373. ifeq ($(PRODUCTION_MACOS_MAKE_DMG),true)
  374. $(shell hdiutil detach /Volumes/$(PRODUCTION_MACOS_BUNDLE_NAME)/ &> /dev/null)
  375. @printf '\n'
  376. @printf ' $(color_blue)Creating the dmg image for the application...\n'
  377. @printf '\n'
  378. $(_Q)hdiutil create -megabytes 54 -fs HFS+ -volname $(PRODUCTION_MACOS_BUNDLE_NAME) $(PRODUCTION_FOLDER_MACOS)/.tmp.dmg > /dev/null
  379. $(_Q)hdiutil attach $(PRODUCTION_FOLDER_MACOS)/.tmp.dmg > /dev/null
  380. $(_Q)cp -r $(PRODUCTION_FOLDER_MACOS)/$(PRODUCTION_MACOS_BUNDLE_NAME).app /Volumes/$(PRODUCTION_MACOS_BUNDLE_NAME)/
  381. -$(_Q)rm -rf /Volumes/$(PRODUCTION_MACOS_BUNDLE_NAME)/.fseventsd
  382. $(MKDIR) /Volumes/$(PRODUCTION_MACOS_BUNDLE_NAME)/.background
  383. $(_Q)tiffutil -cathidpicheck $(PRODUCTION_MACOS_BACKGROUND).png $(PRODUCTION_MACOS_BACKGROUND)@2x.png -out /Volumes/$(PRODUCTION_MACOS_BUNDLE_NAME)/.background/background.tiff
  384. $(_Q)ln -s /Applications /Volumes/$(PRODUCTION_MACOS_BUNDLE_NAME)/Applications
  385. $(_Q)appName=$(PRODUCTION_MACOS_BUNDLE_NAME) osascript env/osx/dmg.applescript
  386. $(_Q)hdiutil detach /Volumes/$(PRODUCTION_MACOS_BUNDLE_NAME)/ > /dev/null
  387. $(_Q)hdiutil convert $(PRODUCTION_FOLDER_MACOS)/.tmp.dmg -format UDZO -o $(PRODUCTION_FOLDER_MACOS)/$(PRODUCTION_MACOS_BUNDLE_NAME).dmg > /dev/null
  388. $(_Q)rm -f $(PRODUCTION_FOLDER_MACOS)/.tmp.dmg
  389. @printf '\n'
  390. @printf ' $(color_blue)Created $(PRODUCTION_FOLDER_MACOS)/$(PRODUCTION_MACOS_BUNDLE_NAME).dmg\n'
  391. endif
  392. endif
  393. .PHONY: makeproduction
  394. #==============================================================================
  395. # Dependency recipes
  396. $(DEP_DIR)/%.d: ;
  397. .PRECIOUS: $(DEP_DIR)/%.d
  398. include $(wildcard $(DEPS))