sbin/hammer: Add /* not reached */ for usage() variants
[dragonfly.git] / contrib / ee / create.make
blob5d6ec30624bb1dfb842c2f0fde0b33a2c80c55d9
1 #!/bin/sh
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.
7 # $Header: /home/hugh/sources/old_ae/RCS/create.make,v 1.13 2002/09/23 04:18:13 hugh Exp $
10 #set -x
12 name_string="`uname`"
14 # test for existence of termcap (exists on both BSD and SysV systems)
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\\\"\""
28 else
29 termcap_exists=""
32 # test for terminfo directory (exists on SysV systems)
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"
41 # test for existence of termio header (on SysV systems)
43 if [ -f /usr/include/termio.h ]
44 then
45 termio="-DSYS5"
46 else
47 termio=""
50 # test for sgtty header (on BSD systems)
52 if [ -f /usr/include/sgtty.h ]
53 then
54 sgtty="TRUE"
55 else
56 sgtty=""
59 # look for select call in headers, make sure headers exist
61 HEADER_FILES=""
63 if [ -f /usr/include/sys/time.h ]
64 then
65 HEADER_FILES="/usr/include/sys/time.h "
68 if [ -f /usr/include/sys/types.h ]
69 then
70 HEADER_FILES="$HEADER_FILES /usr/include/sys/types.h"
73 # check for unistd.h
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=""
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=""
94 # check for existence of select.h (on AIX)
96 if [ -f /usr/include/sys/select.h ]
97 then
98 select_hdr="-DSLCT_HDR"
99 else
100 select_hdr=""
103 # check for stdlib.h
105 if [ -f /usr/include/stdlib.h ]
106 then
107 HAS_STDLIB=-DHAS_STDLIB
108 else
109 HAS_STDLIB=""
112 # check for stdarg.h
114 if [ -f /usr/include/stdarg.h ]
115 then
116 HAS_STDARG=-DHAS_STDARG
117 else
118 HAS_STDARG=""
121 # check for ctype.h
123 if [ -f /usr/include/ctype.h ]
124 then
125 HAS_CTYPE=-DHAS_CTYPE
126 else
127 HAS_CTYPE=""
130 # check for sys/ioctl.h
132 if [ -f /usr/include/sys/ioctl.h ]
133 then
134 HAS_SYS_IOCTL=-DHAS_SYS_IOCTL
135 else
136 HAS_SYS_IOCTL=""
139 # check for sys/wait.h
141 if [ -f /usr/include/sys/wait.h ]
142 then
143 HAS_SYS_WAIT=-DHAS_SYS_WAIT
144 else
145 HAS_SYS_WAIT=""
148 # check for localization headers
150 if [ -f /usr/include/locale.h -a -f /usr/include/nl_types.h ]
151 then
152 catgets=""
153 else
154 catgets="-DNO_CATGETS"
157 # make decisions about use of new_curse.c (use of new_curse is recommended
158 # rather than local curses)
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!
171 Modify the file make.default and build ee by typing:
173 make -f make.default
177 exit 1
180 TARGET="curses"
181 curses=""
182 else
183 curses="-DNCURSE"
184 TARGET="ee"
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!
198 Modify the file make.default and build ee by typing:
200 make -f make.default
204 exit 1
207 TARGET="curses"
208 curses=""
211 # check if this is a SunOS system
213 if [ -d /usr/5include ]
214 then
215 five_include="-I/usr/5include"
216 else
217 five_include=""
220 if [ -d /usr/5lib ]
221 then
222 five_lib="-L/usr/5lib"
223 else
224 five_lib=""
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"
236 else
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}"
246 else
247 other_cflags="-s"
251 # time to write the makefile
253 echo "Generating make.local"
255 if [ -f make.local ]
256 then
257 mv make.local make.lcl.old
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
267 cat >> make.local << EOF
269 curses : ee.c
270 cc ee.c -o ee \$(CFLAGS) -lcurses
272 ee : ee.o new_curse.o
273 cc -o ee ee.o new_curse.o \$(CFLAGS)
275 ee.o : ee.c new_curse.h
276 cc -c ee.c \$(DEFINES) \$(CFLAGS)
278 new_curse.o : new_curse.c new_curse.h
279 cc new_curse.c -c \$(DEFINES) \$(CFLAGS)
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
290 rm -f make.lcl.old