Next: Enabling Debugging Up: Writing GNUstep Makefiles Previous: What is it

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
shared_obj/ix86/linux-gnu/gnu-gnu-gnu-xgps
(or in a similar one, according to your system). To install the tool, simply type make install; you usually need to be root to install the tool on a system directory. If you want to have it installed in your own user GNUstep directory (eg, /home/nicola/GNUstep), which doesn't require you to be root and could be a better place for testing, you just need to add the line
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_USER_ROOT)
after including common.make, as follows:
include $(GNUSTEP_MAKEFILES)/common.make
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_USER_ROOT)

TOOL_NAME = LogTest
LogTest_OBJC_FILES = source.m

include $(GNUSTEP_MAKEFILES)/tool.make
I usually do this when testing my own code and programs, and it is very handy.


Next: Enabling Debugging Up: Writing GNUstep Makefiles Previous: What is it
Nicola Pero 2000-10-12