User Tools

Site Tools


how_to_use_xcode2_as_ide_on_a_mac

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
how_to_use_xcode2_as_ide_on_a_mac [2006/07/13 19:26]
audiocommander
how_to_use_xcode2_as_ide_on_a_mac [2011/07/22 14:51] (current)
digineural removed spam
Line 1: Line 1:
-===== Installing GPUTILS & SDCC =====+====== ​How to use Xcode2 as IDE on a Mac ====== 
 While you probably need a PC to burn the MBHP-Loader into the PIC, you can stick to your beloved Macintosh while coding your C-Applications! While you probably need a PC to burn the MBHP-Loader into the PIC, you can stick to your beloved Macintosh while coding your C-Applications!
  
 And more than that: you are able to use Apple'​s powerful Xcode IDE and don't leave that except for sending the .syx file! You can even debug your MIOS C-Applications with the [[MIOS C Simulator - Debugger]] - although this is in a very early development state, please contribute code! //​audiocommander.//​ And more than that: you are able to use Apple'​s powerful Xcode IDE and don't leave that except for sending the .syx file! You can even debug your MIOS C-Applications with the [[MIOS C Simulator - Debugger]] - although this is in a very early development state, please contribute code! //​audiocommander.//​
  
-Wer're starting with SDCC-Installationthen we'll setup a new Xcode2 project:+Firstgo and install [[installing gputils and sdcc on osx|GPUUTILS and SDCC]] on your mac if not already done!
  
-The first step in this process is to install SDCC. If you have already SDCC running and calling "sdcc -v" in terminal gives you the info you're running 2.5. or higher, you have the most complicated step already completed!+If you have already SDCC running and calling "sdcc -v" in terminal gives you the info you're running 2.5. or higher, you have the most complicated step already completed!
  
