PageRenderTime 23ms CodeModel.GetById 10ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 1ms

/contrib/ee/create.make

https://bitbucket.org/freebsd/freebsd-head/
Shell | 292 lines | 204 code | 63 blank | 25 comment | 30 complexity | d126ecfa1493b58054dea6d932d9dba8 MD5 | raw file
  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
 12name_string="`uname`"
 13
 14# test for existence of termcap (exists on both BSD and SysV systems)
 15
 16if [ -f /etc/termcap -o -f /usr/share/lib/termcap -o -f /usr/share/misc/termcap ]
 17then
 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
 28else
 29	termcap_exists=""
 30fi
 31
 32# test for terminfo directory (exists on SysV systems)
 33
 34if [ -d /usr/lib/terminfo -o -d /usr/share/lib/terminfo -o -d /usr/share/terminfo ]
 35then
 36	terminfo_exists=""
 37else
 38	terminfo_exists="-DCAP"
 39fi
 40
 41# test for existence of termio header (on SysV systems)
 42
 43if [ -f /usr/include/termio.h ]
 44then
 45	termio="-DSYS5"
 46else
 47	termio=""
 48fi
 49
 50# test for sgtty header (on BSD systems)
 51
 52if [ -f /usr/include/sgtty.h ]
 53then
 54	sgtty="TRUE"
 55else
 56	sgtty=""
 57fi
 58
 59# look for select call in headers, make sure headers exist
 60
 61HEADER_FILES=""
 62
 63if [ -f /usr/include/sys/time.h ]
 64then
 65	HEADER_FILES="/usr/include/sys/time.h "
 66fi
 67
 68if [ -f /usr/include/sys/types.h ]
 69then
 70	HEADER_FILES="$HEADER_FILES /usr/include/sys/types.h"
 71fi
 72
 73# check for unistd.h
 74
 75if [ -f /usr/include/unistd.h ]
 76then
 77	HAS_UNISTD=-DHAS_UNISTD
 78	HEADER_FILES="$HEADER_FILES /usr/include/unistd.h"
 79else
 80	HAS_UNISTD=""
 81fi
 82
 83if [ -n "$HEADER_FILES" ]
 84then
 85	string="`grep select $HEADER_FILES`"
 86	if [ -n "$string" ]
 87	then
 88		BSD_SELECT="-DBSD_SELECT"
 89	else
 90		BSD_SELECT=""
 91	fi
 92fi
 93
 94# check for existence of select.h (on AIX)
 95
 96if [ -f /usr/include/sys/select.h ]
 97then
 98	select_hdr="-DSLCT_HDR"
 99else
100	select_hdr=""
101fi
102
103# check for stdlib.h
104
105if [ -f /usr/include/stdlib.h ]
106then
107	HAS_STDLIB=-DHAS_STDLIB
108else
109	HAS_STDLIB=""
110fi
111
112# check for stdarg.h
113
114if [ -f /usr/include/stdarg.h ]
115then
116	HAS_STDARG=-DHAS_STDARG
117else
118	HAS_STDARG=""
119fi
120
121# check for ctype.h
122
123if [ -f /usr/include/ctype.h ]
124then
125	HAS_CTYPE=-DHAS_CTYPE
126else
127	HAS_CTYPE=""
128fi
129
130# check for sys/ioctl.h
131
132if [ -f /usr/include/sys/ioctl.h ]
133then
134	HAS_SYS_IOCTL=-DHAS_SYS_IOCTL
135else
136	HAS_SYS_IOCTL=""
137fi
138
139# check for sys/wait.h
140
141if [ -f /usr/include/sys/wait.h ]
142then
143        HAS_SYS_WAIT=-DHAS_SYS_WAIT
144else
145        HAS_SYS_WAIT=""
146fi
147
148# check for localization headers
149
150if [ -f /usr/include/locale.h -a -f /usr/include/nl_types.h ]
151then
152	catgets=""
153else
154	catgets="-DNO_CATGETS"
155fi
156
157# make decisions about use of new_curse.c (use of new_curse is recommended 
158# rather than local curses)
159
160if [ -n "$terminfo_exists" -a -z "$termcap_exists" ]
161then
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=""
182else
183	curses="-DNCURSE"
184	TARGET="ee"
185fi
186
187if [ -z "$termio" -a -z "$sgtty" ]
188then
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=""
209fi
210
211# check if this is a SunOS system
212
213if [ -d /usr/5include ]
214then
215	five_include="-I/usr/5include"
216else
217	five_include=""
218fi
219
220if [ -d /usr/5lib ]
221then
222	five_lib="-L/usr/5lib"
223else
224	five_lib=""
225fi
226
227
228if [ "$name_string" = "Darwin" ]
229then
230	if [ -n "$CFLAGS" ]
231	then
232		other_cflags="${CFLAGS} -DNO_CATGETS"
233	else
234		other_cflags="-DNO_CATGETS"
235	fi
236else
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
249fi
250
251# time to write the makefile
252
253echo "Generating make.local"
254
255if [ -f make.local ]
256then
257	mv make.local make.lcl.old
258fi
259
260echo "DEFINES =	$termio $terminfo_exists $BSD_SELECT $catgets $select $curses " > make.local
261echo "" >> make.local
262echo "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
263echo "" >> make.local
264echo "" >> make.local
265echo "all :	$TARGET" >> make.local
266
267cat  >> make.local << EOF
268
269curses :	ee.c
270	cc ee.c -o ee \$(CFLAGS) -lcurses 
271
272ee :	ee.o new_curse.o
273	cc -o ee ee.o new_curse.o \$(CFLAGS) 
274
275ee.o :	ee.c new_curse.h
276	cc -c ee.c \$(DEFINES) \$(CFLAGS) 
277
278new_curse.o :	new_curse.c new_curse.h
279	cc new_curse.c -c \$(DEFINES) \$(CFLAGS)
280
281EOF
282
283if [ -f make.lcl.old ]
284then
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
291fi
292