| 1 |
# Makefile for compiling, testing, and installing Mathomatic and its documentation. |
| 2 |
# Requires the GNU make utility, in BSD Unix this is called "gmake". |
| 3 |
# Remove the -DUNIX define in CFLAGS when not using Mathomatic for desktop UNIX/Linux. |
| 4 |
|
| 5 |
# For normal compilation and testing on a GNU system, |
| 6 |
# please type the following at the shell prompt: |
| 7 |
# make clean |
| 8 |
# make READLINE=1 |
| 9 |
# make test |
| 10 |
# |
| 11 |
# For Slackware, or any other OS that fails to find the curses library functions, use: |
| 12 |
# LDLIBS=-lncurses make READLINE=1 |
| 13 |
# for the second make line. |
| 14 |
# |
| 15 |
# To use the Tiny C Compiler (tcc) to compile Mathomatic: |
| 16 |
# make clean |
| 17 |
# CC=tcc LDFLAGS="-L/usr/lib/x86_64-linux-gnu/ -L/lib/x86_64-linux-gnu/" make READLINE=1 |
| 18 |
# make test |
| 19 |
# The -L options might need to be set to the library directories your current gcc uses, |
| 20 |
# as the above example shows. |
| 21 |
# They will probably differ from the above, try "locate libm." to find your library paths, |
| 22 |
# one or two of them will probably work. |
| 23 |
|
| 24 |
# To install the base Mathomatic system after compiling and testing, type: |
| 25 |
# make install |
| 26 |
# if that doesn't work, try: |
| 27 |
# sudo make install |
| 28 |
# and enter your password. This is because write permission is required to /usr/local/*. |
| 29 |
# |
| 30 |
# To install all of Mathomatic, including m4 Mathomatic (rmath), instead type: |
| 31 |
# make m4install |
| 32 |
# or: |
| 33 |
# sudo make m4install |
| 34 |
|
| 35 |
# To compile, test, and install all of Mathomatic under CygWin for MS-Windows: |
| 36 |
# CFLAGS="-DCYGWIN -DBOLD_COLOR -O3" make READLINE=1 |
| 37 |
# make test |
| 38 |
# make m4install |
| 39 |
|
| 40 |
# To compile Mathomatic with the MinGW cross-compiler for MS-Windows under Debian or Ubuntu: |
| 41 |
# sudo apt-get install gcc-mingw32 |
| 42 |
# ./compile.mingw |
| 43 |
# This will create Windows executables for Mathomatic and the Prime Number Tools. |
| 44 |
# For cross-compiling under other systems, just edit "compile.mingw". |
| 45 |
|
| 46 |
# To compile, test, and install all of Mathomatic under OpenIndiana (SunOS), type: |
| 47 |
# LDLIBS=-lcurses make READLINE=1 |
| 48 |
# make test |
| 49 |
# sudo make m4install INSTALL=ginstall prefix=/usr M4=gm4 |
| 50 |
|
| 51 |
# This makefile does NOT compile and install the Prime Number Tools in the "primes" directory, |
| 52 |
# nor does it compile and install the Symbolic Math Library in the "lib" directory. |
| 53 |
# sudo make uninstall |
| 54 |
# here will uninstall all of Mathomatic, |
| 55 |
# including the Prime Number Tools and the Symbolic Math Library, |
| 56 |
# but it must know the "prefix" used to install Mathomatic, if specified during the install. |
| 57 |
|
| 58 |
SHELL = /bin/sh # from "http://www.gnu.org/prep/standards/", do not change |
| 59 |
CC ?= gcc # C compiler to use; this statement doesn't work usually, instead using cc. |
| 60 |
M4 ?= m4 # Change this to gm4 in Unix or a non-GNU system. |
| 61 |
INSTALL ?= install # Installer utility to use; change to ginstall under Unix. |
| 62 |
INSTALL_PROGRAM ?= $(INSTALL) # Command to install executable program files. |
| 63 |
INSTALL_DATA ?= $(INSTALL) -m 0644 # Command to install data files. |
| 64 |
|
| 65 |
CC_OPTIMIZE ?= -O3 # Default C compiler optimization flags that are safe (but please remove for LLVM/Clang, see "misc/known_bugs.txt"). |
| 66 |
# Be sure and run tests to see if Mathomatic works and runs faster, if you uncomment the following line: |
| 67 |
#CC_OPTIMIZE += -fno-signaling-nans -fno-trapping-math -fomit-frame-pointer # Possible additional optimizations, not tested. |
| 68 |
|
| 69 |
VERSION = `cat VERSION` |
| 70 |
OPTFLAGS ?= $(CC_OPTIMIZE) -Wall -Wshadow -Wno-char-subscripts # optional gcc specific flags |
| 71 |
CFLAGS ?= $(OPTFLAGS) |
| 72 |
CFLAGS += -fexceptions -DUNIX -DVERSION=\"$(VERSION)\" |
| 73 |
LDLIBS += -lm # libraries to link with to create the Mathomatic executable |
| 74 |
|
| 75 |
# Run "make READLINE=1" to include the optional readline editing and history support: |
| 76 |
CFLAGS += $(READLINE:1=-DREADLINE) |
| 77 |
LDLIBS += $(READLINE:1=-lreadline) # Add -lncurses if needed for readline, might be called "curses" on some systems. |
| 78 |
# Run "make EDITLINE=1" to include the optional editline editing and history support (smaller than readline): |
| 79 |
CFLAGS += $(EDITLINE:1=-DEDITLINE) |
| 80 |
LDLIBS += $(EDITLINE:1=-leditline) |
| 81 |
|
| 82 |
# Uncomment the following line to force generation of x86-64-bit code: |
| 83 |
#CFLAGS += -m64 |
| 84 |
|
| 85 |
# Install directories follow; installs everything in $(DESTDIR)/usr/local by default. |
| 86 |
# Note that support for the DESTDIR variable was added in version 15.2.1. |
| 87 |
# DESTDIR is used by package maintainers, who should remove all DESTDIR patches, |
| 88 |
# because DESTDIR is handled properly (according to GNU standards) by this makefile now. |
| 89 |
prefix ?= /usr/local |
| 90 |
bindir ?= $(prefix)/bin |
| 91 |
datadir ?= $(prefix)/share |
| 92 |
mandir ?= $(prefix)/share/man |
| 93 |
docdir ?= $(prefix)/share/doc |
| 94 |
mathdocdir ?= $(docdir)/mathomatic |
| 95 |
mathdatadir ?= $(datadir)/mathomatic |
| 96 |
|
| 97 |
# Mathomatic program names: |
| 98 |
AOUT ?= mathomatic |
| 99 |
M4SCRIPTPATH = $(DESTDIR)$(bindir)/matho |
| 100 |
|
| 101 |
INCLUDES = includes.h license.h standard.h am.h externs.h blt.h complex.h proto.h altproto.h |
| 102 |
MATHOMATIC_OBJECTS += main.o globals.o am.o solve.o help.o parse.o cmds.o simplify.o \ |
| 103 |
factor.o super.o unfactor.o poly.o diff.o integrate.o \ |
| 104 |
complex.o complex_lib.o list.o gcd.o factor_int.o |
| 105 |
|
| 106 |
PRIMES_MANHTML = doc/matho-primes.1.html doc/matho-pascal.1.html doc/matho-sumsq.1.html \ |
| 107 |
doc/primorial.1.html doc/matho-mult.1.html doc/matho-sum.1.html |
| 108 |
# HTML man pages to make: |
| 109 |
MANHTML = doc/mathomatic.1.html doc/rmath.1.html $(PRIMES_MANHTML) |
| 110 |
|
| 111 |
# Flags to make HTML man pages with rman: |
| 112 |
RMANOPTS = -f HTML -r '%s.%s.html' |
| 113 |
RMAN = rman |
| 114 |
# Flags to make HTML man pages with groff instead (uncomment below and comment above to use): |
| 115 |
#RMANOPTS = -man -Thtml -P -l |
| 116 |
#RMAN = groff |
| 117 |
|
| 118 |
# man pages to install: |
| 119 |
MAN1 = mathomatic.1 rmath.1 |
| 120 |
# Text files to install: |
| 121 |
TEXT_DOCS ?= VERSION AUTHORS COPYING README.txt NEWS |
| 122 |
|
| 123 |
PDFDOC = manual.pdf # Name of PDF file containing the Mathomatic User Guide and Command Reference. |
| 124 |
PDFMAN = bookman.pdf # Name of PDF file containing all the Mathomatic man pages. |
| 125 |
|
| 126 |
all static: $(AOUT) html NEWS # make these by default |
| 127 |
|
| 128 |
# Make sure the HTML man pages are up-to-date. |
| 129 |
html: $(MANHTML) |
| 130 |
|
| 131 |
# Make the Quick Reference Card. |
| 132 |
htmlcard doc/quickrefcard.html: $(AOUT) |
| 133 |
./makehtmlcard.sh doc/ # shell script that uses awk to make a nice command reference card |
| 134 |
|
| 135 |
# Make the PDF cheat sheet. |
| 136 |
pdfsheet quickref.pdf: $(AOUT) |
| 137 |
./makepdfsheet.sh doc/ # shell script |
| 138 |
|
| 139 |
# TEST MATHOMATIC |
| 140 |
|
| 141 |
# Run "make test" to see if the resulting mathomatic executable runs properly on your system. |
| 142 |
# It does a diff between the output of the test and the expected output. |
| 143 |
# If no differences are reported, "All tests passed 100% correctly" is displayed. |
| 144 |
test: |
| 145 |
@echo |
| 146 |
@echo Testing ./$(AOUT) \(`./$(AOUT) -v`\) |
| 147 |
cd tests && time -p ../$(AOUT) -t all 0<&- >test.out && diff -u --strip-trailing-cr all.out test.out && rm test.out && cd .. |
| 148 |
@echo "All tests passed 100% correctly." |
| 149 |
|
| 150 |
# Same as "make test", except it doesn't run the time command. |
| 151 |
check: |
| 152 |
@echo |
| 153 |
@echo Testing ./$(AOUT) \(`./$(AOUT) -v`\) |
| 154 |
cd tests && ../$(AOUT) -t all 0<&- >test.out && diff -u --strip-trailing-cr all.out test.out && rm test.out && cd .. |
| 155 |
@echo "All tests passed 100% correctly." |
| 156 |
|
| 157 |
# "make baseline" generates the expected output file for "make test". |
| 158 |
# Do not run this unless you are sure Mathomatic is working correctly |
| 159 |
# and you need "make test" to succeed with no errors. |
| 160 |
baseline tests/all.out: |
| 161 |
cd tests && ../$(AOUT) -t all 0<&- >all.out && cd .. |
| 162 |
@rm -f tests/test.out |
| 163 |
@echo |
| 164 |
@echo File tests/all.out updated with current test output. |
| 165 |
|
| 166 |
# BUILD MATHOMATIC |
| 167 |
|
| 168 |
# ./update updates the function prototypes in proto.h by using the cproto utility. |
| 169 |
# Run ./update whenever a new C function is added to the Mathomatic source code or |
| 170 |
# whenever a function definition is changed. |
| 171 |
proto.h: |
| 172 |
./update # shell script |
| 173 |
|
| 174 |
$(MATHOMATIC_OBJECTS): $(INCLUDES) VERSION |
| 175 |
|
| 176 |
# To compile Mathomatic as a stand-alone executable |
| 177 |
# that has no shared library dependencies, type "make clean static". |
| 178 |
static: LDFLAGS += -static |
| 179 |
|
| 180 |
# Create the mathomatic executable: |
| 181 |
$(AOUT): $(MATHOMATIC_OBJECTS) |
| 182 |
$(CC) $(CFLAGS) $(LDFLAGS) $+ $(LDLIBS) -o $(AOUT) |
| 183 |
@echo |
| 184 |
@echo ./$(AOUT) successfully created. |
| 185 |
|
| 186 |
# BUILD THE MATHOMATIC DOCUMENTATION |
| 187 |
|
| 188 |
# Build the nicely ordered changelog. |
| 189 |
NEWS: changes.txt makenews.sh |
| 190 |
./makenews.sh # shell script |
| 191 |
|
| 192 |
# "make pdfdoc" creates the PDF version of the Mathomatic User Guide and Command Reference, if desired. |
| 193 |
# Requires the htmldoc program be installed. |
| 194 |
pdf pdfdoc $(PDFDOC): doc/manual.html doc/am.html doc/fdl-1.3-standalone.html |
| 195 |
htmldoc --webpage --format pdf --title --logoimage icons/mathomatic.png --footer h1l --header "c d" -f $(PDFDOC) $+ |
| 196 |
@echo Mathomatic PDF user documentation $(PDFDOC) generated. |
| 197 |
|
| 198 |
# "make pdfman" creates a PDF of all the Mathomatic Man pages, if desired. |
| 199 |
# Requires the very latest version of the txt2man package. |
| 200 |
bookman pdfman $(PDFMAN): $(MAN1) primes/*.1 lib/*.3 |
| 201 |
bookman -p -t "Mathomatic version $(VERSION) Man Pages" -a "George Gesslein II" -d `date +%F` $+ >$(PDFMAN) </dev/null |
| 202 |
@echo Complete Mathomatic PDF man pages book created in $(PDFMAN) |
| 203 |
|
| 204 |
# Here we convert the man pages to HTML docs with rman: |
| 205 |
doc/mathomatic.1.html: mathomatic.1 |
| 206 |
$(RMAN) $(RMANOPTS) $< >/dev/null # Test for the success of rman command. |
| 207 |
@tidy -version >/dev/null |
| 208 |
-$(RMAN) $(RMANOPTS) $< | tidy -q -i -file /dev/null >$@ |
| 209 |
@echo Successfully created $@ |
| 210 |
|
| 211 |
doc/rmath.1.html: rmath.1 |
| 212 |
$(RMAN) $(RMANOPTS) $< >/dev/null # Test for the success of rman command. |
| 213 |
@tidy -version >/dev/null |
| 214 |
-$(RMAN) $(RMANOPTS) $< | tidy -q -i -file /dev/null >$@ |
| 215 |
@echo Successfully created $@ |
| 216 |
|
| 217 |
$(PRIMES_MANHTML): doc/%.1.html: primes/%.1 |
| 218 |
$(RMAN) $(RMANOPTS) $< >/dev/null # Test for the success of rman command. |
| 219 |
@tidy -version >/dev/null |
| 220 |
-$(RMAN) $(RMANOPTS) $< | tidy -q -i -file /dev/null >$@ |
| 221 |
@echo Successfully created $@ |
| 222 |
|
| 223 |
# INSTALL MATHOMATIC |
| 224 |
|
| 225 |
# The following installs everything, including m4 Mathomatic with documentation. |
| 226 |
m4install: install matho-rmath-install |
| 227 |
@echo |
| 228 |
@echo m4 Mathomatic install completed. |
| 229 |
@echo |
| 230 |
|
| 231 |
# The following installs shell scripts matho and rmath, |
| 232 |
# allowing convenient entry of standard math functions. |
| 233 |
# Requires at least "make bininstall" first. |
| 234 |
matho-rmath-install: |
| 235 |
$(INSTALL) -d $(DESTDIR)$(mathdatadir) |
| 236 |
$(INSTALL) -d $(DESTDIR)$(mathdatadir)/m4 |
| 237 |
echo '#!/bin/sh' >$(M4SCRIPTPATH) |
| 238 |
echo '# Shell script to run Mathomatic with the GNU m4 preprocessor.' >>$(M4SCRIPTPATH) |
| 239 |
echo '# This allows entry of many standard math functions.' >>$(M4SCRIPTPATH) |
| 240 |
echo '#' >>$(M4SCRIPTPATH) |
| 241 |
echo '# Usage: matho [ input_files ]' >>$(M4SCRIPTPATH) |
| 242 |
echo >>$(M4SCRIPTPATH) |
| 243 |
echo 'if ! $(M4) --version >/dev/null' >>$(M4SCRIPTPATH) |
| 244 |
echo 'then' >>$(M4SCRIPTPATH) |
| 245 |
echo ' echo The $(M4) package is not installed. GNU m4 is required to run m4 Mathomatic.' >>$(M4SCRIPTPATH) |
| 246 |
echo ' exit 1' >>$(M4SCRIPTPATH) |
| 247 |
echo 'fi' >>$(M4SCRIPTPATH) |
| 248 |
echo >>$(M4SCRIPTPATH) |
| 249 |
echo '$(M4) -eP -- $(mathdatadir)/m4/functions.m4 "$$@" - | mathomatic -ru -s-1' >>$(M4SCRIPTPATH) |
| 250 |
chmod 0755 $(M4SCRIPTPATH) |
| 251 |
$(INSTALL_PROGRAM) m4/rmath $(DESTDIR)$(bindir) |
| 252 |
$(INSTALL_DATA) rmath.1 $(DESTDIR)$(mandir)/man1 |
| 253 |
cd $(DESTDIR)$(mandir)/man1 && ln -sf rmath.1 matho.1 |
| 254 |
$(INSTALL_DATA) m4/functions.m4 m4/degrees.m4 m4/gradians.m4 $(DESTDIR)$(mathdatadir)/m4 |
| 255 |
|
| 256 |
# Install m4 Mathomatic with trig functions that use degree units, instead of radians. |
| 257 |
matho-rmath-install-degrees: matho-rmath-install |
| 258 |
cat m4/degrees.m4 >>$(DESTDIR)$(mathdatadir)/m4/functions.m4 |
| 259 |
@echo Degree mode installed. |
| 260 |
|
| 261 |
# Install complete m4 Mathomatic with trig functions that use degree units, instead of radians. |
| 262 |
m4install-degrees: m4install |
| 263 |
cat m4/degrees.m4 >>$(DESTDIR)$(mathdatadir)/m4/functions.m4 |
| 264 |
@echo Degree mode installed. |
| 265 |
|
| 266 |
# Install the Mathomatic binaries and documentation. Does not install m4 Mathomatic. |
| 267 |
install: bininstall docinstall |
| 268 |
@echo |
| 269 |
@echo Mathomatic is installed. |
| 270 |
@echo |
| 271 |
|
| 272 |
# Strip the binaries of their symbol tables. Makes smaller executables, but debugging becomes impossible. |
| 273 |
strip: $(AOUT) |
| 274 |
strip $(AOUT) |
| 275 |
|
| 276 |
# Binaries only install. |
| 277 |
bininstall: |
| 278 |
$(INSTALL) -d $(DESTDIR)$(bindir) |
| 279 |
$(INSTALL) -d $(DESTDIR)$(datadir)/applications |
| 280 |
$(INSTALL) -d $(DESTDIR)$(datadir)/pixmaps |
| 281 |
$(INSTALL) -d $(DESTDIR)$(mandir)/man1 |
| 282 |
$(INSTALL_PROGRAM) $(AOUT) $(DESTDIR)$(bindir) |
| 283 |
$(INSTALL_DATA) icons/mathomatic.desktop $(DESTDIR)$(datadir)/applications |
| 284 |
$(INSTALL_DATA) icons/mathomatic.png icons/mathomatic.xpm $(DESTDIR)$(datadir)/pixmaps |
| 285 |
$(INSTALL_DATA) mathomatic.1 $(DESTDIR)$(mandir)/man1 |
| 286 |
|
| 287 |
# Documentation only install. |
| 288 |
docinstall: |
| 289 |
@echo Installing docs... |
| 290 |
$(INSTALL) -d $(DESTDIR)$(mathdocdir) |
| 291 |
$(INSTALL) -d $(DESTDIR)$(mathdocdir)/html |
| 292 |
$(INSTALL) -d $(DESTDIR)$(mathdocdir)/tests |
| 293 |
$(INSTALL) -d $(DESTDIR)$(mathdocdir)/examples |
| 294 |
$(INSTALL_DATA) $(TEXT_DOCS) $(DESTDIR)$(mathdocdir) |
| 295 |
$(INSTALL_DATA) doc/* $(DESTDIR)$(mathdocdir)/html |
| 296 |
-$(INSTALL_DATA) *.pdf $(DESTDIR)$(mathdocdir) |
| 297 |
$(INSTALL_DATA) tests/* $(DESTDIR)$(mathdocdir)/tests |
| 298 |
$(INSTALL_DATA) examples/* $(DESTDIR)$(mathdocdir)/examples |
| 299 |
|
| 300 |
# UNINSTALL MATHOMATIC |
| 301 |
|
| 302 |
# Entirely remove Mathomatic from your local computer system. |
| 303 |
uninstall: |
| 304 |
cd $(DESTDIR)$(mandir)/man1 && rm -f $(MAN1) matho.1 |
| 305 |
cd $(DESTDIR)$(bindir) && rm -f $(AOUT) rmath matho |
| 306 |
rm -rf $(DESTDIR)$(mathdocdir) |
| 307 |
rm -rf $(DESTDIR)$(mathdatadir) |
| 308 |
rm -f $(DESTDIR)$(datadir)/applications/mathomatic.desktop |
| 309 |
rm -f $(DESTDIR)$(datadir)/pixmaps/mathomatic.* |
| 310 |
@echo |
| 311 |
@echo Mathomatic uninstall completed. |
| 312 |
@echo |
| 313 |
-$(MAKE) -C primes prefix=$(prefix) uninstall |
| 314 |
@echo |
| 315 |
-$(MAKE) -C lib prefix=$(prefix) uninstall |
| 316 |
|
| 317 |
# CLEAN THIS DIRECTORY |
| 318 |
|
| 319 |
# Tidy this directory and sub-directories after building, testing, and installing Mathomatic. |
| 320 |
# Useful to run before a build make, to be sure we are building something complete and new. |
| 321 |
clean: |
| 322 |
rm -f *.o *.pyc *.pyo |
| 323 |
rm -f */*.o */*.pyc */*.pyo |
| 324 |
rm -f tests/test.out primes/test.out primes/bigtest.out |
| 325 |
|
| 326 |
# distclean cleans everything to the defaults, before distributing the source code |
| 327 |
# from this directory, if it has not been corrupted or carelessly modified. |
| 328 |
distclean: clean |
| 329 |
rm -f *.a */*.a |
| 330 |
rm -f $(AOUT) |
| 331 |
rm -f mathomatic_secure |
| 332 |
rm -f *.exe |
| 333 |
rm -f *.pdf |
| 334 |
$(MAKE) -C primes distclean |
| 335 |
$(MAKE) -C lib distclean |
| 336 |
|
| 337 |
# maintainer-clean prepares to rebuild absolutely everything. Not recommended. |
| 338 |
maintainer-clean flush: distclean |
| 339 |
rm -f $(MANHTML) |
| 340 |
./update # shell script to update proto.h using the cproto utility. |
| 341 |
|
| 342 |
# make a clean distribution out of this directory in ~/am.zip |
| 343 |
zip: distclean |
| 344 |
./zipsrc # shell script |