Monday, August 17, 2009

Simple Symbian Makefile

Symbian requires makefile for gcce build.
Here is the sample of my makefile, let's call it myproject.mk


# myproject.mk
#
TARGETDIR=.
CERTDIR=../../../../Certificates
TARGETSISFILE=$(TARGETDIR)/myproject.sis
TARGETSISXFILE=$(TARGETDIR)/myprojects.sisx
TARGETPKGFILE=$(TARGETDIR)/myprojects.target.pkg
SOURCEPKGFILE=$(TARGETDIR)/myprojects.pkg

SOURCECERFILE=$(CERTDIR)/dev.cer
SOURCEKEYFILE=$(CERTDIR)/dev.key
PASSWORD=mypassword

BLD : do_nothing

CLEAN : do_nothing

LIB : do_nothing

ifeq (GCCE,$(findstring GCCE, $(PLATFORM)))
FINAL :

$(SOURCECERFILE)
@echo EPOCROOT=$(EPOCROOT)
@echo $(PLATFORM)
#Delete existing sis file
@echo del $(TARGETSISFILE)
@echo del $(TARGETSISXFILE)
# we use command here, please note that we need the double quotes here
del "$(TARGETSISFILE)"
del "$(TARGETSISXFILE)"

#Pass the PKG through the CPP precompiler
# @echo cpp -P $(SOURCEPKGFILE) $(TARGETPKGFILE)
# cpp -P $(SOURCEPKGFILE) $(TARGETPKGFILE)
@echo perl -e "print `makesis -d%EPOCROOT% $(SOURCEPKGFILE) $(TARGETSISFILE)`"
# we can execute this with perl as well
perl -e "print `makesis -d%EPOCROOT% $(SOURCEPKGFILE) $(TARGETSISFILE)`"
#Sign the SIS file
@echo signsis -v -s $(TARGETSISFILE) $(TARGETSISXFILE) $(SOURCECERFILE) $(SOURCEKEYFILE) $(PASSWORD)
signsis -v -s $(TARGETSISFILE) $(TARGETSISXFILE) $(SOURCECERFILE) $(SOURCEKEYFILE) $(PASSWORD)
else
FINAL : do_nothing
endif


Now, if we want to execute the makefile without calling "abld" command, you need firstly set $PLATFORM=GCCE at your shell. Next we can call the make from here:

c:\...sis\>make -f myproject.mk


If anything goes wrong, you can try with "make -d" to debug.

Some pitfalls from make:

- *** missing separator *** => You use the "space" instead of "tab"
- Invalid switch when trying to execute the command from (dos) shell => you missing double quote around the argument passing to the command.