Created
February 13, 2013 21:09
-
-
Save DamnedFacts/4948295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/4948295 | |
# GistID: 4948295 | |
# | |
# prereq: | |
# apt-get install build-essential clang gobjc libicu-dev libxml2-dev libgnutls-dev libssl-dev | |
# | |
# Based on: http://www.dev-smart.com/archives/401 | |
# Install: | |
# clang (Low-Level Virtual Machine (LLVM), C language family frontend) | |
# libgnustep-base-dev (GNUstep Base header files and development libraries) | |
# libdispatch-dev | |
# libdispatch0 | |
# libffi6 | |
# libffi-dev | |
# libxslt-dev | |
# libicu-dev | |
# | |
# | |
# On a Debian system, like Ubuntu, it will install other dependencies for gnustep, including | |
# the: | |
# gnustep-base-common | |
# gnustep-base-runtime | |
# gnustep-common | |
# gnustep-make | |
# gobjc-4.6 | |
# libgnustep-base-dev | |
# libgnustep-base1.22 | |
# libobjc3 | |
# These are not necessary as clang has its own Objective-C compiler and runtime. | |
# The runtime it installs here is for gcc. | |
# | |
# Ref: http://wiki.gnustep.org/index.php/GNUstep_under_Ubuntu_Linux | |
# Ref: http://lists.gnu.org/archive/html/discuss-gnustep/2012-08/msg00094.html | |
# Ref: http://www.dev-smart.com/archives/401 | |
# | |
# To run code compiled against these libraries, set LD_LIBRARY_PATH=$(BUILD_DIR)/lib | |
.PHONY: clean | |
ifdef DEBUG | |
SILENT := | |
REDIR_NULL := | |
else | |
SILENT := @ | |
REDIR_NULL := "2> /dev/null" | |
endif | |
BUILD_DIR := $(shell pwd)/build | |
LIBOBJC2_VER := libobjc2-1.6.1 | |
LIBOBJC2_TAR := $(LIBOBJC2_VER).tgz | |
LIBOBJC2_LIB := $(BUILD_DIR)/lib/libobjc.so.4.6.0 | |
GNUSTEP_BASE_VER := gnustep-base-1.24.0 | |
GNUSTEP_BASE_TAR := $(GNUSTEP_BASE_VER).tar.gz | |
GNUSTEP_BASE_LIB := $(BUILD_DIR)/lib/libgnustep-base.so | |
GNUSTEP_MAKE_VER := gnustep-make-2.6.2 | |
GNUSTEP_MAKE_TAR := $(GNUSTEP_MAKE_VER).tar.gz | |
GNUSTEP_MAKE_CFG := $(BUILD_DIR)/bin/gnustep-config | |
all: hello gcd | |
clean: | |
$(SILENT)echo -n Cleaning... | |
$(SILENT)-rm -f *.d | |
$(SILENT)-rm -f hello gcd | |
$(SILENT)echo done. | |
distclean: clean | |
$(SILENT)echo -n Cleaning real good... | |
$(SILENT)-rm -rf $(BUILD_DIR) $(LIBOBJC2_VER) $(LIBOBJC2_TAR) | |
$(SILENT)-rm -rf $(GNUSTEP_BASE_VER) $(GNUSTEP_BASE_TAR) | |
$(SILENT)-rm -rf $(GNUSTEP_MAKE_VER) $(GNUSTEP_MAKE_TAR) | |
$(SILENT)echo done. | |
#### | |
$(GNUSTEP_BASE_TAR): | |
$(SILENT)echo -n Downloading $@... | |
$(SILENT)wget http://ftp.gnustep.org/pub/gnustep/core/$(GNUSTEP_BASE_TAR) 2> /dev/null | |
$(SILENT)echo done. | |
$(SILENT)echo -n Extracting $@... | |
$(SILENT)tar zxvf $(GNUSTEP_BASE_TAR) 2>&1 > /dev/null | |
$(SILENT)echo done. | |
$(LIBOBJC2_TAR): | |
$(SILENT)echo -n Downloading $@... | |
$(SILENT)wget http://download.gna.org/gnustep/$(LIBOBJC2_TAR) 2> /dev/null | |
$(SILENT)echo done. | |
$(SILENT)echo -n Extracting $@... | |
$(SILENT)tar zxvf $(LIBOBJC2_TAR) 2>&1 > /dev/null | |
$(SILENT)echo done. | |
$(GNUSTEP_MAKE_TAR): | |
$(SILENT)echo -n Downloading $@... | |
$(SILENT)wget http://ftp.gnustep.org/pub/gnustep/core/$(GNUSTEP_MAKE_TAR) 2> /dev/null | |
$(SILENT)echo done. | |
$(SILENT)echo -n Extracting $@... | |
$(SILENT)tar zxvf $(GNUSTEP_MAKE_TAR) 2>&1 > /dev/null | |
$(SILENT)echo done. | |
#### | |
#### | |
$(GNUSTEP_MAKE_CFG): $(GNUSTEP_MAKE_TAR) | |
$(SILENT)echo -n Compiling $(GNUSTEP_MAKE_VER)... | |
$(SILENT)cd $(GNUSTEP_MAKE_VER) && \ | |
CC="clang" CXX="clang++" ./configure --prefix="$(BUILD_DIR)" 2>&1 > /dev/null &&\ | |
make install | |
$(SILENT)echo done. | |
$(LIBOBJC2_LIB): $(LIBOBJC2_TAR) | |
# clang seems sensitive to which order shared libraries are added | |
# to the command-line. The only way I can see to fix the problem in | |
# compiling gnustep_base during its configure phase is to patch | |
# the libobjc2 Makefile and force it to link to libdispatch ahead of time | |
$(SILENT)echo -n Compiling $(LIBOBJC2_VER)... | |
$(SILENT)cd $(LIBOBJC2_VER) && \ | |
sed -i 's/^\(\s*-o $$@ $$(OBJECTS)\)/\1 -ldispatch/g' Makefile && \ | |
sed -i 's/^\(\s*-o $$@ $$(OBJCXX_OBJECTS)\)/\1 -ldispatch/g' Makefile && \ | |
. $(BUILD_DIR)/share/GNUstep/Makefiles/GNUstep.sh && \ | |
CC="clang" CXX="clang++" LIBS="-ldispatch" PREFIX="$(BUILD_DIR)" make -f Makefile install | |
$(SILENT)echo done. | |
$(GNUSTEP_BASE_LIB): $(GNUSTEP_MAKE_CFG) $(LIBOBJC2_LIB) $(GNUSTEP_BASE_TAR) | |
$(SILENT)echo -n Compiling $(GNUSTEP_BASE_VER)... | |
$(SILENT)cd $(GNUSTEP_BASE_VER) && \ | |
. $(BUILD_DIR)/share/GNUstep/Makefiles/GNUstep.sh && \ | |
CC="clang" CXX="clang++" ./configure --prefix="$(BUILD_DIR)" 2>&1 > /dev/null && \ | |
make && make install | |
$(SILENT)echo done. | |
#### | |
hello: $(GNUSTEP_BASE_LIB) | |
$(SILENT)echo -n Compiling $@... | |
$(SILENT)clang -I$(BUILD_DIR)/include -L$(BUILD_DIR)/lib `$(BUILD_DIR)/bin/gnustep-config --objc-flags` `$(BUILD_DIR)/bin/gnustep-config --objc-libs` -fobj-arc -fobjc-runtime=gnustep -fblocks -lobjc hello.m -o hello | |
$(SILENT)echo done. | |
$(SILENT)echo Since this is a local install, set "LD_LIBRARY_PATH=$(BUILD_DIR)/lib" in your environment before executing. | |
gcd: $(GNUSTEP_BASE_LIB) | |
$(SILENT)echo -n Compiling $@... | |
$(SILENT)clang gcd.m -I$(BUILD_DIR)/include -L$(BUILD_DIR)/lib `$(BUILD_DIR)/bin/gnustep-config --objc-flags` `$(BUILD_DIR)/bin/gnustep-config --objc-libs` -I/usr/include/GNUstep -lgnustep-base -lobjc -fobjc-runtime=gnustep -fobj-arc -fblocks -lobjc -ldispatch -o gcd | |
$(SILENT)echo done. | |
$(SILENT)echo Since this is a local install, set "LD_LIBRARY_PATH=$(BUILD_DIR)/lib" in your environment before executing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment