File: Makefile

package info (click to toggle)
calc 2.15.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,848 kB
  • sloc: ansic: 62,147; makefile: 7,664; sh: 503; awk: 74; sed: 7
file content (787 lines) | stat: -rw-r--r-- 22,281 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
#!/usr/bin/env make
#
# help - makefile for calc help files
#
# Copyright (C) 1999-2006,2017,2021-2023  Landon Curt Noll
#
# Suggestion: Read the ../HOWTO.INSTALL file.
#
# Calc is open software; you can redistribute it and/or modify it under
# the terms of the version 2.1 of the GNU Lesser General Public License
# as published by the Free Software Foundation.
#
# Calc is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.	See the GNU Lesser General
# Public License for more details.
#
# A copy of version 2.1 of the GNU Lesser General Public License is
# distributed with calc under the filename COPYING-LGPL.  You should have
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
# Under source code control:	1991/07/23 06:47:57
# File existed as early as:	1991
#
# This calculator first developed by David I. Bell with help/mods from others.
#
# chongo <was here> /\oo/\	http://www.isthe.com/chongo/
# Share and enjoy!  :-)		http://www.isthe.com/chongo/tech/comp/calc/


# SUGGESTION: Instead of modifying this file, consider adding
#	      statements to modify, replace or append Makefile
#	      variables in the ../Makefile.local file.


###########################################
# Files used or included by this Makefile #
###########################################

# Normally certain files depend on the Makefile.  If the Makefile is
# changed, then certain steps should be redone.  If MAKE_FILE is
# set to Makefile, then these files will depend on Makefile.  If
# MAKE_FILE is empty, then they won't.
#
# If in doubt, set MAKE_FILE to Makefile
#
MAKE_FILE= Makefile

# Calc configuration and compile configuration values
#
CONFIG_MKF= ../Makefile.config

# Host targets that are shared in common with both Makefile
# and custom/Makefile.
#
TARGET_MKF= ../Makefile.target

# Host target information.
#
LOCAL_MKF= ../Makefile.local

# The set of Makefiles
#
MK_SET= ${MAKE_FILE} ${CONFIG_MKF} ${TARGET_MKF} ${LOCAL_MKF}


#######################################################
# Calc configuration and compile configuration values #
#######################################################
include ${CONFIG_MKF}


###############################
# host target section include #
###############################
include ${TARGET_MKF}


##########################################################################
#=-=-=-=-=- Be careful if you change something below this line -=-=-=-=-=#
##########################################################################

# Makefile debug
#
# Q=@	do not echo internal Makefile actions (quiet mode)
# Q=	echo internal Makefile actions (debug / verbose mode)
#
# H=@:	do not report hsrc file formation progress
# H=@	do echo hsrc file formation progress
#
# S= >/dev/null 2>&1	silence ${CC} output during hsrc file formation
# S=			full ${CC} output during hsrc file formation
#
# E= 2>/dev/null	silence command stderr during hsrc file formation
# E=			full command stderr during hsrc file formation
#
# V=@:	do not echo debug statements (quiet mode)
# V=@	do echo debug statements (debug / verbose mode)
#
#Q=
Q=@
#
S= >/dev/null 2>&1
#S=
#
E= 2>/dev/null
#E=
#
#H=@:
H=@
#
V=@:
#V=@


##################################
# Files managed by this Makefile #
##################################

STD_HELP_FILES_1= intro overview
BLT_HELP_FILES_1a= calc

STD_HELP_FILES_2= assoc
BLT_HELP_FILES_3= builtin
STD_HELP_FILES_4= command config custom define environment
BLT_HELP_FILES_5= errorcodes
STD_HELP_FILES_6= expression file history interrupt list mat
# because obj is built special (due to confusion with it as
# a symlink for some built environments, we treat obj specially
# and call it obj.file
#
SPECIAL_HELP_7= obj.file
STD_HELP_FILES_8= operator
BLT_HELP_FILES_9= resource
STD_HELP_FILES_10= script statement types unexpected variable

BLT_HELP_FILES_11= bindings custom_cal libcalc new_custom cscript

