############################################ ## QSIEVE 3.02 - MAKEFILE ## ## 2007-06 by Thorsten Reinecke ## ############################################ # please modify this Makefile for proper # # configuration... # # ... then simply type "make" to compile # ############################################ MAKE:= $(MAKE) -f Makefile.crafted ##################################### # compile options ##################################### # If one of the below defines is activated, then the program will use # its own heap-implementation instead of STL-heaps. # # You can enable fibonacci-heap for sieving large primes, but probably # the priority-queue given by C++-STL is faster... # # You can also try fakeheap, which is a vector that behaves like a heap, # if certain conditions are fulfilled. # # In most cases, fakeheap appears to be the fastest; if unsure, use fakeheap. # #DEFINES += -DUSE_FIBHEAP DEFINES += -DUSE_FAKEHEAP # If you want to use i386 inline assembler code optimizations, you # should enable "-DASM_386", otherwise you should disable this flag. # "-DASM_MMX" enables crafted MMX code. # "-DASM_CMOV" allows to use the conditional mov-instructions. # "-DASM_3DNOW" enables 3DNOW-assembler optimizations. # "-DASM_ATHLON" enables ATHLON-assembler optimizations (3DNOW+extensions). # "-DASM_SSE" allows SSE inline assembler code optimization, which # work on pentium3 and better. If you have an athlon-xp, you may want to # activate them additionally to ASM_ATHLON. # "-DASM_SSE2" allows SSE2 inline assembler code optimization, which # work on pentium4 and better. If you have an athlon-64 (32 bit mode), # you may want to activate them additionally to ASM_ATHLON and ASM_SSE. # In 32 bit mode, it is a good idea to enable as much of these options # as possible, whereas for X86_64 (64 bit mode) you should enable # only -DASM_X86_64 and no others. # On Linux you can determine your processor abilities with the command # "cat /proc/cpuinfo". # @mode_386@DEFINES += -DASM_386 @mode_mmx@DEFINES += -DASM_MMX @mode_cmov@DEFINES += -DASM_CMOV @mode_sse@DEFINES += -DASM_SSE @mode_sse2@DEFINES += -DASM_SSE2 @mode_3dnow@DEFINES += -DASM_3DNOW @mode_athlon@DEFINES += -DASM_ATHLON @mode_X86_64@DEFINES += -DASM_X86_64 # These options enable sieving of squares larger than the sieve interval. # Sieving with large squares takes a lot more time. On the other hand, # using a short sieve interval and a small factorbase, you may have a # chance to factorize more relations using these options. # If unsure, leave these options disabled. # #DEFINES += -DSIEVING_LARGE_SQUARES #DEFINES += -DSIEVING_MORE_LARGE_SQUARES # If you want the server to raise signals to the parent process, # you should enable the following option. If the server is compiled # with this define, it will # send "SIGUSR1" when it's ready to accept clients, # send "SIGUSR2" whenever it finds a new factor. # Be aware that you must install a signalhandler, if you activate this # option!! # In bash you may use "trap" to catch signals, eg.: # trap "echo caught SIGUSR2" SIGUSR2 # #DEFINES += -DNOTIFY_PARENT # For elliptic-curve-method (ecm), phi and fibonacci methods, you can choose # between three continuation methods: # 0: improved standard continuation # 1: fast polynomial evaluation method (using karatsuba) # 2: fast polynomial evaluation method (using fast fourier transform) # # The improved standard continuation should be faster in finding factors up # to 25 decimal digits. If you want to factorize large numbers using lots of # elliptic curves you may find it useful to switch to fft-continuation. The # fft-continuation is asymptotically faster than the improved standard # continuation since it takes advantage of fast polynomial evaluation # schemes. If you run low on memory or if you want to use qsieve as # background-process, it may be better to use improved standard # continuation. # # Method 0: moderate speed, low memory consumption # Method 1: high speed, high memory consumption # Method 2: fastest speed, highest memory consumption # # If unsure, use Method 2, which is actually a mix of karatsuba and dft # and gains best performance for large search intervals. # DEFINES += -DCONTINUATION_METHOD=2 # Is the Linux-specifc sysinfo function available (to get info about # available system resources)? (see fft_param.cc for further information) # @have_linux_sysinfo@DEFINES += -DHAVE_LINUX_SYSINFO=1 # If you use newer versions of gmp (>=gmp-4.0.x), they have defined own # output operators. This conflicts with our own wrappers. As a quick hack, # you should modify the gmp.h-file and enable the cpp-operators only, if # __cplusplus is enabled and USER_GMP_WRAP is disabled. # (See README for more information.) # DEFINES += -DUSER_GMP_WRAP # Do you want to abort some long-running algorithms without changing the # config file? # You can send signals to qsieve! Simply activate the define REACT_ON_SIGUSR # and you are able to send SIGUSR1 to abort the current algorithm or SIGUSR2 # to step right to the continuation phase. # example: killall -i -s USR1 -v qsieve # # If unsure, leave this option disabled. # #DEFINES += -DREACT_ON_SIGUSR # Fancy output in tiled terminal screen using ncurses # (it is safe to leave these disabled) # #DEFINES += -DUSE_NCURSES #NCURSES_LIB = -lncurses -lgpm # For accessing some data structures written to files, qsieve needs to seek # to certain filepositions on various streams and to compare them. - # Comparing stream positions using the "<" operator was disabled for some # experimental prerelease versions of gcc-3.4. - (Since streampositions are # not necessarily standard integer values, this behaviour seems to be # reasonable, but it urged me to write some workarounds to get the desired # values.) - However, these workarounds seem not to be necessary for the # release version of gcc-3.4.0. Nevertheless, if you encounter problems due # to STL-stream incompatibilities, you may want to activate these # workarounds. # #DEFINES += -DSTL_STREAM_workaround # Cygwin support # Some quick and experimental hacks. # standalone version, clients and servers # should now run under Cygwin as well. # @cygwin_mode@DEFINES += -DCYGWIN_COMPAT # Verbosity of output (normal user level) # You can control the verbosity of output by setting various defines. # The verbosity can only be defined at compile time and NOT at run time. # VERBOSE_WARN : print warnings # VERBOSE_NOTICE : print (interesting) notices # VERBOSE_INFO : print (additional) infos # DEFINES += -DVERBOSE_WARN DEFINES += -DVERBOSE_NOTICE #DEFINES += -DVERBOSE_INFO # Protect against various type of errors, forgery, attacks, etc. # If the program is running in an untrusted environment (eg. Internet), # then defective relations could be sent to the server. # This define adds some protection and detection, but it is far # from perfect and reduces performance for the sake of integrity. @safemode@DEFINES += -DSAFEMODE ##################################### # Programs to compile ##################################### # # standard-standalone-factorization # PROGRAMS += qsieve # # network-server for distributed sieving (UNIX) # @generic_os_mode@PROGRAMS += server # # network-client for distributed sieving (UNIX) # @generic_os_mode@PROGRAMS += net-client # # offline-client for distributed sieving # PROGRAMS += file-client # # communication between offline-client and online-server (UNIX) # @generic_os_mode@PROGRAMS += transfer-client # # validate relation files after an aborted factorization # PROGRAMS += validator # # small utility to evaluate integer expressions # PROGRAMS += ieval ####################################################### # path's to GNU-multiple-precision-library # comment out the right ones (or define them yourself) # (CPUFLAGS may be left undefined) ####################################################### #CPUFLAGS = -march=pentium-mmx #CPUFLAGS = -march=pentium3 #CPUFLAGS = -march=pentium4 #CPUFLAGS = -march=k6-3 #CPUFLAGS = -march=athlon #CPUFLAGS = -march=athlon-xp #CPUFLAGS = -march=athlon64 CPUFLAGS ?= @cpuflags@ @gmp_inc_dir@ @gmp_lib_dir@ ############################################################################## # # For proper installation and code-optimization you may modify CFLAGS... # (depending on your compiler, less optimization produces less memory overhead # and simpler code, which could be faster sometimes: so check out # which optimization level works best on your system. On most systems # -O2 would be a safe bet.) # Static linking (LDFLAGS: -static) may improve performance, too. # # Leave the other lines untouched unless you know # exactly what you're doing... # ############################################################################## CXX = @CXX@ OBJ = qsieve.o DEBUG = -g #DEBUG += -DDEBUG #DEBUG += -DVERBOSE #DEBUG += -pg -ftest-coverage -DPROFILE #DEBUG += -fprofile-arcs CFLAGS = -O2 $(CPUFLAGS) -Wall -Wreorder $(DEFINES) @omit_framepointer@CFLAGS += -fomit-frame-pointer #CFLAGS += -Wsynth -fno-weak -fuse-cxa-atexit -fno-elide-constructors CFLAGS += -W -Woverloaded-virtual -Wimplicit -Wcast-qual -Wcast-align CFLAGS += -Wredundant-decls -Wdisabled-optimization -Wconversion -Wsign-promo CFLAGS += -Wwrite-strings #CFLAGS += -Wfloat-equal -Winline #CFLAGS += -Wpadded #CFLAGS += -Weffc++ CFLAGS += -Wold-style-cast CFLAGS += -pedantic CFLAGS += -Wno-long-long #CFLAGS += -fbranch-probabilities # avoiding temporary files may help to speedup compilation @generic_os_mode@CFLAGS += -pipe # create assembler file instead of object code: #CFLAGS += -S -fverbose-asm INCLUDES = -I. $(if $(GMP_inc_dir),-I$(GMP_inc_dir)) #NETLIBS = -lsocket -lnsl LDFLAGS = -L. $(if $(GMP_lib_dir),-L$(GMP_lib_dir)) -lgmp -lm $(NCURSES_LIB) $(NETLIBS) @link_static@LDFLAGS += -static # pthread-library: #PTHREAD = -L/usr/lib -lpthread # this is weird: some weak symbols are set to 0 and causing net-client and server to segfault (when statically linked), # we can circumvent this issue by undefining the weak symbols and forcing to link against libpthread. # It's a hack, but it seems to work... PTHREAD = -u pthread_create -u pthread_cancel -u pthread_mutex_init -u pthread_mutex_lock -u pthread_mutex_trylock -u pthread_mutex_unlock -lpthread ALL_FLAGS_NO_LD = $(DEBUG) $(CFLAGS) $(INCLUDES) ALL_FLAGS = $(ALL_FLAGS_NO_LD) $(LDFLAGS) # DO NOT EDIT THIS... SERVER = -DIS_SERVER -DUSE_NETWORK -D_REENTRANT CLIENT = -DIS_CLIENT VERSION := $(shell cat VERSION) DEFINES += -DVERSION=\"$(VERSION)\" .PHONY : Makefile Makefile.* clean debug-clean distclean doc .EXPORT_ALL_VARIABLES : ; all: $(MAKE) -C src @cygwin_invmode@ln -i $(addprefix src/, $(PROGRAMS)) . @cygwin_mode@ln -i $(addsuffix .exe, $(addprefix src/, $(PROGRAMS))) . # reference manual by given (default) sample file doc: @doxygen@ # do we have an libstdc++.tag file? -> get it... libstdc++.tag: @wget@ http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/libstdc++.tag # reference manual for standalone version of qsieve refman-qsieve: libstdc++.tag sed s/@PROJECT_NAME@/"qsieve-standalone"/g Doxyfile.in > x.tmp sed s/@PREDEFINES@/"IS_STANDALONE"/g x.tmp > y.tmp sed s/@GENERIC_PREDEFINES@/"$(subst -D,,$(DEFINES))"/g y.tmp > x.tmp @doxygen@ x.tmp # reference manual for net-client refman-net-client: libstdc++.tag sed s/@PROJECT_NAME@/"qsieve-net-client"/g Doxyfile.in > x.tmp sed s/@PREDEFINES@/"IS_CLIENT USE_NETWORK _REENTRANT"/g x.tmp > y.tmp sed s/@GENERIC_PREDEFINES@/"$(subst -D,,$(DEFINES))"/g y.tmp > x.tmp @doxygen@ x.tmp # reference manual for server refman-server: libstdc++.tag sed s/@PROJECT_NAME@/"qsieve-server"/g Doxyfile.in > x.tmp sed s/@PREDEFINES@/"IS_SERVER USE_NETWORK _REENTRANT"/g x.tmp > y.tmp sed s/@GENERIC_PREDEFINES@/"$(subst -D,,$(DEFINES))"/g y.tmp > x.tmp @doxygen@ x.tmp clean: $(MAKE) -C src $@ rm -f *.o $(PROGRAMS) @cygwin_mode@rm -f $(addsuffix .exe,$(PROGRAMS)) debug-clean: $(MAKE) -C src $@ rm -f *.bb *.bbg *.out *.gcov *.da core distclean: clean debug-clean $(MAKE) -C src $@ rm -f *.d *.o *.dat *.tmp *~ factorizations.txt qsieve-fc.param* rm -f qsieve file-client server net-client transfer-client ieval rm -f qsieve@* file-client@* server@* net-client@* transfer-client@* rm -rf doc qsieve server net-client file-client transfer-client validator ieval %: Makefile $(MAKE) -C src $@ @cygwin_invmode@$(if $(findstring $@,$(PROGRAMS)),ln -i src/$(findstring $@,$(PROGRAMS)) .,echo "nothing to copy") @cygwin_mode@$(if $(findstring $@,$(PROGRAMS)),ln -i src/$(findstring $@,$(PROGRAMS)).exe .,echo "nothing to copy") install: @echo "Sorry, you have to install Qsieve manually..."