Monday, January 20, 2014

Compiling objective-c 2.0 with Foundation on Freebsd 9.1

This was harder than xubuntu, so here is the corresponding how to.

1. Install necessary packages
pkg_add -r subversion
pkg_add -r libffi
pkg_add -r libicu
pkg_add -r nano

2. Install libobjc2
cd ~
mkdir tempSetup
svn co svn://svn.gna.org/svn/gnustep/libs/libobjc2/trunk libobjc2
cd libobjc2
setenv CC /usr/bin/clang
setenv CXX /usr/bin/clang++
make

3. Install gnustep tools
cd ..
svn co svn://theraven@svn.gna.org/svn/gnustep/tools/make/trunk make
cd make
./configure -enable-debug-by-default
gmake install

Note the output for the next step:

Creating system tools directory: /usr/local/bin
Creating makefile directories in: /usr/local/share/GNUstep/Makefiles
Installing GNUstep configuration file in /usr/local/etc/GNUstep/GNUstep.conf
Installing gnustep-make support software
Installing makefiles
Installing Test Framework scripts
Installing Test Framework support files

Installing (and compressing) manpages


chmod 755 ./usr/local/share/GNUstep/Makefiles/GNUstep.csh
./usr/local/share/GNUstep/makefiles/GNUstep.csh
echo ./usr/local/share/GNUstep/Makefiles/GNUstep.csh >> ~/.profile

4. Install gnustep base
cd ..
svn co svn://svn.gna.org/svn/gnustep/libs/base/trunk base
cd base
./configure --disable-mixedabi CC=/usr/bin/clang CXX=/usr/bin/clang++
gmake install

5. Make a test program
cd ~
mkdir testapp
cd testapp
nano test.m
#import <Foundation/Foundation.h>
int main(int argc, const char *argv[])
{
   @autoreleasepool
   {
      NSLog(@"Helloworld");
   }
   return 0;
}
exit nano and save

6. Create the makefile

nano GNUmakefile

GNUSTEP_MAKEFILES=/usr/local/share/GNUstep/Makefiles

include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = test
test_OBJC_FILES = test.m

include $(GNUSTEP_MAKEFILES)/tool.make


exit nano and save


11. Make and run the test
gmake
cd obj
./test

References:
https://forums.freebsd.org/viewtopic.php?&t=39466
http://etoileos.com/downloads/installtrunk/freebsd/