2 # cscript - makefile for calc shell script files
4 # Copyright (C) 1999-2006 Landon Curt Noll
6 # Calc is open software; you can redistribute it and/or modify it under
7 # the terms of the version 2.1 of the GNU Lesser General Public License
8 # as published by the Free Software Foundation.
10 # Calc is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 # Public License for more details.
15 # A copy of version 2.1 of the GNU Lesser General Public License is
16 # distributed with calc under the filename COPYING-LGPL. You should have
17 # received a copy with calc; if not, write to Free Software Foundation, Inc.
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # @(#) $Revision: 30.4 $
21 # @(#) $Id: Makefile,v 30.4 2013/08/11 08:41:38 chongo Exp $
22 # @(#) $Source: /usr/local/src/bin/calc/cscript/RCS/Makefile,v $
24 # Under source code control: 1999/11/29 11:10:26
25 # File existed as early as: 1999
27 # chongo <was here> /\oo/\ http://www.isthe.com/chongo/
28 # Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
30 # calculator by David I. Bell with help/mods from others
31 # 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)
186 # The ${SCRIPT} list is the list of calc shell script files (without the .calc
187 # extension) which will be installed.
189 # The ${SCRIPT_SRC} is built from ${SCRIPT} and has the .calc extensions.
191 # This list is produced by the detaillist rule when no WARNINGS are detected.
194 # 1) Name the file with a .calc filename extension
195 # 2) Place that file under RCS control
196 # 3) Add the name, without the .calc extension to the ${SCRIPT} below
197 # 4) Write out this Makefile
198 # 5) Replace the ${SCRIPT} and ${SCRIPT_SRC} lines with the output of:
202 SCRIPT
= 4dsphere fproduct mersenne piforever plus powerterm \
205 SCRIPT_SRC
= 4dsphere.calc fproduct.calc mersenne.calc \
206 piforever.calc plus.calc powerterm.calc simple.calc square.calc
208 # These files are found (but not built) in the distribution
210 DISTLIST
= ${SCRIPT_SRC} ${MAKE_FILE} README.src
212 # These files are used to make (but not build) a calc .a library
216 # complete list of targets
218 # NOTE: This list MUST be coordinated with the ${CSCRIPT_TARGETS} variable
219 # in the upper level ../Makefile
221 CSCRIPT_TARGETS
= ${SCRIPT}
222 TARGETS
= ${CSCRIPT_TARGETS} README
224 # The reason for this Makefile
230 @
${SED} -e
"s:#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?
>$@
232 # used by the upper level Makefile to determine if we have done all
234 # NOTE: Due to bogus shells found on one common system we must have
235 # a non-empty else clause for every if condition. *sigh*
243 # File list generation. You can ignore this section.
246 # We will form the names of source files as if they were in a
247 # sub-directory called calc/cscript.
251 distlist
: ${DISTLIST}
252 ${Q} for i in
${DISTLIST} /dev
/null
; do \
253 if
[ X
"$$i" != X
"/dev/null" ]; then \
256 done | LANG
=C
${SORT}
263 # These next rule help me form the ${SCRIPT} and ${SCRIPT_SRC} makefile
267 ${Q} -(echo
"xxxxxxx"; \
268 for i in
${SCRIPT} /dev
/null
; do \
269 if
[ X
"$$i" != X
"/dev/null" ]; then \
270 if
[ ! -f RCS
/$$i.calc
,v
]; then \
271 echo
"WARNING: $$i.calc not under RCS control" 1>&2; \
276 done | LANG
=C
${SORT}) |
${FMT} -70 | \
277 ${SED} -e
'1s/xxxxxxx/SCRIPT=/' -e
'2,$$s/^/ /' \
278 -e
's/$$/ \\/' -e
'$$s/ \\$$//'
280 ${Q} -(echo
"xxxxxxxxxxx"; \
281 for i in
${SCRIPT} /dev
/null
; do \
282 if
[ X
"$$i" != X
"/dev/null" ]; then \
283 if
[ ! -f RCS
/$$i.calc
,v
]; then \
284 echo
"WARNING: $$i.calc not under RCS control" 1>&2; \
289 done | LANG
=C
${SORT}) |
${FMT} -70 | \
290 ${SED} -e
'1s/xxxxxxxxxxx/SCRIPT_SRC=/' -e
'2,$$s/^/ /' \
291 -e
's/$$/ \\/' -e
'$$s/ \\$$//'
295 # Home grown make dependency rules. Your system make not support
296 # or have the needed tools. You can ignore this section.
298 # We will form a skelaton tree of *.c files containing only #include "foo.h"
299 # lines and .h files containing the same lines surrounded by multiple include
300 # prevention lines. This allows us to build a static depend list that will
301 # satisfy all possible cpp symbol definition combinations.
306 ${Q} if
[ -f
${MAKE_FILE}.bak
]; then \
307 echo
"${MAKE_FILE}.bak exists, remove or move it"; \
312 ${Q} ${RM} -f makedep.out
313 ${Q} echo forming cscript dependency list
314 ${Q} for i in
${SCRIPT} /dev
/null
; do \
315 if
[ X
"$$i" != X
"/dev/null" ]; then \
316 echo
"$$i: $$i.calc"; \
317 echo
' @$${RM} -f $$@'; \
318 echo
-n
' @$${SED} -e "1s:'; \
319 echo
"^#!/usr/local/src/cmd/calc/calc:#!$${BINDIR}/calc:" \
321 echo ' @
$${CHMOD} +x
$$@
'; \
324 ${Q} echo sample dependency list formed
325 ${Q} echo forming new cscript/${MAKE_FILE}
326 ${Q} ${RM} -f ${MAKE_FILE}.bak
327 ${Q} ${MV} ${MAKE_FILE} ${MAKE_FILE}.bak
328 ${Q} ${SED} -n '1,/^
# DO NOT DELETE THIS LINE/p' \
329 ${MAKE_FILE}.bak
> ${MAKE_FILE}
330 ${Q} echo
"" >> ${MAKE_FILE}
331 ${Q} ${CAT} makedep.out
>> ${MAKE_FILE}
332 ${Q} ${RM} -f makedep.out
333 -${Q} if
${CMP} -s
${MAKE_FILE}.bak
${MAKE_FILE}; then \
334 echo
'sample ${MAKE_FILE} was already up to date'; \
335 ${MV} -f
${MAKE_FILE}.bak
${MAKE_FILE}; \
337 ${RM} -f
${MAKE_FILE}.tmp
; \
338 ${MV} ${MAKE_FILE} ${MAKE_FILE}.tmp
; \
339 if
[ -d RCS
-a
! -w
"${MAKE_FILE}" ]; then \
340 ${CO} -l
${MAKE_FILE}; \
342 ${MV} ${MAKE_FILE}.tmp
${MAKE_FILE}; \
343 if
[ -d RCS
]; then \
344 echo
'*****************************************************'; \
345 echo
'new sample ${MAKE_FILE} formed -- need to check it in'; \
346 echo
'*****************************************************'; \
357 ${Q} for i in
${SCRIPT} /dev
/null
; do \
358 if
[ X
"$$i" != X
"/dev/null" ]; then \
359 echo __file__
${SCRIPTDIR}/$$i; \
378 # NOTE: Keep the uninstall rule in reverse order to the install rule
381 -${Q} if
[ ! -d
${T}${BINDIR} ]; then \
382 echo
${MKDIR} ${T}${BINDIR}; \
383 ${MKDIR} ${T}${BINDIR}; \
384 if
[ ! -d
"${T}${BINDIR}" ]; then \
385 echo
${MKDIR} -p
"${T}${BINDIR}"; \
386 ${MKDIR} -p
"${T}${BINDIR}"; \
388 echo
${CHMOD} 0755 ${T}${BINDIR}; \
389 ${CHMOD} 0755 ${T}${BINDIR}; \
393 -${Q} if
[ ! -d
${T}${SCRIPTDIR} ]; then \
394 echo
${MKDIR} ${T}${SCRIPTDIR}; \
395 ${MKDIR} ${T}${SCRIPTDIR}; \
396 if
[ ! -d
"${T}${SCRIPTDIR}" ]; then \
397 echo
${MKDIR} -p
"${T}${SCRIPTDIR}"; \
398 ${MKDIR} -p
"${T}${SCRIPTDIR}"; \
400 echo
${CHMOD} 0755 ${T}${SCRIPTDIR}; \
401 ${CHMOD} 0755 ${T}${SCRIPTDIR}; \
405 ${Q} for i in
${SCRIPT} /dev
/null
; do \
406 if
[ "$$i" = "/dev/null" ]; then \
409 if
${CMP} -s
$$i ${T}${SCRIPTDIR}/$$i; then \
412 ${RM} -f
${T}${SCRIPTDIR}/$$i.new
; \
413 ${CP} -f
$$i ${T}${SCRIPTDIR}/$$i.new
; \
414 ${CHMOD} 0755 ${T}${SCRIPTDIR}/$$i.new
; \
415 ${MV} -f
${T}${SCRIPTDIR}/$$i.new
${T}${SCRIPTDIR}/$$i; \
416 echo
"installed ${T}${SCRIPTDIR}/$$i"; \
420 # Try to remove everything that was installed
422 # NOTE: Keep the uninstall rule in reverse order to the install rule
425 -${Q} for i in
${SCRIPT} /dev
/null
; do \
426 if
[ "$$i" = "/dev/null" ]; then \
429 if
[ -f
"${T}${SCRIPTDIR}/$$i" ]; then \
430 ${RM} -f
"${T}${SCRIPTDIR}/$$i"; \
431 if
[ -f
"${T}${SCRIPTDIR}/$$i" ]; then \
432 echo
"cannot uninstall ${T}${SCRIPTDIR}/$$i"; \
434 echo
"uninstalled ${T}${SCRIPTDIR}/$$i"; \
438 -${Q} for i in
${SCRIPTDIR} ${BINDIR}; do \
439 if
[ -d
"${T}$$i" ]; then \
440 ${RMDIR} "${T}$$i" 2>/dev
/null
; \
441 echo
"cleaned up ${T}$$i"; \
445 # DO NOT DELETE THIS LINE -- make depend depends on it.
447 4dsphere
: 4dsphere.calc
449 @
${SED} -e
"1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?
>$@
451 fproduct
: fproduct.calc
453 @
${SED} -e
"1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?
>$@
455 mersenne
: mersenne.calc
457 @
${SED} -e
"1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?
>$@
459 piforever
: piforever.calc
461 @
${SED} -e
"1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?
>$@
465 @
${SED} -e
"1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?
>$@
467 powerterm
: powerterm.calc
469 @
${SED} -e
"1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?
>$@
473 @
${SED} -e
"1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?
>$@
477 @
${SED} -e
"1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?
>$@