2010年11月17日 星期三

Real-Time Object Detection by Stefan Hintersser running on linux Intel X86

Computer Version is an interesting topic, I found an implementation of real-time object detection which is really work on my linux X86.

Stefan Hintersser home page
http://campar.in.tum.de/Main/StefanHinterstoisser

Document
http://campar.in.tum.de/personal/hinterst/index/project/CVPR10.pdf

Although the author says it can work on linux but not really tested.
Now, let's do some fix to get it work.

1.Download and install source code and all necessary libraries

Source code
http://campar.in.tum.de/personal/hinterst/index/downloads.html

OpenCV

ESM
ftp://ftp-sop.inria.fr/evolution/malis/software/ESM/ESMkitLin_0_4.tar.gz
Install in
$DOT_vs_1.0/resources/ESM/ESMkitLin

Intel IPP
I'm running with Intel IPP 6.0.1.071. it installed in /opt

1.Create Makefile

CC=gcc
AR=ar

CFLAGS=-Wall -O3 -funroll-loops -msse2 -I./include -I/usr/include/opencv -I/opt/intel/ipp/6.0.1.071/ia32/include -I./resources/ESM/ESMkitLin/inc
LDFLAGS=-L/opt/intel/ipp/6.0.1.071/ia32/lib -lcv -lcvaux -lhighgui -lcxcore -lippcvmerged -lippmemerged -lippmmerged -lippccmerged -lipprmerged -lippiemerged -lippimerged -lippsemerged -lippsmerged -lippsrmerged -lippcore -lm

LIBS=src/cv_camera.o src/cv_utilities.o src/cv_esm.o

%.o : %.cc
        $(CC) -c $(CFLAGS) $< -o $@

all : main_dot2D main_dot3D

main_dot2D : ${LIBS} src/main_dot2D.o
        ${CC} -o $@ ${LIBS} src/main_dot2D.o ${LDFLAGS} resources/ESM/ESMkitLin/lib/ESMlib.a

main_dot3D : ${LIBS} src/main_dot3D.o
        ${CC} -o $@ ${LIBS} src/main_dot3D.o ${LDFLAGS} resources/ESM/ESMkitLin/lib/ESMlib.a

