Version 3 of cross-building a starkit

Updated 2009-11-30 19:48:47 by JOB

JOB It is possible to "cross compile" starkits for a specific platform! The following Makefile shows how it works.

Some further explanations: For cross compilation, we need both: a binary (tclkit) for the current platform, we are running the Makefile on (which is used to create a working sdx utility) and another pre-compiled binary for the target platform. The sdx utility in turn is capable to maintain any tclkit binary regardless which binary it belongs to!

I am using a similar Makefile to create binaries for win* although the development platform is a mac - which works pretty well!

# Makefile ---
# -------------------------------------------------------------------------
#   Purpose:
#       Create (*)starkit and application binaries
#       for unix and windows. This makefile might be used to
#       "cross compile" binaries for any target OS.
# 
#   Copyright(c) 2008,  Johann Oberdorfer
#                       mail-to: [email protected]
# -------------------------------------------------------------------------
# This source file is distributed under the BSD license.

# main entry point:
TCLROOT=$(HOME)/myCoolSoftware

# unix / win / osx ...
AIX_KIT=$(TCLROOT)/binary_repository/kbskit8.5-gui_aix
WIN_KIT=$(TCLROOT)/binary_repository/tclkit-win32.upx.exe
OSX_KIT=$(TCLROOT)/binary_repository/kbskit8.5-gui_darwin

# the sdx utility:
SDXUTIL=$(TCLROOT)/binary_repository/sdx.kit


# *edit* to reflect your build platform
# you are currently running on:
# -------------------------------------
TCL_KIT=$(AIX_KIT)

VER=V0.1
APP=myCoolApplication
INSTALL_DIR=$(TCLROOT)/myCoolApps


all:         aix win ls
devel:         aix win kit ls

aix:        $(APP).aix
win:        $(APP).exe
osx:        $(APP).osx
kit:    $(APP).kit


sdx:
        cp $(TCL_KIT) kitbin
        cp $(SDXUTIL) sdx.kit
        $(TCL_KIT) $(SDXUTIL) unwrap sdx.kit
        $(TCL_KIT) $(SDXUTIL) wrap sdx -runtime kitbin
        rm -rf sdx.vfs
        rm -r  sdx.kit
        rm -f  kitbin


$(APP).kit: $(VER)
        $(TCL_KIT) $(SDXUTIL) wrap $@ -vfs $(VER)

$(APP).aix: $(VER)
        cp $(AIX_KIT) aixkitbin
        $(TCL_KIT) $(SDXUTIL) wrap $@ -vfs $(VER) -runtime aixkitbin
        rm -f aixkitbin

$(APP).exe: $(VER)
        cp $(WIN_KIT) winkitbin
        $(TCL_KIT) $(SDXUTIL) wrap $@ -vfs $(VER) -runtime winkitbin
        rm -f winkitbin

$(APP).osx: $(VER)
        cp $(OSX_KIT) osxkitbin
        $(OSX_KIT) $(SDXUTIL) wrap $@ -vfs $(VER) -runtime osxkitbin
        rm -f osxkitbin


ls:
        ls -ltr        

install:
        @if [ -f $(APP).aix ]; then \
          echo "Moving file: $(APP).aix to: $(INSTALL_DIR)" ; \
          mv $(APP).aix $(INSTALL_DIR) ; \
        fi
        @if [ -f $(APP).exe ]; then \
          echo "Moving file: $(APP).exe to: $(INSTALL_DIR)" ; \
          mv $(APP).exe $(INSTALL_DIR) ; \
        fi
        @if [ -f $(APP).osx ]; then \
          echo "Moving file: $(APP).osx to: $(INSTALL_DIR)" ; \
          mv $(APP).osx $(INSTALL_DIR) ; \
        fi


clean:
        rm -f aixkitbin
        rm -f winkitbin
        rm -f osxkitbin
        rm -f kitbin
        rm -f $(APP).kit
        rm -f $(APP).aix
        rm -f $(APP).exe

lyon

Just a word of caution about this makefile.

It renames the windows kit and the new name does *not* finish with .exe and this has a side effect: sdx *will ignore* the tclkit.ico you may have inserted in your vfs.

If you do mind about making a custom icon, rename the windows kit with a trailing .exe and consider reading Pat Thoyts web page detailing the process of adding an icon to a Windows Starkit:

http://www.equi4.com/wikis/equi4/267


JOB Thank you lyon for your remark (looks as I am heavily influenced by unix driven boxes, where the file extension for executables isn't relevant at all). Next time I am going to try to extend the Makefile to handle custom icons as well. The main purpose of the Makefile although is the fact that - with starkit technology - you can freely choose your development platform - a kind of freedom for developers!