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
|
# Makefile for compiling, testing, and installing Mathomatic and its documentation.
# Requires the GNU make utility, in BSD Unix this is called "gmake".
# Remove the -DUNIX define in CFLAGS when not using Mathomatic for desktop UNIX/Linux.
# For normal compilation and testing on a GNU system,
# please type the following at the shell prompt:
# make clean
# make READLINE=1
# make test
#
# For Slackware, or any other OS that fails to find the curses library functions, use:
# LDLIBS=-lncurses make READLINE=1
# for the second make line.
#
# To use the Tiny C Compiler (tcc) to compile Mathomatic:
# make clean
# CC=tcc LDFLAGS="-L/usr/lib/x86_64-linux-gnu/ -L/lib/x86_64-linux-gnu/" make READLINE=1
# make test
# The -L options might need to be set to the library directories your current gcc uses,
# as the above example shows.
# They will probably differ from the above, try "locate libm." to find your library paths,
# one or two of them will probably work.
# To install the base Mathomatic system after compiling and testing, type:
# make install
# if that doesn't work, try:
# sudo make install
# and enter your password. This is because write permission is required to /usr/local/*.
#
# To install all of Mathomatic, including m4 Mathomatic (rmath), instead type:
# make m4install
# or:
# sudo make m4install
# To compile, test, and install all of Mathomatic under CygWin for MS-Windows:
# CFLAGS="-DCYGWIN -DBOLD_COLOR -O3" make READLINE=1
# make test
# make m4install
# To compile Mathomatic with the MinGW cross-compiler for MS-Windows under Debian or Ubuntu:
# sudo apt-get install gcc-mingw32
# ./compile.mingw
# This will create Windows executables for Mathomatic and the Prime Number Tools.
# For cross-compiling under other systems, just edit "compile.mingw".
# To compile, test, and install all of Mathomatic under OpenIndiana (SunOS), type:
# LDLIBS=-lcurses make READLINE=1
# make test
# sudo make m4install INSTALL=ginstall prefix=/usr M4=gm4
# This makefile does NOT compile and install the Prime Number Tools in the "primes" directory,
# nor does it compile and install the Symbolic Math Library in the "lib" directory.
# sudo make uninstall
# here will uninstall all of Mathomatic,
# including the Prime Number Tools and the Symbolic Math Library,
# but it must know the "prefix" used to install Mathomatic, if specified during the install.
SHELL = /bin/sh # from "http://www.gnu.org/prep/standards/", do not change
CC ?= gcc # C compiler to use; this statement doesn't work usually, instead using cc.
M4 ?= m4 # Change this to gm4 in Unix or a non-GNU system.
INSTALL ?= install # Installer utility to use; change to ginstall under Unix.
INSTALL_PROGRAM ?= $(INSTALL) # Command to install executable program files.
INSTALL_DATA ?= $(INSTALL) -m 0644 # Command to install data files.
CC_OPTIMIZE ?= -O3 # Default C compiler optimization flags that are safe (but please remove for LLVM/Clang, see "misc/known_bugs.txt").
# Be sure and run tests to see if Mathomatic works and runs faster, if you uncomment the following line:
#CC_OPTIMIZE += -fno-signaling-nans -fno-trapping-math -fomit-frame-pointer # Possible additional optimizations, not tested.
VERSION = `cat VERSION`
OPTFLAGS ?= $(CC_OPTIMIZE) -Wall -Wshadow -Wno-char-subscripts # optional gcc specific flags
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.
# Run "make EDITLINE=1" to include the optional editline editing and history support (smaller than readline):
CFLAGS += $(EDITLINE:1=-DEDITLINE)
LDLIBS += $(EDITLINE:1=-leditline)
# 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 blt.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 and Command Reference.
PDFMAN = bookman.pdf # Name of PDF file containing all the Mathomatic man pages.
all static: $(AOUT) html NEWS # 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/ # shell script that uses awk to make a nice command reference card
# Make the PDF cheat sheet.
pdfsheet quickref.pdf: $(AOUT)
./makepdfsheet.sh doc/ # shell script
# 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 100% correctly" is displayed.
test:
@echo
@echo Testing ./$(AOUT) \(`./$(AOUT) -v`\)
cd tests && time -p ../$(AOUT) -t all 0<&- >test.out && diff -u --strip-trailing-cr all.out test.out && rm test.out && cd ..
@echo "All tests passed 100% correctly."
# Same as "make test", except it doesn't run the time command.
check:
@echo
@echo Testing ./$(AOUT) \(`./$(AOUT) -v`\)
cd tests && ../$(AOUT) -t all 0<&- >test.out && diff -u --strip-trailing-cr all.out test.out && rm test.out && cd ..
@echo "All tests passed 100% correctly."
# "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
# ./update updates the function prototypes in proto.h by using the cproto utility.
# Run ./update whenever a new C function is added to the Mathomatic source code or
# whenever a function definition is changed.
proto.h:
./update # shell script
$(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) $(CFLAGS) $(LDFLAGS) $+ $(LDLIBS) -o $(AOUT)
@echo
@echo ./$(AOUT) successfully created.
# BUILD THE MATHOMATIC DOCUMENTATION
# Build the nicely ordered changelog.
NEWS: changes.txt makenews.sh
./makenews.sh # shell script
# "make pdfdoc" creates the PDF version of the Mathomatic User Guide and Command Reference, 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 --title --logoimage icons/mathomatic.png --footer h1l --header "c d" -f $(PDFDOC) $+
@echo Mathomatic PDF user 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 Complete Mathomatic 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) $(RMANOPTS) $< >/dev/null # Test for the success of rman command.
@tidy -version >/dev/null
-$(RMAN) $(RMANOPTS) $< | tidy -q -i -file /dev/null >$@
@echo Successfully created $@
doc/rmath.1.html: rmath.1
$(RMAN) $(RMANOPTS) $< >/dev/null # Test for the success of rman command.
@tidy -version >/dev/null
-$(RMAN) $(RMANOPTS) $< | tidy -q -i -file /dev/null >$@
@echo Successfully created $@
$(PRIMES_MANHTML): doc/%.1.html: primes/%.1
$(RMAN) $(RMANOPTS) $< >/dev/null # Test for the success of rman command.
@tidy -version >/dev/null
-$(RMAN) $(RMANOPTS) $< | tidy -q -i -file /dev/null >$@
@echo Successfully created $@
# INSTALL MATHOMATIC
# The following installs everything, including m4 Mathomatic with documentation.
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 m4/degrees.m4 m4/gradians.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
# Tidy this directory and sub-directories after building, testing, and installing Mathomatic.
# Useful to run before a build make, to be sure we are building something complete and new.
clean:
rm -f *.o *.pyc *.pyo
rm -f */*.o */*.pyc */*.pyo
rm -f tests/test.out primes/test.out primes/bigtest.out
# distclean cleans everything to the defaults, before distributing the source code
# from this directory, if it has not been corrupted or carelessly modified.
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 prepares to rebuild absolutely everything. Not recommended.
maintainer-clean flush: distclean
rm -f $(MANHTML)
./update # shell script to update proto.h using the cproto utility.
# make a clean distribution out of this directory in ~/am.zip
zip: distclean
./zipsrc # shell script
|