STD_HELP_FILES_12= archive
BLT_HELP_FILES_13= bugs changes contrib
STD_HELP_FILES_14= todo wishlist

STD_HELP_FILES_15= credit
# copyright is printed by help.c is from the Copyright string found in version.c
BLT_HELP_FILES_16= COPYING COPYING-LGPL questions releases

STD_HELP_FILES_17= help

# These files are used in the following order to construct full
#
FULL_HELP_FILES= ${STD_HELP_FILES_1} ${BLT_HELP_FILES_1a} \
		 ${STD_HELP_FILES_2} \
		 ${BLT_HELP_FILES_3}  ${STD_HELP_FILES_4} \
		 ${BLT_HELP_FILES_5}  ${STD_HELP_FILES_6} \
		 ${SPECIAL_HELP_7}    ${STD_HELP_FILES_8} \
		 ${BLT_HELP_FILES_9}  ${STD_HELP_FILES_10} \
		 ${BLT_HELP_FILES_11} ${STD_HELP_FILES_12} \
		 ${BLT_HELP_FILES_13} ${STD_HELP_FILES_14} \
		 ${STD_HELP_FILES_15} ${BLT_HELP_FILES_16} \
		 ${STD_HELP_FILES_17}

# These full files are those who are not built or constructed
#
STD_HELP_FILES= ${STD_HELP_FILES_1}  ${STD_HELP_FILES_2} \
		${STD_HELP_FILES_4}  ${STD_HELP_FILES_6} \
		${STD_HELP_FILES_8}  ${STD_HELP_FILES_10} \
		${STD_HELP_FILES_12} ${STD_HELP_FILES_14} \
		${STD_HELP_FILES_15} ${STD_HELP_FILES_17}

# These full files are those who are built by this Makefile
#
# Note that ${SPECIAL_HELP_7} is not included in this list
# because of problems with its name.
#
BLT_HELP_FILES= ${BLT_HELP_FILES_1a} \
		${BLT_HELP_FILES_3}  ${BLT_HELP_FILES_5} \
		${BLT_HELP_FILES_9}  ${BLT_HELP_FILES_11} \
		${BLT_HELP_FILES_13} ${BLT_HELP_FILES_16}

# The detailed list of help files to install
#
# This list is produced by the detaillist rule when no WARNINGS are detected.
#
# Please use:
#
#	make clobber >/dev/null && make detail_help_list
#
# to keep this list in nice sorted order.
#
DETAIL_HELP= abs access acos acosh acot acoth acovercos acoversin \
	acrd acsc acsch address aexcsc aexsec agd ahacovercos ahacoversin \
	ahavercos ahaversin append appr arg argv arrow asec asech asin asinh \
	assign atan atan2 atanh avercos aversin avg base base2 bernoulli bit \
	blk blkcpy blkfree blocks bround btrunc calc_tty calclevel calcpath \
	cas catalan ceil cfappr cfsim char cis cmdbuf cmp comb conj cos cosh \
	cot coth count covercos coversin cp crd csc csch ctime d2dm d2dms d2g \
	d2r delete den dereference det digit digits display dms2d dp epsilon \
	errcount errmax errno error errsym estr euler eval excsc exp exsec \
	fact factor fclose fcnt feof ferror fflush fgetc fgetfield fgetfile \
	fgetline fgets fgetstr fib files floor fopen forall fpathopen fprintf \
	fputc fputs fputstr frac free freebernoulli freeeuler freeglobals \
	freeredc freestatics frem freopen fscan fscanf fseek fsize ftell g2d \
	g2gm g2gms g2r gcd gcdrem gd getenv gms2g h2hm h2hms hacovercos \
	hacoversin hash havercos haversin head highbit hmean hms2h hnrmod \
	hypot ilog ilog10 ilog2 im indices inputlevel insert int inverse iroot \
	isalnum isalpha isassoc isatty isblk iscntrl isconfig isdefined \
	isdigit iserror iseven isfile isgraph ishash isident isint islist \
	islower ismat ismult isnull isnum isobj isobjtype isodd isprime \
	isprint isptr ispunct isqrt isrand israndom isreal isrel issimple \
	isspace issq isstr istype isupper isxdigit jacobi join lcm lcmfact \
	lfactor ln log log2 logn lowbit ltol makelist matdim matfill matmax \
	matmin matsum mattrace mattrans max memsize meq min minv mmin mne mod \
	modify name near newerror nextcand nextprime norm null num oldvalue \
	ord param perm pfact pi pix places pmod polar poly pop popcnt pound \
	power prevcand prevprime printf prompt protect ptest push putenv quo \
	quomod r2d r2g rand randbit random randombit randperm rcin rcmul rcout \
	rcpow rcsq re remove reverse rewind rm root round rsearch runtime \
	saveval scale scan scanf search sec sech seed segment select sgn sha1 \
	sin sinh size sizeof sleep sort sqrt srand srandom ssq stoponerror str \
	strcasecmp strcat strcmp strcpy strerror strlen strncasecmp strncmp \
	strncpy strpos strprintf strscan strscanf strtolower strtoupper substr \
	sum swap system systime tail tan tanh test time trunc usertime vercos \
	versin version xor

