Commit | Line | Data |
---|---|---|
459d3fb5 MBT |
1 | #!/bin/sh |
2 | # @(#) Generates a Makefile from a Jmakefile | |
3 | ||
4 | # $Id: jmkmf.SH 1 2006-08-24 12:32:52Z rmanfredi $ | |
5 | # | |
6 | # Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi | |
7 | # | |
8 | # You may redistribute only under the terms of the Artistic Licence, | |
9 | # as specified in the README file that comes with the distribution. | |
10 | # You may reuse parts of this distribution only within the terms of | |
11 | # that same Artistic Licence; a copy of which may be found at the root | |
12 | # of the source tree for dist 4.0. | |
13 | # | |
14 | # $Log: jmkmf.SH,v $ | |
15 | # Revision 3.0.1.2 2004/08/21 23:18:13 ram | |
16 | # patch71: automatically figures the top dir and the current dir | |
17 | # patch71: don't run Makefile.SH if the jmake call failed | |
18 | # | |
19 | # Revision 3.0.1.1 1993/08/19 06:42:14 ram | |
20 | # patch1: leading config.sh searching was not aborting properly | |
21 | # | |
22 | # Revision 3.0 1993/08/18 12:04:19 ram | |
23 | # Baseline for dist 3.0 netwide release. | |
24 | # | |
25 | ||
26 | usage="usage: $0 [top_of_sources_pathname [current_directory]]" | |
27 | ||
28 | curdir= | |
29 | ||
30 | case $# in | |
31 | 0) | |
32 | if test -f .package; then topdir=.; | |
33 | elif test -f ../.package; then topdir=..; | |
34 | elif test -f ../../.package; then topdir=../..; | |
35 | elif test -f ../../../.package; then topdir=../../..; | |
36 | elif test -f ../../../../.package; then topdir=../../../..; | |
37 | else | |
38 | echo "$0: WARNING: can't determine top package directory" >&2 | |
39 | fi | |
40 | ;; | |
41 | 1) topdir=$1 ;; | |
42 | 2) topdir=$1 curdir=$2 ;; | |
43 | *) echo "$usage" 1>&2; exit 1 ;; | |
44 | esac | |
45 | ||
46 | case "$topdir" in | |
47 | -*) echo "$usage" 1>&2; exit 1 ;; | |
48 | esac | |
49 | ||
50 | case "$curdir" in | |
51 | '') | |
52 | here=`pwd` | |
53 | top=`cd $topdir; pwd` | |
54 | curdir=`perl -e \ | |
55 | 'print substr($ARGV[0], length($ARGV[1])+1), "\n";' $here $top` | |
56 | case "$curdir" in | |
57 | '') curdir=.;; | |
58 | esac | |
59 | ;; | |
60 | esac | |
61 | ||
62 | if test -f Jmakefile; then | |
63 | : ok | |
64 | else | |
65 | echo "$0: no Jmakefile found in current directory" >&2 | |
66 | exit 1 | |
67 | fi | |
68 | ||
69 | if test -f Makefile.SH; then | |
70 | echo mv Makefile.SH Makefile.SH~ | |
71 | mv Makefile.SH Makefile.SH~ | |
72 | fi | |
73 | ||
74 | args="-DTOPDIR=$topdir -DCURDIR=$curdir" | |
75 | ||
76 | echo jmake $args | |
77 | if jmake $args; then | |
78 | echo sh Makefile.SH | |
79 | sh Makefile.SH | |
80 | else | |
81 | echo "jmake failed, aborting" >&2 | |
82 | exit 1 | |
83 | fi |