deps.mk 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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 = 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. {ok, Conf2} = file:script("$(DEPS_DIR)/$(1)/rebar.config.script", Bindings),
  123. Conf2
  124. end,
  125. Write = fun (Text) ->
  126. file:write_file("$(DEPS_DIR)/$(1)/Makefile", Text, [append])
  127. end,
  128. Escape = fun (Text) ->
  129. re:replace(Text, "\\\\$$$$", "\$$$$$$$$", [global, {return, list}])
  130. end,
  131. Write("IGNORE_DEPS = edown eper eunit_formatters meck node_package "
  132. "rebar_lock_deps_plugin rebar_vsn_plugin reltool_util\n\n"),
  133. fun() ->
  134. Write("ERLC_OPTS = +debug_info\n"),
  135. case lists:keyfind(erl_opts, 1, Conf) of
  136. false -> ok;
  137. {_, ErlOpts} ->
  138. lists:foreach(fun
  139. ({d, D}) ->
  140. Write("ERLC_OPTS += -D" ++ atom_to_list(D) ++ "=1\n");
  141. ({platform_define, Regex, D}) ->
  142. case rebar_utils:is_arch(Regex) of
  143. true -> Write("ERLC_OPTS += -D" ++ atom_to_list(D) ++ "=1\n");
  144. false -> ok
  145. end;
  146. ({parse_transform, PT}) ->
  147. Write("ERLC_OPTS += +'{parse_transform, " ++ atom_to_list(PT) ++ "}'\n");
  148. (_) -> ok
  149. end, ErlOpts)
  150. end,
  151. Write("\n")
  152. end(),
  153. fun() ->
  154. File = case lists:keyfind(deps, 1, Conf) of
  155. false -> [];
  156. {_, Deps} ->
  157. [begin
  158. Name = element(1, Dep),
  159. {Method, Repo, Commit} = case element(3, Dep) of
  160. {git, R} -> {git, R, master};
  161. {M, R, {branch, C}} -> {M, R, C};
  162. {M, R, {tag, C}} -> {M, R, C};
  163. {M, R, C} -> {M, R, C}
  164. end,
  165. Write(io_lib:format("DEPS += ~s\ndep_~s = ~s ~s ~s~n", [Name, Name, Method, Repo, Commit]))
  166. end || Dep <- Deps, tuple_size(Dep) > 2]
  167. end
  168. end(),
  169. fun() ->
  170. First = case lists:keyfind(erl_first_files, 1, Conf) of false -> []; {_, Files} ->
  171. Names = [[" ", begin "lre." ++ Elif = lists:reverse(F), lists:reverse(Elif) end]
  172. || "src/" ++ F <- Files],
  173. Write(io_lib:format("COMPILE_FIRST +=~s\n", [Names]))
  174. end
  175. end(),
  176. FindFirst = fun(F, Fd) ->
  177. case io:parse_erl_form(Fd, undefined) of
  178. {ok, {attribute, _,compile, {parse_transform, PT}}, _} ->
  179. [PT, F(F, Fd)];
  180. {ok, {attribute, _, include, Hrl}, _} ->
  181. case file:open("$(DEPS_DIR)/$(1)/include/" ++ Hrl, [read]) of
  182. {ok, HrlFd} -> [F(F, HrlFd), F(F, Fd)];
  183. _ ->
  184. case file:open("$(DEPS_DIR)/$(1)/src/" ++ Hrl, [read]) of
  185. {ok, HrlFd} -> [F(F, HrlFd), F(F, Fd)];
  186. _ -> [F(F, Fd)]
  187. end
  188. end;
  189. {ok, {attribute, _, include_lib, "$(1)/include/" ++ Hrl}, _} ->
  190. {ok, HrlFd} = file:open("$(DEPS_DIR)/$(1)/include/" ++ Hrl, [read]),
  191. [F(F, HrlFd), F(F, Fd)];
  192. {ok, {attribute, _, import, {Imp, _}}, _} ->
  193. case file:open("$(DEPS_DIR)/$(1)/src/" ++ atom_to_list(Imp) ++ ".erl", [read]) of
  194. {ok, ImpFd} -> [Imp, F(F, ImpFd), F(F, Fd)];
  195. _ -> [F(F, Fd)]
  196. end;
  197. {eof, _} ->
  198. file:close(Fd),
  199. [];
  200. _ ->
  201. F(F, Fd)
  202. end
  203. end,
  204. fun() ->
  205. ErlFiles = filelib:wildcard("$(DEPS_DIR)/$(1)/src/*.erl"),
  206. First0 = lists:usort(lists:flatten([begin
  207. {ok, Fd} = file:open(F, [read]),
  208. FindFirst(FindFirst, Fd)
  209. end || F <- ErlFiles])),
  210. First = lists:flatten([begin
  211. {ok, Fd} = file:open("$(DEPS_DIR)/$(1)/src/" ++ atom_to_list(M) ++ ".erl", [read]),
  212. FindFirst(FindFirst, Fd)
  213. end || M <- First0, lists:member("$(DEPS_DIR)/$(1)/src/" ++ atom_to_list(M) ++ ".erl", ErlFiles)]) ++ First0,
  214. Write(["COMPILE_FIRST +=", [[" ", atom_to_list(M)] || M <- First,
  215. lists:member("$(DEPS_DIR)/$(1)/src/" ++ atom_to_list(M) ++ ".erl", ErlFiles)], "\n"])
  216. end(),
  217. PortSpecWrite = fun(Name, Output, Input, Env) ->
  218. filelib:ensure_dir("$(DEPS_DIR)/$(1)/" ++ Output),
  219. file:write_file("$(DEPS_DIR)/$(1)/c_src/Makefile." ++ Name, [
  220. [["override ", K, " = $$$$\(shell echo ", Escape(V), "\)\n"]
  221. || {_, K, V} <- Env],
  222. "\nall:\n\t$$$$\(CC\) $$$$\(CFLAGS\) $$$$\(LDLIBS\) $$$$\(LDFLAGS\) ",
  223. "-o $(DEPS_DIR)/$(1)/", Output,
  224. [[" ../", F] || F <- Input]
  225. ])
  226. end,
  227. PortSpecNoop = fun(Name) -> file:write_file("$(DEPS_DIR)/$(1)/c_src/Makefile." ++ Name, "noop:\n") end,
  228. PortSpec = fun
  229. (Name, {Output, Input}) ->
  230. PortSpecWrite(Name, Output, Input, []);
  231. (Name, {Regex, Output, Input}) ->
  232. case rebar_utils:is_arch(Regex) of
  233. true -> PortSpecWrite(Name, Output, Input, []);
  234. false -> PortSpecNoop(Name)
  235. end;
  236. (Name, {Regex, Output, Input, [{env, Env}]}) ->
  237. case rebar_utils:is_arch(Regex) of
  238. true -> PortSpecWrite(Name, Output, Input, Env);
  239. false -> PortSpecNoop(Name)
  240. end
  241. end,
  242. fun() ->
  243. case filelib:is_dir("$(DEPS_DIR)/$(1)/c_src") of
  244. false -> ok;
  245. true ->
  246. Sources = filelib:fold_files("$(DEPS_DIR)/$(1)/c_src", ".*\\\\.(c|C|cc|cpp)$$$$", true, fun(F, Acc) -> [F|Acc] end, []),
  247. Write(io_lib:format("SOURCES :=~s\n", [[[" ", S] || S <- Sources]]))
  248. end
  249. end(),
  250. fun() ->
  251. case lists:keyfind(port_specs, 1, Conf) of
  252. {_, [{Output, Wildcards}]} ->
  253. filelib:ensure_dir("$(DEPS_DIR)/$(1)/" ++ Output),
  254. Write("C_SRC_OUTPUT = " ++ Escape(Output) ++ "\n"),
  255. Sources = [[[" ", S] || S <- filelib:wildcard("$(DEPS_DIR)/$(1)/" ++ W)] || W <- Wildcards],
  256. Write(io_lib:format("SOURCES :=~s\n", [Sources]));
  257. {_, [First, Second]} ->
  258. PortSpec("1", First),
  259. PortSpec("2", Second),
  260. file:write_file("$(DEPS_DIR)/$(1)/c_src/Makefile",
  261. "all:\n\t$$$$\(MAKE\) -f Makefile.1\n\t$$$$\(MAKE\) -f Makefile.2\n");
  262. _ -> ok
  263. end
  264. end(),
  265. EnvValue = fun(V) ->
  266. Escape(re:replace(V, "\\\\$$$$\ERLANG_ARCH", rebar_utils:wordsize(), [{return, list}]))
  267. end,
  268. fun() ->
  269. case lists:keyfind(port_env, 1, Conf) of
  270. {_, Vars} ->
  271. lists:foldl(fun
  272. ({K, V}, Acc) ->
  273. case lists:member(K, Acc) of
  274. true -> Acc;
  275. false ->
  276. Write(K ++ " = $$$$\(shell echo " ++ EnvValue(V) ++ "\)\n"),
  277. [K|Acc]
  278. end;
  279. ({Regex, K, V}, Acc) ->
  280. case lists:member(K, Acc) of
  281. true -> Acc;
  282. false ->
  283. case rebar_utils:is_arch(Regex) of
  284. true ->
  285. Write(K ++ " = $$$$\(shell echo " ++ EnvValue(V) ++ "\)\n"),
  286. [K|Acc];
  287. false ->
  288. Acc
  289. end
  290. end
  291. end, [], Vars),
  292. Write("CFLAGS += $$$$\(DRV_CFLAGS\)\n"),
  293. Write("CXXFLAGS += $$$$\(DRV_CFLAGS\)\n"),
  294. Write("LDFLAGS += $$$$\(DRV_LDFLAGS\)\n");
  295. _ -> ok
  296. end
  297. end(),
  298. Write("\n\nrebar_dep: pre-deps deps pre-app app\n"),
  299. Write("\npre-deps::\n"),
  300. Write("\npre-app::\n"),
  301. fun() ->
  302. case lists:keyfind(pre_hooks, 1, Conf) of
  303. false -> ok;
  304. {_, Hooks} ->
  305. [case H of
  306. {'get-deps', Command} ->
  307. Write("\npre-deps::\n\t" ++ Escape(Command) ++ "\n");
  308. {compile, Command} ->
  309. Write("\npre-app::\n\t" ++ Escape(Command) ++ "\n");
  310. {Regex, compile, Command0} ->
  311. case rebar_utils:is_arch(Regex) of
  312. true ->
  313. Command = case Command0 of
  314. "make -C" ++ _ -> Escape(Command0);
  315. "gmake -C" ++ _ -> Escape(Command0);
  316. "make " ++ Command1 -> "make -f Makefile.orig.mk " ++ Escape(Command1);
  317. "gmake " ++ Command1 -> "gmake -f Makefile.orig.mk " ++ Escape(Command1);
  318. _ -> Command0
  319. end,
  320. Write("\npre-app::\n\t" ++ Command ++ "\n");
  321. false ->
  322. ok
  323. end;
  324. _ -> ok
  325. end || H <- Hooks]
  326. end
  327. end(),
  328. Write("\ninclude ../../erlang.mk"),
  329. fun() ->
  330. case filelib:is_dir("$(DEPS_DIR)/$(1)/c_src") of
  331. false -> ok;
  332. true ->
  333. Write("\n\nCFLAGS := $$$$\(filter-out -std=c99 -Wmissing-prototypes,$$$$\(CFLAGS\)\)\n")
  334. end
  335. end(),
  336. fun() ->
  337. case lists:keyfind(plugins, 1, Conf) of
  338. {_, [Plugin]} when is_atom(Plugin) ->
  339. ErlFile = "$(DEPS_DIR)/$(1)/plugins/" ++ atom_to_list(Plugin) ++ ".erl",
  340. try
  341. {ok, PF} = file:read_file(ErlFile),
  342. ok = file:write_file(ErlFile, PF),
  343. {ok, Mod, Bin} = compile:file(ErlFile, [binary]),
  344. {module, Mod} = code:load_binary(Mod, ErlFile, Bin),
  345. c:cd("$(DEPS_DIR)/$(1)/"),
  346. ok = Mod:pre_compile(Conf, undefined)
  347. catch _:_ ->
  348. ok
  349. end;
  350. _ -> ok
  351. end
  352. end(),
  353. halt()
  354. endef
  355. define dep_autopatch_appsrc.erl
  356. AppSrcOut = "$(DEPS_DIR)/$(1)/src/$(1).app.src",
  357. AppSrcIn = case filelib:is_regular(AppSrcOut) of false -> "$(DEPS_DIR)/$(1)/ebin/$(1).app"; true -> AppSrcOut end,
  358. case filelib:is_regular(AppSrcIn) of
  359. false -> ok;
  360. true ->
  361. fun() ->
  362. {ok, [{application, $(1), L}]} = file:consult(AppSrcIn),
  363. L2 = case lists:keyfind(modules, 1, L) of {_, _} -> L; false -> [{modules, []}|L] end,
  364. L3 = case lists:keyfind(vsn, 1, L2) of {vsn, git} -> lists:keyreplace(vsn, 1, L2, {vsn, "git"}); _ -> L2 end,
  365. ok = file:write_file(AppSrcOut, io_lib:format("~p.~n", [{application, $(1), L3}]))
  366. end(),
  367. case AppSrcOut of AppSrcIn -> ok; _ -> ok = file:delete(AppSrcIn) end
  368. end,
  369. halt()
  370. endef
  371. define dep_fetch
  372. if [ "$$$$VS" = "git" ]; then \
  373. git clone -q -n -- $$$$REPO $(DEPS_DIR)/$(1); \
  374. cd $(DEPS_DIR)/$(1) && git checkout -q $$$$COMMIT; \
  375. elif [ "$$$$VS" = "hg" ]; then \
  376. hg clone -q -U $$$$REPO $(DEPS_DIR)/$(1); \
  377. cd $(DEPS_DIR)/$(1) && hg update -q $$$$COMMIT; \
  378. elif [ "$$$$VS" = "svn" ]; then \
  379. svn checkout -q $$$$REPO $(DEPS_DIR)/$(1); \
  380. elif [ "$$$$VS" = "cp" ]; then \
  381. cp -R $$$$REPO $(DEPS_DIR)/$(1); \
  382. else \
  383. echo "Unknown or invalid dependency: $(1). Please consult the erlang.mk README for instructions." >&2; \
  384. exit 78; \
  385. fi
  386. endef
  387. define dep_target
  388. $(DEPS_DIR)/$(1):
  389. @mkdir -p $(DEPS_DIR)
  390. ifeq (,$(dep_$(1)))
  391. @if [ ! -f $(PKG_FILE2) ]; then $(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL)); fi
  392. $(dep_verbose) DEPPKG=$$$$(awk 'BEGIN { FS = "\t" }; $$$$1 == "$(1)" { print $$$$2 " " $$$$3 " " $$$$4 }' $(PKG_FILE2);); \
  393. VS=$$$$(echo $$$$DEPPKG | cut -d " " -f1); \
  394. REPO=$$$$(echo $$$$DEPPKG | cut -d " " -f2); \
  395. COMMIT=$$$$(echo $$$$DEPPKG | cut -d " " -f3); \
  396. $(call dep_fetch,$(1))
  397. else
  398. ifeq (1,$(words $(dep_$(1))))
  399. $(dep_verbose) VS=git; \
  400. REPO=$(dep_$(1)); \
  401. COMMIT=master; \
  402. $(call dep_fetch,$(1))
  403. else
  404. ifeq (2,$(words $(dep_$(1))))
  405. $(dep_verbose) VS=git; \
  406. REPO=$(word 1,$(dep_$(1))); \
  407. COMMIT=$(word 2,$(dep_$(1))); \
  408. $(call dep_fetch,$(1))
  409. else
  410. $(dep_verbose) VS=$(word 1,$(dep_$(1))); \
  411. REPO=$(word 2,$(dep_$(1))); \
  412. COMMIT=$(word 3,$(dep_$(1))); \
  413. $(call dep_fetch,$(1))
  414. endif
  415. endif
  416. endif
  417. @if [ -f $(DEPS_DIR)/$(1)/configure.ac ]; then \
  418. echo " AUTO " $(1); \
  419. cd $(DEPS_DIR)/$(1) && autoreconf -vif; \
  420. fi
  421. -@if [ -f $(DEPS_DIR)/$(1)/configure ]; then \
  422. echo " CONF " $(1); \
  423. cd $(DEPS_DIR)/$(1) && ./configure; \
  424. fi
  425. ifeq ($(filter $(1),$(NO_AUTOPATCH)),)
  426. @$(call dep_autopatch,$(1))
  427. endif
  428. endef
  429. $(foreach dep,$(DEPS),$(eval $(call dep_target,$(dep))))
  430. distclean-deps:
  431. $(gen_verbose) rm -rf $(DEPS_DIR)
  432. # Packages related targets.
  433. $(PKG_FILE2):
  434. @$(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL))
  435. pkg-list: $(PKG_FILE2)
  436. @cat $(PKG_FILE2) | awk 'BEGIN { FS = "\t" }; { print \
  437. "Name:\t\t" $$1 "\n" \
  438. "Repository:\t" $$3 "\n" \
  439. "Website:\t" $$5 "\n" \
  440. "Description:\t" $$6 "\n" }'
  441. ifdef q
  442. pkg-search: $(PKG_FILE2)
  443. @cat $(PKG_FILE2) | grep -i ${q} | awk 'BEGIN { FS = "\t" }; { print \
  444. "Name:\t\t" $$1 "\n" \
  445. "Repository:\t" $$3 "\n" \
  446. "Website:\t" $$5 "\n" \
  447. "Description:\t" $$6 "\n" }'
  448. else
  449. pkg-search:
  450. $(error Usage: $(MAKE) pkg-search q=STRING)
  451. endif
  452. ifeq ($(PKG_FILE2),$(CURDIR)/.erlang.mk.packages.v2)
  453. distclean-pkg:
  454. $(gen_verbose) rm -f $(PKG_FILE2)
  455. endif
  456. help::
  457. @printf "%s\n" "" \
  458. "Package-related targets:" \
  459. " pkg-list List all known packages" \
  460. " pkg-search q=STRING Search for STRING in the package index"