From 43873ef0ff403a6bc0242f8cc8510060127abde3 Mon Sep 17 00:00:00 2001 From: Matthew Cline Date: Sat, 17 Oct 2009 20:22:24 -0700 Subject: makefile: Automatically optimize for your machine Setting the makefile variable AUTO_OPT_GCC will give GCC a list of optimization flags suited for the machine make is run on. It does this using util/auto-opt.sh. "-march=native -mtune=native" are always outputted, which causes GCC to detect the CPU type you use and generate code for that. On Linux systems it also looks at the flags line of /proc/cpuinfo to pick x86 optimization flags. --- crawl-ref/source/makefile | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/makefile') diff --git a/crawl-ref/source/makefile b/crawl-ref/source/makefile index f3bcd0b51b..03557f4a4f 100644 --- a/crawl-ref/source/makefile +++ b/crawl-ref/source/makefile @@ -24,16 +24,35 @@ GAME = crawl # CFWARN(_L) - Warning flags # CFOTHERS(_L) - Anything else # -# These are good optimizations for a Pentium M or better: -#CFOPTIMIZE := -O2 -march=i686 -mtune=i686 -mmmx -msse -msse2 -mfpmath=sse -funroll-all-loops + # These are really good options for the Intel C++ compiler: #CFOPTIMIZE := -O2 -parallel -CFOPTIMIZE := -O2 + +# Define this to automatically generate code optimized for your machine +# (GCC only as of now). +# +# NOTE: Don't use this with a release build, since the generated code +# won't work for all machines. +ifdef AUTO_OPT_GCC + +ifdef CROSSHOST +error Can not do AUTO_OPT_GCC with CROSSHOST +endif + +ifdef HURRY +error Can not do AUTO_OPT_GCC with HURRY +endif + +AUTO_OPT_FLAGS := $(shell util/auto-opt.sh) +endif + +CFOPTIMIZE := -O2 $(AUTO_OPT_FLAGS) CFOTHERS := -fno-strict-aliasing -pipe CFOTHERS_L := -fsigned-char CFWARN := -Wall MAKEFLAGS := --no-print-directory + # # The GCC and GXX variables are set later. # -- cgit v1.2.3-54-g00ecf