Re: [AMBER-Developers] recommended compilers for MacOSX

From: Thorsten M Woelfle <twoelfle.sdsc.edu>
Date: Mon, 25 Apr 2011 14:52:17 +0200

On Apr 25, 2011, at 1:46 AM, Mengjuei Hsieh wrote:

> The purpose of this procedure is to eliminate one possible factor that
> might interfere users experience. It's really hard for people to understand
> what's going on in their .bashrc/.cshrc, if they didn't remove them from
> the PATH variable and RELOGIN, the Makefiles would most likely still be
> using macports/fink's compilers. That's why I suggested removing them all
> together so that at least we are sure that the prebuilt binaries are indeed
> used for the compilation.


Hi,

Lets assume somebody reads this and now he is curious
1. what a ,, real " mac person is and
2. what is the magic behind .bashrc/.cshrc and in case of mac OS X .profile,
which can be referred as ,,real" unix know how.

Here is what I wanted to read (not too serious):

Essential Mac OS X:
---------------------------
What you buy is called (computer) hardware and on it's own it is quite useless so
you need software which is controlling the hardware. Apart from the startup of a computer, the
software is a operation system and in case of Apple it is OS X and it is mostly opensource today
and can be found here:
http://opensource.apple.com/

The software that really operates the hardware is the kernel, which is mostly linux on gnu compiler based systems and (surprise) xnu
on Mac based systems (today). Get it and compile it yourself, here is how:
http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/KernelProgramming/build/build.html%23//apple_ref/doc/uid/TP30000905-CH221-BEHJDFCA
(I like good to remember, short links :D )
xnu is a mixture of Mach, BSD and other stuff which is perfectly described in
Amit Singh's book Mac OS X internals: A system approach,
very condensed on about 1700 pages.

If you are done, reboot and end up happy, but confused, due to the fact that the computer runs,
 but you can not interact, so get some punch cards ... noooooo.
The first and lowest instance to interact with the kernel today is called a shell which sh/bash on most linux systems and Mac OS X today,
csh on ,,Little Machines" found in my home town and could be zsh if you are weird and lucky enough nobody mentioned.

Apart from graphics which nobody needs, you log in and end up with a shell, but already a lot happened.
On mac .profile is read and executed, on most linux flavors .bashrc (among others) is read.

To make linux and Mac OS X some sort of similar, we write:

 #! /bin/bash
. .bashrc

inside .profile.

If you installed macports you find lines like

##
# Your previous /Users/bla/.profile file was backed up as /Users/bla/.profile. macports-saved_2009-07-14_at_03:04:29
##
 
# MacPorts Installer addition on 2009-07-14_at_03:04:29: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.

# MacPorts Installer addition on 2009-07-14_at_03:04:29: adding an appropriate MANPATH variable for use with MacPorts.
export MANPATH=/opt/local/share/man:$MANPATH
# Finished adapting your MANPATH environment variable for use with MacPorts.

Why?
Well, some things of the great world of opensource are not found on Mac OS X, but this system
occupied your file system on / which is the root, so these things are optional to your local system
so they end up in /opt/local installed with macports. Makes sense.

If you delete this folder you get rid of nothing essential for running your system, you loose macports completely and
if you are unlucky you loose something else, so better
http://guide.macports.org/#installing.macports.uninstalling

The PATH is where your Unix systems looks for programs to execute, the MANPATH is the one which gives you the manpages
which you should read before you ask questions.
In bin there are user programs, in sbin there are super user programs, which are for people that make you think that you know about computers.

All the variables set can be viewed with env in your shell.

If you want to run your own code you download it or write it your own and compile it. Mac OS X, mostly written in C (not too much details) is compiled
with the gnu 4.0 and 4.2 compilers, extended for little things the wanted to make better than BSD 4.4 Unix out of the year 1994.

The xnu kernel requires something like gnu 3.3 the last time I looked at it, see my links.

These compilers lack some cool stuff like openmp support so you as a linux developer want to have some gnu 4.4 or higher and maybe
Apple gets it done, some day ...
They stopped doing ,,real" servers some time last year and found that more money can be made with mobile devices, which (surprise)
run unix, because they have the computational power of computers from ten years ago, which is enough for almost
everybody (read iWoz to know how they think).
 
So today, Mac OS X is like a uber enterprise linux with a xnu kernel. (Again, nobody needs graphics :D )
That is why we use it, no real surprises for unix people, limited amount of very good supported high end hardware and for
your primary system you do not have to worry about, that it works. Please buy whatever you like, or think you like.

Almost thru:
If you want to compile a compiler, you need a compiler unless you bootstrap which is beautiful and ugly at the same time.
The good thing is that even the basis of macports is compiled with the gnu compilers of your mac.
This saves some confusion with libraries.

So choose your compiler with gcc_select:

which gcc_select
vi /opt/local/bin/gcc_select

tells us that they need 200 lines of code in bash (could be sh, boring), to do

which gcc
ls -l /opt/local/bin/gcc | grep gcc
lrwxr-xr-x 1 root admin 25 Feb 27 2010 /opt/local/bin/gcc. -> /opt/local/bin/gcc-mp-4.4

ok nice, so where have I been on that day :D , guess ...

so what they did is

ln -s /opt/local/bin/gcc-mp-4.4 /opt/local/bin/gcc

Great ! Thats all.

"Unix is simple. It just takes a genius to understand its simplicity." – Dennis Ritchie

from http://en.wikipedia.org/wiki/Unix_philosophy.

With that quote I hope you had some fun with my easter egg!

Of course, it is a bit over simplified and I skipped the windows part for the sake of shortness and the good weather outside.
Correct me if I am wrong and point the that link if you like it!


All the best

Thorsten



 
_______________________________________________
AMBER-Developers mailing list
AMBER-Developers.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber-developers
Received on Mon Apr 25 2011 - 06:00:03 PDT
Custom Search