From: Kim Nguyễn Date: Thu, 18 Apr 2013 09:27:51 +0000 (+0200) Subject: Re-organize the Remakefile. X-Git-Tag: v0.1~97 X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=commitdiff_plain;h=82fa70675272c579a642c6e62c8fbf28a1bba56c Re-organize the Remakefile. Fixes a few typos and make remake.cpp callable from subdirectories. --- diff --git a/Remakefile.in b/Remakefile.in index d173e83..8a20f92 100644 --- a/Remakefile.in +++ b/Remakefile.in @@ -9,7 +9,10 @@ ODEP=tools/odeps.sh @OCAMLDEP@ BIN=@PACKAGE_TARNAME@ EXE=@EXE@ +all: + @REMAKE@ src/@PACKAGE_TARNAME@.native@EXE@ +tools: tools/xml_diff.native@EXE@ tools/XPathEval.class Remakefile: Remakefile.in config.status ./config.status Remakefile @@ -18,22 +21,47 @@ configure config.status: configure.in autoconf ./config.status --recheck -%.native: +clean: + for dir in src tools; do + find $dir -name '*.cm*' -o -name '*.o' -o -name '*.byte' -o \ + -name '*.native' -o -name '*.mll' -o -name '*.mly' -o \ + -name '*.class' | while read file; do + case "$file" in + *.mll) + rm -f "${file%.mll}.ml" + ;; + *.mly) + rm -f "${file%.mly}.ml" "${file%.mly}.mli" + ;; + *) + rm -f "$file" + ;; + esac + done + done + +distclean: clean + rm -rf config.status configure config.log autom4te.cache .remake Remakefile remake + +%.class: %.java + javac $1 + +%.native@EXE@: base=${1%.native} src=${base}.ml obj=${base}.cmx dir=$(dirname $1) - ./remake -v OCAMLDEPNATIVE=-native "$obj" + @REMAKE@ -v OCAMLDEPNATIVE=-native "$obj" SRCS=$(ls "$dir"/*.cmx | sed 's/\.cmx/.ml/g') OBJS=$(@OCAMLDEP@ $OCAMLDEPNATIVE $OCAMLFINDFLAGS -modules $SRCS | tools/osort.sh cmx) @OCAMLOPT@ -o "$1" @OCAMLFLAGS@ @OCAMLOPTFLAGS@ $OCAMLFINDLINKFLAGS $OCAMLFINDFLAGS $OBJS -%.byte: +%.byte@EXE@: base=${1%.byte} src=${base}.ml obj=${base}.cmo dir=$(dirname $1) - ./remake "$obj" + @REMAKE@ "$obj" OBJS="" for i in "$dir"/*.cmi; do ibase=${i%.cmi} @@ -41,7 +69,7 @@ configure config.status: configure.in OBJS="$OBJS ${ibase}.cmo" fi done - ./remake $OBJS + @REMAKE@ $OBJS SRCS=$(ls "$dir"/*.cmo | sed 's/\.cmo/.ml/g') SORTED_OBJS=$(@OCAMLDEP@ $OCAMLFINDFLAGS -modules $SRCS | tools/osort.sh cmo) @OCAMLC@ -o "$1" @OCAMLFLAGS@ @OCAMLCFLAGS@ $OCAMLFINDLINKFLAGS $OCAMLFINDFLAGS $SORTED_OBJS @@ -51,22 +79,22 @@ configure config.status: configure.in base="${target%.cmx}" src="${base}.ml" if [ -f "$src" ]; then - ./remake "$src" + @REMAKE@ "$src" DEPS=$( $ODEP -native $OCAMLFINDFLAGS $PACKINCLUDE "$src" ) - echo "$DEPS" | ./remake -v PACKINCLUDE="$PACKINCLUDE" -v OCAMLDEPNATIVE=-native -v OCAMLFORPACK="$OCAMLFORPACK" -r "$target" + echo "$DEPS" | @REMAKE@ -v PACKINCLUDE="$PACKINCLUDE" -v OCAMLDEPNATIVE=-native -v OCAMLFORPACK="$OCAMLFORPACK" -r "$target" @OCAMLOPT@ -o "$target" -c @OCAMLFLAGS@ @OCAMLOPTFLAGS@ $OCAMLFORPACK $OCAMLFINDFLAGS $PACKINCLUDE "$src" elif [ -d "$base" ]; then modname=$(basename "$base") packname=$(echo "$modname" | sed 's/\(.*\)/\u\1/') OBJS=$(ls "$base"/*.ml | sed 's/\.ml/.cmx/g') - ./remake -v PACKINCLUDE="-I $base" -v OCAMLFORPACK="-for-pack $packname" $OBJS + @REMAKE@ -v PACKINCLUDE="-I $base" -v OCAMLFORPACK="-for-pack $packname" $OBJS SORTED_OBJS=$(@OCAMLDEP@ -native $OCAMLFINDFLAGS -I $base -modules "$base"/*.ml | tools/osort.sh cmx) @OCAMLOPT@ -o "$target" -pack $SORTED_OBJS elif [ -f "$base".mly ]; then - ./remake "$base".mly + @REMAKE@ "$base".mly @OCAMLYACC@ "$base".mly $ODEP $OCAMLDEPNATIVE $OCAMLFINDFLAGS "$src" | \ - ./remake -v PACKINCLUDE="$PACKINCLUDE" -v OCAMLDEPNATIVE=-native -v OCAMLFORPACK="$OCAMLFORPACK" -r "$target" + @REMAKE@ -v PACKINCLUDE="$PACKINCLUDE" -v OCAMLDEPNATIVE=-native -v OCAMLFORPACK="$OCAMLFORPACK" -r "$target" @OCAMLOPT@ -o "$target" -c @OCAMLFLAGS@ @OCAMLOPTFLAGS@ $OCAMLFORPACK $OCAMLFINDFLAGS $PACKINCLUDE "$src" fi @@ -76,21 +104,21 @@ configure config.status: configure.in base="${target%.cmo}" src="${base}.ml" if [ -f "$src" ]; then - ./remake "$src" + @REMAKE@ "$src" DEPS=$( $ODEP $OCAMLFINDFLAGS $PACKINCLUDE "$src" ) - echo "$DEPS" | ./remake -v PACKINCLUDE="$PACKINCLUDE" -r "$target" + echo "$DEPS" | @REMAKE@ -v PACKINCLUDE="$PACKINCLUDE" -r "$target" @OCAMLC@ -o "$target" -c @OCAMLFLAGS@ @OCAMLCFLAGS@ $OCAMLFINDFLAGS $PACKINCLUDE "$src" elif [ -d "$base" ]; then modname=$(basename "$base") packname=$(echo "$modname" | sed 's/\(.*\)/\u\1/') OBJS=$(ls "$base"/*.ml | sed 's/\.ml/.cmo/g') - ./remake -v PACKINCLUDE="-I $base" $OBJS + @REMAKE@ -v PACKINCLUDE="-I $base" $OBJS SORTED_OBJS=$(@OCAMLDEP@ $OCAMLFINDFLAGS -I $base -modules "$base"/*.ml | tools/osort.sh cmo) @OCAMLC@ -o "$target" -pack $SORTED_OBJS elif [ -f "$base".mly ]; then - ./remake "$base".mly + @REMAKE@ "$base".mly @OCAMLYACC@ "$base".mly - $ODEP $OCAMLFINDFLAGS $PACKINCLUDE "$src" | ./remake -v PACKINCLUDE="$PACKINCLUDE" -r "$target" + $ODEP $OCAMLFINDFLAGS $PACKINCLUDE "$src" | @REMAKE@ -v PACKINCLUDE="$PACKINCLUDE" -r "$target" @OCAMLC@ -o "$target" -c @OCAMLFLAGS@ @OCAMLCFLAGS@ $OCAMLFINDFLAGS $PACKINCLUDE "$src" fi @@ -100,10 +128,10 @@ configure config.status: configure.in target="$1" base=${target%.cmi} if test -f "$base".mli; then - ./remake "$base".mli + @REMAKE@ "$base".mli src=${base}.mli DEPS=$($ODEP $OCAMLDEPNATIVE $OCAMLFINDFLAGS $PACKINCLUDE "$src") - echo "$DEPS" | ./remake -v PACKINCLUDE="$PACKINCLUDE" -v OCAMLDEPNATIVE="$OCAMLDEPNATIVE" -v OCAMLFORPACK="$OCAMLFORPACK" -r "$target" + echo "$DEPS" | @REMAKE@ -v PACKINCLUDE="$PACKINCLUDE" -v OCAMLDEPNATIVE="$OCAMLDEPNATIVE" -v OCAMLFORPACK="$OCAMLFORPACK" -r "$target" if test -z "$OCAMLDEPNATIVE"; then @OCAMLC@ -o "$target" -c @OCAMLFLAGS@ @OCAMLCFLAGS@ $OCAMLFINDFLAGS $PACKINCLUDE "$src" else @@ -115,24 +143,6 @@ configure config.status: configure.in else obj=${base}.cmx fi - ./remake -v PACKINCLUDE="$PACKINCLUDE" -v OCAMLDEPNATIVE="$OCAMLDEPNATIVE" -v OCAMLFORPACK="$OCAMLFORPACK" "$obj" + @REMAKE@ -v PACKINCLUDE="$PACKINCLUDE" -v OCAMLDEPNATIVE="$OCAMLDEPNATIVE" -v OCAMLFORPACK="$OCAMLFORPACK" "$obj" fi -clean: - find src -name '*.cm*' -o -name '*.o' -o -name '*.byte' -o -name '*.native' -o -name '*.mll' -o -name '*.mly' | while read file; do - case "$file" in - *.mll) - rm -f "${file%.mll}.ml" - ;; - *.mly) - rm -f "${file%.mly}.ml" "${file%.mly}.mli" - ;; - *) - rm -f "$file" - ;; - esac - done - -distclean: clean - rm -rf config.status configure config.log autom4te.cache .remake Remakefile remake - diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..d3b4e14 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +autoconf +./configure $* diff --git a/remake.cpp b/remake.cpp index 5d8dc3d..23a44f8 100644 --- a/remake.cpp +++ b/remake.cpp @@ -676,9 +676,31 @@ static std::string escape_string(std::string const &s) /** * Initialize #working_dir. */ -void init_working_dir() +void init_working_dir(const char* argv0) { char buf[1024]; +#ifdef WINDOWS + char const *delim = "/\\"; +#else + char delim = '/'; +#endif + if (!getenv("REMAKE_SOCKET")) + { + std::string path = argv0; + + size_t found = path.find_last_of(delim); + if (found != std::string::npos) + { + path = path.substr(0, found); + std::cout << "Entering directory `" << path << "'" << std::endl; + if (chdir(path.c_str())) + { + perror("Failed to change working directory"); + exit(EXIT_FAILURE); + } + } + } + char *res = getcwd(buf, sizeof(buf)); if (!res) { @@ -2230,7 +2252,7 @@ void usage(int exit_status) */ int main(int argc, char *argv[]) { - init_working_dir(); + init_working_dir(argv[0]); string_list targets; bool indirect_targets = false; diff --git a/src/hlist.mli b/src/hlist.mli index 80204d2..ed47be0 100644 --- a/src/hlist.mli +++ b/src/hlist.mli @@ -14,7 +14,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) include module type of Hlist_sig diff --git a/src/xpath/ast.ml b/src/xpath/ast.ml index a90a41b..c83dd91 100644 --- a/src/xpath/ast.ml +++ b/src/xpath/ast.ml @@ -14,7 +14,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *)