Front end of the Slack clone application.

Makefile 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. # We borrow heavily from the kernel build setup, though we are simpler since
  2. # we don't have Kconfig tweaking settings on us.
  3. # The implicit make rules have it looking for RCS files, among other things.
  4. # We instead explicitly write all the rules we care about.
  5. # It's even quicker (saves ~200ms) to pass -r on the command line.
  6. MAKEFLAGS=-r
  7. # The source directory tree.
  8. srcdir := ..
  9. abs_srcdir := $(abspath $(srcdir))
  10. # The name of the builddir.
  11. builddir_name ?= .
  12. # The V=1 flag on command line makes us verbosely print command lines.
  13. ifdef V
  14. quiet=
  15. else
  16. quiet=quiet_
  17. endif
  18. # Specify BUILDTYPE=Release on the command line for a release build.
  19. BUILDTYPE ?= Release
  20. # Directory all our build output goes into.
  21. # Note that this must be two directories beneath src/ for unit tests to pass,
  22. # as they reach into the src/ directory for data with relative paths.
  23. builddir ?= $(builddir_name)/$(BUILDTYPE)
  24. abs_builddir := $(abspath $(builddir))
  25. depsdir := $(builddir)/.deps
  26. # Object output directory.
  27. obj := $(builddir)/obj
  28. abs_obj := $(abspath $(obj))
  29. # We build up a list of every single one of the targets so we can slurp in the
  30. # generated dependency rule Makefiles in one pass.
  31. all_deps :=
  32. CC.target ?= $(CC)
  33. CFLAGS.target ?= $(CPPFLAGS) $(CFLAGS)
  34. CXX.target ?= $(CXX)
  35. CXXFLAGS.target ?= $(CPPFLAGS) $(CXXFLAGS)
  36. LINK.target ?= $(LINK)
  37. LDFLAGS.target ?= $(LDFLAGS)
  38. AR.target ?= $(AR)
  39. # C++ apps need to be linked with g++.
  40. LINK ?= $(CXX.target)
  41. # TODO(evan): move all cross-compilation logic to gyp-time so we don't need
  42. # to replicate this environment fallback in make as well.
  43. CC.host ?= gcc
  44. CFLAGS.host ?= $(CPPFLAGS_host) $(CFLAGS_host)
  45. CXX.host ?= g++
  46. CXXFLAGS.host ?= $(CPPFLAGS_host) $(CXXFLAGS_host)
  47. LINK.host ?= $(CXX.host)
  48. LDFLAGS.host ?=
  49. AR.host ?= ar
  50. # Define a dir function that can handle spaces.
  51. # http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
  52. # "leading spaces cannot appear in the text of the first argument as written.
  53. # These characters can be put into the argument value by variable substitution."
  54. empty :=
  55. space := $(empty) $(empty)
  56. # http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces
  57. replace_spaces = $(subst $(space),?,$1)
  58. unreplace_spaces = $(subst ?,$(space),$1)
  59. dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1)))
  60. # Flags to make gcc output dependency info. Note that you need to be
  61. # careful here to use the flags that ccache and distcc can understand.
  62. # We write to a dep file on the side first and then rename at the end
  63. # so we can't end up with a broken dep file.
  64. depfile = $(depsdir)/$(call replace_spaces,$@).d
  65. DEPFLAGS = -MMD -MF $(depfile).raw
  66. # We have to fixup the deps output in a few ways.
  67. # (1) the file output should mention the proper .o file.
  68. # ccache or distcc lose the path to the target, so we convert a rule of
  69. # the form:
  70. # foobar.o: DEP1 DEP2
  71. # into
  72. # path/to/foobar.o: DEP1 DEP2
  73. # (2) we want missing files not to cause us to fail to build.
  74. # We want to rewrite
  75. # foobar.o: DEP1 DEP2 \
  76. # DEP3
  77. # to
  78. # DEP1:
  79. # DEP2:
  80. # DEP3:
  81. # so if the files are missing, they're just considered phony rules.
  82. # We have to do some pretty insane escaping to get those backslashes
  83. # and dollar signs past make, the shell, and sed at the same time.
  84. # Doesn't work with spaces, but that's fine: .d files have spaces in
  85. # their names replaced with other characters.
  86. define fixup_dep
  87. # The depfile may not exist if the input file didn't have any #includes.
  88. touch $(depfile).raw
  89. # Fixup path as in (1).
  90. sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)
  91. # Add extra rules as in (2).
  92. # We remove slashes and replace spaces with new lines;
  93. # remove blank lines;
  94. # delete the first line and append a colon to the remaining lines.
  95. sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\
  96. grep -v '^$$' |\
  97. sed -e 1d -e 's|$$|:|' \
  98. >> $(depfile)
  99. rm $(depfile).raw
  100. endef
  101. # Command definitions:
  102. # - cmd_foo is the actual command to run;
  103. # - quiet_cmd_foo is the brief-output summary of the command.
  104. quiet_cmd_cc = CC($(TOOLSET)) $@
  105. cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $<
  106. quiet_cmd_cxx = CXX($(TOOLSET)) $@
  107. cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
  108. quiet_cmd_objc = CXX($(TOOLSET)) $@
  109. cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $<
  110. quiet_cmd_objcxx = CXX($(TOOLSET)) $@
  111. cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $<
  112. # Commands for precompiled header files.
  113. quiet_cmd_pch_c = CXX($(TOOLSET)) $@
  114. cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
  115. quiet_cmd_pch_cc = CXX($(TOOLSET)) $@
  116. cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
  117. quiet_cmd_pch_m = CXX($(TOOLSET)) $@
  118. cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $<
  119. quiet_cmd_pch_mm = CXX($(TOOLSET)) $@
  120. cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $<
  121. # gyp-mac-tool is written next to the root Makefile by gyp.
  122. # Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd
  123. # already.
  124. quiet_cmd_mac_tool = MACTOOL $(4) $<
  125. cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@"
  126. quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@
  127. cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4)
  128. quiet_cmd_infoplist = INFOPLIST $@
  129. cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@"
  130. quiet_cmd_touch = TOUCH $@
  131. cmd_touch = touch $@
  132. quiet_cmd_copy = COPY $@
  133. # send stderr to /dev/null to ignore messages when linking directories.
  134. cmd_copy = rm -rf "$@" && cp -af "$<" "$@"
  135. quiet_cmd_alink = LIBTOOL-STATIC $@
  136. cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^)
  137. quiet_cmd_link = LINK($(TOOLSET)) $@
  138. cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)
  139. quiet_cmd_solink = SOLINK($(TOOLSET)) $@
  140. cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)
  141. quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
  142. cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
  143. # Define an escape_quotes function to escape single quotes.
  144. # This allows us to handle quotes properly as long as we always use
  145. # use single quotes and escape_quotes.
  146. escape_quotes = $(subst ','\'',$(1))
  147. # This comment is here just to include a ' to unconfuse syntax highlighting.
  148. # Define an escape_vars function to escape '$' variable syntax.
  149. # This allows us to read/write command lines with shell variables (e.g.
  150. # $LD_LIBRARY_PATH), without triggering make substitution.
  151. escape_vars = $(subst $$,$$$$,$(1))
  152. # Helper that expands to a shell command to echo a string exactly as it is in
  153. # make. This uses printf instead of echo because printf's behaviour with respect
  154. # to escape sequences is more portable than echo's across different shells
  155. # (e.g., dash, bash).
  156. exact_echo = printf '%s\n' '$(call escape_quotes,$(1))'
  157. # Helper to compare the command we're about to run against the command
  158. # we logged the last time we ran the command. Produces an empty
  159. # string (false) when the commands match.
  160. # Tricky point: Make has no string-equality test function.
  161. # The kernel uses the following, but it seems like it would have false
  162. # positives, where one string reordered its arguments.
  163. # arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
  164. # $(filter-out $(cmd_$@), $(cmd_$(1))))
  165. # We instead substitute each for the empty string into the other, and
  166. # say they're equal if both substitutions produce the empty string.
  167. # .d files contain ? instead of spaces, take that into account.
  168. command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\
  169. $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1))))
  170. # Helper that is non-empty when a prerequisite changes.
  171. # Normally make does this implicitly, but we force rules to always run
  172. # so we can check their command lines.
  173. # $? -- new prerequisites
  174. # $| -- order-only dependencies
  175. prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?))
  176. # Helper that executes all postbuilds until one fails.
  177. define do_postbuilds
  178. @E=0;\
  179. for p in $(POSTBUILDS); do\
  180. eval $$p;\
  181. E=$$?;\
  182. if [ $$E -ne 0 ]; then\
  183. break;\
  184. fi;\
  185. done;\
  186. if [ $$E -ne 0 ]; then\
  187. rm -rf "$@";\
  188. exit $$E;\
  189. fi
  190. endef
  191. # do_cmd: run a command via the above cmd_foo names, if necessary.
  192. # Should always run for a given target to handle command-line changes.
  193. # Second argument, if non-zero, makes it do asm/C/C++ dependency munging.
  194. # Third argument, if non-zero, makes it do POSTBUILDS processing.
  195. # Note: We intentionally do NOT call dirx for depfile, since it contains ? for
  196. # spaces already and dirx strips the ? characters.
  197. define do_cmd
  198. $(if $(or $(command_changed),$(prereq_changed)),
  199. @$(call exact_echo, $($(quiet)cmd_$(1)))
  200. @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))"
  201. $(if $(findstring flock,$(word 2,$(cmd_$1))),
  202. @$(cmd_$(1))
  203. @echo " $(quiet_cmd_$(1)): Finished",
  204. @$(cmd_$(1))
  205. )
  206. @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile)
  207. @$(if $(2),$(fixup_dep))
  208. $(if $(and $(3), $(POSTBUILDS)),
  209. $(call do_postbuilds)
  210. )
  211. )
  212. endef
  213. # Declare the "all" target first so it is the default,
  214. # even though we don't have the deps yet.
  215. .PHONY: all
  216. all:
  217. # make looks for ways to re-generate included makefiles, but in our case, we
  218. # don't have a direct way. Explicitly telling make that it has nothing to do
  219. # for them makes it go faster.
  220. %.d: ;
  221. # Use FORCE_DO_CMD to force a target to run. Should be coupled with
  222. # do_cmd.
  223. .PHONY: FORCE_DO_CMD
  224. FORCE_DO_CMD:
  225. TOOLSET := target
  226. # Suffix rules, putting all outputs into $(obj).
  227. $(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
  228. @$(call do_cmd,cc,1)
  229. $(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
  230. @$(call do_cmd,cxx,1)
  231. $(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD
  232. @$(call do_cmd,cxx,1)
  233. $(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD
  234. @$(call do_cmd,cxx,1)
  235. $(obj).$(TOOLSET)/%.o: $(srcdir)/%.m FORCE_DO_CMD
  236. @$(call do_cmd,objc,1)
  237. $(obj).$(TOOLSET)/%.o: $(srcdir)/%.mm FORCE_DO_CMD
  238. @$(call do_cmd,objcxx,1)
  239. $(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD
  240. @$(call do_cmd,cc,1)
  241. $(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD
  242. @$(call do_cmd,cc,1)
  243. # Try building from generated source, too.
  244. $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD
  245. @$(call do_cmd,cc,1)
  246. $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
  247. @$(call do_cmd,cxx,1)
  248. $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD
  249. @$(call do_cmd,cxx,1)
  250. $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD
  251. @$(call do_cmd,cxx,1)
  252. $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.m FORCE_DO_CMD
  253. @$(call do_cmd,objc,1)
  254. $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.mm FORCE_DO_CMD
  255. @$(call do_cmd,objcxx,1)
  256. $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD
  257. @$(call do_cmd,cc,1)
  258. $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD
  259. @$(call do_cmd,cc,1)
  260. $(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD
  261. @$(call do_cmd,cc,1)
  262. $(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD
  263. @$(call do_cmd,cxx,1)
  264. $(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD
  265. @$(call do_cmd,cxx,1)
  266. $(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD
  267. @$(call do_cmd,cxx,1)
  268. $(obj).$(TOOLSET)/%.o: $(obj)/%.m FORCE_DO_CMD
  269. @$(call do_cmd,objc,1)
  270. $(obj).$(TOOLSET)/%.o: $(obj)/%.mm FORCE_DO_CMD
  271. @$(call do_cmd,objcxx,1)
  272. $(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD
  273. @$(call do_cmd,cc,1)
  274. $(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD
  275. @$(call do_cmd,cc,1)
  276. ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
  277. $(findstring $(join ^,$(prefix)),\
  278. $(join ^,binding.target.mk)))),)
  279. include binding.target.mk
  280. endif
  281. ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
  282. $(findstring $(join ^,$(prefix)),\
  283. $(join ^,src/libsass.target.mk)))),)
  284. include src/libsass.target.mk
  285. endif
  286. quiet_cmd_regen_makefile = ACTION Regenerating $@
  287. cmd_regen_makefile = cd $(srcdir); /Users/nicholasm/Labs/ZipTeamPurple-FrontEnd/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/Users/nicholasm/Labs/ZipTeamPurple-FrontEnd/node_modules/node-sass/build/config.gypi -I/Users/nicholasm/Labs/ZipTeamPurple-FrontEnd/node_modules/node-gyp/addon.gypi -I/Users/nicholasm/.node-gyp/10.4.0/include/node/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/nicholasm/.node-gyp/10.4.0" "-Dnode_gyp_dir=/Users/nicholasm/Labs/ZipTeamPurple-FrontEnd/node_modules/node-gyp" "-Dnode_lib_file=/Users/nicholasm/.node-gyp/10.4.0/<(target_arch)/node.lib" "-Dmodule_root_dir=/Users/nicholasm/Labs/ZipTeamPurple-FrontEnd/node_modules/node-sass" "-Dnode_engine=v8" binding.gyp
  288. Makefile: $(srcdir)/src/libsass.gyp $(srcdir)/../node-gyp/addon.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../.node-gyp/10.4.0/include/node/common.gypi
  289. $(call do_cmd,regen_makefile)
  290. # "all" is a concatenation of the "all" targets from all the included
  291. # sub-makefiles. This is just here to clarify.
  292. all:
  293. # Add in dependency-tracking rules. $(all_deps) is the list of every single
  294. # target in our tree. Only consider the ones with .d (dependency) info:
  295. d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d))
  296. ifneq ($(d_files),)
  297. include $(d_files)
  298. endif