1# ***** Variables 2 3rawSources := main.cpp Action.cpp IOParameters.cpp \ 4 IrreducibleDecomAction.cpp fplllIO.cpp IOHandler.cpp fourti2.cpp \ 5 randomDataGenerators.cpp MonosIOHandler.cpp BigIdeal.cpp \ 6 TransformAction.cpp Macaulay2IOHandler.cpp NewMonosIOHandler.cpp \ 7 HelpAction.cpp stdinc.cpp DynamicFrobeniusAction.cpp \ 8 dynamicFrobeniusAlgorithm.cpp GenerateIdealAction.cpp \ 9 GenerateFrobeniusAction.cpp intersect.cpp FrobeniusAction.cpp \ 10 Facade.cpp IOFacade.cpp DynamicFrobeniusFacade.cpp \ 11 GenerateDataFacade.cpp AnalyzeAction.cpp IdealFacade.cpp \ 12 Parameter.cpp ParameterGroup.cpp IntegerParameter.cpp \ 13 SliceParameters.cpp BoolParameter.cpp Scanner.cpp Partition.cpp \ 14 StringParameter.cpp Term.cpp TermTranslator.cpp Timer.cpp \ 15 VarNames.cpp LatticeFormatAction.cpp Ideal.cpp \ 16 IntersectionAction.cpp IntersectFacade.cpp \ 17 AssociatedPrimesAction.cpp MsmSlice.cpp IndependenceSplitter.cpp \ 18 Projection.cpp MsmStrategy.cpp lattice.cpp LatticeFacade.cpp \ 19 DecomRecorder.cpp TermGrader.cpp Fourti2IOHandler.cpp \ 20 NullIOHandler.cpp Minimizer.cpp AlexanderDualAction.cpp frobby.cpp \ 21 BigTermConsumer.cpp TranslatingTermConsumer.cpp HilbertAction.cpp \ 22 HilbertSlice.cpp Polynomial.cpp CanonicalCoefTermConsumer.cpp \ 23 HilbertStrategy.cpp Slice.cpp SliceStrategyCommon.cpp \ 24 DebugStrategy.cpp OptimizeStrategy.cpp SliceFacade.cpp \ 25 BigTermRecorder.cpp CoCoA4IOHandler.cpp SingularIOHandler.cpp \ 26 TotalDegreeCoefTermConsumer.cpp BigPolynomial.cpp \ 27 CoefBigTermRecorder.cpp PolyTransformAction.cpp VarSorter.cpp \ 28 TermConsumer.cpp NullTermConsumer.cpp CoefTermConsumer.cpp \ 29 NullCoefTermConsumer.cpp TranslatingCoefTermConsumer.cpp \ 30 PolynomialFacade.cpp HilbertBasecase.cpp \ 31 HilbertIndependenceConsumer.cpp SplitStrategy.cpp \ 32 CanonicalTermConsumer.cpp StatisticsStrategy.cpp TestAction.cpp \ 33 NameFactory.cpp error.cpp DebugAllocator.cpp FrobbyStringStream.cpp \ 34 SliceStrategy.cpp PrimaryDecomAction.cpp IdealComparator.cpp \ 35 IrreducibleIdealSplitter.cpp DataType.cpp IdealConsolidator.cpp \ 36 CoefBigTermConsumer.cpp PolynomialConsolidator.cpp \ 37 OptimizeAction.cpp MaximalStandardAction.cpp test/Test.cpp \ 38 test/TestCase.cpp test/TestQualifier.cpp test/TestRunner.cpp \ 39 test/TestSuite.cpp test/TestVisitor.cpp test/macroes.cpp \ 40 test/asserts.cpp IdealFactory.cpp PolynomialFactory.cpp \ 41 LatticeAnalyzeAction.cpp SatBinomIdeal.cpp SatBinomConsumer.cpp \ 42 SatBinomRecorder.cpp CountingIOHandler.cpp test/TestSorter.cpp \ 43 DimensionAction.cpp SizeMaxIndepSetAlg.cpp TaskEngine.cpp Task.cpp \ 44 BigattiHilbertAlgorithm.cpp BigattiState.cpp ObjectCache.cpp \ 45 HashPolynomial.cpp BigattiBaseCase.cpp BigattiPivotStrategy.cpp \ 46 BigattiFacade.cpp UniHashPolynomial.cpp CommonParams.cpp \ 47 CliParams.cpp SliceParams.cpp SliceLikeParams.cpp BigattiParams.cpp \ 48 IOHandlerImpl.cpp IdealWriter.cpp PolyWriter.cpp IOHandlerCommon.cpp \ 49 CommonParamsHelper.cpp ActionPrinter.cpp ScarfHilbertAlgorithm.cpp \ 50 ScarfFacade.cpp Deformer.cpp IdealTree.cpp TermPredicate.cpp \ 51 ScarfParams.cpp IdealOrderer.cpp TermExtra.cpp display.cpp \ 52 Matrix.cpp BigIntVector.cpp ColumnPrinter.cpp EulerAction.cpp \ 53 RawSquareFreeTerm.cpp RawSquareFreeIdeal.cpp PivotEulerAlg.cpp \ 54 EulerState.cpp PivotStrategy.cpp Arena.cpp LocalArray.cpp \ 55 LatticeAlgs.cpp InputConsumer.cpp SquareFreeIdeal.cpp 56 57rawTests := LibAlexanderDualTest.cpp LibHilbertPoincareTest.cpp \ 58 LibIrreducibleDecomTest.cpp LibMaxStdTest.cpp LibStdProgramTest.cpp \ 59 LibTest.cpp OptimizeStrategyTest.cpp TermTest.cpp \ 60 TermTranslatorTest.cpp RawSquareFreeTermTest.cpp \ 61 RawSquareFreeIdealTest.cpp LibPrimaryDecomTest.cpp \ 62 LibAssociatedPrimesTest.cpp MatrixTest.cpp IdealTest.cpp \ 63 LibDimensionTest.cpp TermGraderTest.cpp ArenaTest.cpp 64 65ifndef CXX 66 CXX = "g++" 67endif 68 69ifndef BIN_INSTALL_DIR 70 BIN_INSTALL_DIR = "/usr/local/bin/" 71endif 72 73cxxflags = $(CXXFLAGS) $(CPPFLAGS) -I $(GMP_INC_DIR) -Wno-uninitialized -Wno-unused-parameter 74program = frobby 75library = libfrobby.a 76benchArgs = $(FROBBYARGS) 77 78ifndef MODE 79 MODE=release 80endif 81 82ifndef ldflags 83 ldflags = $(LDFLAGS) -lgmpxx -lgmp 84endif 85 86MATCH=false 87ifeq ($(MODE), release) 88 outdir = bin/release/ 89 MATCH=true 90endif 91ifeq ($(MODE), debug) 92 rawSources := $(rawSources) $(rawTests) 93 outdir = bin/debug/ 94 cxxflags += -g -D DEBUG -fno-inline -Werror -Wextra -Wno-uninitialized \ 95 -Wno-unused-parameter 96 MATCH=true 97endif 98ifeq ($(MODE), shared) 99 outdir = bin/shared/ 100 cxxflags += -fPIC 101 library = libfrobby.so 102 MATCH=true 103endif 104ifeq ($(MODE), profile) 105 outdir = bin/profile/ 106 cxxflags += -g -pg -D PROFILE 107 ldflags += -pg 108 MATCH=true 109 benchArgs = _profile $(FROBBYARGS) 110endif 111ifeq ($(MODE), analysis) 112 rawSources := $(rawSources) $(rawTests) 113 outdir = bin/analysis/ 114 cxxflags += -Wextra -fsyntax-only -O1 -Wfloat-equal -Wundef \ 115 -Wno-endif-labels -Wshadow -Wlarger-than-1000 -Wpointer-arith \ 116 -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wsign-compare \ 117 -Waggregate-return -Wmissing-noreturn -Wmissing-format-attribute \ 118 -Wno-multichar -Wno-deprecated-declarations -Wpacked \ 119 -Wno-redundant-decls -Wunreachable-code -Winline \ 120 -Wno-invalid-offsetof -Winvalid-pch -Wlong-long \ 121 -Wdisabled-optimization -D DEBUG -Werror 122 MATCH=true 123endif 124 125ifeq ($(MATCH), false) 126 $(error Unknown value of MODE: "$(MODE)") 127endif 128 129sources = $(patsubst %.cpp, src/%.cpp, $(rawSources)) 130objs = $(patsubst %.cpp, $(outdir)%.o, $(rawSources)) 131 132# ***** Compilation 133 134.PHONY: all depend clean bin/$(program) test library distribution clear fixspace 135 136all: bin/$(program) $(outdir)$(program) 137 138# ****************** Testing 139# use TESTARGS of 140# _valgrind to run under valgrind. 141# _debugAlloc to test recovery when running out of memory. 142# _full to obtain extra tests by verifying relations 143# between outputs of different actions, and generally testing 144# everything that can be tested. 145# _full cannot follow the other options because it is picked up at an earlier 146# point in the test system than they are. There are more options - see 147# test/testScripts/testhelper for a full list. 148# 149# Only miniTest and bareTest support TESTARGS, and some options are not 150# available unless MODE=debug. 151 152# The correct choice to do a reasonably thorough test of an 153# installation of Frobby. 154test: all 155 test/runTests 156 157# Run all tests that it makes sense to run. 158fullTest: all 159 test/runTests _full 160 test/runSplitTests _full 161 162# Good for testing Frobby after a small change. 163microTest: all 164 test/runTests _few $(TESTARGS) 165miniTest: all 166 test/runTests $(TESTARGS) 167 168# Runs all tests and allows full control over the arguments. 169bareTest: all 170 test/runTests $(TESTARGS) 171 test/runSplitTests $(TESTARGS) 172 173# Run benchmarks to detect performance regressions. When MODE=profile, 174# profile files for the benchmarked actions will be placed in bin/. 175bench: all 176 cd test/bench; ./runbench $(benchArgs) 177benchHilbert: all 178 cd test/bench; ./run_hilbert_bench $(benchArgs) 179benchOptimize: all 180 cd test/bench; ./run_optimize_bench $(benchArgs) 181benchAlexdual: all 182 cd test/bench; ./run_alexdual_bench $(benchArgs) 183 184bin/: 185 mkdir bin/; 186 187# Make symbolic link to program from bin/ 188bin/$(program): $(outdir)$(program) bin/ 189ifneq ($(MODE), analysis) 190 cd bin; rm -f $(program); ln -s ../$(outdir)$(program) $(program); cd .. 191endif 192 193# Link object files into executable 194$(outdir)$(program): $(objs) | $(outdir) 195 @mkdir -p $(dir $@) 196ifeq ($(MODE), analysis) 197 echo > $@ 198endif 199ifneq ($(MODE), analysis) 200 $(CXX) $(objs) $(ldflags) -o $@ 201 if [ -f $@.exe ]; then \ 202 mv -f $@.exe $@; \ 203 fi 204endif 205ifeq ($(MODE), release) 206 strip $@ 207endif 208 209# Link object files into library 210library: bin/$(library) 211bin/$(library): $(objs) | bin/ 212 rm -f bin/$(library) 213ifeq ($(MODE), shared) 214 $(CXX) -shared -Wl,-soname,$(library) -o bin/$(library) $(ldflags) \ 215 $(patsubst $(outdir)main.o,,$(objs)) 216else 217 ar crs bin/$(library) $(patsubst $(outdir)main.o,,$(objs)) 218 $(RANLIB) bin/$(library) 219endif 220 221# Compile and output object files. 222# In analysis mode no file is created, so create one 223# to allow dependency analysis to work. 224$(outdir)%.o: src/%.cpp 225 @mkdir -p $(dir $@) 226 $(CXX) ${cxxflags} -c $< -o $@ 227 $(CXX) $(cxxflags) -MM -c $< > $(@:.o=.d).tmp 228# using /usr/bin/env echo to get the non-built-in echo on OS X, since 229# the built-in one does not understand the parameter -n. 230 @/usr/bin/env echo -n "$(dir $@)" > $(@:.o=.d) 231 @cat $(@:.o=.d).tmp >> $(@:.o=.d) 232 @sed -e 's/.*://' -e 's/\\$$//' < $(@:.o=.d).tmp | fmt -1 | \ 233 sed -e 's/^ *//' -e 's/$$/:/' >> $(@:.o=.d) 234 @rm -f $(@:.o=.d).tmp 235ifeq ($(MODE), analysis) 236 echo > $@ 237endif 238 239-include $(objs:.o=.d) 240 241# Installation. 242install: 243 if [ "`uname|grep CYGWIN`" = "" ]; then \ 244 sudo install bin/frobby $(BIN_INSTALL_DIR); \ 245 else \ 246 install bin/frobby $(BIN_INSTALL_DIR); \ 247 fi # Cygwin has no sudo 248 249# ***** Documentation 250 251# We need to run latex three times to make sure that references are done 252# properly in the output. 253doc: docPs docPdf 254docPs: 255 rm -rf bin/doc 256 mkdir bin/doc 257 for i in 1 2 3; do latex -output-directory=bin/doc/ doc/manual.tex; done 258 cd bin; dvips doc/manual.dvi 259docPdf: 260 rm -rf bin/doc 261 mkdir bin/doc 262 for i in 1 2 3; do pdflatex -output-directory=bin/doc/ doc/manual.tex; done 263 mv bin/doc/manual.pdf bin 264docDviOnce: # Useful to view changes when writing the manual 265 latex -output-directory=bin/doc doc/manual.tex 266 267# It may seem wasteful to run doxygen three times to generate three 268# kinds of output. However, the latex output for creating a pdf file 269# and for creating a PostScript file is different, and so at least two 270# runs are necessary. Making the HTML output a third run is cleaner 271# than tacking it onto one or both of the other two targets. 272bin/develDoc/: bin/ 273 mkdir bin/develDoc 274develDoc: develDocHtml develDocPdf develDocPs 275develDocHtml: bin/develDoc/ 276 cat doc/doxygen.conf doc/doxHtml|doxygen - 277develDocPdf: bin/develDoc/ 278 rm -rf bin/develDoc/latexPdf bin/develDoc/warningLog 279 cat doc/doxygen.conf doc/doxPdf|doxygen - 280 cd bin/develDoc/latexPdf; for f in `ls *.eps`; do epstopdf $$f; done # Cygwin fix 281 cd bin/develDoc/latexPdf/; make refman.pdf; mv refman.pdf ../develDoc.pdf 282develDocPs: bin/develDoc/ 283 rm -rf bin/develDoc/latexPs bin/develDoc/warningLog 284 cat doc/doxygen.conf doc/doxPs|doxygen - 285 cd bin/develDoc/latexPs/; make refman.ps; mv refman.ps ../develDoc.ps 286 287clean: tidy 288 rm -rf bin 289 290# ***** Miscellaneous 291 292tidy: 293 find .|grep -x ".*~\|.*/\#.*\#|.*\.stackdump\|gmon\.out\|.*\.orig\|.*/core\|core"|xargs rm -f 294 295# Fixes various white space related issues. 296fixspace: 297 find src/ doc/ -type f|xargs ./fixspace; 298 299commit: test 300 echo 301 hg commit -m "$(MSG)" 302 303# ***** Distribution 304 305remoteUrl = ssh://daimi/projs/frobby 306pull: 307 hg pull $(remoteUrl) 308push: 309 hg push $(remoteUrl) 310 311distribution: 312ifndef VER 313 echo "Please specify version of Frobby distribution using VER=x.y.z"; 314 exit 1; 315endif 316 rm -fr frobby_v$(VER).tar.gz frobby_v$(VER) 317 mkdir frobby_v$(VER) 318 cp -r changelog.txt frobgrob COPYING Makefile src test doc frobby_v$(VER) 319 mkdir frobby_v$(VER)/4ti2 320 tar --create --gzip --file=frobby_v$(VER).tar.gz frobby_v$(VER)/ 321 rm -fr frobby_v$(VER) 322 ls -l frobby_v$(VER).tar.gz 323 324spkg: tidy depend 325ifndef VER 326 echo "Please specify version of Frobby spkg using VER=x.y.z"; 327 exit 1; 328endif 329 if [ "$$SAGE_LOCAL" = "" ]; then \ 330 echo "SAGE_LOCAL undefined ... exiting"; \ 331 echo "Maybe run 'sage -sh?'" \ 332 exit 1; \ 333 fi 334 335 if [ ! -d sage/ ]; then echo "sage/ directory not found."; exit 1; fi 336# Ensure that previous builds have been cleaned up 337 rm -rf bin/sagetmp bin/frobby-$(VER) bin/frobby-$(VER).spkg 338 339 hg clone sage bin/sagetmp 340 341 mkdir bin/sagetmp/src 342 cp -r COPYING Makefile src test bin/sagetmp/src 343 344 mv bin/sagetmp bin/frobby-$(VER) 345 cd bin/; $(SAGE_ROOT)/sage -pkg `pwd`/frobby-$(VER) 346 rm -rf bin/frobby-$(VER) 347