I'm trying to write a script that will automagically detect what kind of CPU the machine its running on has, for purposes of say, compiling a kernel optimized for that architecture. I'd like to identify a machine as one of:
Pentium MMX, Pentium II, Pentium III, Pentium IV, Athlon, Athlon XP
I'd also like to determine the number of processors running on that machine, to tell whether I should have a SMP enabled kernel or not.
Unforunately, I can't depend on checking which architecture the currently running kernel is (could be a 386-targetted kernel running on a dual AMD64, for instance).
I've tried the uname -m and arch commands, but these don't seem to differentiate between the various i686 architectures, for instance. Parsing the "model name" field of /proc/cpuinfo doesn't work, either, for instance, because of the various kinds of Xeons on the market (the model name doesn't reflect what kind of core the Xeon is based on, and there are several of these).
One thing that might work would be to build a look-up table based on the "cpu model" "family" and "stepping" fields in /proc/cpuinfo, but I haven't been able to find one that is anything near complete.
Is there anything I'm overlooking? Does anyone know how to do this?
Thanks in advance.

