Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Beautify makefile

  • Loading branch information...
commit e9e94fdd63e62b88ebcd7523a7496127868ee814 1 parent fca835f
@psyeugenic authored
Showing with 68 additions and 7 deletions.
  1. +55 −5 Makefile
  2. +12 −1 bin/eplot
  3. +0 −1  ebin/README
  4. +1 −0  vsn.mk
View
60 Makefile
@@ -1,7 +1,57 @@
-all: Makefile
- erlc -oebin src/egd_chart.erl
- erlc -oebin src/eplot_main.erl -oebin
- erlc -oebin src/eview.erl -oebin
+include vsn.mk
+ERLC = erlc
+ESRC = src
+EBIN = ebin
+BIN = bin
+LINK = ln -s
+
+MODULES = \
+ egd_chart \
+ eplot_main \
+ eview
+
+DATAFILES = \
+ example/data1.dat \
+ example/data2.dat \
+ example/test1.png
+
+INSTALL = /usr/bin/install -c
+INSTALL_DIR = /usr/bin/install -c -d
+INSTALL_DATA = /usr/bin/install -m 644
+prefix = /usr/local
+
+ifeq ($(DESTDIR),)
+ RELEASE_DIR = $(prefix)
+else
+ RELEASE_DIR = $(DESTDIR)/$(prefix)
+endif
+
+RELEASE_LIB_DIR = $(RELEASE_DIR)/lib/erlang/lib/eplot-$(VSN)
+
+TARGETS = $(MODULES:%=$(EBIN)/%.beam)
+
+all: build
+
+build: Makefile $(TARGETS)
+
+$(EBIN)/%.beam : $(ESRC)/%.erl
+ $(ERLC) $(EFLAGS) -o $(EBIN) $<
+
+install : build $(EXAMPLE)
+ $(INSTALL_DIR) $(RELEASE_LIB_DIR)/ebin
+ $(INSTALL) $(TARGETS) $(RELEASE_LIB_DIR)/ebin
+ $(INSTALL_DIR) $(RELEASE_LIB_DIR)/example
+ $(INSTALL_DATA) $(DATAFILES) $(RELEASE_LIB_DIR)/example
+ $(INSTALL_DIR) $(RELEASE_LIB_DIR)/bin
+ $(INSTALL) bin/eplot $(RELEASE_LIB_DIR)/bin
+ $(INSTALL_DIR) $(RELEASE_DIR)/bin
+ $(LINK) $(RELEASE_LIB_DIR)/bin/eplot $(RELEASE_DIR)/bin/eplot
+
+
+info:
+ @echo "$(TARGETS)"
clean:
- rm ebin/*.beam
+ rm -f $(TARGETS)
+
+.PHONY: install clean info
View
13 bin/eplot
@@ -1,4 +1,7 @@
#!/usr/bin/env escript
+%%! -smp enable -sname eplot
+
+-mode(compile).
usage() ->
Text =
@@ -17,7 +20,7 @@ usage() ->
main([]) -> usage();
main(Args) ->
- code:add_patha(filename:join(filename:dirname(escript:script_name()), "../ebin")),
+ code:add_patha(ebin()),
Options = parse_args(Args),
Input = proplists:get_value(input, Options, []),
case proplists:get_value(o, Options) of
@@ -88,3 +91,11 @@ string2value(Value) ->
end
end.
+ebin() ->
+ Sname = escript:script_name(),
+ Rname = real_name(Sname),
+ filename:join([filename:dirname(Rname),"..","ebin"]).
+
+real_name(Sname) -> real_name(Sname, file:read_link(Sname)).
+real_name(_, {ok, Rname}) -> real_name(Rname, file:read_link(Rname));
+real_name(Rname, {error, einval}) -> Rname.
View
1  ebin/README
@@ -1 +0,0 @@
-Directory for beam files.
View
1  vsn.mk
@@ -0,0 +1 @@
+VSN = 1.0
Please sign in to comment.
Something went wrong with that request. Please try again.