deps.mk 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. # Copyright (c) 2013-2015, Loïc Hoguin <essen@ninenines.eu>
  2. # This file is part of erlang.mk and subject to the terms of the ISC License.
  3. .PHONY: distclean-deps distclean-pkg pkg-list pkg-search
  4. # Configuration.
  5. IGNORE_DEPS ?=
  6. DEPS_DIR ?= $(CURDIR)/deps
  7. export DEPS_DIR
  8. REBAR_DEPS_DIR = $(DEPS_DIR)
  9. export REBAR_DEPS_DIR
  10. ALL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(filter-out $(IGNORE_DEPS),$(DEPS)))
  11. ifeq ($(filter $(DEPS_DIR),$(subst :, ,$(ERL_LIBS))),)
  12. ifeq ($(ERL_LIBS),)
  13. ERL_LIBS = $(DEPS_DIR)
  14. else
  15. ERL_LIBS := $(ERL_LIBS):$(DEPS_DIR)
  16. endif
  17. endif
  18. export ERL_LIBS
  19. PKG_FILE2 ?= $(CURDIR)/.erlang.mk.packages.v2
  20. export PKG_FILE2
  21. PKG_FILE_URL ?= https://raw.githubusercontent.com/ninenines/erlang.mk/master/packages.v2.tsv
  22. # Verbosity.
  23. dep_verbose_0 = @echo " DEP " $(1);
  24. dep_verbose = $(dep_verbose_$(V))
  25. # Core targets.
  26. ifneq ($(SKIP_DEPS),)
  27. deps::
  28. else
  29. deps:: $(ALL_DEPS_DIRS)
  30. @for dep in $(ALL_DEPS_DIRS) ; do \
  31. if [ -f $$dep/GNUmakefile ] || [ -f $$dep/makefile ] || [ -f $$dep/Makefile ] ; then \
  32. $(MAKE) -C $$dep IS_DEP=1 || exit $$? ; \
  33. else \
  34. echo "ERROR: No Makefile to build dependency $$dep." ; \
  35. exit 1 ; \
  36. fi ; \
  37. done
  38. endif
  39. distclean:: distclean-deps distclean-pkg
  40. # Deps related targets.
  41. # @todo rename GNUmakefile and makefile into Makefile first, if they exist
  42. # While Makefile file could be GNUmakefile or makefile,
  43. # in practice only Makefile is needed so far.
  44. define dep_autopatch
  45. if [ -f $(DEPS_DIR)/$(1)/Makefile ]; then \
  46. if [ 0 != `grep -c "include ../\w*\.mk" $(DEPS_DIR)/$(1)/Makefile` ]; then \
  47. $(call dep_autopatch2,$(1)); \
  48. elif [ 0 != `grep -ci rebar $(DEPS_DIR)/$(1)/Makefile` ]; then \
  49. $(call dep_autopatch2,$(1)); \
  50. elif [ 0 != `find $(DEPS_DIR)/$(1)/ -type f -name \*.mk -not -name erlang.mk | xargs grep -ci rebar` ]; then \
  51. $(call dep_autopatch2,$(1)); \
  52. else \
  53. $(call dep_autopatch_erlang_mk,$(1)); \
  54. fi \
  55. else \
  56. if [ ! -d $(DEPS_DIR)/$(1)/src/ ]; then \
  57. $(call dep_autopatch_noop,$(1)); \
  58. else \
  59. $(call dep_autopatch2,$(1)); \
  60. fi \
  61. fi
  62. endef
  63. define dep_autopatch2
  64. if [ -f $(DEPS_DIR)/$(1)/rebar.config -o -f $(DEPS_DIR)/$(1)/rebar.config.script ]; then \
  65. $(call dep_autopatch_rebar_utils); \
  66. $(call dep_autopatch_rebar,$(1)); \
  67. else \
  68. $(call dep_autopatch_gen,$(1)); \
  69. fi
  70. endef
  71. define dep_autopatch_noop
  72. printf "noop:\n" > $(DEPS_DIR)/$(1)/Makefile
  73. endef
  74. # Overwrite erlang.mk with the current file by default.
  75. ifeq ($(NO_AUTOPATCH_ERLANG_MK),)
  76. define dep_autopatch_erlang_mk
  77. rm -f $(DEPS_DIR)/$(1)/erlang.mk; \
  78. cd $(DEPS_DIR)/$(1)/ && ln -s ../../erlang.mk; \
  79. $(call erlang,$(call dep_autopatch_appsrc.erl,$(1)))
  80. endef
  81. else
  82. define dep_autopatch_erlang_mk
  83. $(call erlang,$(call dep_autopatch_appsrc.erl,$(1)))
  84. endef
  85. endif
  86. define dep_autopatch_gen
  87. printf "%s\n" \
  88. "ERLC_OPTS = +debug_info" \
  89. "include ../../erlang.mk" > $(DEPS_DIR)/$(1)/Makefile; \
  90. $(call erlang,$(call dep_autopatch_appsrc.erl,$(1)))
  91. endef
  92. define dep_autopatch_rebar_utils
  93. mkdir -p $(ERLANG_MK_TMP)/ebin; \
  94. if [ ! -f $(ERLANG_MK_TMP)/rebar.hrl ]; then \
  95. $(call core_http_get,$(ERLANG_MK_TMP)/rebar.hrl,https://raw.githubusercontent.com/rebar/rebar/791db716b5a3a7671e0b351f95ddf24b848ee173/include/rebar.hrl); \
  96. fi; \
  97. if [ ! -f $(ERLANG_MK_TMP)/rebar_utils.erl ]; then \
  98. $(call core_http_get,$(ERLANG_MK_TMP)/rebar_utils.erl,https://raw.githubusercontent.com/rebar/rebar/791db716b5a3a7671e0b351f95ddf24b848ee173/src/rebar_utils.erl); \
  99. fi; \
  100. if [ ! -f $(ERLANG_MK_TMP)/ebin/rebar_utils.beam ]; then \
  101. erlc -o $(ERLANG_MK_TMP)/ebin $(ERLANG_MK_TMP)/rebar_utils.erl; \
  102. fi
  103. endef
  104. define dep_autopatch_rebar
  105. if [ -f $(DEPS_DIR)/$(1)/Makefile ]; then \
  106. mv $(DEPS_DIR)/$(1)/Makefile $(DEPS_DIR)/$(1)/Makefile.orig.mk; \
  107. fi; \
  108. $(call erlang,$(call dep_autopatch_rebar.erl,$(1))); \
  109. $(call erlang,$(call dep_autopatch_appsrc.erl,$(1)))
  110. endef
  111. define dep_autopatch_rebar.erl
  112. Conf1 = case file:consult("$(DEPS_DIR)/$(1)/rebar.config") of
  113. {ok, Conf0} -> Conf0;
  114. _ -> []
  115. end,
  116. {Conf, OsEnv} = case filelib:is_file("$(DEPS_DIR)/$(1)/rebar.config.script") of
  117. false -> {Conf1, []};
  118. true ->
  119. Bindings0 = erl_eval:new_bindings(),
  120. Bindings1 = erl_eval:add_binding('CONFIG', Conf1, Bindings0),
  121. Bindings = erl_eval:add_binding('SCRIPT', "$(DEPS_DIR)/$(1)/rebar.config.script", Bindings1),
  122. Before = os:getenv(),
  123. {ok, Conf2} = file:script("$(DEPS_DIR)/$(1)/rebar.config.script", Bindings),
  124. {Conf2, lists:foldl(fun(E, Acc) -> lists:delete(E, Acc) end, os:getenv(), Before)}
  125. end,
  126. Write = fun (Text) ->
  127. file:write_file("$(DEPS_DIR)/$(1)/Makefile", Text, [append])
  128. end,
  129. Escape = fun (Text) ->
  130. re:replace(Text, "\\\\$$$$", "\$$$$$$$$", [global, {return, list}])
  131. end,
  132. Write("IGNORE_DEPS = edown eper eunit_formatters meck node_package "
  133. "rebar_lock_deps_plugin rebar_vsn_plugin reltool_util\n\n"),
  134. Write("C_SRC_DIR = /path/do/not/exist\n\n"),
  135. Write("DRV_CFLAGS = -fPIC\nexport DRV_CFLAGS\n\n"),
  136. fun() ->
  137. Write("ERLC_OPTS = +debug_info\n"),
  138. case lists:keyfind(erl_opts, 1, Conf) of
  139. false -> ok;
  140. {_, ErlOpts} ->
  141. lists:foreach(fun
  142. ({d, D}) ->
  143. Write("ERLC_OPTS += -D" ++ atom_to_list(D) ++ "=1\n");
  144. ({platform_define, Regex, D}) ->
  145. case rebar_utils:is_arch(Regex) of
  146. true -> Write("ERLC_OPTS += -D" ++ atom_to_list(D) ++ "=1\n");
  147. false -> ok
  148. end;
  149. ({parse_transform, PT}) ->
  150. Write("ERLC_OPTS += +'{parse_transform, " ++ atom_to_list(PT) ++ "}'\n");
  151. (_) -> ok
  152. end, ErlOpts)
  153. end,
  154. Write("\n")
  155. end(),
  156. fun() ->
  157. File = case lists:keyfind(deps, 1, Conf) of
  158. false -> [];
  159. {_, Deps} ->
  160. [begin
  161. Name = element(1, Dep),
  162. {Method, Repo, Commit} = case element(3, Dep) of
  163. {git, R} -> {git, R, master};
  164. {M, R, {branch, C}} -> {M, R, C};
  165. {M, R, {tag, C}} -> {M, R, C};
  166. {M, R, C} -> {M, R, C}
  167. end,
  168. Write(io_lib:format("DEPS += ~s\ndep_~s = ~s ~s ~s~n", [Name, Name, Method, Repo, Commit]))
  169. end || Dep <- Deps, tuple_size(Dep) > 2]
  170. end
  171. end(),
  172. fun() ->
  173. First = case lists:keyfind(erl_first_files, 1, Conf) of false -> []; {_, Files} ->
  174. Names = [[" ", begin "lre." ++ Elif = lists:reverse(F), lists:reverse(Elif) end]
  175. || "src/" ++ F <- Files],
  176. Write(io_lib:format("COMPILE_FIRST +=~s\n", [Names]))
  177. end
  178. end(),
  179. FindFirst = fun(F, Fd) ->
  180. case io:parse_erl_form(Fd, undefined) of
  181. {ok, {attribute, _,compile, {parse_transform, PT}}, _} ->
  182. [PT, F(F, Fd)];
  183. {ok, {attribute, _, include, Hrl}, _} ->
  184. case file:open("$(DEPS_DIR)/$(1)/include/" ++ Hrl, [read]) of
  185. {ok, HrlFd} -> [F(F, HrlFd), F(F, Fd)];
  186. _ ->
  187. case file:open("$(DEPS_DIR)/$(1)/src/" ++ Hrl, [read]) of
  188. {ok, HrlFd} -> [F(F, HrlFd), F(F, Fd)];
  189. _ -> [F(F, Fd)]
  190. end
  191. end;
  192. {ok, {attribute, _, include_lib, "$(1)/include/" ++ Hrl}, _} ->
  193. {ok, HrlFd} = file:open("$(DEPS_DIR)/$(1)/include/" ++ Hrl, [read]),
  194. [F(F, HrlFd), F(F, Fd)];
  195. {ok, {attribute, _, import, {Imp, _}}, _} ->
  196. case file:open("$(DEPS_DIR)/$(1)/src/" ++ atom_to_list(Imp) ++ ".erl", [read]) of
  197. {ok, ImpFd} -> [Imp, F(F, ImpFd), F(F, Fd)];
  198. _ -> [F(F, Fd)]
  199. end;
  200. {eof, _} ->
  201. file:close(Fd),
  202. [];
  203. _ ->
  204. F(F, Fd)
  205. end
  206. end,
  207. fun() ->
  208. ErlFiles = filelib:wildcard("$(DEPS_DIR)/$(1)/src/*.erl"),
  209. First0 = lists:usort(lists:flatten([begin
  210. {ok, Fd} = file:open(F, [read]),
  211. FindFirst(FindFirst, Fd)
  212. end || F <- ErlFiles])),
  213. First = lists:flatten([begin
  214. {ok, Fd} = file:open("$(DEPS_DIR)/$(1)/src/" ++ atom_to_list(M) ++ ".erl", [read]),
  215. FindFirst(FindFirst, Fd)
  216. end || M <- First0, lists:member("$(DEPS_DIR)/$(1)/src/" ++ atom_to_list(M) ++ ".erl", ErlFiles)]) ++ First0,
  217. Write(["COMPILE_FIRST +=", [[" ", atom_to_list(M)] || M <- First,
  218. lists:member("$(DEPS_DIR)/$(1)/src/" ++ atom_to_list(M) ++ ".erl", ErlFiles)], "\n"])
  219. end(),
  220. Write("\n\nrebar_dep: pre-deps deps pre-app app\n"),
  221. Write("\npre-deps::\n"),
  222. Write("\npre-app::\n"),
  223. fun() ->
  224. case lists:keyfind(pre_hooks, 1, Conf) of
  225. false -> ok;
  226. {_, Hooks} ->
  227. [case H of
  228. {'get-deps', Command} ->
  229. Write("\npre-deps::\n\t" ++ Escape(Command) ++ "\n");
  230. {compile, Command} ->
  231. Write("\npre-app::\n\t" ++ Escape(Command) ++ "\n");
  232. {Regex, compile, Command0} ->
  233. case rebar_utils:is_arch(Regex) of
  234. true ->
  235. Command = case Command0 of
  236. "make -C" ++ _ -> Escape(Command0);
  237. "gmake -C" ++ _ -> Escape(Command0);
  238. "make " ++ Command1 -> "make -f Makefile.orig.mk " ++ Escape(Command1);
  239. "gmake " ++ Command1 -> "gmake -f Makefile.orig.mk " ++ Escape(Command1);
  240. _ -> Command0
  241. end,
  242. Write("\npre-app::\n\t" ++ Command ++ "\n");
  243. false ->
  244. ok
  245. end;
  246. _ -> ok
  247. end || H <- Hooks]
  248. end
  249. end(),
  250. ShellToMk = fun(V) ->
  251. re:replace(V, "(\\\\$$$$)(\\\\w*)", "\\\\1(\\\\2)", [{return, list}, global])
  252. end,
  253. PortSpecs = fun() ->
  254. case lists:keyfind(port_specs, 1, Conf) of
  255. false ->
  256. case filelib:wildcard("$(DEPS_DIR)/$(1)/c_src/*.c") of
  257. [] -> [];
  258. Src -> [{"priv/$(1)_drv.so", ["c_src/*.c"], []}]
  259. end;
  260. {_, Specs} ->
  261. lists:flatten([case S of
  262. {Output, Input} -> {ShellToMk(Output), Input, []};
  263. {Regex, Output, Input} ->
  264. case rebar_utils:is_arch(Regex) of
  265. true -> {ShellToMk(Output), Input, []};
  266. false -> []
  267. end;
  268. {Regex, Output, Input, [{env, Env}]} ->
  269. case rebar_utils:is_arch(Regex) of
  270. true -> {ShellToMk(Output), Input, Env};
  271. false -> []
  272. end
  273. end || S <- Specs])
  274. end
  275. end(),
  276. PortSpecWrite = fun (Text) ->
  277. file:write_file("$(DEPS_DIR)/$(1)/c_src/Makefile.erlang.mk", Text, [append])
  278. end,
  279. case PortSpecs of
  280. [] -> ok;
  281. _ ->
  282. Write("\npre-app::\n\t$$$$\(MAKE) -f c_src/Makefile.erlang.mk\n"),
  283. PortSpecWrite(io_lib:format("ERL_CFLAGS = -finline-functions -Wall -fPIC -I ~s/erts-~s/include -I ~s\n",
  284. [code:root_dir(), erlang:system_info(version), code:lib_dir(erl_interface, include)])),
  285. PortSpecWrite(io_lib:format("ERL_LDFLAGS = -L ~s -lerl_interface -lei\n",
  286. [code:lib_dir(erl_interface, lib)])),
  287. PortSpecWrite(["\nERLANG_ARCH = ", rebar_utils:wordsize(), "\n"]),
  288. [PortSpecWrite(["\n", E, "\n"]) || E <- OsEnv],
  289. FilterEnv = fun(Env) ->
  290. lists:flatten([case E of
  291. {_, _} -> E;
  292. {Regex, K, V} ->
  293. case rebar_utils:is_arch(Regex) of
  294. true -> {K, V};
  295. false -> []
  296. end
  297. end || E <- Env])
  298. end,
  299. MergeEnv = fun(Env) ->
  300. lists:foldl(fun ({K, V}, Acc) ->
  301. case lists:keyfind(K, 1, Acc) of
  302. false -> [{K, rebar_utils:expand_env_variable(V, K, "")}|Acc];
  303. {_, V0} -> [{K, rebar_utils:expand_env_variable(V, K, V0)}|Acc]
  304. end
  305. end, [], Env)
  306. end,
  307. PortEnv = case lists:keyfind(port_env, 1, Conf) of
  308. false -> [];
  309. {_, PortEnv0} -> FilterEnv(PortEnv0)
  310. end,
  311. PortSpec = fun ({Output, Input0, Env}) ->
  312. filelib:ensure_dir("$(DEPS_DIR)/$(1)/" ++ Output),
  313. Input = [[" ", I] || I <- Input0],
  314. PortSpecWrite([
  315. [["\n", K, " = ", ShellToMk(V)] || {K, V} <- lists:reverse(MergeEnv(PortEnv ++ FilterEnv(Env)))],
  316. "\n\nall:: ", Output, "\n\n",
  317. "%.o: %.c\n\t$$$$\(CC) -c -o $$$$\@ $$$$\< $$$$\(CFLAGS) $$$$\(ERL_CFLAGS) $$$$\(DRV_CFLAGS) $$$$\(EXE_CFLAGS)\n\n",
  318. "%.o: %.C\n\t$$$$\(CXX) -c -o $$$$\@ $$$$\< $$$$\(CXXFLAGS) $$$$\(ERL_CFLAGS) $$$$\(DRV_CFLAGS) $$$$\(EXE_CFLAGS)\n\n",
  319. "%.o: %.cc\n\t$$$$\(CXX) -c -o $$$$\@ $$$$\< $$$$\(CXXFLAGS) $$$$\(ERL_CFLAGS) $$$$\(DRV_CFLAGS) $$$$\(EXE_CFLAGS)\n\n",
  320. "%.o: %.cpp\n\t$$$$\(CXX) -c -o $$$$\@ $$$$\< $$$$\(CXXFLAGS) $$$$\(ERL_CFLAGS) $$$$\(DRV_CFLAGS) $$$$\(EXE_CFLAGS)\n\n",
  321. Output, ": $$$$\(foreach ext,.c .C .cc .cpp,",
  322. "$$$$\(patsubst %$$$$\(ext),%.o,$$$$\(filter %$$$$\(ext),$$$$\(wildcard", Input, "))))\n",
  323. "\t$$$$\(CC) -o $$$$\@ $$$$\? $$$$\(LDFLAGS) $$$$\(ERL_LDFLAGS) $$$$\(DRV_LDFLAGS) $$$$\(EXE_LDFLAGS)",
  324. case filename:extension(Output) of
  325. [] -> "\n";
  326. _ -> " -shared\n"
  327. end])
  328. end,
  329. [PortSpec(S) || S <- PortSpecs]
  330. end,
  331. Write("\ninclude ../../erlang.mk"),
  332. fun() ->
  333. case lists:keyfind(plugins, 1, Conf) of
  334. {_, [Plugin]} when is_atom(Plugin) ->
  335. ErlFile = "$(DEPS_DIR)/$(1)/plugins/" ++ atom_to_list(Plugin) ++ ".erl",
  336. try
  337. {ok, Mod, Bin} = compile:file(ErlFile, [binary]),
  338. {module, Mod} = code:load_binary(Mod, ErlFile, Bin),
  339. c:cd("$(DEPS_DIR)/$(1)/"),
  340. ok = Mod:pre_compile(Conf, undefined)
  341. catch _:_ ->
  342. ok
  343. end;
  344. _ -> ok
  345. end
  346. end(),
  347. halt()
  348. endef
  349. define dep_autopatch_appsrc.erl
  350. AppSrcOut = "$(DEPS_DIR)/$(1)/src/$(1).app.src",
  351. AppSrcIn = case filelib:is_regular(AppSrcOut) of false -> "$(DEPS_DIR)/$(1)/ebin/$(1).app"; true -> AppSrcOut end,
  352. case filelib:is_regular(AppSrcIn) of
  353. false -> ok;
  354. true ->
  355. fun() ->
  356. {ok, [{application, $(1), L}]} = file:consult(AppSrcIn),
  357. L2 = lists:keystore(modules, 1, L, {modules, []}),
  358. L3 = case lists:keyfind(vsn, 1, L2) of {vsn, git} -> lists:keyreplace(vsn, 1, L2, {vsn, "git"}); _ -> L2 end,
  359. ok = file:write_file(AppSrcOut, io_lib:format("~p.~n", [{application, $(1), L3}]))
  360. end(),
  361. case AppSrcOut of AppSrcIn -> ok; _ -> ok = file:delete(AppSrcIn) end
  362. end,
  363. halt()
  364. endef
  365. define dep_fetch
  366. if [ "$$$$VS" = "git" ]; then \
  367. git clone -q -n -- $$$$REPO $(DEPS_DIR)/$(1); \
  368. cd $(DEPS_DIR)/$(1) && git checkout -q $$$$COMMIT; \
  369. elif [ "$$$$VS" = "hg" ]; then \
  370. hg clone -q -U $$$$REPO $(DEPS_DIR)/$(1); \
  371. cd $(DEPS_DIR)/$(1) && hg update -q $$$$COMMIT; \
  372. elif [ "$$$$VS" = "svn" ]; then \
  373. svn checkout -q $$$$REPO $(DEPS_DIR)/$(1); \
  374. elif [ "$$$$VS" = "cp" ]; then \
  375. cp -R $$$$REPO $(DEPS_DIR)/$(1); \
  376. else \
  377. echo "Unknown or invalid dependency: $(1). Please consult the erlang.mk README for instructions." >&2; \
  378. exit 78; \
  379. fi
  380. endef
  381. define dep_target
  382. $(DEPS_DIR)/$(1):
  383. @mkdir -p $(DEPS_DIR)
  384. ifeq (,$(dep_$(1)))
  385. @if [ ! -f $(PKG_FILE2) ]; then $(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL)); fi
  386. $(dep_verbose) DEPPKG=$$$$(awk 'BEGIN { FS = "\t" }; $$$$1 == "$(1)" { print $$$$2 " " $$$$3 " " $$$$4 }' $(PKG_FILE2);); \
  387. VS=$$$$(echo $$$$DEPPKG | cut -d " " -f1); \
  388. REPO=$$$$(echo $$$$DEPPKG | cut -d " " -f2); \
  389. COMMIT=$$$$(echo $$$$DEPPKG | cut -d " " -f3); \
  390. $(call dep_fetch,$(1))
  391. else
  392. ifeq (1,$(words $(dep_$(1))))
  393. $(dep_verbose) VS=git; \
  394. REPO=$(dep_$(1)); \
  395. COMMIT=master; \
  396. $(call dep_fetch,$(1))
  397. else
  398. ifeq (2,$(words $(dep_$(1))))
  399. $(dep_verbose) VS=git; \
  400. REPO=$(word 1,$(dep_$(1))); \
  401. COMMIT=$(word 2,$(dep_$(1))); \
  402. $(call dep_fetch,$(1))
  403. else
  404. $(dep_verbose) VS=$(word 1,$(dep_$(1))); \
  405. REPO=$(word 2,$(dep_$(1))); \
  406. COMMIT=$(word 3,$(dep_$(1))); \
  407. $(call dep_fetch,$(1))
  408. endif
  409. endif
  410. endif
  411. @if [ -f $(DEPS_DIR)/$(1)/configure.ac ]; then \
  412. echo " AUTO " $(1); \
  413. cd $(DEPS_DIR)/$(1) && autoreconf -vif; \
  414. fi
  415. -@if [ -f $(DEPS_DIR)/$(1)/configure ]; then \
  416. echo " CONF " $(1); \
  417. cd $(DEPS_DIR)/$(1) && ./configure; \
  418. fi
  419. ifeq ($(filter $(1),$(NO_AUTOPATCH)),)
  420. @$(call dep_autopatch,$(1))
  421. endif
  422. endef
  423. $(foreach dep,$(DEPS),$(eval $(call dep_target,$(dep))))
  424. distclean-deps:
  425. $(gen_verbose) rm -rf $(DEPS_DIR)
  426. # Packages related targets.
  427. $(PKG_FILE2):
  428. @$(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL))
  429. pkg-list: $(PKG_FILE2)
  430. @cat $(PKG_FILE2) | awk 'BEGIN { FS = "\t" }; { print \
  431. "Name:\t\t" $$1 "\n" \
  432. "Repository:\t" $$3 "\n" \
  433. "Website:\t" $$5 "\n" \
  434. "Description:\t" $$6 "\n" }'
  435. ifdef q
  436. pkg-search: $(PKG_FILE2)
  437. @cat $(PKG_FILE2) | grep -i ${q} | awk 'BEGIN { FS = "\t" }; { print \
  438. "Name:\t\t" $$1 "\n" \
  439. "Repository:\t" $$3 "\n" \
  440. "Website:\t" $$5 "\n" \
  441. "Description:\t" $$6 "\n" }'
  442. else
  443. pkg-search:
  444. $(error Usage: $(MAKE) pkg-search q=STRING)
  445. endif
  446. ifeq ($(PKG_FILE2),$(CURDIR)/.erlang.mk.packages.v2)
  447. distclean-pkg:
  448. $(gen_verbose) rm -f $(PKG_FILE2)
  449. endif
  450. help::
  451. @printf "%s\n" "" \
  452. "Package-related targets:" \
  453. " pkg-list List all known packages" \
  454. " pkg-search q=STRING Search for STRING in the package index"