clean :
        rm -rf src/*.o

2.Then make.
After successful compile and link
run ./main_dot2D

The program almost eating all CPU resource and window shows nothing.
I found the camera frame rate seems too high (90 fps !!!)
So I try to reduce the frame rate by change

        int l_key = cvWaitKey(1);

to

        int l_key = cvWaitKey(60);

Now it's worked ...








 

2010年9月24日 星期五

Rowboat Android Overlay Setup

There are some trick to setup omap overlay

1. omap_vout omap_vout: probed for an unknown device

To fix this problem set u-boot environment variable

setenv optargs 'init=/init omapdss.def_disp=dvi omapfb.mode=dvi:1280x1024MR-16@60 vram=4M omapfb.vram=0:4M'

http://groups.google.com/group/beagleboard/browse_thread/thread/ff11355c5834a187

2.TIDmaiVideoSink params

Make sure what video output you are using ...

gst-launch-0.10 -v videotestsrc ! TIDmaiVideoSink videoStd=VGA videoOutput=DVI sync=false

gst-launch-0.10 filesrc location=/sdcard/video.mp4 ! typefind ! qtdemux name=demux demux.video_00 ! queue ! TIViddec2 ! TIDmaiVideoSink videoStd=VGA videoOutput=DVI sync=false

3.Resolution issue

Refer this mail

Re: [rowboat] Display resolution
...
寄件者:
Vladimir Barinov
...
加到通訊錄
收件者:rowboat@googlegroups.com

Juan,

Juan Garibay wrote:
> Hi,
>
> I was facing the same issue described by Abdi and I followed the instructions described in the following link:
> http://code.google.com/p/rowboat/wiki/ConfigureAndBuild#External_Display
> Here it is specified to use "omap-dss.def_disp" and "omapfb.video_mode" without mentioning the kernel version constrains, it would be nice to update it.
ok
>
> Using the parameters mentioned by Vladimir, I am able to set different resolutions however the highest resolution for which it works is 1280x720MR-16@60. According to the "Video modes for external display" section from this link:
> http://code.google.com/p/rowboat/wiki/SimpleTests
> The BeagleBoard should also support 1280x1024MR-16@60 , 1440x900MR-16@60, 1440x1050MR-16@60,1600x1024MR-16@60 but I am getting the following error:
try to add these option in your kernel command line: vram=XXX
for example for 1280x1024MR-16@60 you should add vram=4M
1440x1050MR-16@60, vram=6M
1600x1024MR-16@60, vram=7M
etc, the equation to calculate the vram value is x_res*y_rex*4

Regards,
Vladimir
>
> omaplfb: OMAPLFB_Init: OMAPLFBInit failed
>
> Can anyone help me on this?
>
> I am using a Beagle C2, rowboat-eclair-dsp.xml and as display a TV that supports fullHD (1920x1080) so it should not be an issue.
>
> Regards,
> Juan Garibay
>
>
>
>
>
> > Date: Wed, 15 Sep 2010 18:20:49 +0400
> > From: batareich@gmail.com
> > To: rowboat@googlegroups.com
> > Subject: Re: [rowboat] Display resolution
> >
> > abdi farah wrote:
> > > Hi,
> > >
> > >
> > > I would like to know how to change the display resolution using
> > > rowboat-android.
> > > I manage to port rowboat-android 2.1 to beagleboard revc4.
> > >
> > > i used the console commands:
> > >
> > > #Beagleboard# setenv bootcmd 'mmc init; fatload mmc 0 84000000 uImage; bootm 84000000'
> > > #Beagleboard# setenv bootargs 'mem=128M androidboot.console=ttyS2 console=tty0 console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw
> > >
> > > init=/init rootwait omapfb.video_mode=640x480MR-16@60'
> > these params are redundant since they are siutable for 2.6.29.
> > The 2.6.32 DSS takes these parameters from kernel command line -
> > omapdss.def_disp and omapfb.mode, f.e:
> > omapdss.def_disp=dvi omapfb.mode=dvi:720x576MR-16@60
> >
> > >
> > > #Beagleboard# saveenv
> > > Beagleboard# reset
> > > i try to change the second line to my desired resolution. but it does
> > > not change anything.
> > >
> > > Best regards
> > > Abdi



2010年9月15日 星期三

Extract Ubuntu initrd.img

mkdir initrd
cd initrd
cp /boot/initrd.img-2.6.32-21-generic-pae .
sudo mv initrd.img-2.6.32-21-generic-pae initrd.img-2.6.32-21-generic-pae.gz
sudo gzip -dc initrd.img-2.6.32-21-generic-pae.gz | sudo cpio -id

2010年9月3日 星期五

Get default gateway in C language

紀錄一下這件看起來很簡單的事

呼叫 SxNetDefaultGateway() 傳回 default gateway

Source code below



/* numeric: & 0x8000: default instead of *,
 *          & 0x4000: host instead of net,
 *          & 0x0fff: don't resolve
 */
char *INET_rresolve(struct sockaddr_in *s_in, int numeric, uint32_t netmask)
{
  /* addr-to-name cache */
  struct addr {
    struct addr *next;
    struct sockaddr_in addr;
    int host;
    char name[1];
  };
/* 
  static struct addr *cache = NULL;

  struct addr *pn;
  char *name;
  uint32_t ad, host_ad;
  int host = 0;
*/
  uint32_t ad;
 
  /* Grmpf. -FvK */
  if (s_in->sin_family != AF_INET) {
#ifdef DEBUG
    printf("rresolve: unsupported address family %d!",
          s_in->sin_family);
#endif
    errno = EAFNOSUPPORT;
    return NULL;
  }
  ad = s_in->sin_addr.s_addr;
#ifdef DEBUG
  printf("rresolve: %08x, mask %08x, num %08x", (unsigned)ad, netmask, numeric);
#endif
  if (ad == INADDR_ANY) {
    if ((numeric & 0x0FFF) == 0) {
      if (numeric & 0x8000)
        return strdup("default");
      return strdup("*");
    }
  }
  if (numeric & 0x0FFF)
    return strdup(inet_ntoa(s_in->sin_addr));
 
  return 0;
}