# This list is of files that are clones of DETAIL_HELP files.  They are
# built from DETAIL_HELP files.
#
DETAIL_CLONE= copy ilogn

# Singular files
#
# These files are copies of their plural form.
#
PLURAL_FILES= bindings bugs changes errorcodes types
SINGULAR_FILES= binding bug change errorcode type

# These files are found (but not built) in the distribution
#
DISTLIST= ${STD_HELP_FILES} ${DETAIL_HELP} ${MAKE_FILE} \
	obj.file builtin.top builtin.end funclist.sed

# These files are used to make (but not built) a calc .a link library
#
CALCLIBLIST=

# complete list of files that may be created as part of the build process
#
# Used by chk_tree via make prep
#
BUILD_ALL= ${BLT_HELP_FILES} ${SINGULAR_FILES} ${DETAIL_CLONE} \
	   full funclist${EXT} funclist.c funclist.o

# rules that are not also names of files
#
PHONY= all distlist buildlist distdir calcliblist detail_help_list \
	echo_inst_files clean clobber install uninstall


############################################################
# Allow Makefile.local to change any of the above settings #
############################################################
include ${LOCAL_MKF}


###########################################
# all - First and default Makefile target #
###########################################

all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \
     ${SINGULAR_FILES} .all


###############################
# additional Makefile targets #
###############################

.PHONY: ${PHONY}

# used by the upper level Makefile to determine of we have done all
#
# NOTE: Due to bogus shells found on one common system we must have
#	an non-empty else clause for every if condition.  *sigh*
#
.all:
	${RM} -f .all
	${TOUCH} .all

bindings: ../cal/bindings
	${RM} -f $@
	${CP} ../cal/bindings $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

resource: ../cal/README
	${RM} -f $@
	${CP} ../cal/README $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

changes: ../CHANGES
	${RM} -f $@
	${CP} ../CHANGES $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

libcalc: ../LIBRARY
	${RM} -f $@
	${SED} -e 's:$${LIBDIR}:${LIBDIR}:g' \
	       -e 's:$${CALC_INCDIR}:${CALC_INCDIR}:g' < ../LIBRARY > $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

bugs: ../BUGS
	${RM} -f $@
	${CP} ../BUGS $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

contrib: ../CONTRIB-CODE
	${RM} -f $@
	${CP} ../CONTRIB-CODE $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

errorcodes: ../errcode${EXT}
	${RM} -f $@
	../errcode${EXT} -e > $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

calc: ../calc.usage
	${RM} -f $@
	${CP} ../calc.usage $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

../calc.usage:
	(cd ..; ${MAKE} -f ${MAKE_FILE} calc.usage)

custom_cal: ../custom/CUSTOM_CAL
	${RM} -f $@
	${CP} ../custom/CUSTOM_CAL $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

new_custom: ../custom/HOW_TO_ADD
	${RM} -f $@
	${CP} ../custom/HOW_TO_ADD $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

copy: blkcpy
	${RM} -f $@
	${CP} blkcpy $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

COPYING: ../COPYING
	${RM} -f $@
	${CP} ../COPYING $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

COPYING-LGPL: ../COPYING-LGPL
	${RM} -f $@
	${CP} ../COPYING-LGPL $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

questions: ../QUESTIONS
	${RM} -f $@
	${CP} ../QUESTIONS $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

cscript: ../cscript/README
	${RM} -f $@
	${CP} ../cscript/README $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

../cscript/README: ../cscript/README.src
	${Q} echo "forming cscript/README"
	${Q} ${RM} -f $@
	(cd ../cscript; ${MAKE} -f Makefile README)

releases: ../README.RELEASE
	${RM} -f $@
	${CP} ../README.RELEASE $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

ilogn: ilog
	${RM} -f $@
	${CP} ilog $@
	${CHMOD} 0444 $@
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

full: ${FULL_HELP_FILES} ${MAKE_FILE}
	${Q} echo "forming full"
	${Q} ${RM} -f $@
	-${Q} for i in ${FULL_HELP_FILES}; do \
	    if [ Xintro != X"$$i" ]; then \
		echo ""; \
	    else \
		${TRUE}; \
	    fi; \
	    if [ Xobj.file = X"$$i" ]; then \
		j=obj; \
	    else \
		j=$$i; \
	    fi; \
	    echo "*************"; \
	    echo "* $$j"; \
	    echo "*************"; \
	    echo ""; \
	    ${CAT} $$i; \
	done > $@
	${Q} echo "full formed"
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

# Singular files are the same files as their plural form.
#
${SINGULAR_FILES}: ${PLURAL_FILES}
	${Q} for i in ${SINGULAR_FILES} /dev/null; do \
	    if [ X"$$i" != X"/dev/null" ]; then \
		echo "${RM} -f $${i}"; \
		${RM} -f $${i}; \
		echo "${CP} $${i}s $${i}"; \
		${CP} $${i}s $${i}; \
	    fi; \
	done
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/SINGULAR_FILES =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

# Form the builtin file
#
# We have a "chicken-and-egg" problem.  We want the builtin help file to
# accurately reflect the function list.	 It would be nice if we could
# just execute calc show builtin, but calc may not have been built or
# build-able at this point.  The hack-a-round used is to convert ../func.c
# into a stand-alone program that generates a suitable function list
# that is sandwiched between the top and bottom builtin help text.
#
# We form funclist.c by sed-ing out unwanted stuff from builtins table,
# converting NUMBER* and VALUE into harmless types and converting
# the showbuiltins() function into main().  Combined with the -DFUNCLIST
# we will avoid all of the complex calc types, macros and defines and
# be left with just main() and a minimal builtins table.
#
# Building funclist.o a portable fashion is ugly because some systems
# do not treat -I.. correctly!
#
builtin: builtin.top builtin.end ../func.c funclist.sed
	${Q} echo "forming builtin help file"
	${Q} ${RM} -f funclist.c
	${Q} ${SED} -n -f funclist.sed ../func.c > funclist.c
	${Q} ${RM} -f funclist.o funclist${EXT}
	${Q} ${LCC} ${ICFLAGS} -DFUNCLIST -I/usr/include \
	    -I.. funclist.c -c ${S}
	${Q} ${LCC} ${ILDFLAGS} funclist.o -o funclist${EXT} ${S}
	${Q} ${RM} -f builtin
	${Q} ${GREP} -E -v '^#'  builtin.top > builtin
	${Q} ./funclist${EXT} | \
	    ${SED} -e 's/^/	/' -e 's/[	 ][	 ]*$$//' >> builtin
	${Q} ${CAT} builtin.end >> builtin
	${Q} echo "builtin help file formed"
	-@if [ -z "${Q}" ]; then \
	    echo ''; \
	    echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
	    echo ''; \
	else \
	    ${TRUE}; \
	fi

##
#
# File list generation.	 You can ignore this section.
#
#
# We will form the names of source files as if they were in a
# sub-directory called calc/help.
#
##

distlist: ${DISTLIST}
	${Q} for i in ${DISTLIST} /dev/null; do \
	    if [ X"$$i" != X"/dev/null" ]; then \
		echo help/$$i; \
	    fi; \
	done | fgrep -v '.bak' | LANG=C ${SORT}

buildlist:
	${Q} for i in ${BUILD_ALL} /dev/null; do \
	    if [ X"$$i" != X"/dev/null" ]; then \
		echo help/$$i; \
	    fi; \
	done | fgrep -v '.bak' | LANG=C ${SORT}

distdir:
	${Q} echo help

calcliblist:
	${Q} for i in ${CALCLIBLIST} /dev/null; do \
	    if [ X"$$i" != X"/dev/null" ]; then \
		echo help/$$i; \
	    fi; \
	done

# These next rule help form the ${DETAIL_HELP} makefile variables above.
#
# NOTE: The ${DETAIL_HELP} list does not include special help files.
#
detail_help_list:
	${Q} -(find .  -mindepth 1 -maxdepth 1 -type f \
	         ! -name Makefile ! -name '.Makefile.swp' \
		 ! -name archive ! -name assoc ! -name builtin.end \
		 ! -name builtin.top ! -name command ! -name config \
		 ! -name contrib ! -name credit ! -name custom ! -name define \
		 ! -name environment ! -name expression ! -name file \
		 ! -name funclist.c ! -name funclist.sed ! -name help \
		 ! -name history ! -name interrupt ! -name intro ! -name list \
		 ! -name mat ! -name obj.file ! -name operator \
		 ! -name overview ! -name script ! -name statement \
		 ! -name todo ! -name types ! -name unexpected \
		 ! -name variable ! -name wishlist ! -name questions \
		 -print | \
	   while read i; do \
		if [ X"$$i" != X"/dev/null" ]; then \
		    echo $$i; \
		fi; \
	done; \
	echo '--first_line--') | \
	    ${SED} -e 's:^\./::' | LANG=C ${SORT} | ${FMT} -70 | \
	    ${SED} -e '1s/--first_line--/DETAIL_HELP=/' -e '2,$$s/^/	/' \
		   -e 's/$$/ \\/' -e '$$s/ \\$$//'

##
#
# rpm rules
#
##

echo_inst_files:
	${Q} for i in ${STD_HELP_FILES} full ${BLT_HELP_FILES} \
		  builtin ${DETAIL_HELP} ${SINGULAR_FILES} /dev/null; do \
	    if [ X"$$i" != X"/dev/null" ]; then \
		echo __file__ ${HELPDIR}/$$i; \
	    fi; \
	done
	${Q} echo __file__ ${HELPDIR}/obj

##
#
# Utility rules
#
##

clean:
	${RM} -f obj mkbuiltin funclist.c funclist.o funclist${EXT}
	${RM} -f COPYING COPYING-LGPL questions

clobber: clean
	${RM} -f ${BLT_HELP_FILES} full .all calc man usage
	${RM} -f ${SINGULAR_FILES} ${DETAIL_CLONE}
	-${Q} if [ -e .DS_Store ]; then \
	    echo ${RM} -rf .DS_Store; \
	    ${RM} -rf .DS_Store; \
	fi

