20100411

Another Ben NanoNote port: pMARS

Ben Nanonote
Screenshot compositing, made with free software

Since I bought the Nanonote, I have been finding new uses for it. Music player, note taker, voice recorder. I can also use it to start learning Python again, or Perl, which are (together with Lua) the languages currently installed by default.

After my first successful port (gnugo), I decided to try something else, and while idling at the train I thought that pMARS, the portable Memory Array Redcode Simulator was probably a good bet. If you don't know what I am talking about, you can check here. I had just started writing some test warriors, to see if I understood the code, but had too little time to test it working.

And as I thought, pMARS was not as hard as other programs have turned to., but without graphical output, just text based. Enough. What changes are needed?

Follow the steps in my previous tutorial, the changes needed fit in there.

The corresponding openwrt Makefile for pMARS should be
# Copyright (C) 2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
#

include $(TOPDIR)/rules.mk
## Package name
PKG_NAME:=pmars
## Package version we need (to match our download source)
PKG_VERSION:=0.9.2
## Release version (don't really needed, just for completeness)
PKG_RELEASE:=3
## Name of the file we will download, with the previous package name definitions
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
## Url with the PKG_SOURCE file
PKG_SOURCE_URL:=http://downloads.sourceforge.net/project/corewar/pMARS/0.9.2/pmars-0.9.2.tar.gz?use_mirror=mesh
## Program to uncompress the sources
PKG_CAT:=zcat

include $(INCLUDE_DIR)/package.mk
# Definition of the package, for adding to menuconfig and creating the ipkg.
define Package/pmars
TITLE:=Pmars
SECTION:=games
CATEGORY:=Games
URL:=
endef
# Directory where the sources will be uncompiled and built BUILD_DIR
# is an env variable from the OpenWrt toolchain, you don't need to set
# it.
PKG_BUILD_DIR:=$(BUILD_DIR)/pmars-$(PKG_VERSION)
# Long description of the package
define Package/pmars/description
PMARS
endef
# If ./configure does not need any options, leave it as follows

define Build/Prepare
$(call Build/Prepare/Default)
$(CP) $(PKG_BUILD_DIR)/src/* $(PKG_BUILD_DIR)/
endef

define Package/pmars/Build/Configure
$(call Build/Configure/Default)
endef

define Package/pmars/Build/Compile
$(call Build/Compile/Default)
endef

# Where will be copied the binaries and libraries after installation.
define Package/pmars/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/pmars $(1)/usr/sbin/
endef
# Final step for bulding the package
$(eval $(call BuildPackage,pmars))
And for it to work, you need to make some static patches to the Makefile in the src directory of the pmars package. Change the compiler for
CC = mipsel-openwrt-linux-uclibc-gcc
and the compiler and linker flags for
CFLAGS = -O -DEXT94 -DPERMUTATE
LFLAGS = -x
And remove (or comment) this line:
@strip $(MAINFILE)
I hope you enjoy your Linux portable freedom, and write nice warriors to compete in The Hill. I will look into making a graphical version, although it looks quite hard in such a small window. If you have any question, don't hesitate to post a comment or send me an e-mail.

Related posts:
Nanonote ports: Yacas, 4th (forth compiler and interpreter)
My first port to the Ben NanoNote: gnugo
Unpacking my Ben NanoNote
Gcal: the ultra-powerful command line GNU calendar
Written by Ruben Berenguel