| 1 |
# Makefile for compiling and installing the Mathomatic Prime Number Tools |
| 2 |
# under a Unix-like system. |
| 3 |
# See file README.txt for instructions. |
| 4 |
# |
| 5 |
# If make fails due to incomplete "long double" support, try: |
| 6 |
# CFLAGS="-O3 -DUSE_DOUBLES" make |
| 7 |
|
| 8 |
|
| 9 |
SHELL = /bin/sh # from http://www.gnu.org/prep/standards/ |
| 10 |
CC ?= gcc # C compiler to use |
| 11 |
INSTALL ?= install # installer to use |
| 12 |
INSTALL_PROGRAM ?= $(INSTALL) # Command to install executable program files. |
| 13 |
INSTALL_DATA ?= $(INSTALL) -m 0644 # Command to install data files. |
| 14 |
|
| 15 |
CC_OPTIMIZE = -O3 # Default C compiler optimization flags that are safe. |
| 16 |
#CC_OPTIMIZE += -ffast-math -fomit-frame-pointer # Extra optimize for speed, not functional under Mac OS X. |
| 17 |
|
| 18 |
OPTFLAGS ?= $(CC_OPTIMIZE) -Wall -Wshadow -Wno-char-subscripts # gcc specific flags; change for other C compilers. |
| 19 |
CFLAGS ?= $(OPTFLAGS) |
| 20 |
#CFLAGS += -std=gnu99 # Uses the Gnu99 standard; may require setting this on gcc command line if using an older compiler. |
| 21 |
LDLIBS += -lm |
| 22 |
|
| 23 |
# Install directories follow, installs everything in $(DESTDIR)/usr/local by default. |
| 24 |
prefix ?= /usr/local |
| 25 |
bindir ?= $(prefix)/bin |
| 26 |
mandir ?= $(prefix)/share/man |
| 27 |
|
| 28 |
# The executables to create: |
| 29 |
TARGETS = matho-primes matho-pascal matho-sumsq |
| 30 |
# The Python scripts to install: |
| 31 |
PYTHON_SCRIPTS = primorial matho-mult matho-sum |
| 32 |
# The executables to install: |
| 33 |
EXECUTABLES = $(TARGETS) $(PYTHON_SCRIPTS) |
| 34 |
# The man pages to install: |
| 35 |
MAN1 = matho-primes.1 matho-pascal.1 matho-sumsq.1 primorial.1 matho-mult.1 matho-sum.1 |
| 36 |
|
| 37 |
all static: $(TARGETS) # make these by default |
| 38 |
@echo |
| 39 |
@echo Prime Number Tools successfully created. |
| 40 |
|
| 41 |
# Strip the binaries of their symbol tables. Makes smaller executables, but debugging becomes impossible. |
| 42 |
strip: $(TARGETS) |
| 43 |
strip $(TARGETS) |
| 44 |
|
| 45 |
matho-sumsq: matho-sumsq.o lsqrt.o |
| 46 |
$(CC) $(CFLAGS) $(LDFLAGS) $+ $(LDLIBS) -o $@ |
| 47 |
|
| 48 |
# To compile the Mathomatic Prime Number Tools as stand-alone executables |
| 49 |
# that have no shared library dependencies, type "make flush static". |
| 50 |
static: LDFLAGS += -static |
| 51 |
|
| 52 |
test: |
| 53 |
@echo Testing basic functionality of matho-primes: |
| 54 |
time -p ./matho-primes 10000000000000 10000000300000 twin >test.out && diff -u --strip-trailing-cr twins.out test.out |
| 55 |
@rm test.out |
| 56 |
@echo Small primes test passed. |
| 57 |
@echo |
| 58 |
|
| 59 |
# Same as "make test", except doesn't run the time command. |
| 60 |
check: |
| 61 |
@echo Testing basic functionality of matho-primes: |
| 62 |
./matho-primes 10000000000000 10000000300000 twin >test.out && diff -u --strip-trailing-cr twins.out test.out |
| 63 |
@rm test.out |
| 64 |
@echo Small primes test passed. |
| 65 |
@echo |
| 66 |
|
| 67 |
bigtest: |
| 68 |
@echo Testing that long doubles are fully functional in matho-primes: |
| 69 |
time -p ./matho-primes 100000000000000000 100000000000300000 twin >bigtest.out && diff -u --strip-trailing-cr bigtwins.out bigtest.out |
| 70 |
@rm bigtest.out |
| 71 |
@echo Big primes test passed. |
| 72 |
@echo |
| 73 |
|
| 74 |
# Same as "make bigtest", except doesn't run the time command. |
| 75 |
bigcheck: |
| 76 |
@echo Testing that long doubles are fully functional in matho-primes: |
| 77 |
./matho-primes 100000000000000000 100000000000300000 twin >bigtest.out && diff -u --strip-trailing-cr bigtwins.out bigtest.out |
| 78 |
@rm bigtest.out |
| 79 |
@echo Big primes test passed. |
| 80 |
@echo |
| 81 |
|
| 82 |
install: |
| 83 |
$(INSTALL) -d $(DESTDIR)$(bindir) |
| 84 |
$(INSTALL) -d $(DESTDIR)$(mandir)/man1 |
| 85 |
$(INSTALL_PROGRAM) $(EXECUTABLES) $(DESTDIR)$(bindir) |
| 86 |
$(INSTALL_DATA) $(MAN1) $(DESTDIR)$(mandir)/man1 |
| 87 |
@echo |
| 88 |
@echo The Prime Number Tools are installed. |
| 89 |
|
| 90 |
uninstall: |
| 91 |
cd $(DESTDIR)$(bindir) && rm -f $(EXECUTABLES) |
| 92 |
cd $(DESTDIR)$(mandir)/man1 && rm -f $(MAN1) |
| 93 |
@echo |
| 94 |
@echo Prime Number Tools uninstall completed. |
| 95 |
|
| 96 |
clean: |
| 97 |
rm -f *.o *.pyc *.pyo |
| 98 |
rm -f test.out bigtest.out |
| 99 |
|
| 100 |
flush distclean maintainer-clean: clean |
| 101 |
rm -f *.a |
| 102 |
rm -f $(TARGETS) |
| 103 |
rm -f *.exe |