# install everything
#
# NOTE: Keep the uninstall rule in reverse order to the install rule
#
install: all
	-${Q} if [ ! -d ${T}${CALC_SHAREDIR} ]; then \
	    echo ${MKDIR} -p ${T}${CALC_SHAREDIR}; \
	    ${MKDIR} -p ${T}${CALC_SHAREDIR}; \
	    if [ ! -d "${T}${CALC_SHAREDIR}" ]; then \
		echo ${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
		${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
	    fi; \
	    echo ${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
	    ${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
	else \
	    ${TRUE}; \
	fi
	-${Q} if [ ! -d ${T}${HELPDIR} ]; then \
	    echo ${MKDIR} -p ${T}${HELPDIR}; \
	    ${MKDIR} -p ${T}${HELPDIR}; \
	    if [ ! -d "${T}${HELPDIR}" ]; then \
		echo ${MKDIR} -p "${T}${HELPDIR}"; \
		${MKDIR} -p "${T}${HELPDIR}"; \
	    fi; \
	    echo ${CHMOD} 0755 ${T}${HELPDIR}; \
	    ${CHMOD} 0755 ${T}${HELPDIR}; \
	else \
	    ${TRUE}; \
	fi
	-${Q} for i in ${STD_HELP_FILES} ${BLT_HELP_FILES} builtin \
		  full ${DETAIL_HELP} ${SINGULAR_FILES} /dev/null; do \
	    if [ "$$i" = "/dev/null" ]; then \
		continue; \
	    fi; \
	    if ${CMP} -s $$i ${T}${HELPDIR}/$$i; then \
		${TRUE}; \
	    else \
		${RM} -f ${T}${HELPDIR}/$$i.new; \
		${CP} -f $$i ${T}${HELPDIR}/$$i.new; \
		${CHMOD} 0444 ${T}${HELPDIR}/$$i.new; \
		${MV} -f ${T}${HELPDIR}/$$i.new ${T}${HELPDIR}/$$i; \
		echo "installed ${T}${HELPDIR}/$$i"; \
	    fi; \
	done
	-${Q} if ${CMP} -s obj.file ${T}${HELPDIR}/obj; then \
	    ${TRUE}; \
	else \
	    ${RM} -f ${T}${HELPDIR}/obj.new; \
	    ${CP} -f obj.file ${T}${HELPDIR}/obj.new; \
	    ${CHMOD} 0444 ${T}${HELPDIR}/obj.new; \
	    ${MV} -f ${T}${HELPDIR}/obj.new ${T}${HELPDIR}/obj; \
	    echo "installed ${T}${HELPDIR}/obj"; \
	fi
	-${Q} if [ -f "${T}${HELPDIR}/sha" ]; then \
	    ${RM} -f ${T}${HELPDIR}/sha; \
	    echo "removed old ${T}${HELPDIR}/sha"; \
	fi;
	-${Q} if [ -f "${T}${HELPDIR}/md5" ]; then \
	    ${RM} -f ${T}${HELPDIR}/md5; \
	    echo "removed old ${T}${HELPDIR}/md5"; \
	fi;
	-${Q} if [ -f "${T}${HELPDIR}/man" ]; then \
	    ${RM} -f ${T}${HELPDIR}/man; \
	    echo "removed old ${T}${HELPDIR}/man"; \
	fi;
	-${Q} if [ -f "${T}${HELPDIR}/usage" ]; then \
	    ${RM} -f ${T}${HELPDIR}/usage; \
	    echo "removed old ${T}${HELPDIR}/usage"; \
	fi;

# Try to remove everything that was installed
#
# NOTE: Keep the uninstall rule in reverse order to the install rule
#
uninstall:
	-${Q} if [ -f "${T}${HELPDIR}/obj" ]; then \
	    ${RM} -f "${T}${HELPDIR}/obj"; \
	    if [ -f "${T}${HELPDIR}/obj" ]; then \
		echo "cannot uninstall ${T}${HELPDIR}/obj"; \
	    else \
		echo "uninstalled ${T}${HELPDIR}/obj"; \
	    fi; \
	fi
	-${Q} for i in ${SINGULAR_FILES} ${DETAIL_HELP} full builtin \
	    ${BLT_HELP_FILES} ${STD_HELP_FILES} /dev/null; do \
	    if [ "$$i" = "/dev/null" ]; then \
		continue; \
	    fi; \
	    if [ -f "${T}${HELPDIR}/$$i" ]; then \
		${RM} -f "${T}${HELPDIR}/$$i"; \
		if [ -f "${T}${HELPDIR}/$$i" ]; then \
		   echo "cannot uninstall ${T}${HELPDIR}/$$i"; \
		else \
		   echo "uninstalled ${T}${HELPDIR}/$$i"; \
		fi; \
	    fi; \
	done
	-${Q} for i in ${HELPDIR} ${CALC_SHAREDIR}; do \
	    if [ -d "${T}$$i" ]; then \
		${RMDIR} "${T}$$i" 2>/dev/null; \
		echo "cleaned up ${T}$$i"; \
	    fi; \
	done