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
|
SHELL = /bin/sh
CC ?= gcc
M4 ?= m4
INSTALL ?= install
INSTALL_PROGRAM ?= $(INSTALL)
INSTALL_DATA ?= $(INSTALL) -m 0644
CC_OPTIMIZE ?= -O3
VERSION = `cat VERSION`
OPTFLAGS ?= $(CC_OPTIMIZE) -Wall -Wshadow -Wno-char-subscripts
CFLAGS ?= $(OPTFLAGS)
CFLAGS += -fexceptions -DUNIX -DVERSION=\"$(VERSION)\"
LDLIBS += -lm # libraries to link with to create the Mathomatic executable
# Run "make READLINE=1" to include the optional readline editing and history support:
CFLAGS += $(READLINE:1=-DREADLINE)
LDLIBS += $(READLINE:1=-lreadline) # Add -lncurses if needed for readline, might be called "curses" on some systems.
# Uncomment the following line to force generation of x86-64-bit code:
#CFLAGS += -m64
# Install directories follow; installs everything in $(DESTDIR)/usr/local by default.
# Note that support for the DESTDIR variable was added in version 15.2.1.
# DESTDIR is used by package maintainers, who should remove all DESTDIR patches,
# because DESTDIR is handled properly (according to GNU standards) by this makefile now.
prefix ?= /usr/local
bindir ?= $(prefix)/bin
datadir ?= $(prefix)/share
mandir ?= $(prefix)/share/man
docdir ?= $(prefix)/share/doc
mathdocdir ?= $(docdir)/mathomatic
mathdatadir ?= $(datadir)/mathomatic
# Mathomatic program names:
AOUT ?= mathomatic
M4SCRIPTPATH = $(DESTDIR)$(bindir)/matho
INCLUDES = includes.h license.h standard.h am.h externs.h complex.h proto.h altproto.h
MATHOMATIC_OBJECTS += main.o globals.o am.o solve.o help.o parse.o cmds.o simplify.o \
factor.o super.o unfactor.o poly.o diff.o integrate.o \
complex.o complex_lib.o list.o gcd.o factor_int.o
PRIMES_MANHTML = doc/matho-primes.1.html doc/matho-pascal.1.html doc/matho-sumsq.1.html \
doc/primorial.1.html doc/matho-mult.1.html doc/matho-sum.1.html
# HTML man pages to make:
MANHTML = doc/mathomatic.1.html doc/rmath.1.html $(PRIMES_MANHTML)
# Flags to make HTML man pages with rman:
RMANOPTS = -f HTML -r '%s.%s.html'
RMAN = rman
# Flags to make HTML man pages with groff instead (uncomment below and comment above to use):
#RMANOPTS = -man -Thtml -P -l
#RMAN = groff
# man pages to install:
MAN1 = mathomatic.1 rmath.1
# Text files to install:
TEXT_DOCS ?= VERSION AUTHORS COPYING README.txt NEWS
PDFDOC = manual.pdf # Name of PDF file containing the Mathomatic User Guide.
PDFMAN = bookman.pdf # Name of PDF file containing all the Mathomatic man pages.
all static: $(AOUT) html # make these by default
# Make sure the HTML man pages are up-to-date.
html: $(MANHTML)
# Make the Quick Reference Card.
htmlcard doc/quickrefcard.html: $(AOUT)
./makehtmlcard.sh doc/
# Make the PDF cheat sheet.
pdfsheet quickref.pdf: $(AOUT)
./makepdfsheet.sh doc/
# TEST MATHOMATIC
# Run "make test" to see if the resulting mathomatic executable runs properly on your system.
# It does a diff between the output of the test and the expected output.
# If no differences are reported, "All tests passed" is displayed.
test:
@echo
@echo Testing ./$(AOUT)
cd tests && time -p ../$(AOUT) -t all 0<&- >test.out && diff -u --strip-trailing-cr all.out test.out && rm test.out && cd ..
@echo
@echo All tests passed.
# Same as "make test", except it doesn't run the time command.
check:
@echo
@echo Testing ./$(AOUT)
cd tests && ../$(AOUT) -t all 0<&- >test.out && diff -u --strip-trailing-cr all.out test.out && rm test.out && cd ..
@echo
@echo All tests passed.
# "make baseline" generates the expected output file for "make test".
# Do not run this unless you are sure Mathomatic is working correctly
# and you need "make test" to succeed with no errors.
baseline tests/all.out:
cd tests && ../$(AOUT) -t all 0<&- >all.out && cd ..
@rm -f tests/test.out
@echo
@echo File tests/all.out updated with current test output.
# BUILD MATHOMATIC
proto.h:
./update # Shell script to update proto.h using the cproto utility.
$(MATHOMATIC_OBJECTS): $(INCLUDES) VERSION
# To compile Mathomatic as a stand-alone executable
# that has no shared library dependencies, type "make clean static".
static: LDFLAGS += -static
# Create the mathomatic executable:
$(AOUT): $(MATHOMATIC_OBJECTS)
$(CC) $(LDFLAGS) $(CFLAGS) $+ $(LDLIBS) -o $(AOUT)
@echo
@echo ./$(AOUT) successfully created.
# BUILD THE MATHOMATIC DOCUMENTATION
# "make pdfdoc" creates the PDF version of the Mathomatic User Guide, if desired.
# Requires the htmldoc program be installed.
pdf pdfdoc $(PDFDOC): doc/manual.html doc/am.html doc/fdl-1.3-standalone.html
htmldoc --webpage --format pdf --linkstyle plain --no-links --title --logoimage icons/mathomatic.png --footer h1l --header "c d" -f $(PDFDOC) $+
@echo PDF documentation $(PDFDOC) generated.
# "make pdfman" creates a PDF of all the Mathomatic Man pages, if desired.
# Requires the very latest version of the txt2man package.
bookman pdfman $(PDFMAN): $(MAN1) primes/*.1 lib/*.3
bookman -p -t "Mathomatic version $(VERSION) Man Pages" -a "George Gesslein II" -d `date +%F` $+ >$(PDFMAN) </dev/null
@echo PDF man pages book created in $(PDFMAN)
# Here we convert the man pages to HTML docs with rman:
doc/mathomatic.1.html: mathomatic.1
@$(RMAN) --version $(RMANOPTS) >/dev/null # Test for existence of command.
$(RMAN) $(RMANOPTS) $< >$@
doc/rmath.1.html: rmath.1
@$(RMAN) --version $(RMANOPTS) >/dev/null # Test for existence of command.
$(RMAN) $(RMANOPTS) $< >$@
$(PRIMES_MANHTML): doc/%.1.html: primes/%.1
@$(RMAN) --version $(RMANOPTS) >/dev/null
$(RMAN) $(RMANOPTS) $< >$@
# INSTALL MATHOMATIC
# The following installs everything.
m4install: install matho-rmath-install
@echo
@echo m4 Mathomatic install completed.
@echo
# The following installs shell scripts matho and rmath,
# allowing convenient entry of standard math functions.
# Requires at least "make bininstall" first.
matho-rmath-install:
$(INSTALL) -d $(DESTDIR)$(mathdatadir)
$(INSTALL) -d $(DESTDIR)$(mathdatadir)/m4
echo '#!/bin/sh' >$(M4SCRIPTPATH)
echo '# Shell script to run Mathomatic with the GNU m4 preprocessor.' >>$(M4SCRIPTPATH)
echo '# This allows entry of many standard math functions.' >>$(M4SCRIPTPATH)
echo '#' >>$(M4SCRIPTPATH)
echo '# Usage: matho [ input_files ]' >>$(M4SCRIPTPATH)
echo >>$(M4SCRIPTPATH)
echo 'if ! $(M4) --version >/dev/null' >>$(M4SCRIPTPATH)
echo 'then' >>$(M4SCRIPTPATH)
echo ' echo The $(M4) package is not installed. GNU m4 is required to run m4 Mathomatic.' >>$(M4SCRIPTPATH)
echo ' exit 1' >>$(M4SCRIPTPATH)
echo 'fi' >>$(M4SCRIPTPATH)
echo >>$(M4SCRIPTPATH)
echo '$(M4) -eP -- $(mathdatadir)/m4/functions.m4 "$$@" - | mathomatic -ru -s-1' >>$(M4SCRIPTPATH)
chmod 0755 $(M4SCRIPTPATH)
$(INSTALL_PROGRAM) m4/rmath $(DESTDIR)$(bindir)
$(INSTALL_DATA) rmath.1 $(DESTDIR)$(mandir)/man1
cd $(DESTDIR)$(mandir)/man1 && ln -sf rmath.1 matho.1
$(INSTALL_DATA) m4/functions.m4 $(DESTDIR)$(mathdatadir)/m4
# Install m4 Mathomatic with trig functions that use degree units, instead of radians.
matho-rmath-install-degrees: matho-rmath-install
cat m4/degrees.m4 >>$(DESTDIR)$(mathdatadir)/m4/functions.m4
@echo Degree mode installed.
# Install complete m4 Mathomatic with trig functions that use degree units, instead of radians.
m4install-degrees: m4install
cat m4/degrees.m4 >>$(DESTDIR)$(mathdatadir)/m4/functions.m4
@echo Degree mode installed.
# Install the Mathomatic binaries and documentation. Does not install m4 Mathomatic.
install: bininstall docinstall
@echo
@echo Mathomatic is installed.
@echo
# Strip the binaries of their symbol tables. Makes smaller executables, but debugging becomes impossible.
strip: $(AOUT)
strip $(AOUT)
# Binaries only install.
bininstall:
$(INSTALL) -d $(DESTDIR)$(bindir)
$(INSTALL) -d $(DESTDIR)$(datadir)/applications
$(INSTALL) -d $(DESTDIR)$(datadir)/pixmaps
$(INSTALL) -d $(DESTDIR)$(mandir)/man1
$(INSTALL_PROGRAM) $(AOUT) $(DESTDIR)$(bindir)
$(INSTALL_DATA) icons/mathomatic.desktop $(DESTDIR)$(datadir)/applications
$(INSTALL_DATA) icons/mathomatic.png icons/mathomatic.xpm $(DESTDIR)$(datadir)/pixmaps
$(INSTALL_DATA) mathomatic.1 $(DESTDIR)$(mandir)/man1
# Documentation only install.
docinstall:
@echo Installing docs...
$(INSTALL) -d $(DESTDIR)$(mathdocdir)
$(INSTALL) -d $(DESTDIR)$(mathdocdir)/html
$(INSTALL) -d $(DESTDIR)$(mathdocdir)/tests
$(INSTALL) -d $(DESTDIR)$(mathdocdir)/examples
$(INSTALL_DATA) $(TEXT_DOCS) $(DESTDIR)$(mathdocdir)
$(INSTALL_DATA) doc/* $(DESTDIR)$(mathdocdir)/html
-$(INSTALL_DATA) *.pdf $(DESTDIR)$(mathdocdir)
$(INSTALL_DATA) tests/* $(DESTDIR)$(mathdocdir)/tests
$(INSTALL_DATA) examples/* $(DESTDIR)$(mathdocdir)/examples
# UNINSTALL MATHOMATIC
# Entirely remove Mathomatic from your local computer system.
uninstall:
cd $(DESTDIR)$(mandir)/man1 && rm -f $(MAN1) matho.1
cd $(DESTDIR)$(bindir) && rm -f $(AOUT) rmath matho
rm -rf $(DESTDIR)$(mathdocdir)
rm -rf $(DESTDIR)$(mathdatadir)
rm -f $(DESTDIR)$(datadir)/applications/mathomatic.desktop
rm -f $(DESTDIR)$(datadir)/pixmaps/mathomatic.*
@echo
@echo Mathomatic uninstall completed.
@echo
-$(MAKE) -C primes prefix=$(prefix) uninstall
@echo
-$(MAKE) -C lib prefix=$(prefix) uninstall
# CLEAN THIS DIRECTORY
clean:
rm -f *.o
rm -f */*.o */*.pyc */*.pyo
rm -f tests/test.out primes/test.out primes/bigtest.out
distclean: clean
rm -f *.a */*.a
rm -f $(AOUT)
rm -f mathomatic_secure
rm -f *.exe
rm -f *.pdf
$(MAKE) -C primes distclean
$(MAKE) -C lib distclean
maintainer-clean flush: distclean
rm -f $(MANHTML)
|