-==== How to install a library from the terminal ==== 
-If you've never installed *nix libs or codes, don't worry: 
-Either you can fetch a binary (that'​s easy if available for your system, just copy it to usr/​local/​bin) or you have to fetch the source and compile by yourself. In most cases this should be also ok, but if there are missing libraries it can be a bit tricky... 
  
-The "​normal"​ way to install ​and compile packages you loaded (eg from sourceforge) is this:+\\ 
 +Now, let's go on to real cool stuff and switch to Xcode.
  
-Open the Terminal and type "​cd"​ (change directory)Now drag the folder ​containing the unpacked source directory onto the terminal window ​to save yourself from typing the pathClose this step with pressing enter. You should now be in the right directory (hopefully!)+I presume, you have **[[http://​www.ucapps.de/​mios_download.html|downloaded ​the MIOS-C-Skeleton]]**,​ unpacked it in an appropriate ​folder ​and you're ready to start coding your own nifty MIOS-App.
  
-Now you have to type three commands: 
-  * ./config 
-  * make 
-  * make install 
-sometimes you have to call these with "​sudo",​ esp. "sudo make install"​. 
  
-If you have problems compiling and installing SDCC, you might lack a library.+\\
  
-Here is what you should have installed (in this particularly order)+====== About Targets and Makefiles ======
  
-==== 1. GPUTILS ==== +Okay, if you'​re ​pro, you can skip this, else some words for the basic understanding.
-[[http://​www.1710.co.uk/​picosx/​|Ben]] has released ​[[http://​www.1710.co.uk/​picosx/​Resources/​gputils-installer-osx.zip|precompiled GPUTILS installer]]. Thanks ​for that!\\ +
-Check out the rest of his site, he has some useful infos about MicroChip Dev on OSX+
  
-==== 2. SDCC ==== +To generate the myapplication.syx file that we can upload to the Core, a process of different steps has to be processed. This process is normally handled by a script called "​Makefile":​ 
-The SDCC sourcecode is available here: http://sdcc.sourceforge.net/index.php#​Download ​(latest snapshot – don'​t use the installer for SDCC 2.4.0 for Mac, it won't work; you'll need 2.5.x or higher)+  * (SDCC) Preprocess the sources (=> main.c & otherfiles.c)  
 +  * (SDCC) Compile the sources (=> output/​*.asm) 
 +  * (SDCC) Assemble to objects (=> output/*.o) 
 +  * (GAPSM ​GPLINK) Link objects to executeable (=> *.hex) 
 +  * (hex2syx.pl) Convert to SysEx (=> *.syx)
  
-If you have trouble compiling ​the sdcc source (and you will have trouble, believe me), you might better try binary precompiled release. I've built a binary installerhttp://www.audiocommander.de/downloads/midibox/​sdcc254-installer-osx.mpkg.tgz ​ **(MAC OS X Only!)** +If you're using the [[ACSim]], you need different script; now the GCC compiler is used instead of SDCC because the executeable should run on the Macintosh and not on the box, so the process above would look like this: 
-Now, is that cool? 8-)+  * (GCC) Preprocess the sources (=> main.c & otherfiles.c) 
 +  * (GCC) Compile the sources (=> build/myApp.build/*.asm) 
 +  * (GCCAssemble to objects (=> build/​myApp.build/​*.o) 
 +  * Link objects to binary executeable (=> build/​Debug/​*.bin)
  
-A test in the terminal with "sdcc -v" should ​now show the proper version: +Okay, now you could either sit down and write your own Makefile (uuhh, that's for the real nerds only), or you do it the easy way by calling some scripts! In Xcode (and any other IDE) you can compile/assemble/link as many executeables out of your sources as you like, by setting up different targets for each applicationSo once you've set up a target it can easily be selected by a drop-down menuDon't forget to choose the right target before compiling your sources ;)
-<code bash> +
-mymac:~ user$ sdcc -v +
-SDCC : mcs51/gbz80/z80/​avr/​ds390/​pic16/​pic14/​TININative/​xa51/​ds400/​hc08 2.5.4 #1189 (Dec 30 2005(UNIX) +
-</​code>​+
  
-If you get instead a return "​command not found",​ you have to add usr/​local/​bin ​to your path environment:​ +But targets aren't only useful ​to generate executeables,​ they can also be used to generate the Makefile!
-<code bash> +
-mymac:~ user$ echo $PATH +
-</​code>​+
  
-now you should something like this: "/​bin:/​sbin:/​usr/​bin:/​usr/​sbin"​+As you can see, the Makefile invokes several installed applications,​ which makes the file not cross-platform compliant. So before we can compile the real application,​ we need to generate our own Makefile, which can be easily done by adapting the included MAKEFILE.SPEC and setting up an extra target.
  
-copy this line (the output from your terminal window, not the one above)now type & paste: +This is what we will need to do: 
-<code bash> +  * Create a new project 
-mymac:~ user$ PATH=:<​paste here>:/​usr/​local/​bin +  * Set up a new target: Makefile ​(run once and whenever you add more object sources to the MAKEFILE.SPEC) 
-</​code>​+  * Set up a new targetApplication.syx 
 +  * Set up a new target: Application_debug (optional if [[ACSim]] is used)
  
-==== 3. If there are errors ====  
-You might need additional libraries. 
-Go and load [[http://​fink.sourceforge.net/​|Fink]] and [[http://​finkcommander.sourceforge.net/​|FinkCommander]]! 
  
-Then open FinkCommander and install these libraries: 
--> gettext-0.14.5,​ gputils-0.13.2,​ libiconv-1.9.2_1,​ libtool-1.5.22_1 
-And don't blame me or anyone else if this breaks up something. It's your own responsibility! 
  
-If you have trouble installing SDCC on your mac, post your questions/​problems here: http://​www.midibox.org/​forum/​index.php?​topic=6527.0+\\
  
-===== Let's open Xcode2 ===== +====== Creating a new project ​======
- +
-That was pretty easy, wasn't it? +
- +
-Now, let's go on to real cool stuff and switch to Xcode. +
- +
-I presume, you have downloaded the MIOS-C-Skeleton,​ unpacked it in an appropriate folder and you're ready to start coding your own cheezy MIOS-App. +
- +
- +
-==== Creating a new project ====+
  
 Create a new, empty project from the File-Menu. Select your MIOS-application folder. Create a new, empty project from the File-Menu. Select your MIOS-application folder.
Line 81: Line 59:
 Edit the file "​MAKEFILE.SPEC"​ to your needs. That means, if you have additional classes, you should add them to "​MK_ADD_OBJ myfile.c"​ Edit the file "​MAKEFILE.SPEC"​ to your needs. That means, if you have additional classes, you should add them to "​MK_ADD_OBJ myfile.c"​
  
-==== Setting up the make target ====+\\ 
 + 
 +====== Setting up the make target ​======
  
 Because things change a lot, we're making it easy: we set up a "​makefile"​-target,​ so with a press of button, your new makefile is generated! Because things change a lot, we're making it easy: we set up a "​makefile"​-target,​ so with a press of button, your new makefile is generated!
Line 100: Line 80:
  
 PATH=/​usr/​local/​bin:​$PATH PATH=/​usr/​local/​bin:​$PATH
 +cd "​$SRCROOT"​
 +./​tools/​mkmk.pl "​$SRCROOT/​MAKEFILE.SPEC"​
 +echo Makefile replaced.
  
-cd $SRCROOT/​tools +exit 0 
-./mkmk.pl $SRCROOT/MAKEFILE.SPEC+</code>
  
-rm Makefile.bat +for Xcode 3 you need to strip the quotes: 
-echo Makefile.bat deleted \(blame Windows®\). +<code bash> 
-mv -f Makefile ​../+# shell script goes here 
 + 
 +PATH=/​usr/​local/​bin:​$PATH 
 +cd $SRCROOT/​tools 
 +./mkmk.pl "​$SRCROOT/MAKEFILE.SPEC"​
 echo Makefile replaced. echo Makefile replaced.
-echo Success. 
  
 exit 0 exit 0
 +</​code>​
 +
 +If you get an error like "line x: ./mkmk.pl: Permission denied",​ you need to give the perl script execute rights. Easiest way to do this is open your favorite FTP program and set "​Executeable"​ or use the Terminal:
 +<​code>​
 +chmod 750 <drag mkmk.pl in terminal window, path should appear)
 </​code>​ </​code>​
  
Line 121: Line 112:
 If you want to, you can now add "​$(SRCROOT)/​MAKEFILE.SPEC"​ to the "Input Files" and "​$(SRCROOT)/​Makefile"​ to the "​Output Files"​. Then Xcode2 checks if any of the input files is newer than the output files and will start the build only if necessary. If you want to, you can now add "​$(SRCROOT)/​MAKEFILE.SPEC"​ to the "Input Files" and "​$(SRCROOT)/​Makefile"​ to the "​Output Files"​. Then Xcode2 checks if any of the input files is newer than the output files and will start the build only if necessary.
  
-==== Setting up the primary application target ====+\\ 
 + 
 +====== Setting up the primary application target ​======
  
 Now this is basically the same as before. Now this is basically the same as before.
-Repeat the steps above, but call your target like your application. The bash script would look like this in the "Run Script":​+Repeat the steps above, but name your target like your application. The bash script would look like this in the "Run Script":​
  
 <code bash> <code bash>
Line 131: Line 124:
 PATH=/​usr/​local/​bin:​$PATH PATH=/​usr/​local/​bin:​$PATH
  
-cd $SRCROOT+cd "$SRCROOT"
 make make
  
 exit 0 exit 0
 </​code>​ </​code>​
 +
 +For XCode 3.0 (under Leopard) do not forget to remove the quotes around the $SRCROOT (the variable points to your project directory).
  
 As you see, the only trick is, to invoke the makefile. As you see, the only trick is, to invoke the makefile.
Line 143: Line 138:
 Easy, isn't it? Easy, isn't it?
  
-===== Debugging with Xcode ===== 
  
-go to the [[mios_c_simulator_-_debugger]] page and grab the debug sources. Note, that these are far from being complete. If you add functions in your own project, please update the files here in the wiki!+\\ 
 + 
 +====== Debugging with Xcode ====== 
 + 
 +go to the [[mios_c_simulator_-_debugger|ACSim]] page and grab the debug sources. Note, that these are far from being complete. If you add functions in your own project, please update the files here in the wiki!
  
 Add the debug-files to your Xcode project, and adapt what needs to be adapted (defines, includes etc...). Add the debug-files to your Xcode project, and adapt what needs to be adapted (defines, includes etc...).
Line 153: Line 151:
 Now you have to add the Carbon Framework (Right Mouse on the Folder "​Libraries",​ Add Framework, Search for Carbon). Now you have to add the Carbon Framework (Right Mouse on the Folder "​Libraries",​ Add Framework, Search for Carbon).
  
-At this point you just have to make sure, that "debug.c" ​is the only file that is included for this target. If you open the debug target, you see "​Compile Sources (1)". If there are more files than "​debug.c",​ delete them from this target.+At this point you just have to make sure, that "ACSim_console.c", "​ACSim_mios.c"​ and "​ACSim_toolbox.c"​ are the only files that is included for this target. If you open the debug target, you see "​Compile Sources (3)". If there are more files than "​debug.c",​ delete them from this target.
  
 **Important:​** ​ **Important:​** ​
Line 159: Line 157:
  
 If you have questions, feel free to post them here: http://​www.midibox.org/​forum/​index.php?​topic=6527.0 If you have questions, feel free to post them here: http://​www.midibox.org/​forum/​index.php?​topic=6527.0
 +
 +
how_to_use_xcode2_as_ide_on_a_mac.1152818790.txt.gz · Last modified: 2006/10/15 09:35 (external edit)