#ifndef RTF_UP
/* Keep this in sync with /usr/src/linux/include/linux/route.h */
#define RTF_UP          0x0001  /* route usable                 */
#define RTF_GATEWAY     0x0002  /* destination is a gateway     */
#define RTF_HOST        0x0004  /* host entry (net otherwise)   */
#define RTF_REINSTATE   0x0008  /* reinstate route after tmout  */
#define RTF_DYNAMIC     0x0010  /* created dyn. (by redirect)   */
#define RTF_MODIFIED    0x0020  /* modified dyn. (by redirect)  */
#define RTF_MTU         0x0040  /* specific MTU for this route  */
#ifndef RTF_MSS
#define RTF_MSS         RTF_MTU /* Compatibility :-(            */
#endif
#define RTF_WINDOW      0x0080  /* per route window clamping    */
#define RTF_IRTT        0x0100  /* Initial round trip time      */
#define RTF_REJECT      0x0200  /* Reject route                 */
#endif

static const unsigned flagvals[] = { /* Must agree with flagchars[]. */
  RTF_GATEWAY,
  RTF_HOST,
  RTF_REINSTATE,
  RTF_DYNAMIC,
  RTF_MODIFIED,
#if ENABLE_FEATURE_IPV6
  RTF_DEFAULT,
  RTF_ADDRCONF,
  RTF_CACHE
#endif
};

#define IPV4_MASK (RTF_GATEWAY|RTF_HOST|RTF_REINSTATE|RTF_DYNAMIC|RTF_MODIFIED)
#define IPV6_MASK (RTF_GATEWAY|RTF_HOST|RTF_DEFAULT|RTF_ADDRCONF|RTF_CACHE)

/* Must agree with flagvals[]. */
static const char flagchars[] =
  "GHRDM"
#if ENABLE_FEATURE_IPV6
  "DAC"
#endif
;

static void set_flags(char *flagstr, int flags)
{
  int i;

  *flagstr++ = 'U';

  for (i = 0; (*flagstr = flagchars[i]) != 0; i++) {
    if (flags & flagvals[i]) {
      ++flagstr;
    }
  }
}

const char *SxNetDefaultGateway()
{
  char devname[64], flags[16];
  static char *sdest = 0, *sgw = 0;
  unsigned long d, g, m;
  int flgs, ref, use, metric, mtu, win, ir;
  struct sockaddr_in s_addr;
  struct in_addr mask;

  FILE *fp = fopen("/proc/net/route", "r");
  if(!fp)
    return 0;
 
  if (fscanf(fp, "%*[^\n]\n") < 0) { /* Skip the first line. */
    goto ERROR;      /* Empty or missing line, or read error. */
  }
  while (1) {
    int r;
    r = fscanf(fp, "%63s%lx%lx%X%d%d%d%lx%d%d%d\n",
           devname, &d, &g, &flgs, &ref, &use, &metric, &m,
           &mtu, &win, &ir);
    if (r != 11) {
      if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */
        break;
      }
 ERROR:
      fclose(fp);
      perror("fscanf");
      return 0;
    }

    if (!(flgs & RTF_UP)) { /* Skip interfaces that are down. */
      continue;
    }

    set_flags(flags, (flgs & IPV4_MASK));
#ifdef RTF_REJECT
    if (flgs & RTF_REJECT) {
      flags[0] = '!';
    }
#endif
    if(sdest) free(sdest);
    if(sgw)  free(sgw);

    memset(&s_addr, 0, sizeof(struct sockaddr_in));
    s_addr.sin_family = AF_INET;
    s_addr.sin_addr.s_addr = d;
    sdest = INET_rresolve(&s_addr, (0x0fff | 0x8000), m); /* 'default' instead of '*' */
    s_addr.sin_addr.s_addr = g;
    sgw = INET_rresolve(&s_addr, (0x0fff | 0x4000), m); /* Host instead of net */
    mask.s_addr = m;  
    /* "%15.15s" truncates hostnames, do we really want that? */
    /*
    printf("%-15.15s %-15.15s %-16s%-6s", sdest, sgw, inet_ntoa(mask), flags);   
    if (netstatfmt) {
      printf("%5d %-5d %6d %s\n", mtu, win, ir, devname);
    } else {
      printf("%-6d %-2d %7d %s\n", metric, ref, use, devname);
    }
    */
    if(flgs & RTF_GATEWAY)  {
      fclose(fp);
      return sgw;
    }
  }
 
  fclose(fp);
  return 0;
}


2010年8月27日 星期五

Android 心得感想

還記的一年前Android大張旗鼓出現,偶當時也具有高度的興趣,因為base on linux而且open source.
而且google也在Android上導入open source所缺乏的重要軟體,例如Web Browser, 穩定的Java VM等.
這一年來偶接觸過兩個Android platform分別是TI OMAP 3530 & Samsung S3C6410, 軟體的部份有修改一些driver以符合Android的要求,簡單的JNI及Android application.偶嘗試以技術的角度將這些與Android的經歷紀錄下來.

1.Linux kernel

Linux kernel必須加上一些Android fix & driver才能跑Android.
例如,比較奇特的像是pmem driver,用來保留memory給Android使用.
坦白說為了特定application保留memory這件事偶個人覺得非常不妥,
一般都是保留給其他hardware使用像是DSP而且也不需要額外的driver來處理,
只要在kernel param設定mem=XXX就能保留剩下的memory,甚至是保留特定memory region也可透過類似方式達到.是效率或著是security issue非得用如此的作法不可嗎 ?

這只是冰山一角,還有其他特異的程式碼在系統中運作著.
事實上Linux Kernel的維護者已經在年初宣佈移除所有Android相關的程式碼.

2.Where is linux ?

第一次順利booting kernel啟動Android進入console之後偶發現一切都很陌生.
是的,的確有個shell,很難用的shell... OK,Android自己搞的shell.

每個指令的功能都陽春到不行,backspace & tab key都不能用.進入/etc目錄之後更是大吃一驚,在UNIX系統沿用多年的許多系統檔案都不見了,全部被Android一手包辦.

在Android 中init.rc這個檔案負責系統初始化的設定,如mount file system, init network 及週邊初始化.其中的script語法並非shell script而是Android自訂的key word所組成.

嗯,這真的不是Linux更不是UNIX like system.
Android是以linux kernel為核心基礎也僅只於此了.

3.Porting Android

Android 具有跨平台在不同CPU上工作的能力,但porting的工作則是各憑本事.
目前Embedded ARM CPU往往有許多特殊硬體的功能,例如2D, 3D graphic engine, video coder及camera interface等.

這些功能在linux kernel driver端常常就有許多新增的ioctl及操作流程,porting的困難是需要對driver及Android都有相當程度的了解才能進行的下去.

在開發環境上以往熟悉的Makefile已經被Android.mk取代,完全不同於傳統Embedded System.

Android對自身系統設計的文件並不多,但光從source code的量來看要能有詳細的文件確實是很難.
所以想要porting Android到產品等級絕對不是幾個有經驗的工程師就能作到其中的know how真的非常多.

4.Java VM

Android提供一個Java VM Engine - dalvik,我相當喜歡這樣的設計.dalvik提供一個可以達到同一個application java binary在不同平台執行,而且其效能不見得比native binary來的差.不過這不是絕對的,例如Android允許使用JNI的方式撰寫直接控制硬體或是連結close source binary.許多商業軟體就會透過這種方式達到保護自身利益.java binary跨平台的特性也因此弱化了.但不可否認的是使用Java 單一語言來開發application的確是很大的好處,尤其是Graphic Interface.如果是c/c++因為語言開放特性的關係就算有完整library也不是一件容易的事(例如QT, gtk).


2010年8月18日 星期三

Maemo 5 DBus 初探

DBus 在Maemo 5系統中是很重要的 IPC 功能,透過DBus可以控制許多硬體如LED, Keypad,甚至是撥電話及發簡訊.現在我想要在程式執行時LCD panel不要進入power saving而關閉也需要透過DBus.

1.Reference

http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/DBus/DBus_Basics

http://maemo.org/api_refs/5.0/5.0-final/mce-dev/dbus-names_8h.html#c9f233f336f9be78f223a31866455b80

http://www.mail-archive.com/maemo-developers@maemo.org/msg01889.html


2.以下的程式碼片段就是我想要的囉

    DBusConnection *conn;
DBusMessage *msg = NULL;
DBusError dbus_error;
dbus_bool_t dresult;

#define MCE_SERVICE "com.nokia.mce"
#define MCE_REQUEST_PATH "/com/nokia/mce/request"
#define MCE_REQUEST_IF "com.nokia.mce.request"
#define MCE_PREVENT_BLANK_REQ "req_display_blanking_pause"

dbus_error_init(&dbus_error);

conn = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);

msg = dbus_message_new_method_call(MCE_SERVICE,
MCE_REQUEST_PATH,
MCE_REQUEST_IF,
MCE_PREVENT_BLANK_REQ);
if (msg == NULL)
return;

dresult = dbus_connection_send (conn, msg, NULL);

if (!dresult)
{
dbus_message_unref(msg);
return;
}

dbus_connection_flush(conn);
dbus_message_unref(msg);


2010年8月9日 星期一

Maemo 5 debian packaging

初次嘗試Maemo 5 hello world programing之後,將binary複製到target上就可以執行.
但這樣並不是正規的散布方式,Maemo 5支援Debian dpkg的方式包裝binary,包含icon, desktop設定等...
網路上搜尋Maemo 5 dpkg相關的資料並不多,流程也有些複雜,因此作個紀錄供往後參考用.

以下將延續之前的example_hildonprogram

1.要使用dpkg packaging需要配合autotools (據說也可以不要)
2.建立目錄及環境,之後複製example_hildonprogram.c

