1#!/bin/make
2#
3# help - makefile for calc help files
4#
5# Copyright (C) 1999-2006,2017,2021  Landon Curt Noll
6#
7# SRC: help/Makefile
8#
9#	The "# SRC: ... - ..." comment line above indicates
10#	the origin of this file.
11#
12# IMPORTANT: Please see the section on Makefiles near the
13#	     bottom of the HOWTO.INSTALL file.
14#
15# Calc is open software; you can redistribute it and/or modify it under
16# the terms of the version 2.1 of the GNU Lesser General Public License
17# as published by the Free Software Foundation.
18#
19# Calc is distributed in the hope that it will be useful, but WITHOUT
20# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21# or FITNESS FOR A PARTICULAR PURPOSE.	See the GNU Lesser General
22# Public License for more details.
23#
24# A copy of version 2.1 of the GNU Lesser General Public License is
25# distributed with calc under the filename COPYING-LGPL.  You should have
26# received a copy with calc; if not, write to Free Software Foundation, Inc.
27# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
28#
29# Under source code control:	1991/07/23 06:47:57
30# File existed as early as:	1991
31#
32# chongo <was here> /\oo/\	http://www.isthe.com/chongo/
33# Share and enjoy!  :-) http://www.isthe.com/chongo/tech/comp/calc/
34#
35# calculator by David I. Bell with help/mods from others
36# Makefile by Landon Curt Noll
37
38
39# The shell used by this Makefile
40#
41# On some systems, /bin/sh is a rather reduced shell with
42# deprecated behavior.
43#
44# If your system has a up to date, bash shell, then
45# you may wish to use:
46#
47#	SHELL= /bin/sh
48#
49# On some systems such as macOS, the bash shell is very
50# far behind to the point where is cannot be depended on.
51# On such systems, the sh may be a much better alternative
52# shell for this Makefile to use:
53#
54#	SHELL= /bin/sh
55#
56SHELL= /bin/sh
57#SHELL= /bin/sh
58#if 0	/* start of skip for non-Gnu makefiles */
59ifeq ($(target),Darwin)
60SHELL:= /bin/zsh
61endif
62#endif	/* end of skip for non-Gnu makefiles */
63
64
65####
66# Normally, the upper level makefile will set these values.  We provide
67# a default here just in case you want to build from this directory.
68####
69
70# PREFIX - Top level location for calc
71#
72# The PREFIX is often prepended to paths within calc and calc Makefiles.
73#
74# Starting with calc v2.13.0.1, nearly all Makefile places that used
75# /usr/local now use ${PREFIX}.  An exception is the olduninstall rule
76# and, of course, this section. :-)
77#
78# NOTE: The ${PREFIX} is not the same as ${T}.  The ${T} specifies
79#	a top level directory under which calc installs things.
80#	While usually ${T} is empty, it can be specific path
81#	as if calc where "chrooted" during an install.
82#	The ${PREFIX} value, during install, is a path between
83#	the top level ${T} install directory and the object
84#	such as an include file.
85#
86# NOTE: See also, ${T}, below.
87#
88# There are some paths that do NOT call under ${PREFIX}, such as
89# ${CALCPATH}, that include paths not under ${PREFIX}, but those
90# too are exceptions to this general rule.
91#
92# When in doubt, try:
93#
94#	PREFIX= /usr/local
95#
96PREFIX= /usr/local
97#PREFIX= /usr
98#PREFIX= /usr/global
99
100# Normally certain files depend on the Makefile.  If the Makefile is
101# changed, then certain steps should be redone.  If MAKE_FILE is
102# set to Makefile, then these files will depend on Makefile.  If
103# MAKE_FILE is empty, then they wont.
104#
105# If in doubt, set MAKE_FILE to Makefile
106#
107MAKE_FILE= Makefile
108
109# Where the system include (.h) files are kept
110#
111# For DJGPP, select:
112#
113#	INCDIR= /dev/env/DJDIR/include
114#
115# If in doubt, set:
116#
117#	INCDIR= /usr/include
118#
119
120#INCDIR= /usr/local/include
121#INCDIR= /dev/env/DJDIR/include
122INCDIR= /usr/include
123
124# where to install calc related things
125#
126# ${BINDIR}		where to install calc binary files
127# ${LIBDIR}		where calc link library (*.a) files are installed
128# ${CALC_SHAREDIR}	where to install calc help, .cal, startup, config files
129#
130# NOTE: The install rule prepends installation paths with ${T}, which
131#	by default is empty.  If ${T} is non-empty, then installation
132#	locations will be relative to the ${T} directory.
133#
134# For DJGPP, select:
135#
136#	BINDIR= /dev/env/DJDIR/bin
137#	LIBDIR= /dev/env/DJDIR/lib
138#	CALC_SHAREDIR= /dev/env/DJDIR/share/calc
139#
140# If in doubt, set:
141#
142#	BINDIR= /usr/bin
143#	LIBDIR= /usr/lib
144#	CALC_SHAREDIR= /usr/share/calc
145#
146#BINDIR= ${PREFIX}/bin
147#BINDIR= /dev/env/DJDIR/bin
148BINDIR= /usr/bin
149
150#LIBDIR= ${PREFIX}/lib
151#LIBDIR= /dev/env/DJDIR/lib
152LIBDIR= /usr/lib
153
154#CALC_SHAREDIR= ${PREFIX}/lib/calc
155#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
156CALC_SHAREDIR= /usr/share/calc
157
158# By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
159# ---------------------------------------------------------------
160# ${HELPDIR}		where the help directory is installed
161# ${CALC_INCDIR}	where the calc include files are installed
162# ${SCRIPTDIR}		where calc shell scripts are installed
163#
164# NOTE: The install rule prepends installation paths with ${T}, which
165#	by default is empty.  If ${T} is non-empty, then installation
166#	locations will be relative to the ${T} directory.
167#
168# If in doubt, set:
169#
170#	HELPDIR= ${CALC_SHAREDIR}/help
171#	CALC_INCDIR= ${INCDIR}/calc
172#	SCRIPTDIR= ${BINDIR}/cscript
173#
174HELPDIR= ${CALC_SHAREDIR}/help
175CALC_INCDIR= ${INCDIR}/calc
176SCRIPTDIR= ${BINDIR}/cscript
177
178# T - top level directory under which calc will be installed
179#
180# The calc install is performed under ${T}, the calc build is
181# performed under /.	The purpose for ${T} is to allow someone
182# to install calc somewhere other than into the system area.
183#
184# For example, if:
185#
186#     BINDIR= /usr/bin
187#     LIBDIR= /usr/lib
188#     CALC_SHAREDIR= /usr/share/calc
189#
190# and if:
191#
192#     T= /var/tmp/testing
193#
194# Then the installation locations will be:
195#
196#     calc binary files:	/var/tmp/testing/usr/bin
197#     calc link library:	/var/tmp/testing/usr/lib
198#     calc help, .cal ...:	/var/tmp/testing/usr/share/calc
199#     ... etc ...		/var/tmp/testing/...
200#
201# If ${T} is empty, calc is installed under /, which is the same
202# top of tree for which it was built.  If ${T} is non-empty, then
203# calc is installed under ${T}, as if one had to chroot under
204# ${T} for calc to operate.
205#
206# If in doubt, use T=
207#
208T=
209
210# Makefile debug
211#
212# Q=@	do not echo internal Makefile actions (quiet mode)
213# Q=	echo internal Makefile actions (debug / verbose mode)
214#
215# H=@:	do not report hsrc file formation progress
216# H=@	do echo hsrc file formation progress
217#
218# S= >/dev/null 2>&1	silence ${CC} output during hsrc file formation
219# S=			full ${CC} output during hsrc file formation
220#
221# E= 2>/dev/null	silence command stderr during hsrc file formation
222# E=			full command stderr during hsrc file formation
223#
224# V=@:	do not echo debug statements (quiet mode)
225# V=@	do echo debug statements (debug / verbose mode)
226#
227#Q=
228Q=@
229#
230S= >/dev/null 2>&1
231#S=
232#
233E= 2>/dev/null
234#E=
235#
236#H=@:
237H=@
238#
239V=@:
240#V=@
241
242# standard tools
243#
244CAT= cat
245CHMOD= chmod
246CMP= cmp
247CP= cp
248FMT= fmt
249GREP= egrep
250ICFLAGS=
251ILDFLAGS=
252LCC= cc
253MKDIR= mkdir
254MV= mv
255RM= rm
256RMDIR= rmdir
257SED= sed
258SORT= sort
259TOUCH= touch
260TRUE= true
261
262# Some out of date operating systems require / want an executable to
263# end with a certain file extension.  Some compile systems such as
264# Cygwin build calc as calc.exe.  The EXT variable is used to denote
265# the extension required by such.
266#
267# EXT=				# normal Un*x / Linux / GNU/Linux systems
268# EXT=.exe			# Windows / Cygwin
269#
270# If in doubt, use EXT=
271#
272EXT=
273#EXT=.exe
274
275# Standard and Builtin help files
276#
277STD_HELP_FILES_1= intro overview help
278STD_HELP_FILES_2= assoc
279
280BLT_HELP_FILES_3= builtin man
281
282STD_HELP_FILES_4= command config custom define environment expression
283
284BLT_HELP_FILES_5= errorcodes
285
286STD_HELP_FILES_6= file history interrupt list mat
287
288# because obj is built special (due to confusion with it as
289# a symlink for some built environments, we treat obj specially
290# and call it obj.file
291#
292SPECIAL_HELP_7= obj.file
293
294STD_HELP_FILES_8= operator statement
295
296BLT_HELP_FILES_9= resource
297
298STD_HELP_FILES_10= types script
299
300BLT_HELP_FILES_10a= usage cscript
301
302STD_HELP_FILES_10b= unexpected variable
303
304BLT_HELP_FILES_11= bindings custom_cal libcalc new_custom resource
305
306STD_HELP_FILES_12= archive
307
308BLT_HELP_FILES_13= bugs changes
309
310STD_HELP_FILES_14= credit
311
312BLT_HELP_FILES_14= contrib COPYING COPYING-LGPL questions releases
313
314STD_HELP_FILES_15= wishlist todo
315
316# These files are used in the following order to construct full
317#
318FULL_HELP_FILES= ${STD_HELP_FILES_1} ${STD_HELP_FILES_2} \
319		${BLT_HELP_FILES_3} ${STD_HELP_FILES_4} \
320		${BLT_HELP_FILES_5} ${STD_HELP_FILES_6} \
321		${SPECIAL_HELP_7} ${STD_HELP_FILES_8} \
322		${BLT_HELP_FILES_9} ${STD_HELP_FILES_10} \
323		${BLT_HELP_FILES_10a} ${STD_HELP_FILES_10b} \
324		${BLT_HELP_FILES_11} ${STD_HELP_FILES_12} \
325		${BLT_HELP_FILES_13} ${STD_HELP_FILES_14} \
326		${BLT_HELP_FILES_14} ${STD_HELP_FILES_15}
327
328# These full files are those who are not built or constructed
329#
330STD_HELP_FILES= ${STD_HELP_FILES_1} ${STD_HELP_FILES_2} \
331		${STD_HELP_FILES_4} ${STD_HELP_FILES_6} \
332		${STD_HELP_FILES_8} ${STD_HELP_FILES_10} \
333		${STD_HELP_FILES_10b} \
334		${STD_HELP_FILES_12} ${STD_HELP_FILES_14} \
335		${STD_HELP_FILES_15}
336
337# These full files are those who are built by this Makefile
338#
339# Note that ${SPECIAL_HELP_7} is not included in this list
340# because of problems with its name.
341#
342BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
343		${BLT_HELP_FILES_9} \
344		${BLT_HELP_FILES_10a} \
345		${BLT_HELP_FILES_11} ${BLT_HELP_FILES_13} \
346		${BLT_HELP_FILES_14}
347
348# The detailed list of help files to install
349#
350# This list is produced by the detaillist rule when no WARNINGS are detected.
351#
352# Please use:
353#
354#	make clobber >/dev/null && make detail_help_list
355#
356# to keep this list in nice sorted order.
357#
358DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd \
359	append appr arg argv arrow asec asech asin asinh assign atan atan2 \
360	atanh avg base base2 bernoulli bit blk blkcpy blkfree blocks bround \
361	btrunc calc_tty calclevel calcpath catalan ceil cfappr cfsim char \
362	cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime d2dm \
363	d2dms d2g d2r delete den dereference det digit digits display dms2d dp \
364	epsilon errcount errmax errno error estr euler eval exp fact factor \
365	fclose fcnt feof ferror fflush fgetc fgetfield fgetfile fgetline fgets \
366	fgetstr fib files floor fopen forall fpathopen fprintf fputc fputs \
367	fputstr frac free freebernoulli freeeuler freeglobals freeredc \
368	freestatics frem freopen fscan fscanf fseek fsize ftell g2d g2gm g2gms \
369	g2r gcd gcdrem gd getenv gms2g h2hm h2hms hash head highbit hmean \
370	hms2h hnrmod hypot ilog ilog10 ilog2 im indices inputlevel insert int \
371	inverse iroot isalnum isalpha isassoc isatty isblk iscntrl isconfig \
372	isdefined isdigit iserror iseven isfile isgraph ishash isident isint \
373	islist islower ismat ismult isnull isnum isobj isobjtype isodd isprime \
374	isprint isptr ispunct isqrt isrand israndom isreal isrel issimple \
375	isspace issq isstr istype isupper isxdigit jacobi join lcm lcmfact \
376	lfactor ln log lowbit ltol makelist matdim matfill matmax matmin \
377	matsum mattrace mattrans max memsize meq min minv mmin mne mod modify \
378	name near newerror nextcand nextprime norm null num oldvalue ord param \
379	perm pfact pi pix places pmod polar poly pop popcnt pound power \
380	prevcand prevprime printf prompt protect ptest push putenv quo quomod \
381	r2d r2g rand randbit random randombit randperm rcin rcmul rcout rcpow \
382	rcsq re remove reverse rewind rm root round rsearch runtime saveval \
383	scale scan scanf search sec sech seed segment select sgn sha1 sin sinh \
384	size sizeof sleep sort sqrt srand srandom ssq stoponerror str \
385	strcasecmp strcat strcmp strcpy strerror strlen strncasecmp strncmp \
386	strncpy strpos strprintf strscan strscanf strtolower strtoupper substr \
387	sum swap system systime tail tan tanh test time trunc usertime version \
388	xor
389
390# This list is of files that are clones of DETAIL_HELP files.  They are
391# built from DETAIL_HELP files.
392#
393DETAIL_CLONE= copy
394
395# Singular files
396#
397# These files are copies of their plural form.
398#
399PLURAL_FILES= bindings bugs changes errorcodes types
400SINGULAR_FILES= binding bug change errorcode type
401
402# These files are found (but not built) in the distribution
403#
404DISTLIST= ${STD_HELP_FILES} ${DETAIL_HELP} ${MAKE_FILE} \
405	obj.file builtin.top builtin.end funclist.sed \
406	errorcodes.hdr errorcodes.sed
407
408# These files are used to make (but not built) a calc .a link library
409#
410CALCLIBLIST=
411
412all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \
413     ${SINGULAR_FILES} .all
414
415# used by the upper level Makefile to determine of we have done all
416#
417# NOTE: Due to bogus shells found on one common system we must have
418#	an non-empty else clause for every if condition.  *sigh*
419#
420.all:
421	${RM} -f .all
422	${TOUCH} .all
423
424bindings: ../cal/bindings
425	${RM} -f $@
426	${CP} ../cal/bindings $@
427	${CHMOD} 0444 $@
428	-@if [ -z "${Q}" ]; then \
429	    echo ''; \
430	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
431	    echo ''; \
432	else \
433	    ${TRUE}; \
434	fi
435
436resource: ../cal/README
437	${RM} -f $@
438	${CP} ../cal/README $@
439	${CHMOD} 0444 $@
440	-@if [ -z "${Q}" ]; then \
441	    echo ''; \
442	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
443	    echo ''; \
444	else \
445	    ${TRUE}; \
446	fi
447
448changes: ../CHANGES
449	${RM} -f $@
450	${CP} ../CHANGES $@
451	${CHMOD} 0444 $@
452	-@if [ -z "${Q}" ]; then \
453	    echo ''; \
454	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
455	    echo ''; \
456	else \
457	    ${TRUE}; \
458	fi
459
460libcalc: ../LIBRARY
461	${RM} -f $@
462	${SED} -e 's:$${LIBDIR}:${LIBDIR}:g' \
463	       -e 's:$${CALC_INCDIR}:${CALC_INCDIR}:g' < ../LIBRARY > $@
464	${CHMOD} 0444 $@
465	-@if [ -z "${Q}" ]; then \
466	    echo ''; \
467	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
468	    echo ''; \
469	else \
470	    ${TRUE}; \
471	fi
472
473bugs: ../BUGS
474	${RM} -f $@
475	${CP} ../BUGS $@
476	${CHMOD} 0444 $@
477	-@if [ -z "${Q}" ]; then \
478	    echo ''; \
479	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
480	    echo ''; \
481	else \
482	    ${TRUE}; \
483	fi
484
485contrib: ../CONTRIB-CODE
486	${RM} -f $@
487	${CP} ../CONTRIB-CODE $@
488	${CHMOD} 0444 $@
489	-@if [ -z "${Q}" ]; then \
490	    echo ''; \
491	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
492	    echo ''; \
493	else \
494	    ${TRUE}; \
495	fi
496
497errorcodes: ../calcerr.h errorcodes.hdr errorcodes.sed
498	${RM} -f $@
499	${CAT} errorcodes.hdr > $@
500	${SED} -n -f errorcodes.sed < ../calcerr.h >> $@
501	${CHMOD} 0444 $@
502	-@if [ -z "${Q}" ]; then \
503	    echo ''; \
504	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
505	    echo ''; \
506	else \
507	    ${TRUE}; \
508	fi
509
510usage: ../calc.usage
511	${RM} -f $@
512	${CP} ../calc.usage $@
513	${CHMOD} 0444 $@
514	-@if [ -z "${Q}" ]; then \
515	    echo ''; \
516	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
517	    echo ''; \
518	else \
519	    ${TRUE}; \
520	fi
521
522../calc.usage:
523	(cd ..; ${MAKE} -f ${MAKE_FILE} calc.usage)
524
525custom_cal: ../custom/CUSTOM_CAL
526	${RM} -f $@
527	${CP} ../custom/CUSTOM_CAL $@
528	${CHMOD} 0444 $@
529	-@if [ -z "${Q}" ]; then \
530	    echo ''; \
531	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
532	    echo ''; \
533	else \
534	    ${TRUE}; \
535	fi
536
537new_custom: ../custom/HOW_TO_ADD
538	${RM} -f $@
539	${CP} ../custom/HOW_TO_ADD $@
540	${CHMOD} 0444 $@
541	-@if [ -z "${Q}" ]; then \
542	    echo ''; \
543	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
544	    echo ''; \
545	else \
546	    ${TRUE}; \
547	fi
548
549copy: blkcpy
550	${RM} -f $@
551	${CP} blkcpy $@
552	${CHMOD} 0444 $@
553	-@if [ -z "${Q}" ]; then \
554	    echo ''; \
555	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
556	    echo ''; \
557	else \
558	    ${TRUE}; \
559	fi
560
561man: help
562	${RM} -f $@
563	${CP} help $@
564	${CHMOD} 0444 $@
565	-@if [ -z "${Q}" ]; then \
566	    echo ''; \
567	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
568	    echo ''; \
569	else \
570	    ${TRUE}; \
571	fi
572
573COPYING: ../COPYING
574	${RM} -f $@
575	${CP} ../COPYING $@
576	${CHMOD} 0444 $@
577	-@if [ -z "${Q}" ]; then \
578	    echo ''; \
579	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
580	    echo ''; \
581	else \
582	    ${TRUE}; \
583	fi
584
585COPYING-LGPL: ../COPYING-LGPL
586	${RM} -f $@
587	${CP} ../COPYING-LGPL $@
588	${CHMOD} 0444 $@
589	-@if [ -z "${Q}" ]; then \
590	    echo ''; \
591	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
592	    echo ''; \
593	else \
594	    ${TRUE}; \
595	fi
596
597questions: ../QUESTIONS
598	${RM} -f $@
599	${CP} ../QUESTIONS $@
600	${CHMOD} 0444 $@
601	-@if [ -z "${Q}" ]; then \
602	    echo ''; \
603	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
604	    echo ''; \
605	else \
606	    ${TRUE}; \
607	fi
608
609cscript: ../cscript/README
610	${RM} -f $@
611	${CP} ../cscript/README $@
612	${CHMOD} 0444 $@
613	-@if [ -z "${Q}" ]; then \
614	    echo ''; \
615	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
616	    echo ''; \
617	else \
618	    ${TRUE}; \
619	fi
620
621../cscript/README: ../cscript/README.src
622	${Q} echo "forming cscript/README"
623	${Q} ${RM} -f $@
624	(cd ../cscript; ${MAKE} -f Makefile README)
625
626releases: ../README.RELEASE
627	${RM} -f $@
628	${CP} ../README.RELEASE $@
629	${CHMOD} 0444 $@
630	-@if [ -z "${Q}" ]; then \
631	    echo ''; \
632	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
633	    echo ''; \
634	else \
635	    ${TRUE}; \
636	fi
637
638full: ${FULL_HELP_FILES} ${MAKE_FILE}
639	${Q} echo "forming full"
640	${Q} ${RM} -f $@
641	-${Q} for i in ${FULL_HELP_FILES}; do \
642	    if [ Xintro != X"$$i" ]; then \
643		echo ""; \
644	    else \
645		${TRUE}; \
646	    fi; \
647	    if [ Xobj.file = X"$$i" ]; then \
648		j=obj; \
649	    else \
650		j=$$i; \
651	    fi; \
652	    echo "*************"; \
653	    echo "* $$j"; \
654	    echo "*************"; \
655	    echo ""; \
656	    ${CAT} $$i; \
657	done > $@
658	${Q} echo "full formed"
659	-@if [ -z "${Q}" ]; then \
660	    echo ''; \
661	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
662	    echo ''; \
663	else \
664	    ${TRUE}; \
665	fi
666
667# Singular files are the same files as their plural form.
668#
669${SINGULAR_FILES}: ${PLURAL_FILES}
670	${Q} for i in ${SINGULAR_FILES} /dev/null; do \
671	    if [ X"$$i" != X"/dev/null" ]; then \
672		echo "${RM} -f $${i}"; \
673		${RM} -f $${i}; \
674		echo "${CP} $${i}s $${i}"; \
675		${CP} $${i}s $${i}; \
676	    fi; \
677	done
678	-@if [ -z "${Q}" ]; then \
679	    echo ''; \
680	    echo '=-=-= skipping the ${CAT} of help/SINGULAR_FILES =-=-='; \
681	    echo ''; \
682	else \
683	    ${TRUE}; \
684	fi
685
686# Form the builtin file
687#
688# We have a "chicken-and-egg" problem.  We want the builtin help file to
689# accurately reflect the function list.	 It would be nice if we could
690# just execute calc show builtin, but calc may not have been built or
691# build-able at this point.  The hack-a-round used is to convert ../func.c
692# into a stand-alone program that generates a suitable function list
693# that is sandwiched between the top and bottom builtin help text.
694#
695# We form funclist.c by sed-ing out unwanted stuff from builtins table,
696# converting NUMBER* and VALUE into harmless types and converting
697# the showbuiltins() function into main().  Combined with the -DFUNCLIST
698# we will avoid all of the complex calc types, macros and defines and
699# be left with just main() and a minimal builtins table.
700#
701# Building funclist.o a portable fashion is ugly because some systems
702# do not treat -I.. correctly!
703#
704builtin: builtin.top builtin.end ../func.c funclist.sed
705	${Q} echo "forming builtin help file"
706	${Q} ${RM} -f funclist.c
707	${Q} ${SED} -n -f funclist.sed ../func.c > funclist.c
708	${Q} ${RM} -f funclist.o funclist${EXT}
709	${Q} ${LCC} ${ICFLAGS} -DFUNCLIST -I/usr/include \
710	    -I.. funclist.c -c ${S}
711	${Q} ${LCC} ${ILDFLAGS} funclist.o -o funclist${EXT} ${S}
712	${Q} ${RM} -f builtin
713	${Q} ${GREP} -v '^#'  builtin.top > builtin
714	${Q} ./funclist${EXT} | \
715	    ${SED} -e 's/^/	/' -e 's/[	 ][	 ]*$$//' >> builtin
716	${Q} ${CAT} builtin.end >> builtin
717	${Q} echo "builtin help file formed"
718	-@if [ -z "${Q}" ]; then \
719	    echo ''; \
720	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
721	    echo ''; \
722	else \
723	    ${TRUE}; \
724	fi
725
726##
727#
728# File list generation.	 You can ignore this section.
729#
730#
731# We will form the names of source files as if they were in a
732# sub-directory called calc/help.
733#
734##
735
736distlist: ${DISTLIST}
737	${Q} for i in ${DISTLIST} /dev/null; do \
738	    if [ X"$$i" != X"/dev/null" ]; then \
739		echo help/$$i; \
740	    fi; \
741	done | fgrep -v '.bak' | LANG=C ${SORT}
742
743distdir:
744	${Q} echo help
745
746calcliblist:
747	${Q} for i in ${CALCLIBLIST} /dev/null; do \
748	    if [ X"$$i" != X"/dev/null" ]; then \
749		echo help/$$i; \
750	    fi; \
751	done
752
753# The BSDI cdrom makefile expects all help files to be pre-built.  This rule
754# creates these files so that the release can be shipped off to BSDI.  You can
755# ignore this rule.
756#
757bsdi: all
758	${RM} -f obj
759	${CP} obj.file obj
760
761# These next rule help form the ${DETAIL_HELP} makefile variables above.
762#
763# NOTE: The ${DETAIL_HELP} list does not include special help files.
764#
765detail_help_list:
766	${Q} -(find .  -mindepth 1 -maxdepth 1 -type f \
767	         ! -name Makefile ! -name '.Makefile.swp' \
768		 ! -name archive ! -name assoc ! -name builtin.end \
769		 ! -name builtin.top ! -name command ! -name config \
770		 ! -name contrib ! -name credit ! -name custom ! -name define \
771		 ! -name environment ! -name errorcodes.hdr \
772		 ! -name errorcodes.sed ! -name expression ! -name file \
773		 ! -name funclist.c ! -name funclist.sed ! -name help \
774		 ! -name history ! -name interrupt ! -name intro ! -name list \
775		 ! -name mat ! -name obj.file ! -name operator \
776		 ! -name overview ! -name script ! -name statement \
777		 ! -name todo ! -name types ! -name unexpected \
778		 ! -name variable ! -name wishlist ! -name questions \
779		 -print | \
780	   while read i; do \
781		if [ X"$$i" != X"/dev/null" ]; then \
782		    echo $$i; \
783		fi; \
784	done; \
785	echo '--first_line--') | \
786	    ${SED} -e 's:^\./::' | LANG=C ${SORT} | ${FMT} -70 | \
787	    ${SED} -e '1s/--first_line--/DETAIL_HELP=/' -e '2,$$s/^/	/' \
788		   -e 's/$$/ \\/' -e '$$s/ \\$$//'
789
790##
791#
792# rpm rules
793#
794##
795
796echo_inst_files:
797	${Q} for i in ${STD_HELP_FILES} full ${BLT_HELP_FILES} \
798		  builtin ${DETAIL_HELP} ${SINGULAR_FILES} /dev/null; do \
799	    if [ X"$$i" != X"/dev/null" ]; then \
800		echo __file__ ${HELPDIR}/$$i; \
801	    fi; \
802	done
803	${Q} echo __file__ ${HELPDIR}/obj
804
805##
806#
807# Utility rules
808#
809##
810
811clean:
812	${RM} -f obj mkbuiltin funclist.c funclist.o funclist${EXT}
813	${RM} -f COPYING COPYING-LGPL questions
814
815clobber: clean
816	${RM} -f ${BLT_HELP_FILES} full .all calc
817	${RM} -f ${SINGULAR_FILES} ${DETAIL_CLONE}
818	-${Q} if [ -e .DS_Store ]; then \
819	    echo ${RM} -rf .DS_Store; \
820	    ${RM} -rf .DS_Store; \
821	fi
822
823# install everything
824#
825# NOTE: Keep the uninstall rule in reverse order to the install rule
826#
827install: all
828	-${Q} if [ ! -d ${T}${CALC_SHAREDIR} ]; then \
829	    echo ${MKDIR} -p ${T}${CALC_SHAREDIR}; \
830	    ${MKDIR} -p ${T}${CALC_SHAREDIR}; \
831	    if [ ! -d "${T}${CALC_SHAREDIR}" ]; then \
832		echo ${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
833		${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
834	    fi; \
835	    echo ${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
836	    ${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
837	else \
838	    ${TRUE}; \
839	fi
840	-${Q} if [ ! -d ${T}${HELPDIR} ]; then \
841	    echo ${MKDIR} -p ${T}${HELPDIR}; \
842	    ${MKDIR} -p ${T}${HELPDIR}; \
843	    if [ ! -d "${T}${HELPDIR}" ]; then \
844		echo ${MKDIR} -p "${T}${HELPDIR}"; \
845		${MKDIR} -p "${T}${HELPDIR}"; \
846	    fi; \
847	    echo ${CHMOD} 0755 ${T}${HELPDIR}; \
848	    ${CHMOD} 0755 ${T}${HELPDIR}; \
849	else \
850	    ${TRUE}; \
851	fi
852	-${Q} for i in ${STD_HELP_FILES} ${BLT_HELP_FILES} builtin \
853		  full ${DETAIL_HELP} ${SINGULAR_FILES} /dev/null; do \
854	    if [ "$$i" = "/dev/null" ]; then \
855		continue; \
856	    fi; \
857	    if ${CMP} -s $$i ${T}${HELPDIR}/$$i; then \
858		${TRUE}; \
859	    else \
860		${RM} -f ${T}${HELPDIR}/$$i.new; \
861		${CP} -f $$i ${T}${HELPDIR}/$$i.new; \
862		${CHMOD} 0444 ${T}${HELPDIR}/$$i.new; \
863		${MV} -f ${T}${HELPDIR}/$$i.new ${T}${HELPDIR}/$$i; \
864		echo "installed ${T}${HELPDIR}/$$i"; \
865	    fi; \
866	done
867	-${Q} if ${CMP} -s obj.file ${T}${HELPDIR}/obj; then \
868	    ${TRUE}; \
869	else \
870	    ${RM} -f ${T}${HELPDIR}/obj.new; \
871	    ${CP} -f obj.file ${T}${HELPDIR}/obj.new; \
872	    ${CHMOD} 0444 ${T}${HELPDIR}/obj.new; \
873	    ${MV} -f ${T}${HELPDIR}/obj.new ${T}${HELPDIR}/obj; \
874	    echo "installed ${T}${HELPDIR}/obj"; \
875	fi
876	-${Q} if [ -f "${T}${HELPDIR}/sha" ]; then \
877	    ${RM} -f ${T}${HELPDIR}/sha; \
878	    echo "removed old ${T}${HELPDIR}/sha"; \
879	fi;
880	-${Q} if [ -f "${T}${HELPDIR}/md5" ]; then \
881	    ${RM} -f ${T}${HELPDIR}/md5; \
882	    echo "removed old ${T}${HELPDIR}/md5"; \
883	fi;
884
885# Try to remove everything that was installed
886#
887# NOTE: Keep the uninstall rule in reverse order to the install rule
888#
889uninstall:
890	-${Q} if [ -f "${T}${HELPDIR}/obj" ]; then \
891	    ${RM} -f "${T}${HELPDIR}/obj"; \
892	    if [ -f "${T}${HELPDIR}/obj" ]; then \
893		echo "cannot uninstall ${T}${HELPDIR}/obj"; \
894	    else \
895		echo "uninstalled ${T}${HELPDIR}/obj"; \
896	    fi; \
897	fi
898	-${Q} for i in ${SINGULAR_FILES} ${DETAIL_HELP} full builtin \
899	    ${BLT_HELP_FILES} ${STD_HELP_FILES} /dev/null; do \
900	    if [ "$$i" = "/dev/null" ]; then \
901		continue; \
902	    fi; \
903	    if [ -f "${T}${HELPDIR}/$$i" ]; then \
904		${RM} -f "${T}${HELPDIR}/$$i"; \
905		if [ -f "${T}${HELPDIR}/$$i" ]; then \
906		   echo "cannot uninstall ${T}${HELPDIR}/$$i"; \
907		else \
908		   echo "uninstalled ${T}${HELPDIR}/$$i"; \
909		fi; \
910	    fi; \
911	done
912	-${Q} for i in ${HELPDIR} ${CALC_SHAREDIR}; do \
913	    if [ -d "${T}$$i" ]; then \
914		${RMDIR} "${T}$$i" 2>/dev/null; \
915		echo "cleaned up ${T}$$i"; \
916	    fi; \
917	done
918