R.A. Epigonos et al.

[dwm-win32] dwm-win32のwindows用バイナリをdebianでクロスコンパイル

windows用のタイル型ウィンドウマネージャをコンパイルする。本家リポジトリにさまざまな変更を加えたリポジトリがgithubにあるため、これを使う。

gcc-mingw32とmingw32-runtimeパッケージをインストールする。makeに失敗したので、gcc-mingw32だけでなく、mingw32-runtime(windows.h等のヘッダーファイルを含むパッケージ)をインストールした。

# aptitude install gcc-mingw32
The following NEW packages will be installed:
  gcc-mingw32 mingw32-binutils{a}
The following packages are RECOMMENDED but will NOT be installed:
  mingw-w64 mingw32-runtime
0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 27.7 MB of archives. After unpacking 70.9 MB will be used.
Do you want to continue? [Y/n/?] y
Get:1 http://ftp.jp.debian.org/debian/ squeeze/main mingw32-binutils i386 2.20-0.1 [11.1 MB]
Get:2 http://ftp.jp.debian.org/debian/ squeeze/main gcc-mingw32 i386 4.4.4-0.1+b1 [16.6 MB]
Fetched 27.7 MB in 8s (3,302 kB/s)
Selecting previously deselected package mingw32-binutils.
(Reading database ... 43284 files and directories currently installed.)
Unpacking mingw32-binutils (from .../mingw32-binutils_2.20-0.1_i386.deb) ...
Selecting previously deselected package gcc-mingw32.
Unpacking gcc-mingw32 (from .../gcc-mingw32_4.4.4-0.1+b1_i386.deb) ...
Processing triggers for man-db ...
Setting up mingw32-binutils (2.20-0.1) ...
Setting up gcc-mingw32 (4.4.4-0.1+b1) ...

# aptitude install mingw32-runtime
The following NEW packages will be installed:
  mingw32-runtime
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,965 kB of archives. After unpacking 21.7 MB will be used.
Get:1 http://ftp.jp.debian.org/debian/ squeeze/main mingw32-runtime all 3.13-1 [1,965 kB]
Fetched 1,965 kB in 5s (358 kB/s)
Selecting previously deselected package mingw32-runtime.
(Reading database ... 44185 files and directories currently installed.)
Unpacking mingw32-runtime (from .../mingw32-runtime_3.13-1_all.deb) ...
Setting up mingw32-runtime (3.13-1) ...

本家のリポジトリは更新が止まっている様子なので、githubにあるリポジトリを使う。

$ git clone git://github.com/emonkak/dwm-win32.git
Cloning into dwm-win32...
remote: Counting objects: 85, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 85 (delta 55), reused 85 (delta 55)
Receiving objects: 100% (85/85), 28.30 KiB, done.
Resolving deltas: 100% (55/55), done.

このリポジトリにはブランチが複数あり、この中で最新のものはstatusブランチなので、ブランチの切り替えを行う。

$ cd dwm-win32/
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/status

チェックアウトでブランチを切り替える。

$ git checkout status
Branch status set up to track remote branch status from origin.
Switched to a new branch 'status'

$ git branch -a
  master
* status
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/status

または以下。

$ git checkout -b status remotes/origin/status
$ git branch -a

config.mkはMakefileの中で読み込まれている。この中のCC変数を書き換える。このままではmingwのgcc(i586-mingw32msvc-gcc)が呼び出されないからだ。編集後のファイルは以下のような感じ。

$ cat config.mk
# dwm-win32 version
VERSION = alpha2

# Customize below to fit your system

# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man

# flags
CPPFLAGS = -DVERSION=\"${VERSION}\"
CFLAGS = -std=c99 -pedantic -Wall -Os ${CPPFLAGS}
LDFLAGS = -s -mwindows

# compiler and linker
CC = gcc
CC = i586-mingw32msvc-gcc

以下のようにmakeするとバイナリが出来上がっていることがわかる。

$ make
dwm-win32 build options:
CFLAGS   = -std=c99 -pedantic -Wall -Os -DVERSION="alpha2"
LDFLAGS  = -s -mwindows
CC       = i586-mingw32msvc-gcc
creating config.h from config.def.h
CC dwm-win32.c
dwm-win32.c: In function ‘movetoprev’:
dwm-win32.c:773: warning: operation on ‘pp’ may be undefined
dwm-win32.c: In function ‘barhandler’:
dwm-win32.c:872: warning: dereferencing type-punned pointer will break strict-aliasing rules
CC status.c
CC -o dwm-win32
$ ls -la
total 160
drwxr-xr-x 3 my my  4096 Nov  4 11:17 .
drwxr-xr-x 3 my my  4096 Nov  4 11:12 ..
-rwxr-xr-x 1 my my  5827 Nov  4 11:12 config.def.h
-rwxr-xr-x 1 my my  5827 Nov  4 11:17 config.h
-rw-r--r-- 1 my my   329 Nov  4 11:17 config.mk
-rwxr-xr-x 1 my my 39424 Nov  4 11:17 dwm-win32
-rw-r--r-- 1 my my 36755 Nov  4 11:12 dwm-win32.c
-rw-r--r-- 1 my my 24783 Nov  4 11:17 dwm-win32.o
drwxr-xr-x 8 my my  4096 Nov  4 11:12 .git
-rw-r--r-- 1 my my  1680 Nov  4 11:12 LICENSE.txt
-rw-r--r-- 1 my my  1607 Nov  4 11:12 Makefile
-rw-r--r-- 1 my my  5946 Nov  4 11:12 README.txt
-rwxr-xr-x 1 my my  2800 Nov  4 11:12 status.c
-rw-r--r-- 1 my my  1776 Nov  4 11:17 status.o
$

リファレンス

  1. kjmkznr/dwm-win32 - GitHub
  2. emonkak/dwm-win32 - GitHub
  3. dwm-win32 || dynamic window manager manager for Microsoft Windows
  4. Gitを使いこなすための20のコマンド - SourceForge.JP Magazine : オープンソースの話題満載
  5. gitのリモートブランチを使って作業を行う流れのメモ - 那由多屋 開発日誌

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2010-03-08T11:20:58+09:00
  2. Modified: 2010-03-08T11:20:58+09:00
  3. Generated: 2023-08-27T23:09:11+09:00