# Makefile for compiling, testing, and installing Mathomatic under any UNIX-like system. # Currently uses gcc only options in CFLAGS, just remove the line containing them for other C compilers. # Remove the -DUNIX define in CFLAGS when not using Mathomatic for desktop UNIX/Linux. # This makefile does not compile and install the Prime Number Tools in the "primes" directory. # This makefile does create and install all documentation. VERSION = `cat VERSION` CFLAGS += -Wall -Wshadow -Wno-char-subscripts -fomit-frame-pointer # gcc specific flags CFLAGS += -O -DUNIX -DVERSION=\"$(VERSION)\" LDLIBS += -lm # libraries to link # "make READLINE=1" to include readline support: CFLAGS += $(READLINE:1=-DREADLINE) LDLIBS += $(READLINE:1=-lreadline -lncurses) # Uncomment the following to generate 64bit x86-64 code: #CFLAGS += -m64 #LDFLAGS += -m64 # Install directories follow, installs everything in /usr/local by default: prefix ?= /usr/local bindir ?= $(prefix)/bin mandir ?= $(prefix)/share/man docdir ?= $(prefix)/share/doc mathdocdir ?= $(docdir)/mathomatic # Mathomatic program names (can be changed): AOUT = mathomatic M4SCRIPTNAME = matho M4SCRIPTPATH = $(bindir)/$(M4SCRIPTNAME) INCLUDES = includes.h license.h am.h externs.h complex.h proto.h altproto.h 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 # HTML man pages to make: MANHTML = doc/mathomatic.1.html doc/matho-primes.1.html doc/matho-pascal.1.html doc/matho-sumsq.1.html # Flags to make HTML man pages with groff: GROFFOPTS = -man -Thtml -P -l # man pages to install: MAN1 = mathomatic.1 # Text files to install: DOCS = VERSION AUTHORS COPYING README.txt changes.txt all: $(AOUT) $(MANHTML) # make these by default doc: $(MANHTML) # 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. check test: @echo Testing Mathomatic... cd tests && time ../$(AOUT) -t all 0<&- >test.out && diff -u all.out test.out && rm test.out @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: cd tests && ../$(AOUT) -t all 0<&- >all.out @rm -f tests/test.out @echo File tests/all.out updated with current test output. $(OBJECTS): $(INCLUDES) VERSION # Create the mathomatic executable: $(AOUT): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $(AOUT) @echo ./$(AOUT) created. # To compile Mathomatic as a stand-alone executable # that has no shared library dependencies, type "make clean static". static: $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) -static $(LDLIBS) -o $(AOUT) @echo ./$(AOUT) created. # Here we convert the man pages to HTML docs: doc/mathomatic.1.html: mathomatic.1 groff -v $(GROFFOPTS) >/dev/null # test for groff functionality groff $(GROFFOPTS) mathomatic.1 >doc/mathomatic.1.html doc/matho-primes.1.html: primes/matho-primes.1 groff $(GROFFOPTS) primes/matho-primes.1 >doc/matho-primes.1.html doc/matho-pascal.1.html: primes/matho-pascal.1 groff $(GROFFOPTS) primes/matho-pascal.1 >doc/matho-pascal.1.html doc/matho-sumsq.1.html: primes/matho-sumsq.1 groff $(GROFFOPTS) primes/matho-sumsq.1 >doc/matho-sumsq.1.html # The following creates a shell script allowing easy entry of trig functions. Only works with GNU m4. m4install: install echo '#!/bin/sh' >$(M4SCRIPTPATH) echo '# Shell script to run Mathomatic with the m4 preprocessor.' >>$(M4SCRIPTPATH) echo '# This allows entry of many standard math functions.' >>$(M4SCRIPTPATH) echo '#' >>$(M4SCRIPTPATH) echo '# Usage: $(M4SCRIPTNAME) [ input_files ]' >>$(M4SCRIPTPATH) echo >>$(M4SCRIPTPATH) echo 'm4 -eP -- $(mathdocdir)/m4/functions.m4 "$$@" - | mathomatic -ru' >>$(M4SCRIPTPATH) chmod 0755 $(M4SCRIPTPATH) install -m 0755 m4/rmath $(bindir) @echo @echo m4 Mathomatic install completed. @echo Type \"rmath\" to run m4 Mathomatic. # Install the binaries and documentation. install: bininstall docinstall @echo Type \"$(AOUT)\" to run Mathomatic. @echo bininstall: install -d $(bindir) install -d $(prefix)/share/applications install -d $(prefix)/share/pixmaps install -m 0755 $(AOUT) $(bindir) install -m 0644 icons/mathomatic.desktop $(prefix)/share/applications install -m 0644 icons/mathomatic.png $(prefix)/share/pixmaps docinstall: install -d $(mandir)/man1 install -d $(mathdocdir) install -d $(mathdocdir)/html install -d $(mathdocdir)/m4 install -d $(mathdocdir)/tests install -d $(mathdocdir)/factorial install -m 0644 $(MAN1) $(mandir)/man1 install -m 0644 $(DOCS) $(mathdocdir) install -m 0644 doc/* $(mathdocdir)/html install -m 0644 m4/* $(mathdocdir)/m4 install -m 0644 tests/* $(mathdocdir)/tests install -m 0644 factorial/* $(mathdocdir)/factorial @echo @echo Documentation is installed in $(mathdocdir)/html uninstall: rm -f $(bindir)/$(AOUT) cd $(mandir)/man1 && rm -f $(MAN1) rm -rf $(mathdocdir) rm -f $(prefix)/share/applications/mathomatic.desktop rm -f $(prefix)/share/pixmaps/mathomatic.png rm -f $(bindir)/rmath $(M4SCRIPTPATH) @echo @echo Mathomatic uninstalled. clean: rm -f *.o *.a rm -f */*.o */*.a */*.pyc rm -f tests/test.out flush: clean rm -f $(AOUT) rm -f mathomatic_secure rm -f $(MANHTML)