I have two Emacs (Aquamacs and text-based Emacs) on my Mac.
In my .emacs file, I can check if I\'m using Aquamacs with ...
.emacs
(boundp \'aquamacs-
Or, you could use this:
(if (or (eq window-system 'ns) (eq window-system 'mac)) (message "hello, world!"))
It will only print "hello, world!" when you run a graphical Emacs in OS X.