Next: 3 Installing the Tool Up: Writing GNUstep Makefiles Previous: 1 What is it

2 A First Tool

Let's try it out by making a little command line tool using the GNUstep make package. Let's start by creating a directory to hold our project. In this directory, type the following extremely simple program in a file called say source.m.
#import <Foundation/Foundation.h>

int
main (void)
{ 
  NSLog (@"Executing");
  return 0;
}
The function NSLog simply outputs the string to stderr, flushing the output before continuing. To compile this little program as a command line tool called LogTest, add in the same directory a file called GNUmakefile, with the following contents:
include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = LogTest
LogTest_OBJC_FILES = source.m

include $(GNUSTEP_MAKEFILES)/tool.make
And that's it. At this point, you have all the usual standard GNU make options: typically make, make clean, make install, make distclean. For example, typing make in the project directory should compile our little tool. It should create a single executable LogTest, and put it in the subdirectory ``obj'' of your current directory, that is, in
./obj
You can try the tool out by typing
./obj/LogTest

When you type make, the system will check if any changes were made to the source code since the last time you compiled, and if so, it will rebuild your software.

If you want to remove the results of a previous compilation (for example, to later force a recompilation with different options) you can use the command

make clean


Next: 3 Installing the Tool Up: Writing GNUstep Makefiles Previous: 1 What is it
2010-02-14