This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use Getopt::Std::getopts() as it comes with all Perl 5 versions.
[metaconfig.git] / bin / jmkmf
CommitLineData
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
26usage="usage: $0 [top_of_sources_pathname [current_directory]]"
27
28curdir=
29
30case $# 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 ;;
44esac
45
46case "$topdir" in
47 -*) echo "$usage" 1>&2; exit 1 ;;
48esac
49
50case "$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 ;;
60esac
61
62if test -f Jmakefile; then
63 : ok
64else
65 echo "$0: no Jmakefile found in current directory" >&2
66 exit 1
67fi
68
69if test -f Makefile.SH; then
70 echo mv Makefile.SH Makefile.SH~
71 mv Makefile.SH Makefile.SH~
72fi
73
74args="-DTOPDIR=$topdir -DCURDIR=$curdir"
75
76echo jmake $args
77if jmake $args; then
78 echo sh Makefile.SH
79 sh Makefile.SH
80else
81 echo "jmake failed, aborting" >&2
82 exit 1
83fi