]> git.cameronkatri.com Git - apple_cmds.git/blob - text_cmds/ee/create.make
patch_cmds: diffstat without autotools
[apple_cmds.git] / text_cmds / ee / create.make
1 #!/bin/sh
2
3 #
4 # This script will determine if the system is a System V or BSD based
5 # UNIX system and create a makefile for ee appropriate for the system.
6 #
7 # $Header: /home/hugh/sources/old_ae/RCS/create.make,v 1.13 2002/09/23 04:18:13 hugh Exp $
8 #
9
10 #set -x
11
12 name_string="`uname`"
13
14 # test for existence of termcap (exists on both BSD and SysV systems)
15
16 if [ -f /etc/termcap -o -f /usr/share/lib/termcap -o -f /usr/share/misc/termcap ]
17 then
18 if [ -f /usr/share/lib/termcap ]
19 then
20 termcap_exists="-DTERMCAP=\"\\\"/usr/share/lib/termcap\\\"\""
21 elif [ -f /usr/share/misc/termcap ]
22 then
23 termcap_exists="-DTERMCAP=\"\\\"/usr/share/misc/termcap\\\"\""
24 elif [ -f /etc/termcap ]
25 then
26 termcap_exists="-DTERMCAP=\"\\\"/etc/termcap\\\"\""
27 fi
28 else
29 termcap_exists=""
30 fi
31
32 # test for terminfo directory (exists on SysV systems)
33
34 if [ -d /usr/lib/terminfo -o -d /usr/share/lib/terminfo -o -d /usr/share/terminfo ]
35 then
36 terminfo_exists=""
37 else
38 terminfo_exists="-DCAP"
39 fi
40
41 # test for existence of termio header (on SysV systems)
42
43 if [ -f /usr/include/termio.h ]
44 then
45 termio="-DSYS5"
46 else
47 termio=""
48 fi
49
50 # test for sgtty header (on BSD systems)
51
52 if [ -f /usr/include/sgtty.h ]
53 then
54 sgtty="TRUE"
55 else
56 sgtty=""
57 fi
58
59 # look for select call in headers, make sure headers exist
60
61 HEADER_FILES=""
62
63 if [ -f /usr/include/sys/time.h ]
64 then
65 HEADER_FILES="/usr/include/sys/time.h "
66 fi
67
68 if [ -f /usr/include/sys/types.h ]
69 then
70 HEADER_FILES="$HEADER_FILES /usr/include/sys/types.h"
71 fi
72
73 # check for unistd.h
74
75 if [ -f /usr/include/unistd.h ]
76 then
77 HAS_UNISTD=-DHAS_UNISTD
78 HEADER_FILES="$HEADER_FILES /usr/include/unistd.h"
79 else
80 HAS_UNISTD=""
81 fi
82
83 if [ -n "$HEADER_FILES" ]
84 then
85 string="`grep select $HEADER_FILES`"
86 if [ -n "$string" ]
87 then
88 BSD_SELECT="-DBSD_SELECT"
89 else
90 BSD_SELECT=""
91 fi
92 fi
93
94 # check for existence of select.h (on AIX)
95
96 if [ -f /usr/include/sys/select.h ]
97 then
98 select_hdr="-DSLCT_HDR"
99 else
100 select_hdr=""
101 fi
102
103 # check for stdlib.h
104
105 if [ -f /usr/include/stdlib.h ]
106 then
107 HAS_STDLIB=-DHAS_STDLIB
108 else
109 HAS_STDLIB=""
110 fi
111
112 # check for stdarg.h
113
114 if [ -f /usr/include/stdarg.h ]
115 then
116 HAS_STDARG=-DHAS_STDARG
117 else
118 HAS_STDARG=""
119 fi
120
121 # check for ctype.h
122
123 if [ -f /usr/include/ctype.h ]
124 then
125 HAS_CTYPE=-DHAS_CTYPE
126 else
127 HAS_CTYPE=""
128 fi
129
130 # check for sys/ioctl.h
131
132 if [ -f /usr/include/sys/ioctl.h ]
133 then
134 HAS_SYS_IOCTL=-DHAS_SYS_IOCTL
135 else
136 HAS_SYS_IOCTL=""
137 fi
138
139 # check for sys/wait.h
140
141 if [ -f /usr/include/sys/wait.h ]
142 then
143 HAS_SYS_WAIT=-DHAS_SYS_WAIT
144 else
145 HAS_SYS_WAIT=""
146 fi
147
148 # check for localization headers
149
150 if [ -f /usr/include/locale.h -a -f /usr/include/nl_types.h ]
151 then
152 catgets=""
153 else
154 catgets="-DNO_CATGETS"
155 fi
156
157 # make decisions about use of new_curse.c (use of new_curse is recommended
158 # rather than local curses)
159
160 if [ -n "$terminfo_exists" -a -z "$termcap_exists" ]
161 then
162 echo "Neither terminfo or termcap are on this system! "
163 if [ -f /usr/include/curses.h ]
164 then
165 echo "Relying on local curses implementation."
166 else
167 cat <<-EOF
168 Don't know where to find curses, you'll need to modify
169 source code to be able to build!
170
171 Modify the file make.default and build ee by typing:
172
173 make -f make.default
174
175 EOF
176
177 exit 1
178 fi
179
180 TARGET="curses"
181 curses=""
182 else
183 curses="-DNCURSE"
184 TARGET="ee"
185 fi
186
187 if [ -z "$termio" -a -z "$sgtty" ]
188 then
189 echo "Neither termio.h or sgtty.h are on this system! "
190 if [ -f /usr/include/curses.h ]
191 then
192 echo "Relying on local curses implementation."
193 else
194 cat <<-EOF
195 Don't know where to find curses, you'll need to modify
196 source code to be able to build!
197
198 Modify the file make.default and build ee by typing:
199
200 make -f make.default
201
202 EOF
203
204 exit 1
205 fi
206
207 TARGET="curses"
208 curses=""
209 fi
210
211 # check if this is a SunOS system
212
213 if [ -d /usr/5include ]
214 then
215 five_include="-I/usr/5include"
216 else
217 five_include=""
218 fi
219
220 if [ -d /usr/5lib ]
221 then
222 five_lib="-L/usr/5lib"
223 else
224 five_lib=""
225 fi
226
227
228 if [ "$name_string" = "Darwin" ]
229 then
230 if [ -n "$CFLAGS" ]
231 then
232 other_cflags="${CFLAGS} -DNO_CATGETS"
233 else
234 other_cflags="-DNO_CATGETS"
235 fi
236 else
237
238 if [ -n "$CFLAGS" ]
239 then
240 if [ -z "`echo $CFLAGS | grep '[-]g'`" ]
241 then
242 other_cflags="${CFLAGS} -s"
243 else
244 other_cflags="${CFLAGS}"
245 fi
246 else
247 other_cflags="-s"
248 fi
249 fi
250
251 # time to write the makefile
252
253 echo "Generating make.local"
254
255 if [ -f make.local ]
256 then
257 mv make.local make.lcl.old
258 fi
259
260 echo "DEFINES = $termio $terminfo_exists $BSD_SELECT $catgets $select $curses " > make.local
261 echo "" >> make.local
262 echo "CFLAGS = $HAS_UNISTD $HAS_STDARG $HAS_STDLIB $HAS_CTYPE $HAS_SYS_IOCTL $HAS_SYS_WAIT $five_lib $five_include $select_hdr $other_cflags $termcap_exists" >> make.local
263 echo "" >> make.local
264 echo "" >> make.local
265 echo "all : $TARGET" >> make.local
266
267 cat >> make.local << EOF
268
269 curses : ee.c
270 cc ee.c -o ee \$(CFLAGS) -lcurses
271
272 ee : ee.o new_curse.o
273 cc -o ee ee.o new_curse.o \$(CFLAGS)
274
275 ee.o : ee.c new_curse.h
276 cc -c ee.c \$(DEFINES) \$(CFLAGS)
277
278 new_curse.o : new_curse.c new_curse.h
279 cc new_curse.c -c \$(DEFINES) \$(CFLAGS)
280
281 EOF
282
283 if [ -f make.lcl.old ]
284 then
285 diffs="`cmp make.lcl.old make.local`"
286 if [ -n "${diffs}" ]
287 then
288 rm -f ee.o new_curse.o ee
289 fi
290 rm -f make.lcl.old
291 fi
292