3 # help - makefile for calc help files
5 # Copyright (C) 1999-2006 Landon Curt Noll
7 # Calc is open software; you can redistribute it and/or modify it under
8 # the terms of the version 2.1 of the GNU Lesser General Public License
9 # as published by the Free Software Foundation.
11 # Calc is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 # Public License for more details.
16 # A copy of version 2.1 of the GNU Lesser General Public License is
17 # distributed with calc under the filename COPYING-LGPL. You should have
18 # received a copy with calc; if not, write to Free Software Foundation, Inc.
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 # @(#) $Revision: 30.5 $
22 # @(#) $Id: Makefile,v 30.5 2007/09/21 01:27:27 chongo Exp $
23 # @(#) $Source: /usr/local/src/cmd/calc/help/RCS/Makefile,v $
25 # Under source code control: 1991/07/23 06:47:57
26 # File existed as early as: 1991
28 # chongo <was here> /\oo/\ http://www.isthe.com/chongo/
29 # Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
31 # calculator by David I. Bell with help/mods from others
32 # Makefile by Landon Curt Noll
39 # Normally, the upper level makefile will set these values. We provide
40 # a default here just in case you want to build from this directory.
43 # Normally certain files depend on the Makefile. If the Makefile is
44 # changed, then certain steps should be redone. If MAKE_FILE is
45 # set to Makefile, then these files will depend on Makefile. If
46 # MAKE_FILE is empty, then they wont.
48 # If in doubt, set MAKE_FILE to Makefile
52 # Controlling file makefile basename (without the path)
54 # This is the basename same of the makefile that may/does/will drive
57 # If in doubt, set TOP_MAKE_FILE to Makefile
59 TOP_MAKE_FILE
= Makefile
61 # Where the system include (.h) files are kept
65 # INCDIR= /dev/env/DJDIR/include
69 # INCDIR= /usr/include
72 #INCDIR= /usr/local/include
73 #INCDIR= /dev/env/DJDIR/include
76 # where to install calc realted things
78 # ${BINDIR} where to install calc binary files
79 # ${LIBDIR} where calc link library (*.a) files are installed
80 # ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
82 # NOTE: The install rule prepends installation paths with ${T}, which
83 # by default is empty. If ${T} is non-empty, then installation
84 # locations will be relative to the ${T} directory.
88 # BINDIR= /dev/env/DJDIR/bin
89 # LIBDIR= /dev/env/DJDIR/lib
90 # CALC_SHAREDIR= /dev/env/DJDIR/share/calc
96 # CALC_SHAREDIR= /usr/share/calc
98 #BINDIR= /usr/local/bin
99 #BINDIR= /dev/env/DJDIR/bin
102 #LIBDIR= /usr/local/lib
103 #LIBDIR= /dev/env/DJDIR/lib
106 #CALC_SHAREDIR= /usr/local/lib/calc
107 #CALC_SHAREDIR= /dev/env/DJDIR/share/calc
108 CALC_SHAREDIR
= /usr
/share
/calc
110 # By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
111 # ---------------------------------------------------------------
112 # ${HELPDIR} where the help directory is installed
113 # ${CALC_INCDIR} where the calc include files are installed
114 # ${SCRIPTDIR} where calc shell scripts are installed
116 # NOTE: The install rule prepends installation paths with ${T}, which
117 # by default is empty. If ${T} is non-empty, then installation
118 # locations will be relative to the ${T} directory.
122 # HELPDIR= ${CALC_SHAREDIR}/help
123 # CALC_INCDIR= ${INCDIR}/calc
124 # SCRIPTDIR= ${BINDIR}/cscript
126 HELPDIR
= ${CALC_SHAREDIR}/help
127 CALC_INCDIR
= ${INCDIR}/calc
128 SCRIPTDIR
= ${BINDIR}/cscript
130 # T - top level directory under which calc will be installed
132 # The calc install is performed under ${T}, the calc build is
133 # performed under /. The purpose for ${T} is to allow someone
134 # to install calc somewhere other than into the system area.
140 # CALC_SHAREDIR= /usr/share/calc
144 # T= /var/tmp/testing
146 # Then the installation locations will be:
148 # calc binary files: /var/tmp/testing/usr/bin
149 # calc link library: /var/tmp/testing/usr/lib
150 # calc help, .cal ...: /var/tmp/testing/usr/share/calc
151 # ... etc ... /var/tmp/testing/...
153 # If ${T} is empty, calc is installed under /, which is the same
154 # top of tree for which it was built. If ${T} is non-empty, then
155 # calc is installed under ${T}, as if one had to chroot under
156 # ${T} for calc to operate.
158 # If in doubt, use T=
164 # Q=@ do not echo internal makefile actions (quiet mode)
165 # Q= echo internal makefile actions (debug / verbose mode)
189 # Some out of date operating systems require / want an executable to
190 # end with a certain file extension. Some compile systems such as
191 # Cygwin build calc as calc.exe. The EXT variable is used to denote
192 # the extension required by such.
194 # EXT= # normal Un*x / Linux / GNU/Linux systems
195 # EXT=.exe # windoz / Cygwin
197 # If in doubt, use EXT=
202 # Standard and Builtin help files
204 STD_HELP_FILES_1
= intro overview help
205 STD_HELP_FILES_2
= assoc
207 BLT_HELP_FILES_3
= builtin
209 STD_HELP_FILES_4
= command config custom
define environment expression
211 BLT_HELP_FILES_5
= errorcodes
213 STD_HELP_FILES_6
= file history interrupt list mat
215 # beacuse obj is built special (due to confusion with it as
216 # a symlink for some built environments, we treat obj specially
217 # and call it obj.file
219 SPECIAL_HELP_7
= obj.file
221 STD_HELP_FILES_8
= operator statement
223 BLT_HELP_FILES_9
= resource
225 STD_HELP_FILES_10
= types script
227 BLT_HELP_FILES_10a
= usage cscript
229 STD_HELP_FILES_10b
= unexpected variable
231 BLT_HELP_FILES_11
= bindings custom_cal libcalc new_custom resource
233 STD_HELP_FILES_12
= archive
235 BLT_HELP_FILES_13
= bugs changes
237 STD_HELP_FILES_14
= contrib credit
239 BLT_HELP_FILES_14
= COPYING COPYING-LGPL
241 STD_HELP_FILES_15
= wishlist todo
243 # These files are used in the following order to construct full
245 FULL_HELP_FILES
= ${STD_HELP_FILES_1} ${STD_HELP_FILES_2} \
246 ${BLT_HELP_FILES_3} ${STD_HELP_FILES_4} \
247 ${BLT_HELP_FILES_5} ${STD_HELP_FILES_6} \
248 ${SPECIAL_HELP_7} ${STD_HELP_FILES_8} \
249 ${BLT_HELP_FILES_9} ${STD_HELP_FILES_10} \
250 ${BLT_HELP_FILES_10a} ${STD_HELP_FILES_10b} \
251 ${BLT_HELP_FILES_11} ${STD_HELP_FILES_12} \
252 ${BLT_HELP_FILES_13} ${STD_HELP_FILES_14} \
253 ${BLT_HELP_FILES_14} ${STD_HELP_FILES_15}
255 # These full files are those who are not built or constrcuted
257 STD_HELP_FILES
= ${STD_HELP_FILES_1} ${STD_HELP_FILES_2} \
258 ${STD_HELP_FILES_4} ${STD_HELP_FILES_6} \
259 ${STD_HELP_FILES_8} ${STD_HELP_FILES_10} \
260 ${STD_HELP_FILES_10b} \
261 ${STD_HELP_FILES_12} ${STD_HELP_FILES_14} \
264 # These full files are those who are built by this Makefile
266 # Note that ${SPECIAL_HELP_7} is not included in this list
267 # because of problems with its name.
269 BLT_HELP_FILES
= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
270 ${BLT_HELP_FILES_9} \
271 ${BLT_HELP_FILES_10a} \
272 ${BLT_HELP_FILES_11} ${BLT_HELP_FILES_13} \
275 # This list is prodiced by the detaillist rule when no WARNINGS are detected.
281 # to keep this list in nice sorted order and to check that these
282 # non-special help files are under RCS control.
284 DETAIL_HELP
= abs access acos acosh acot acoth acsc acsch address agd append \
285 appr arg argv arrow asec asech asin asinh assign atan atan2 atanh \
286 avg base base2 bernoulli bit blk blkcpy blkfree blocks bround btrunc \
287 calc_tty calclevel calcpath catalan ceil cfappr cfsim char cmdbuf \
288 cmp comb conj cos cosh cot coth count cp csc csch ctime delete den \
289 dereference det digit digits display dp epsilon errcount errmax \
290 errno error estr euler eval exp fact factor fclose fcnt feof ferror \
291 fflush fgetc fgetfield fgetfile fgetline fgets fgetstr fib files \
292 floor fopen forall fpathopen fprintf fputc fputs fputstr frac free \
293 freebernoulli freeeuler freeglobals freeredc freestatics frem freopen \
294 fscan fscanf fseek fsize ftell gcd gcdrem gd getenv hash head highbit \
295 hmean hnrmod hypot ilog ilog10 ilog2 im indices inputlevel insert int \
296 inverse iroot isassoc isatty isblk isconfig isdefined iserror iseven \
297 isfile ishash isident isint islist ismat ismult isnull isnum isobj \
298 isobjtype isodd isprime isptr isqrt isrand israndom isreal isrel \
299 issimple issq isstr istype jacobi
join lcm lcmfact lfactor ln log \
300 lowbit ltol makelist matdim matfill matmax matmin matsum mattrace \
301 mattrans max memsize meq min minv mmin mne mod modify name near \
302 newerror nextcand nextprime norm null num oldvalue ord param perm \
303 pfact pi pix places pmod polar poly pop popcnt pound power prevcand \
304 prevprime printf prompt protect ptest push putenv quo quomod rand \
305 randbit random randombit randperm rcin rcmul rcout rcpow rcsq re \
306 remove reverse rewind
rm root round rsearch runtime saveval scale \
307 scan scanf search sec sech seed segment select sgn sha1 sin \
308 sinh size sizeof sleep
sort sqrt srand srandom ssq stoponerror \
309 str strcat strcmp strcpy strerror strlen strncmp strncpy strpos \
310 strprintf strscan strscanf substr sum swap system systime tail tan \
311 tanh
test time trunc usertime version xor
313 # This list is of files that are clones of DETAIL_HELP files. They are
314 # built from DETAIL_HELP files.
320 # These files are copies of their plural form.
322 PLURAL_FILES
= bindings bugs changes errorcodes types
323 SINGULAR_FILES
= binding bug change errorcode type
325 # These files are found (but not built) in the distribution
327 DISTLIST
= ${STD_HELP_FILES} ${DETAIL_HELP} ${MAKE_FILE} \
328 obj.file builtin.top builtin.end funclist.sed \
329 errorcodes.hdr errorcodes.sed
331 # These files are used to make (but not built) a calc .a link library
335 all: ${FULL_HELP_FILES} full
${DETAIL_HELP} ${DETAIL_CLONE} \
336 ${SINGULAR_FILES} .
all
338 # used by the upper level Makefile to determine of we have done all
340 # NOTE: Due to bogus shells found on one common system we must have
341 # an non-emoty else clause for every if condition. *sigh*
347 bindings
: ..
/cal
/bindings
349 ${CP} ..
/cal
/bindings
$@
351 -@if
[ -z
"${Q}" ]; then \
353 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
359 resource
: ..
/cal
/README
361 ${CP} ..
/cal
/README
$@
363 -@if
[ -z
"${Q}" ]; then \
365 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
375 -@if
[ -z
"${Q}" ]; then \
377 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
385 ${SED} -e
's:$${LIBDIR}:${LIBDIR}:g' \
386 -e
's:$${CALC_INCDIR}:${CALC_INCDIR}:g' < ..
/LIBRARY
> $@
388 -@if
[ -z
"${Q}" ]; then \
390 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
400 -@if
[ -z
"${Q}" ]; then \
402 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
408 errorcodes
: ..
/calcerr.h errorcodes.hdr errorcodes.sed
410 ${CAT} errorcodes.hdr
> $@
411 ${SED} -n
-f errorcodes.sed
< ..
/calcerr.h
>> $@
413 -@if
[ -z
"${Q}" ]; then \
415 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
423 ${CP} ..
/calc.usage
$@
425 -@if
[ -z
"${Q}" ]; then \
427 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
434 (cd ..
; ${MAKE} -f
${TOP_MAKE_FILE} calc.usage
)
436 custom_cal
: ..
/custom
/CUSTOM_CAL
438 ${CP} ..
/custom
/CUSTOM_CAL
$@
440 -@if
[ -z
"${Q}" ]; then \
442 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
448 new_custom
: ..
/custom
/HOW_TO_ADD
450 ${CP} ..
/custom
/HOW_TO_ADD
$@
452 -@if
[ -z
"${Q}" ]; then \
454 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
464 -@if
[ -z
"${Q}" ]; then \
466 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
476 -@if
[ -z
"${Q}" ]; then \
478 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
484 COPYING-LGPL
: ..
/COPYING-LGPL
486 ${CP} ..
/COPYING-LGPL
$@
488 -@if
[ -z
"${Q}" ]; then \
490 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
496 cscript
: ..
/cscript
/README
498 ${CP} ..
/cscript
/README
$@
500 -@if
[ -z
"${Q}" ]; then \
502 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
508 ..
/cscript
/README
: ..
/cscript
/README.src
509 ${Q} echo
"forming cscript/README"
511 (cd ..
/cscript
; ${MAKE} -f Makefile README
)
513 full
: ${FULL_HELP_FILES} ${MAKE_FILE}
514 ${Q} echo
"forming full"
516 -${Q} for i in
${FULL_HELP_FILES}; do \
517 if
[ Xintro
!= X
"$$i" ]; then \
522 if
[ Xobj.file
= X
"$$i" ]; then \
527 echo
"*************"; \
529 echo
"*************"; \
533 ${Q} echo
"full formed"
534 -@if
[ -z
"${Q}" ]; then \
536 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
542 # Singular files are the same files as their plural form.
544 ${SINGULAR_FILES}: ${PLURAL_FILES}
545 ${Q} for i in
${SINGULAR_FILES} /dev
/null
; do \
546 if
[ X
"$$i" != X
"/dev/null" ]; then \
547 echo
"${RM} -f $${i}"; \
549 echo
"${CP} $${i}s $${i}"; \
550 ${CP} $${i}s
$${i}; \
553 -@if
[ -z
"${Q}" ]; then \
555 echo
'=-=-= skipping the ${CAT} of help/SINGULAR_FILES =-=-='; \
561 # Form the builtin file
563 # We ave a "chicken-and-egg" problem. We want the builtn help file to
564 # accurately reflect the function list. It would be nice if we could
565 # just execute calc show builtin, but calc may not have been built or
566 # buildable at this point. The hack-a-round used is to convert ../func.c
567 # into a standalone program that generates a suitable function list
568 # that is standwiched between the top and bottom builtin help text.
570 # We form funclist.c by sedding out unwanted stuff from builtins table,
571 # converting NUMBER* and VALUE into harmless types and converting
572 # the showbuiltins() function into main(). Combined with the -DFUNCLIST
573 # we will avoid all of the complex calc types, macros and defines and
574 # be left with just main() and a mininal builtins table.
576 # Building funclist.o a portable fashion is ugly because some systems
577 # do not treat -I.. correctly!
579 builtin
: builtin.top builtin.end ..
/func.c funclist.sed
580 ${Q} echo
"forming builtin help file"
581 ${Q} ${RM} -f funclist.c
582 ${Q} ${SED} -n
-f funclist.sed ..
/func.c
> funclist.c
583 ${Q} ${RM} -f funclist.o funclist
${EXT}
584 ${Q} ${LCC} ${ICFLAGS} -DFUNCLIST
-I
/usr
/include \
585 -I.. funclist.c
-c
2>/dev
/null
586 ${Q} ${LCC} ${ILDFLAGS} funclist.o
-o funclist
${EXT}
587 ${Q} ${RM} -f builtin
588 ${Q} ${CAT} builtin.top
> builtin
589 ${Q} .
/funclist
${EXT} | \
590 ${SED} -e
's/^/ /' -e
's/[ ][ ]*$$//' >> builtin
591 ${Q} ${CAT} builtin.end
>> builtin
592 ${Q} echo
"builtin help file formed"
593 -@if
[ -z
"${Q}" ]; then \
595 echo
'=-=-= skipping the ${CAT} of help/$@ =-=-='; \
603 # File list generation. You can ignore this section.
606 # We will form the names of source files as if they were in a
607 # sub-directory called calc/help.
611 distlist
: ${DISTLIST}
612 ${Q} for i in
${DISTLIST} /dev
/null
; do \
613 if
[ X
"$$i" != X
"/dev/null" ]; then \
616 done | LANG
=C
${SORT}
622 ${Q} for i in
${CALCLIBLIST} /dev
/null
; do \
623 if
[ X
"$$i" != X
"/dev/null" ]; then \
628 # The BSDI cdrom makefile expects all help files to be pre-built. This rule
629 # creats these fils so that the release can be shipped off to BSDI. You can
636 # These next rule help me form the ${DETAIL_HELP} makefile variables above.
639 ${Q} -(echo
"xxxxx"; \
640 for i in
${DETAIL_HELP} /dev
/null
; do \
641 if
[ X
"$$i" != X
"/dev/null" ]; then \
642 if
[ ! -f RCS
/$$i,v
]; then \
643 echo
"WARNING: $$i not under RCS control" 1>&2; \
648 done | LANG
=C
${SORT}) |
${FMT} -70 | \
649 ${SED} -e
'1s/xxxxx/DETAIL_HELP=/' -e
'2,$$s/^/ /' \
650 -e
's/$$/ \\/' -e
'$$s/ \\$$//'
659 ${Q} for i in
${STD_HELP_FILES} full
${BLT_HELP_FILES} \
660 builtin
${DETAIL_HELP} ${SINGULAR_FILES} /dev
/null
; do \
661 if
[ X
"$$i" != X
"/dev/null" ]; then \
662 echo __file__
${HELPDIR}/$$i; \
665 ${Q} echo __file__
${HELPDIR}/obj
674 ${RM} -f obj mkbuiltin funclist.c funclist.o funclist
${EXT}
675 ${RM} -f COPYING COPYING-LGPL
678 ${RM} -f
${BLT_HELP_FILES} full .
all calc
679 ${RM} -f
${SINGULAR_FILES} ${DETAIL_CLONE}
683 # NOTE: Keep the uninstall rule in reverse order to the install rule
686 -${Q} if
[ ! -d
${T}${CALC_SHAREDIR} ]; then \
687 echo
${MKDIR} ${T}${CALC_SHAREDIR}; \
688 ${MKDIR} ${T}${CALC_SHAREDIR}; \
689 if
[ ! -d
"${T}${CALC_SHAREDIR}" ]; then \
690 echo
${MKDIR} -p
"${T}${CALC_SHAREDIR}"; \
691 ${MKDIR} -p
"${T}${CALC_SHAREDIR}"; \
693 echo
${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
694 ${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
698 -${Q} if
[ ! -d
${T}${HELPDIR} ]; then \
699 echo
${MKDIR} ${T}${HELPDIR}; \
700 ${MKDIR} ${T}${HELPDIR}; \
701 if
[ ! -d
"${T}${HELPDIR}" ]; then \
702 echo
${MKDIR} -p
"${T}${HELPDIR}"; \
703 ${MKDIR} -p
"${T}${HELPDIR}"; \
705 echo
${CHMOD} 0755 ${T}${HELPDIR}; \
706 ${CHMOD} 0755 ${T}${HELPDIR}; \
710 -${Q} for i in
${STD_HELP_FILES} ${BLT_HELP_FILES} builtin \
711 full
${DETAIL_HELP} ${SINGULAR_FILES} /dev
/null
; do \
712 if
[ "$$i" = "/dev/null" ]; then \
715 if
${CMP} -s
$$i ${T}${HELPDIR}/$$i; then \
718 ${RM} -f
${T}${HELPDIR}/$$i.new
; \
719 ${CP} -f
$$i ${T}${HELPDIR}/$$i.new
; \
720 ${CHMOD} 0444 ${T}${HELPDIR}/$$i.new
; \
721 ${MV} -f
${T}${HELPDIR}/$$i.new
${T}${HELPDIR}/$$i; \
722 echo
"installed ${T}${HELPDIR}/$$i"; \
725 -${Q} if
${CMP} -s obj.file
${T}${HELPDIR}/obj
; then \
728 ${RM} -f
${T}${HELPDIR}/obj.new
; \
729 ${CP} -f obj.file
${T}${HELPDIR}/obj.new
; \
730 ${CHMOD} 0444 ${T}${HELPDIR}/obj.new
; \
731 ${MV} -f
${T}${HELPDIR}/obj.new
${T}${HELPDIR}/obj
; \
732 echo
"installed ${T}${HELPDIR}/obj"; \
734 -${Q} if
[ -f
"${T}${HELPDIR}/sha" ]; then \
735 ${RM} -f
${T}${HELPDIR}/sha
; \
736 echo
"removed old ${T}${HELPDIR}/sha"; \
738 -${Q} if
[ -f
"${T}${HELPDIR}/md5" ]; then \
739 ${RM} -f
${T}${HELPDIR}/md5
; \
740 echo
"removed old ${T}${HELPDIR}/md5"; \
743 # Try to remove everything that was installed
745 # NOTE: Keep the uninstall rule in reverse order to the install rule
748 -${Q} if
[ -f
"${T}${HELPDIR}/obj" ]; then \
749 ${RM} -f
"${T}${HELPDIR}/obj"; \
750 if
[ -f
"${T}${HELPDIR}/obj" ]; then \
751 echo
"cannot uninstall ${T}${HELPDIR}/obj"; \
753 echo
"uninstalled ${T}${HELPDIR}/obj"; \
756 -${Q} for i in
${SINGULAR_FILES} ${DETAIL_HELP} full builtin \
757 ${BLT_HELP_FILES} ${STD_HELP_FILES} /dev
/null
; do \
758 if
[ "$$i" = "/dev/null" ]; then \
761 if
[ -f
"${T}${HELPDIR}/$$i" ]; then \
762 ${RM} -f
"${T}${HELPDIR}/$$i"; \
763 if
[ -f
"${T}${HELPDIR}/$$i" ]; then \
764 echo
"cannot uninstall ${T}${HELPDIR}/$$i"; \
766 echo
"uninstalled ${T}${HELPDIR}/$$i"; \
770 -${Q} for i in
${HELPDIR} ${CALC_SHAREDIR}; do \
771 if
[ -d
"${T}$$i" ]; then \
772 ${RMDIR} "${T}$$i" 2>/dev
/null
; \
773 echo
"cleaned up ${T}$$i"; \