File: imboot.cpp

package info (click to toggle)
troffcvt 1.04%2Brepack1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,416 kB
  • sloc: ansic: 13,110; makefile: 6,847; perl: 1,583; cpp: 333; sh: 215
file content (160 lines) | stat: -rw-r--r-- 3,999 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
XCOMM!/bin/sh

XCOMM  imboot - imake bootstrapper (bootstrap Makefile from Imakefile)

XCOMM Usage:  imboot [ flags ] [ topdir [ curdir ] ]

XCOMM flags can be:
XCOMM	-c name		specify name of configuration files
XCOMM	-C name		specify name of configuration files, extensible
XCOMM			architecture
XCOMM	-Danything	pass -Danything to imake
XCOMM	-Ianything	pass -Ianything to imake
XCOMM	-d		force UseInstalled on
XCOMM	-u		force UseInstalled off

XCOMM topdir = path to top of project tree (default ".")
XCOMM curdir = path to current directory from top of project tree (default ".")

XCOMM If no -c name or -C name option is given, configuration files from
XCOMM the config directory under the project root (i.e., from topdir/config)
XCOMM are used.  UseInstalled is not defined.

XCOMM If -c name is given, configuration files from CONFIGROOTDIR/name
XCOMM are used instead of the files in topdir/config.  UseInstalled is defined.

XCOMM If -c name is given, configuration files from CONFIGROOTDIR/name
XCOMM are used in conjunction with the files in topdir/config.  UseInstalled
XCOMM is defined.

XCOMM For -c or -C, if name is an absolute path, CONFIGROOTDIR is not
XCOMM prepended.

XCOMM You can also specify other -D and -I flags, to allow arbitrary
XCOMM symbols to be defined or undefined, or other search directories to
XCOMM be given.

XCOMM The -d and -u options may be used to force UseInstalled on or off,
XCOMM overriding the default behavior.

XCOMM 11 Apr 93 Paul DuBois dubois@primate.wisc.edu

XCOMM 11 Apr 93 V1.00
XCOMM - Created.
XCOMM 02 Jun 93 V1.01
XCOMM - Bug fixes.
XCOMM 02 Mar 96 V1.02
XCOMM - Modified to check first for top/config/cf, then top/config if
XCOMM   within-project configuration files are used.  This is allows
XCOMM   imboot to work within the X11R6 source tree, which changed the
XCOMM   location of the configuration files relative to earlier X11 releases.

usage="usage: $0 [-c|-C name] [-d] [-u] [-Dsym] [-Idir] [topdir [curdir]]"

configrootdir=CONFIGROOTDIR
mv=MV
rm=RM
configname=
topdir=.
curdir=.
dopt=n
uopt=n
args=

XCOMM check for -c, -C, -D, -I, -d, -u options

while [ $# -gt 0 ]; do
	case "$1" in
		-c)
			if [ $# -lt 2 ]; then
				echo "$usage" 1>&2
				exit 1
			fi
			configname=$2
			shift;shift
			;;
		-C)
			if [ $# -lt 2 ]; then
				echo "$usage" 1>&2
				exit 1
			fi
			configname=$2
			useboth=y
			shift;shift
			;;
		-d)			# force UseInstalled on unconditionally
			dopt=y
			uopt=n
			shift
			;;
		-u)			# force UseInstalled off unconditionally
			dopt=n
			uopt=y
			shift
			;;
		-[DI]*)			# pass through -D, -I options
			args="$args $1"
			shift
			;;
		-*)			# unrecognized flag
			echo "imboot: unknown flag: $1"
			echo "$usage" 1>&2
			exit 1
			;;
		*)			# non-flag; quit flag processing
			break
			;;
	esac
done

if [ $# -gt 0 ]; then
	topdir="$1"
	shift
fi
if [ $# -gt 0 ]; then
	curdir="$1"
fi

XCOMM find within-project configuration file directory, if there is one
if [ -d "$topdir/config/cf" ]; then
	wpconfigdir="$topdir/config/cf"
else
	wpconfigdir="$topdir/config"
fi

if [ "$configname" = "" ]; then
	useinstalled=
	configdir="-I$wpconfigdir"
elif [ "$useboth" != "y" ]; then
	useinstalled=-DUseInstalled
	case "$configname" in
	/?*) configdir="-I$configname" ;;
	*) configdir="-I$configrootdir/$configname" ;;
	esac
else
	useinstalled=-DUseInstalled
	case "$configname" in
	/?*) configdir="-I$wpconfigdir -I$configname" ;;
	*) configdir="-I$wpconfigdir -I$configrootdir/$configname" ;;
	esac
fi

XCOMM force UseInstalled on/off if -d/-u were given
if [ "$dopt" = "y" ]; then
	useinstalled=-DUseInstalled
fi
if [ "$uopt" = "y" ]; then
	useinstalled=
fi

XCOMM backup current Makefile if it exists
if [ -f Makefile ]; then
	echo $rm Makefile.bak
	$rm Makefile.bak
	echo $mv Makefile Makefile.bak
	$mv Makefile Makefile.bak
fi

XCOMM echo command, then run it
echo imake $args $useinstalled $configdir -DTOPDIR=$topdir -DCURDIR=$curdir
imake $args $useinstalled $configdir -DTOPDIR=$topdir -DCURDIR=$curdir