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