Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / util / scripts / xmkmf.cpp
1 XCOMM!/bin/sh
2
3 XCOMM
4 XCOMM generate a Makefile from an Imakefile from inside or outside the sources
5 XCOMM 
6 XCOMM $XConsortium: xmkmf.cpp,v 1.18 91/08/22 11:08:01 rws Exp $
7
8 usage="usage:  $0 [-a] [top_of_sources_pathname [current_directory]]"
9
10 topdir=
11 curdir=.
12 do_all=
13
14 case "$1" in
15 -a)
16     do_all="yes"
17     shift
18     ;;
19 esac
20
21 case $# in 
22     0) ;;
23     1) topdir=$1 ;;
24     2) topdir=$1  curdir=$2 ;;
25     *) echo "$usage" 1>&2; exit 1 ;;
26 esac
27
28 case "$topdir" in
29     -*) echo "$usage" 1>&2; exit 1 ;;
30 esac
31
32 if [ -f Makefile ]; then 
33     echo mv Makefile Makefile.bak
34     mv Makefile Makefile.bak
35 fi
36
37 if [ "$topdir" = "" ]; then
38     args="-DUseInstalled "CONFIGDIRSPEC
39 else
40     args="-I$topdir/config -DTOPDIR=$topdir -DCURDIR=$curdir"
41 fi
42
43 echo imake $args
44 case "$do_all" in
45 yes)
46     imake $args && 
47     echo "make Makefiles" &&
48     make Makefiles &&
49     echo "make includes" &&
50     make includes &&
51     echo "make depend" &&
52     make depend
53     ;;
54 *)
55     imake $args
56     ;;
57 esac