Permalink
Browse files

switching excavator to Emakefile

  • Loading branch information...
1 parent f5094f6 commit b3fa15decc46b4109942e44f95e2c27a172a6c09 Jacob Vorreuter committed Feb 20, 2010
Showing with 70 additions and 81 deletions.
  1. +10 −0 Emakefile
  2. +12 −25 Makefile
  3. +48 −0 build_rel.escript
  4. +0 −9 src/Makefile
  5. +0 −38 support/include.mk
  6. +0 −9 t/Makefile
View
@@ -0,0 +1,10 @@
+% -*- mode: erlang -*-
+
+{[
+ 'src/*'
+ ], [
+ {i, "include"},
+ {outdir, "ebin"},
+ debug_info
+ ]
+}.
View
@@ -1,36 +1,23 @@
VERSION=0.3
PKGNAME=excavator
-LIBDIR=`erl -eval 'io:format("~s~n", [code:lib_dir()])' -s init stop -noshell`
-ROOTDIR=`erl -eval 'io:format("~s~n", [code:root_dir()])' -s init stop -noshell`
-all: rel
-
-compile: app
- mkdir -p ebin/
- (cd src;$(MAKE))
- (cd t;$(MAKE))
+all: emake
+emake: rel
+ mkdir -p ebin/
+ erl -make
+
+rel: release/$(PKGNAME).tar.gz
+
app:
sh ebin/$(PKGNAME).app.in $(VERSION)
+
+release/$(PKGNAME).rel release/$(PKGNAME).script release/$(PKGNAME).tar.gz: app
+ mkdir -p release
+ escript build_rel.escript $(PKGNAME)
test: compile
prove t/*.t
clean:
- (cd src;$(MAKE) clean)
- rm -rf erl_crash.dump *.boot *.rel *.script ebin/*.beam ebin/*.app
-
-rel: compile
- erl -pa ebin -noshell -run excavator build_rel -s init stop
-
-package: clean
- @mkdir $(PKGNAME)-$(VERSION)/ && cp -rf ebin include Makefile public README.markdown src support t templates $(PKGNAME)-$(VERSION)
- @COPYFILE_DISABLE=true tar zcf $(PKGNAME)-$(VERSION).tgz $(PKGNAME)-$(VERSION)
- @rm -rf $(PKGNAME)-$(VERSION)/
-
-install:
- @mkdir -p $(prefix)/$(LIBDIR)/$(PKGNAME)-$(VERSION)/{ebin,include}
- @mkdir -p $(prefix)/$(ROOTDIR)/bin
- for i in ebin/*.beam include/*.hrl ebin/*.app; do install $$i $(prefix)/$(LIBDIR)/$(PKGNAME)-$(VERSION)/$$i ; done
- cp *.boot $(prefix)/$(ROOTDIR)/bin/
- @mkdir -p $(prefix)/etc/init.d
+ rm -rf $(wildcard ebin/*.beam) erl_crash.dump *.boot *.rel *.script ebin/*.app release
View
@@ -0,0 +1,48 @@
+#!/usr/bin/env escript
+%% -*- erlang -*-
+
+main([AppName]) ->
+ {ok, [{application,_,AppProps}]} = file:consult("ebin/" ++ AppName ++ ".app"),
+ AppDeps = proplists:get_value(applications, AppProps, []),
+ AppVsn = proplists:get_value(vsn, AppProps),
+ {ok, FD} = file:open("release/" ++ AppName ++ ".rel", [write]),
+ RelInfo = {release,
+ {AppName, AppVsn},
+ {erts, erts_vsn()},
+ [{Pkg, lib_vsn(Pkg)} || Pkg <- AppDeps]
+ },
+ io:format(FD, "~p.", [RelInfo]),
+ file:close(FD),
+ systools:make_script("release/" ++ AppName, [{exref, AppDeps}, {outdir, "release"}]),
+ systools:make_tar("release/" ++ AppName, [{dirs, tar_dirs()}, {outdir, "release"}]),
+ ok.
+
+erts_vsn() ->
+ erlang:system_info(version).
+
+lib_vsn(App) ->
+ load(App),
+ {ok, Vsn} = application:get_key(App, vsn),
+ Vsn.
+
+load(App) ->
+ case application:load(App) of
+ ok ->
+ ok;
+ {error, {already_loaded, _}} ->
+ ok;
+ E ->
+ io:format(standard_error, "Warning - can't load ~p (~p)~n", [App, E]),
+ erlang:exit(E)
+ end.
+
+tar_dirs() ->
+ {ok, Files} = file:list_dir("."),
+ [list_to_atom(Dir) || Dir <- lists:filter(
+ fun ("." ++ _) -> false;
+ (File) ->
+ filelib:is_dir(File) andalso not lists:member(File, ["ebin", "include", "t"])
+ end, Files)].
+
+
+
View
@@ -1,9 +0,0 @@
-include ../support/include.mk
-
-all: $(EBIN_FILES)
-
-debug:
- $(MAKE) DEBUG=-DDEBUG
-
-clean:
- rm -rf $(EBIN_FILES) erl_crash.dump
View
@@ -1,38 +0,0 @@
-## -*- makefile -*-
-
-ERL := erl
-ERLC := $(ERL)c
-
-INCLUDE_DIRS := ../include
-EBIN_DIRS := $(wildcard ../ebin)
-ERLC_FLAGS := -W $(INCLUDE_DIRS:../%=-I ../%) $(EBIN_DIRS:%=-pa %)
-
-ifndef no_debug_info
- ERLC_FLAGS += +debug_info
-endif
-
-ifdef debug
- ERLC_FLAGS += -Ddebug
-endif
-
-EBIN_DIR := ../ebin
-DOC_DIR := ../doc
-EMULATOR := beam
-
-ERL_SOURCES := $(wildcard *.erl)
-ERL_HEADERS := $(wildcard *.hrl) $(wildcard ../include/*.hrl)
-ERL_OBJECTS := $(ERL_SOURCES:%.erl=$(EBIN_DIR)/%.beam)
-ERL_TEMPLATES := $(ERL_TEMPLATE:%.et=$(EBIN_DIR)/%.beam)
-ERL_OBJECTS_LOCAL := $(ERL_SOURCES:%.erl=./%.$(EMULATOR))
-APP_FILES := $(wildcard *.app)
-EBIN_FILES = $(ERL_OBJECTS) $(APP_FILES:%.app=../ebin/%.app) $(ERL_TEMPLATES)
-MODULES = $(ERL_SOURCES:%.erl=%)
-
-../ebin/%.app: %.app
- cp $< $@
-
-$(EBIN_DIR)/%.$(EMULATOR): %.erl
- $(ERLC) $(ERLC_FLAGS) -o $(EBIN_DIR) $<
-
-./%.$(EMULATOR): %.erl
- $(ERLC) $(ERLC_FLAGS) -o . $<
View
@@ -1,9 +0,0 @@
-include ../support/include.mk
-
-all: $(EBIN_FILES)
-
-debug:
- $(MAKE) DEBUG=-DDEBUG
-
-clean:
- rm -rf $(EBIN_FILES) erl_crash.dump

0 comments on commit b3fa15d

Please sign in to comment.