Make replacement for Erlang - suggestions?

Eric Merritt <>
Tue Sep 17 14:56:58 CEST 2002


Mickael,

 It looks like I was *way* to hasty to dismiss ermake
as a 'make' clone. I do that more then I like to admit
:-) I apoligize. Thank you for your examples, I will
definatly take the time to look into it further.

Thanks,
Eric

--- Mickael Remond <>
wrote:
> Eric Merritt <>: 
>  
> > Mikael, 
> >  
> >  The only problem with ermake is that Joe simply 
> > reimplemented 'make' in Erlang. Although, it is
> cool 
> > its still 'make'. I am looking to replace 'make', 
> > syntax and all. 
>  
> What is cool in Ermake is that you can develop the
> to build the target 
> directly in Erlang. You can also use some Erlang
> functions to detect where 
> Erlang has been installed, to help you detect the
> os, etc.  
> I have a modified version of ermake where I added
> some helper functions to 
> replace the sed type substitution, with some
> complete examples of how to write 
> an Ermake file that make it possible to compile an
> Erlang code on several 
> platform. 
>  
> Unfortunately the work is still in progress, but you
> will find an example as 
> attachement and the work in progress ermake_lib file
> that is need to use it. 
> You are welcome to improve this file. 
>  
> I hope to release a version 3.0 of ermake soon as a
> packaged new version. 
>  
> I hope this will help promoting the Erlang platform
> on Windows by helping the 
> generation of multiplatform "makefile". 
> I hoping to get time to convert the makefile for BTT
> (Open Source source bug 
> tracker are a nightmare to install except this one=>
> I hope the makefile will 
> make it attractive on windows),and yaws. 
>  
> --  
> Mickaël Rémond > %% -=-=-=-
> %% 20020913 - Mickael Remond
> %%  Platform independant version of the compilation
> file for 
> %%  Eddieware dns_server
> %% -=-=-=-
> include("vsn.emk").
> 
> SRCDIR=src.
> EBINDIR=ebin.
> BINDIR=bin.
> INCDIR=inc.
> PRIVDIR=priv.
> PREFIX=/usr/local.
> 
> include("standard_rules.emk").
> 
> %% Erlang source files
> EBINFILES=$(EBINDIR)/dns_app.beam,
>           $(EBINDIR)/dns_cache.beam,
>           $(EBINDIR)/dns_catalog.beam,
> 	  $(EBINDIR)/dns_domain_sup.beam,
>           $(EBINDIR)/dns_load.beam,
>           $(EBINDIR)/dns_parse.beam,
>           $(EBINDIR)/dns_query.beam,
>           $(EBINDIR)/dns_recurse.beam,
>           $(EBINDIR)/dns_recurse_udp_tracker.beam,
>           $(EBINDIR)/dns_rr.beam,
>           $(EBINDIR)/dns_server.beam,
>           $(EBINDIR)/dns_sig.beam,
>           $(EBINDIR)/dns_sup.beam,
>           $(EBINDIR)/dns_tcp_accept.beam,
>           $(EBINDIR)/dns_udp.beam,
>           $(EBINDIR)/dns_xfr.beam,
>           $(EBINDIR)/dns_zone.beam,
> 	  $(EBINDOR)/config_file.erl.
> 
> %% OTP Application files
> APPFILE=dns_server.app.
> APPSRC=$(SRCDIR)/$(APPFILE).src.
> APPTARGET=$(EBINDIR)/$(APPFILE).
> RELSRC=$(SRCDIR)/dns.rel.src.
> RELFILE=$(EBINDIR)/dns.
> RELTARGET=$(RELFILE).rel.
> 
> CONFIGSRC=$(SRCDIR)/sys.config.src.
> CONFIGTARGET=$(EBINDIR)/dns_sys.config.
> 
> STARTSRC=$(SRCDIR)/lbdns.src.
> STARTTARGET=$(BINDIR)/lbdns.
> 
> %% -=-=-
> 
> all when $(EBINFILES), appfile, script, sysconfig,
> lbdns.
> 
> appfile when $(APPTARGET) ->
> 	ermake_lib:subst("$(APPSRC)", "$(APPTARGET)",
> [{"%VSN%", $(VSN)}]).
> 
> %% TODO: Make start script both on Windows and
> Unix/Linux
> %%     Use: os:type to switch to the proper build of
> the script.
> script ->
> 	ermake_lib:subst("$(RELSRC)", "$(RELTARGET)", []),
> 	systools:make_script("$(RELFILE)", [{path,
> ["$(EBINDIR)"]}]).
> 
> sysconfig ->
> 	ermake_lib:subst("$(CONFIGSRC)", "$(CONFIGTARGET)",
> 			[{"%MF_BYTES%", "512000"},
> 			 {"%MF_FILES%", "5"}]).
> 
> %% Start script:
> %% TODO: Windows version
> lbdns ->
> 	{ok, ROOTDIR} = file:get_cwd(),
> 	ermake_lib:subst("$(STARTSRC)", "$(STARTTARGET)",
> 			[{"%ROOTDIR%", ROOTDIR},
> 			 {"%DNS_BOOT%",
> filename:absname("$(EBINDIR)/dns")},
>                          {"%BINDIR%",
> filename:absname("$(BINDIR)")},
> 			 {"%SYSCONF%",
> filename:absname("$(EBINDIR)/dns_sys")},
> 			 {"%ERL_ROOT%", code:root_dir()}]).
>          %%TODO: chmod of start file
> 
> test ->
> 	%% TODO: Test build
> 	system:cmd("bin/start -b test/named.boot").
> 	%% TODO: Call test functions.
> 
> clean ->
> 	%% Not yet implemented in ermake_lib.
> 	%%ermake_lib:clean("$(APPTARGET)").
> 	io:format("Removing ~s ~n", ["$(EBINFILES)"]).
> %% TODO Tar generation.
> > %% This library contains functions aiming at
> simplifying the development of
> %% EMakefiles
> -module(ermake_lib).
> 
> -author("").
> 
> -export([subst/3]).
> 
> 
> %% This function aims at replacing simple and direct
> substitution traditionaly
> %% done with SED in Unix makefile
> %% Take the name of an Input file and output file.
> %% It is usefull when you have template (for example
> starting scripts)
> %% that need some substitution during the build of
> the project.
> %% Substitution are expressed as a list of tuples of
> the form {"Regexp", "Replacement string"}
> 
> %% Load file, perform substitution, save new file
> subst(InFile, OutFile, ListOfSubsts) ->
>     %% Read the file as a binary.
>     {ok, Bin} = file:read_file(InFile),
>     String = binary_to_list(Bin),
>     NewString = perform_all_substs(String,
> ListOfSubsts),
>     NewBin = list_to_binary(NewString),
>     file:write_file(OutFile, NewBin).
> 
> perform_all_substs(String, []) ->
>     String;
> perform_all_substs(String, [Subst|Substs]) ->
>     {Regexp, NewStr} = Subst,
>     case regexp:gsub(String, Regexp, NewStr) of
> 	{ok, NewString, RepCount} ->
> 	    perform_all_substs(NewString, Substs);
> 	{error, Error} ->
> 	    io:format("Error in Regexp: ~p~n", [Error]),
> 	    perform_all_substs(String, Substs)
>     end.
> 
> %% Clean is intended to be use as a way to remove
> list of target
> %% resulting from previous project build.
> %% It get a string, which is a comma separated list
> of file to remove.
> %% Space, tabulation and carriage return are remove
> from the string.
> %% Then the string is split based on the comma file
> delimiter.
> %% Each file from the resulting list of file is then
> deleted.
> %% It makes easy to write a clean target in
> EMakefile, thus making easier
> %% to clean-up your directory structure before
> release your source code.
> %clean(String) ->
>     %% Remove unwanted characters:
> 


__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com



More information about the erlang-questions mailing list