Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

Using a Bash Script to determine CPU Class?

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
2 posts • Page 1 of 1
Author
Message
cartpullerjack
Apprentice
Apprentice
Posts: 185
Joined: Sun Nov 16, 2003 5:19 am

Using a Bash Script to determine CPU Class?

  • Quote

Post by cartpullerjack » Thu May 18, 2006 9:42 pm

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.
Top
ciaranm
Retired Dev
Retired Dev
User avatar
Posts: 1719
Joined: Sat Jul 19, 2003 11:04 pm
Location: In Hiding
Contact:
Contact ciaranm
Website

  • Quote

Post by ciaranm » Thu May 18, 2006 9:59 pm

Depends upon whether or not you're just after x86 support. dev-util/cpuinfo-collection might be a useful start, anyway.
Paludis 0.12, 127.35% Portage compatible and six times faster.
Top
Post Reply

2 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic