Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Build a GCC 3.3 C compiler for Intel Mac OS X UNIX
Tiger only hintI use a GCC cross compiler for embedded systems development on my Mac. I use Apple's supplied GCC to build the cross toolchain, but when Apple started using GCC 4.0.x, I could no longer compile the specific version of binutils and GCC that I need.

On PowerPC Macs, I could revert to Apple's GCC 3.3 to compile my toolcain, but on my new Macbook Pro, Xcode does not come with GCC 3.3. It is my understanding that Apple will not be providing a GCC 3.3 for Intel OS X.

Fixing my toolchain to compile with GCC 4.0.x is not an option, because the tools are under configuration management and build fine on all of the other computers in my organization ( cygwin and linux ).

After much expermenting, I finally was able to build Apple's GCC 3.3 so I could then build an Intel OS X hosted version of my cross toolchain.

Here is what I did: 1. Download the source code for Apple's GCC 3.3 in Xcode 2.2 here. Get the file named gcc_os-1819.tar.gz

2. Unpack the source.

$ tar -zxf gcc_os-1819.tar.gz

3. Fix a line that causes it to not compile: in the file gcc_os-1819/gcc/gcc.c, on line 5883, change the line to look like this:

(char ) v[q - vt] = 0;

4. Make a build directory and run configure. I installed my compiler in /opt/gcc3, and I only built the C compiler. This would not work for building C++ or Cocoa applications.
$ mkdir build
$ cd build
$ ../gcc_os-1819/configure --prefix=/opt/gcc3 --enable-languages=c
5. Build the compiler:

$ make all

6. Install the compiler in /opt/gcc3:

$ sudo make install

7. Test it:
$ /opt/gcc3/bin/gcc -v
Reading specs from /opt/gcc3/lib/gcc-lib/i686-apple-darwin8.6.1/3.3/specs
Configured with: ../gcc_os-1819/configure --prefix=/opt/gcc3 --enable-languages=c
Thread model: single
gcc version 3.3 20030304 (Apple Computer, Inc. build 1819)
Now, you can use the compiler to build Unix packages that will not build with GCC 4.0.x.

[kirkmc adds: I haven't tested this.]
  Post a comment  •  Comments (10)  
  • Currently 2.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[27,192 views] Email Article To a Friend View Printable Version
Solaris / SysV Style ps UNIX
I come from a Solaris background, and my fingers can't seem to get used to typing ps -aux instead of ps -ef. So I wrote this script called ps-ef to save some sanity and format the ps output as close to Solaris style as I could. It will pass on any options to OS X's ps, so something like ps-ef -ww will work too. Just make it executable (chmod +x and put it somewhere in your path.
#!/bin/bash
pformat="user=UID,pid,ppid,cpu=C,start=STIME,tty,time,command"
psarglist=
psarglistlong=
while true ; do
        if [ -z "$1" ]; then
                break;
        fi
        optchar=${1:1}
        case $optchar in
                O|o|p|t|U)
                        shift
                        psarglistlong="$psarglistlong -$optchar $1"
                ;;
                *)
                        psarglist="$psarglist$optchar"
                ;;
        esac
        shift
done
ps -ax$psarglist $psarglistlong -o $pformat
  Post a comment  •  Comments (5)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[8,697 views] Email Article To a Friend View Printable Version
10.4: Fix a command-line FTP problem with IPv4 servers UNIX
Tiger only hintI sometimes use the command-line FTP program that's included with Mac OS X to upload files to my ISP. Since Tiger was released, I have had problems. The login process always works fine, but when I try to do a dir command, for example, the program stalls and I never get the results.

For a while I suspected my Linksys router to be the problem. But I tried the same FTP commands on a Linux box I have, and everything worked fine. So it really is a Tiger issue.

After some investigation, I found that Tiger's FTP program has an option set by default: EPSV/EPRT on IPv4. To disable this, you must issue the epsv4 command in the FTP program before doing anything else. From now on, any command will work correctly and as expected.

[kirkmc adds: The man page for the ftp command mentions this option and command. It seems that the option exists in Panther, but was not enabled by default.]
  Post a comment  •  Comments (9)  
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[11,552 views] Email Article To a Friend View Printable Version
Create multiple folders from Terminal UNIX
I needed to create a new folder for each of a list of customers, and knew there had to be a better way than doing it manually. So I looked at the mkdir command, which creates new folders or directories. It uses the following syntax:
mkdir folder1 folder2 folder3
I tried redirecting a file with a list of folder names into mkdir with no success, so I ended up just copying and pasting my list into Terminal. You cannot use a list with returns; all the names need to be on one line, separated by spaces.

[kirkmc adds: While this is a pretty basic hint, it shows some interesting things that you can do from Terminal. First, you need to tweak your list of customers (or whatever) so all the names are on one line. Next, you need to worry about spaces: if you have names with spaces, the names need to be in quotes, such as "Henry David Thoreau"; otherwise, you'd get individual folders named Henry, David and Thoreau. You could also use underscores (Henry_David_Thoreau), or other characters as separators.

For example:
$ mkdir "Henry David Thoreau" Ralph_Waldo_Emerson Walt-Whitman
The above command makes a total of three new folders, the first separated by spaces, the second by underscores, and the third with a hyphen; the only constraints are the actual tweaking of your list. You may need to take a tab- or return-delimited list and replace the tab or returns, or manually add quotes, but you can use this to create any number of folders very quickly.]
  Post a comment  •  Comments (36)  
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[43,686 views] Email Article To a Friend View Printable Version
Programmable screenshot utilities UNIX
The usual screenshot utilities, both built-in and third-party, never seemed to do what I wanted. Fortunately, Apple has provided three command-line utilities, screencapture, sips, and pbcopy, which can be combined in scripts to do exactly what I want.

An example script--which takes a screenshot (window, selection rectangle, or entire screen), resizes it to a given size or scale, saves it with a given filename, uploads it via FTP to a specified site, and puts the new file's URL on the clipboard--is described on this page.

[kirkmc adds: We've covered these command line utilities in various tips here in the past: screencapture, sips, and pbcopy, if you're interested in seeing what else you might do with them.]
  Post a comment  •  Comments (1)  
  • Currently 2.00 / 5
  You rated: 2 / 5 (5 votes cast)
 
[6,565 views] Email Article To a Friend View Printable Version
10.4: Create multi-partition Boot Camp disks UNIX
Tiger only hintIt turns out that part of the 10.4.6 update was the inclusion of non-destructive partitioning in diskutil, via the new resizeVolume option.

You can use this feature, for example, to create a Boot Camp setup with more than two partitions. For an explanation, see this entry on bbum's web site.

[robg adds: This will only work on GPT (GUID Partition Table) disks, which are what you'll find in an Intel Mac. I used Disk Utility to format a FireWire drive with GPT, then used diskutil to try to resize it on the fly. I think this should work, but I was having issues with the sizing of the partitions, resulting in an error. Given more time, it should be possible. Disk Utility, however, does not seem to support the non-destructive option, even on GPT disks.]
  Post a comment  •  Comments (10)  
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[38,402 views] Email Article To a Friend View Printable Version
A script to automate clamav package updates UNIX
ClamAV is an open source antivirus product. You can update the virus definitions by running the command freshclam in Terminal. The only shortcoming of the packages is that when the clamav package itself is updated, you have to surf to the sourceforge site, download the latest tarball, compile it and install it.

This shell script automates all of this:

#!/bin/sh
############################################
## Documentation:
## This script downloads the latest version of clamav and installs
## it. I've used the download mirror in Phoenix Arizona. You should
## modify the url variable to the mirror closest to you.
############################################
url="http://easynews.dl.sourceforge.net/sourceforge/clamav/clamav-"
latest=`lynx -dump "http://www.clamav.net/stable.php#pagestart" \
| grep "   clamav" | awk '{print $2}' | head -1`
wget $url$latest.tar.gz && \
printf "The latest version of clamav or %s has been downloaded!\n" $latest && \
tar zxvf clamav-$latest.tar.gz && \
cd clamav-$latest
./configure &&
make && \
sudo make install && \
printf "Ok I am updating to the latest virus definitions for \
version %s by running freshclam.", $latest && \
freshclam && \
cd ..
rm -rf cd clamav-$latest

[robg adds: I haven't tested this one -- there's also a GUI version of ClamAV for OS X called ClamXav, if you'd like to try it out without the command line work.]
  Post a comment  •  Comments (12)  
  • Currently 2.67 / 5
  You rated: 2 / 5 (3 votes cast)
 
[17,594 views] Email Article To a Friend View Printable Version
Watch Star Wars Episode IV in ASCII via Terminal UNIX
Open Terminal and type...
telnet towel.blinkenlights.nl
...to watch Star Wars Episode IV in it's entirety in ASCii characters!

[robg adds: I thought we had run this one before, but a quick search proves my memory is failing after 8,600+ hints...]
  Post a comment  •  Comments (16)  
  • Currently 4.00 / 5
  You rated: 2 / 5 (11 votes cast)
 
[143,526 views] Email Article To a Friend View Printable Version
Play Chess from Terminal.app UNIX
I couldn't find anything on macosxhints.com, so I thought I would post this. In Terminal, navigate into the Chess.app package:
$ cd /Applications/Chess.app/Contents/Resources/
You'll find that Chess.app is based on the free chess program Sjeng (version 11.2). So you can play it in the Terminal, if you wish. Just type ./sjeng (link to it for easier access), and have fun!

Does anybody know how to make it play against gnuchess (via xboard)? It would be cool to see the winner!!
  Post a comment  •  Comments (4)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[8,774 views] Email Article To a Friend View Printable Version
Restore PHP, MySQL, etc. after a fresh OS X install UNIX
Yesterday, when I tried to run the 10.4.6 updater on my Dual G5, it locked up just before the end of the progress bar -- all apps went spinning beachball, and force quit had no affect. I had no choice but to power down manually, after waiting about 45 minutes to make sure it was really and truly locked up.

When the machine rebooted, it booted onto another partition, which was running 10.2.7. That was a bad sign. The 10.4 partition showed up, and all data seemed usable. I quickly made another backup of my key user files (even though I was current as of the day before), then set out to fix the drive. Disk Utility found and fixed a couple problems, but I still couldn't select the partition as my startup drive. Disk Warrior wasn't able to rebuild the directory -- it hung on the final "writing new directory" step. Stumped at this point, I could have restored an old clone, but there's well over 100GB on that partition, and that would take a long time. So instead, I opted to do an archive and install of OS X, with the Retain User Settings option enabled. This archives your current OS X installation, installs a new copy of OS X, then moves all your user data into the new system.

After rebooting and running the Combined 10.4.6 Updater, along with about 15 other updates, the machine was basically perfectly healthy again -- except for the various Unix bits I had installed myself -- things like customizing my Apache configuration file, all my web site stuff in the WebServer directory, my MySQL installation (along with all the databases), and my PHP installation (I use the version on entropy.ch, not the bundled PHP). All of these things live in the Unix side of the system, which was obviously wiped clean with the new OS X install.

Getting them back was relatively trivial, but I thought I'd take a few minutes to document what steps I took...
read more (306 words)   Post a comment  •  Comments (15)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[16,128 views] Email Article To a Friend View Printable Version