.\" $NetBSD: cpuflags.1,v 1.12 2003/05/29 11:45:50 abs Exp $ .Dd May 31, 2001 .Dt CPUFLAGS 1 .Os .Sh NAME .Nm cpuflags .Nd determine compiler flags to best target current cpu .Sh SYNOPSIS .Nm .Op cc_pathname .Sh DESCRIPTION .Nm queries the current cpu type and gcc version, then outputs appropriate compiler options to best target code for that cpu. If no options exist to target the current cpu then nothing is output. .Pp In the event of the cpu not being recognised, a warning is sent to stderr. .Pp If .Pa cc_pathname is not specified it defaults to the first .Pa cc found in the path. .Sh ENVIRONMENT The makefile fragment .Pa /usr/pkg/share/mk/cpuflags.mk will set the following .Xr make 1 variables, plus add CPU_FLAGS and CPU_DIR to .MAKEFLAGS for sub-makes. .Pp .Bl -tag -width CPU_FLAGS -compact .It CPU_FLAGS The output of cpuflags .It CPU_DIR CPU_FLAGS with spaces stripped (eg: for use in PACKAGES) .It CFLAGS Has CPU_FLAGS appended .It CXXFLAGS Has CPU_FLAGS appended .El .Sh FILES .Bl -tag -width /usr/pkg/share/mk/optimize_gcc.mk -compact .It /usr/pkg/share/mk/cpuflags.mk Set appropriate compiler flags based on the output from .Nm . Suitable for inclusion in /etc/mk.conf .It /usr/pkg/share/mk/optimize_gcc.mk Attempt to set additional -mXXX gcc flags based on gcc version and packages being compiled. Note: This is experimental and not supported. .El .Sh EXAMPLES .Nm can be used to set default flags for building entries from pkgsrc and recompiling the .Nx kernel or userland by adding the following to .Pa /etc/mk.conf : .Bd -literal -offset indent .sinclude "/usr/pkg/share/mk/cpuflags.mk" .Ed .Pp Those desiring further optimisation can install the lang/gcc3 package, and add the following to .Pa /etc/mk.conf instead: .Bd -literal -offset indent .sinclude "/usr/pkg/share/examples/gcc/mk.conf" .sinclude "/usr/pkg/share/mk/cpuflags.mk" .Ed .Pp To experiment with optimisations that can break generated code there is optimize_gcc.mk. This is unsupported, but for full effect add the following to .Pa /etc/mk.conf : .Bd -literal -offset indent .sinclude "/usr/pkg/share/examples/gcc/mk.conf" .sinclude "/usr/pkg/share/mk/cpuflags.mk" .sinclude "/usr/pkg/share/mk/optimize_gcc.mk" .Ed .Pp On all except low memory machines compliation can be speeded up by adding the following to /etc/mk.conf. (Note this will not affect the binaries produced) .Bd -literal -offset indent COPTS+=-pipe CFLAGS+=-pipe .Ed .Pp .Sh BUGS .Nm still needs to learn about more cpu types - updates welcomed to . .Pp Currently .Nm is also gcc specific.