[sbox-FREMANTLE_ARMEL: ~/] > mkdir example_hildonprogram
[sbox-FREMANTLE_ARMEL: ~/] > cd example_hildonprogram
[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > mkdir src
[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > mkdir data
[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > mkdir data/maemo

複製example_hildonprogram.c 到 example_hildonprogram/src

3.建立autotools所需檔案

File configure.ac

AC_INIT([example_hildonprogram], [0.1])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CC
PKG_CHECK_MODULES(GTK2,
          [gtk+-2.0]
          [AC_SUBST(GTK2_CFLAGS)
          AC_SUBST(GTK2_LIBS)])

PKG_CHECK_MODULES([HILDON], [hildon-1 >= 2.2])
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

File Makefile.am

SUBDIRS = src
EXTRA_DIST = data/icons/example_hildonprogram.png \
        data/maemo/example_hildonprogram.desktop \
        data/maemo/com.nokia.example_hildonprogram.service

File src/Makefile.am

bin_PROGRAMS = example_hildonprogram

example_hildonprogram_SOURCES = example_hildonprogram.c

example_hildonprogram_CFLAGS = $(GTK2_CFLAGS) \
                  $(HILDON_CFLAGS)

example_hildonprogram_LDADD = $(GTK2_LIBS) \
                 $(HILDON_LIBS)

4.建立Maemo 5所需檔案

File data/maemo/example_hildonprogram.desktop

[Desktop Entry]
Encoding=UTF-8
Version=0.1
Name=example_hildonprogram
Type=Application
Exec=/usr/bin/example_hildonprogram
Icon=example_hildonprogram

File data/maemo/com.nokia.example_hildonprogram.service

[D-BUS Service]
Name=nokia.com.example_hildonprogram
Exec=/usr/bin/example_hildonprogram

5.Run autoreconf to create configure

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > autoreconf --force --install -v
autoreconf2.50: Entering directory `.'
autoreconf2.50: configure.ac: not using Gettext
autoreconf2.50: running: aclocal --force
autoreconf2.50: configure.ac: tracing
autoreconf2.50: configure.ac: not using Libtool
autoreconf2.50: running: /scratchbox/tools/autotools/autoconf2.61/bin/autoconf --force
autoreconf2.50: configure.ac: not using Autoheader
autoreconf2.50: running: automake --add-missing --copy --force-missing
src/Makefile.am: installing `./compile'
autoreconf2.50: Leaving directory `.'

6.configure

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > ./configure
checking for a BSD-compatible install... /scratchbox/tools/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for pkg-config... /scratchbox/tools/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for GTK2... yes
checking for HILDON... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: executing depfiles commands

7.make

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > make
Making all in src
make[1]: Entering directory `/home/gigijoe/example_hildonprogram/src'
if gcc -DPACKAGE_NAME=\"example_hildonprogram\" -DPACKAGE_TARNAME=\"example_hildonprogram\" -DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"example_hildonprogram\ 0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"example_hildonprogram\" -DVERSION=\"0.1\" -I. -I.    -DMAEMO_CHANGES -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -DMAEMO_CHANGES -DMAEMO_GTK -I/usr/include/hildon-1 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -g -O2 -MT example_hildonprogram-example_hildonprogram.o -MD -MP -MF ".deps/example_hildonprogram-example_hildonprogram.Tpo" -c -o example_hildonprogram-example_hildonprogram.o `test -f 'example_hildonprogram.c' || echo './'`example_hildonprogram.c; \
    then mv -f ".deps/example_hildonprogram-example_hildonprogram.Tpo" ".deps/example_hildonprogram-example_hildonprogram.Po"; else rm -f ".deps/example_hildonprogram-example_hildonprogram.Tpo"; exit 1; fi
gcc  -g -O2   -o example_hildonprogram  example_hildonprogram-example_hildonprogram.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -lhildon-1 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0  
make[1]: Leaving directory `/home/gigijoe/example_hildonprogram/src'
make[1]: Entering directory `/home/gigijoe/example_hildonprogram'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/home/gigijoe/example_hildonprogram'

8.make dist, 此時會產生example_hildonprogram-0.1.tar.gz

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > make dist
{ test ! -d example_hildonprogram-0.1 || { find example_hildonprogram-0.1 -type d ! -perm -200 -exec chmod u+w {} ';' && rm -fr example_hildonprogram-0.1; }; }
mkdir example_hildonprogram-0.1
mkdir -p -- . example_hildonprogram-0.1/data/icons example_hildonprogram-0.1/data/maemo
list='src'; for subdir in $list; do \
      if test "$subdir" = .; then :; else \
        test -d "example_hildonprogram-0.1/$subdir" \
        || mkdir "example_hildonprogram-0.1/$subdir" \
        || exit 1; \
        (cd $subdir && \
          make  \
            top_distdir="../example_hildonprogram-0.1" \
            distdir="../example_hildonprogram-0.1/$subdir" \
            distdir) \
          || exit 1; \
      fi; \
    done
make[1]: Entering directory `/home/gigijoe/example_hildonprogram/src'
make[1]: Leaving directory `/home/gigijoe/example_hildonprogram/src'
find example_hildonprogram-0.1 -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
      ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
      ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
      ! -type d ! -perm -444 -exec /bin/sh /home/gigijoe/example_hildonprogram/install-sh -c -m a+r {} {} \; \
    || chmod -R a+r example_hildonprogram-0.1
/bin/sh /home/gigijoe/example_hildonprogram/missing --run tar chof - example_hildonprogram-0.1 | GZIP=--best gzip -c >example_hildonprogram-0.1.tar.gz
{ test ! -d example_hildonprogram-0.1 || { find example_hildonprogram-0.1 -type d ! -perm -200 -exec chmod u+w {} ';' && rm -fr example_hildonprogram-0.1; }; }

9.解開壓縮檔準備以此作為packaging source,這樣的作法不會影響到原來的source.

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > tar -zxvf example_hildonprogram-0.1.tar.gz
example_hildonprogram-0.1/
example_hildonprogram-0.1/compile
example_hildonprogram-0.1/configure
example_hildonprogram-0.1/missing
example_hildonprogram-0.1/install-sh
example_hildonprogram-0.1/depcomp
example_hildonprogram-0.1/configure.ac
example_hildonprogram-0.1/aclocal.m4
example_hildonprogram-0.1/Makefile.am
example_hildonprogram-0.1/Makefile.in
example_hildonprogram-0.1/src/
example_hildonprogram-0.1/src/example_hildonprogram.c
example_hildonprogram-0.1/src/Makefile.am
example_hildonprogram-0.1/src/Makefile.in
example_hildonprogram-0.1/data/
example_hildonprogram-0.1/data/icons/
example_hildonprogram-0.1/data/icons/example_hildonprogram.png
example_hildonprogram-0.1/data/maemo/
example_hildonprogram-0.1/data/maemo/com.nokia.example_hildonprogram.service
example_hildonprogram-0.1/data/maemo/example_hildonprogram.desktop



[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > cd example_hildonprogram-0.1
[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram/example_hildonprogram-0.1] > dh_make -e stevegigijoe@yahoo.com.tw --createorig -c GPL

Type of package: single binary, multiple binary, library, kernel module or cdbs?
 [s/m/l/k/b] s

Maintainer name : unknown
Email-Address   : stevegigijoe@yahoo.com.tw
Date            : Mon,  9 Aug 2010 15:47:56 +0800
Package Name    : example.hildonprogram
Version         : 0.1
License         : gpl
Type of Package : Single
Hit to confirm:
Done. Please edit the files in the debian/ subdirectory now. example.hildonprogram
uses a configure script, so you probably don't have to edit the Makefiles.


11.packaging

首先更動一下 debian/control, 這個檔案很重要.

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram/example.hildonprogram-0.1] > vi debian/control

-Build-Depends: debhelper (>= 5), autotools-dev
+Build-Depends: debhelper (>= 5), autotools-dev, libhildon1 (>= 2.2)
 
OK,go packaging

以下兩者都可以
dpkg-buildpackage -i -rfakeroot -D
dpkg-buildpackage -sa -rfakeroot -kstevegigijoe@yahoo.com.tw


[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram/example.hildonprogram-0.1] > dpkg-buildpackage -sa -rfakeroot -kstevegigijoe@yahoo.com.tw
dpkg-buildpackage: source package is example.hildonprogram
dpkg-buildpackage: source version is 0.1-1
dpkg-buildpackage: source changed by unknown
dpkg-buildpackage: host architecture armel
dpkg-buildpackage: source version without epoch 0.1-1
: Using Scratchbox tools to satisfy builddeps
: Dependency provided by Scratchbox: autotools-dev
 fakeroot debian/rules clean
dh_testdir
dh_testroot
rm -f build-stamp
# Add here commands to clean up after the build process.
/scratchbox/tools/bin/make distclean
make[1]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[1]: *** No rule to make target `distclean'.  Stop.
make[1]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make: [clean] Error 2 (ignored)
cp -f /usr/share/misc/config.sub config.sub
cp -f /usr/share/misc/config.guess config.guess
dh_clean
 dpkg-source -b example.hildonprogram-0.1
dpkg-source: building example.hildonprogram using existing example.hildonprogram_0.1.orig.tar.gz
dpkg-source: building example.hildonprogram in example.hildonprogram_0.1-1.diff.gz
dpkg-source: building example.hildonprogram in example.hildonprogram_0.1-1.dsc
 debian/rules build
dh_testdir
# Add here commands to configure the package.
./configure --host=arm-linux-gnueabi --build=arm-linux-gnueabi --prefix=/usr --mandir=\${prefix}/share/man --infodir=\${prefix}/share/info CFLAGS="-Wall -g -O2" LDFLAGS="-Wl,-z,defs"
checking for a BSD-compatible install... /scratchbox/tools/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for arm-linux-gnueabi-gcc... arm-linux-gnueabi-gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-linux-gnueabi-gcc accepts -g... yes
checking for arm-linux-gnueabi-gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of arm-linux-gnueabi-gcc... gcc3
checking for arm-linux-gnueabi-pkg-config... no
checking for pkg-config... /scratchbox/tools/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for GTK2... yes
checking for HILDON... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: executing depfiles commands
dh_testdir
# Add here commands to compile the package.
/scratchbox/tools/bin/make
make[1]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
Making all in src
make[2]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/src'
if arm-linux-gnueabi-gcc -DPACKAGE_NAME=\"example_hildonprogram\" -DPACKAGE_TARNAME=\"example_hildonprogram\" -DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"example_hildonprogram\ 0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"example_hildonprogram\" -DVERSION=\"0.1\" -I. -I.    -DMAEMO_CHANGES -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -DMAEMO_CHANGES -DMAEMO_GTK -I/usr/include/hildon-1 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -Wall -g -O2 -MT example_hildonprogram-example_hildonprogram.o -MD -MP -MF ".deps/example_hildonprogram-example_hildonprogram.Tpo" -c -o example_hildonprogram-example_hildonprogram.o `test -f 'example_hildonprogram.c' || echo './'`example_hildonprogram.c; \
    then mv -f ".deps/example_hildonprogram-example_hildonprogram.Tpo" ".deps/example_hildonprogram-example_hildonprogram.Po"; else rm -f ".deps/example_hildonprogram-example_hildonprogram.Tpo"; exit 1; fi
arm-linux-gnueabi-gcc  -Wall -g -O2  -Wl,-z,defs -o example_hildonprogram  example_hildonprogram-example_hildonprogram.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -lhildon-1 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0  
make[2]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/src'
make[2]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[1]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
#docbook-to-man debian/example.hildonprogram.sgml > example.hildonprogram.1
touch build-stamp
 fakeroot debian/rules binary
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/example.hildonprogram.
/scratchbox/tools/bin/make DESTDIR=/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/debian/example.hildonprogram install
make[1]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
Making install in src
make[2]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/src'
make[3]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/src'
test -z "/usr/bin" || mkdir -p -- . "/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/debian/example.hildonprogram/usr/bin"
  /scratchbox/tools/bin/install -c 'example_hildonprogram' '/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/debian/example.hildonprogram/usr/bin/example_hildonprogram'
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/src'
make[2]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/src'
make[2]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[3]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[3]: Nothing to be done for `install-exec-am'.
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[2]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[1]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installexamples
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_shlibdeps
dh_gencontrol
dpkg-gencontrol: warning: unknown substitution variable ${misc:Depends}
dh_md5sums
dh_builddeb
dpkg-deb: building package `example.hildonprogram' in `../example.hildonprogram_0.1-1_armel.deb'.
 dpkg-genchanges -sa
dpkg-genchanges: including full source code in upload
dpkg-buildpackage: full upload (original source is included)

到這邊就已經完成囉

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > ls
Makefile     autom4te.cache  configure     example.hildonprogram-0.1            example.hildonprogram_0.1-1_armel.changes  missing
Makefile.am  compile         configure.ac  example.hildonprogram-0.1.tar.gz     example.hildonprogram_0.1-1_armel.deb      packaging
Makefile.in  config.log      data          example.hildonprogram_0.1-1.diff.gz  example.hildonprogram_0.1.orig.tar.gz      src
aclocal.m4   config.status   depcomp       example.hildonprogram_0.1-1.dsc      install-sh