Jump to content

Xcode and makefiles


  • Please log in to reply
2 replies to this topic

#1
helixed

helixed

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 2 posts
I'm in a programming class and part of our assignements is we have to generate our own makefiles. Does anybody know how I can prevent Xcode from generating the makefile for me and instead instead write my own for my C program?

Thanks,

helixed

#2
srs5694

srs5694

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPip
  • 541 posts
  • Gender:Male
  • Location:Woonsocket, RI
Just ignore the Xcode GUI, write your own Makefile, and use it like you would on a Unix box -- by typing "make" in the source directory (which must also include the Makefile). Of course, you can still use the Xcode GUI to edit your code if you like, and it can be helpful for debugging, etc. In other words, you can use both.

#3
moridinbg

moridinbg

    InsanelyMac Protégé

  • Members
  • Pip
  • 48 posts
In fact you can import standard Makefile project in XCode. It's described in Porting UNIX/Linux Applications to Mac OS X

The steps are:

1. Launch Xcode.
2. Choose New Project from the File menu.
3. Select whatever project type you are targeting. If you ultimately want an application, select something like Cocoa Application. If you are just trying to build a command-line utility, select one of the tools—for example, Standard Tool.
4. Follow the prompts to name and save your project. A new default project of that type is opened.
5.Open the Targets disclosure triangle and delete any default targets that may exist.
6. From the Project menu, Choose New Target.
7. Select “External Target” from the list. If this is not shown in the “Special Targets” list, you are not running the latest version of Xcode. Upgrade first.
8. Follow the prompts to name that target. When you have done this, a target icon with the name you just gave it appears in the Targets pane of the open Xcode window.
9. Double-click that new target. You should now see a new window with the build information for this target. This is not the same thing as clicking info. You must double-click the target itself.
10. In the “Custom Build Command” section of the target inspector, change the field called “Directory” to point to the directory containing your makefile, and change any other settings as needed. For example, in the Custom Build Settings pane, you could change Build Tool from /usr/bin/gnumake to /usr/bin/bsdmake. More information on the fields is available in Xcode Help.
11. Change the active target to your new target by choosing "Set Active Target" from the Project menu.
12. Add the source files to the project. To do this, first open the disclosure triangle beside the “Source” folder in the left side of the project window. Next, drag the folder containing the sources from the Finder into that “Source” folder in Xcode. Tell Xcode not to copy files. Xcode will recursively find all of the files in that folder. Delete anything you don’t want listed.
13. When you are ready to build the project, click the Build and Run button in the toolbar, select Build from the Build menu, or just press Command-B.
14. Once the project is built, tell Xcode where to find the executable by choosing “New Custom Executable” from the Project menu. Choose the path where the executable is located, then add the name of the executable.
15. Run the resulting program by pressing Command-R.





Read some of the Apple article. It's really helpfull.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy