Skip to content

Commit

Permalink
added patches written by tobbe to support autoconf
Browse files Browse the repository at this point in the history
  • Loading branch information
Filippo Pacini committed May 2, 2007
1 parent 1a752d6 commit 16148cb
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 17 deletions.
38 changes: 21 additions & 17 deletions Makefile
@@ -1,19 +1,17 @@

include conf/include.mk

SHELL = /bin/sh

#tags command and options
TAG_CMD = etags
TAG_FLAGS =

#erlang compiler
ERLC_CMD = /usr/local/bin/erlc
ERL_CMD = /usr/local/bin/erl -boot start_clean

TEST_PATH = -pa ebin test/ebin
TEST_PATH = -pa ../../ebin ../ebin

LIB_FILES = /usr/local/lib/erlang/lib/sg*/*.erl /usr/local/lib/erlang/lib/sg*/src/*.erl

SRC_FILES = src/sgte.erl src/sgte_render.erl src/sgte_parse.erl
OBJ_FILES = ebin/sgte.beam ebin/sgte_render.beam ebin/sgte_parse.beam

#test
TEST_OBJS = test/ebin/sgte_test_compile.beam \
Expand All @@ -29,26 +27,32 @@ EBIN_DIR = ebin/
#Edoc variables
DOCDIR = doc

all: compile
.PHONY: all conf conf_clean test docs unittest

all: conf compile

compile:
cd src&& $(MAKE)

conf:
cd conf&& $(MAKE)

conf_clean:
cd conf&& $(MAKE) clean


test: unittest
$(ERL_CMD) -noshell $(TEST_PATH) -run run_tests run_tests -s init stop
cd test/src; \
$(ERL) -noshell $(TEST_PATH) -run run_tests run_tests -s init stop

docs: $(SRC_FILES)
erl -noshell -run edoc_run files ["'$<'"] \
'[{dir,"$(DOCDIR)"}]' -s init stop
tags: src/*.erl
cd src/ && $(TAG_CMD) $(TAG_FLAGS) $(TAG_FILES)

unittest: compile $(TEST_OBJS)

test/ebin/%.beam: test/src/%.erl
$(ERLC_CMD) -o test/$(EBIN_DIR) $<

compile: $(OBJ_FILES)

ebin/%.beam: src/%.erl
$(ERLC_CMD) -o $(EBIN_DIR) $<
unittest: conf compile
cd test/src&& $(MAKE)

clean:
rm src/*.beam; rm ebin/*.beam; rm test/src/*.beam; rm test/ebin/*.beam
Expand Down
14 changes: 14 additions & 0 deletions conf/Makefile
@@ -0,0 +1,14 @@
MK_INCLUDE=include.mk

all: config.status $(MK_INCLUDE)

config.status: configure
./configure

configure: configure.ac
autoconf

clean:
-rm -rf config.cache config.log config.status configure $(MK_INCLUDE)


51 changes: 51 additions & 0 deletions conf/configure.ac
@@ -0,0 +1,51 @@
AC_INIT(sgte, 0.4, pacini@sgconsulting.it, sgte)
AC_PREREQ(2.59c)
AC_COPYRIGHT(Copyright (C) 2006-2007 S.G. Consulting)

EBLOG_DIR=$(dirname `pwd`)
AC_SUBST(EBLOG_DIR)

AC_ERLANG_NEED_ERL
AC_ERLANG_NEED_ERLC

AC_ERLANG_SUBST_ROOT_DIR

dnl C support

AC_PROG_CC

case "$target_os" in
*cygwin*)
:
dnl fix this later
;;
linux*)
AC_DEFINE(LINUX,,LINUX)
LD_SHARED="ld -shared"
;;
*bsd*)
AC_DEFINE(BSD,,BSD)
LD_SHARED="ld -Bshareable"
;;
*solaris*)
AC_DEFINE(SOLARIS,,SOLARIS)
LD_SHARED="ld -G"
;;
*darwin*)
AC_DEFINE([DARWIN], [], [Description])
LD_SHARED="cc -bundle -flat_namespace -undefined suppress"
;;
*)
LD_SHARED="ld -shared"
;;
esac

AC_SUBST(LD_SHARED)


define(OUTPUT_FILES,
include.mk)

AC_OUTPUT(OUTPUT_FILES,
[
])dnl
50 changes: 50 additions & 0 deletions conf/include.mk.in
@@ -0,0 +1,50 @@
###-*-makefile-*- ; force emacs to enter makefile-mode

######################################################################
## C

CC := @CC@
CFLAGS := @CFLAGS@ @DEFS@
LD_SHARED := @LD_SHARED@
######################################################################


PREFIX = @prefix@
prefix = ${PREFIX}
ETCDIR = @sysconfdir@
VARDIR = @localstatedir@

ERL=@ERL@
ERLC=@ERLC@

ERLDIR=@ERLANG_ROOT_DIR@
ERL_C_INCLUDE_DIR=$(ERLDIR)/usr/include

EMULATOR=beam
ifdef debug
ERLC_FLAGS+=-Ddebug
endif

ifdef trace
ERLC_FLAGS=+trace
endif

ifdef export_all
ERLC_FLAGS+=-Dexport_all
endif

# Hmm, don't know if you are supposed to like this better... ;-)
APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/%VSN%/$$vsn/; s/%MODULES%/$$mods/; print; }'

# Targets

../ebin/%.app: %.app.src ../vsn.mk Makefile
perl -e $(APPSCRIPT) "$(VSN)" $(MODULES) < $< > $@

../ebin/%.appup: %.appup
cp $< $@

../ebin/%.$(EMULATOR): %.erl $(wildcard $(YAWSDIR)/lib/*/*/*.hrl)
"$(ERLC)" $(ERLC_FLAGS) -o ../ebin $<


12 changes: 12 additions & 0 deletions src/Makefile
@@ -0,0 +1,12 @@

include ../conf/include.mk

EBIN_FILES = ../ebin/sgte.beam \
../ebin/sgte_render.beam \
../ebin/sgte_parse.beam


all: $(EBIN_FILES)

clean:
rm -f ../ebin/*.beam
15 changes: 15 additions & 0 deletions test/src/Makefile
@@ -0,0 +1,15 @@

include ../../conf/include.mk

EBIN_FILES = ../ebin/sgte_test_compile.beam \
../ebin/sgte_test_render.beam \
../ebin/sgte_test_map.beam \
../ebin/gettext_test.beam \
../ebin/sgeunit.beam \
../ebin/run_tests.beam


all: $(EBIN_FILES)

clean:
rm -f ../ebin/*.beam

0 comments on commit 16148cb

Please sign in to comment.