Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: Building win32 simulator under linux

Re: Building win32 simulator under linux

From: Bill Napier <napier_at_pobox.com>
Date: 30 Jul 2002 12:54:36 -0400

On Tue, 30 Jul 2002 09:19:38 +0200 (MET DST), Daniel Stenberg <daniel_at_haxx.se> said:
> On Tue, 16 Jul 2002, Björn Stenberg wrote:
>> Bill Napier wrote: > So I bit the bullet and got a cross compiled
>> build of a win32 simulator > under Linux (build under linux, run
>> under windows)
>>
>> Could you document how you did that? I'd like to run automated
>> builds of the win32 simulator too.

> I'd like to second Björn's request. I wrote up the automated test
> builds we have today, and adding automatic Windows builds under
> Linux would be a good addition.

I responded to Björn in a personal reply. I'll include what I sent to
him here as well (since it seems more people want to know more
details): (BTW - the patches are most certainly out of date. I could
regenerate them, but for the most part they are pretty small changes).

---- Begin included mail -----

Certainly! I posted this to the list but it may have gotten
overlooked since it was posted while you were on vacation. It
includes a short description of what I had to do, the makefile I had
to create and a short patch to comment out some includes. The
makefile and the patch are certainly out of date, so I'll include new
versions of those in this mail as well. BTW - I had to remove the old
version of the uisimulator/win32/makefile to use my version instead
(The two aren't really compatiable).

As for installing the mingw32 compiler and libraries, I just
"apt-get"'ed the mingw32 and mingw32-runtime packages (the runtime is
really just the "w32api" include files and libraries). I'm sure they
could be built, but I didn't want to play around with building them.

Bill

----- Begin uisimulator/win32/Makefile ------
############################################################################
# __________ __ ___.
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
# \/ \/ \/ \/ \/
# $Id: Makefile,v 1.45 2002/06/27 00:25:19 zagor Exp $
#
# Copyright (C) 2002 by Daniel Stenberg <daniel_at_haxx.se>
#
# All files in this archive are subject to the GNU General Public License.
# See the file COPYING in the source tree root for full license agreement.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
############################################################################

APPDIR = ../../apps
RECDIR = $(APPDIR)/recorder

PREVAPPDIR= ..
FIRMWAREDIR = ../../firmware
DRIVERS = $(FIRMWAREDIR)/drivers
COMMON = $(FIRMWAREDIR)/common
LIBMADDIR = $(PREVAPPDIR)/common/libmad

CC = i586-mingw32msvc-gcc
WINDRES = i586-mingw32msvc-windres
RM = rm -f
DEBUG = -g

# where to put all output files
OBJDIR = .

TARGET = $(OBJDIR)/rockboxui

#DISPLAY = -DHAVE_LCD_CHARCELLS
DISPLAY = -DHAVE_LCD_BITMAP

#KEYPAD = -DHAVE_PLAYER_KEYPAD
KEYPAD = -DHAVE_RECORDER_KEYPAD

DEFINES = -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR \
$(KEYPAD) $(DISPLAY) -DAPPSVERSION=\"$(VERSION)\"

LDFLAGS = -lgdi32 -luser32

# Use this for simulator-only files
INCLUDES = -I. -I$(DRIVERS) -I$(COMMON) -I$(FIRMWAREDIR) -I$(APPDIR) -I$(RECDIR)

# The true Rockbox Applications should use this include path:
APPINCLUDES = -I$(FIRMWAREDIR)/include $(INCLUDES)

UNAME := $(shell uname)
ifeq ($(UNAME),Linux)
# INCLUDES += -I/usr/X11R6/include
# LIBDIRS = -L/usr/X11R6/lib
# DEFINES += -DLINUX
#MPEG_PLAY = 1
else
  DEFINES += -DBIG_ENDIAN
  LIBDIRS =
endif

ifdef MPEG_PLAY
  INCLUDES += -I$(PREVAPPDIR)/common
endif

CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) -W -Wall

APPCFLAGS = $(DEBUG) $(DEFINES) $(APPINCLUDES) -W -Wall

FIRMSRCS = chartables.c lcd.c power.c sprintf.c id3.c backlight.c usb.c

APPS = main.c tree.c menu.c credits.c main_menu.c\
        playlist.c showtext.c wps.c settings.c

MENUS = games_menu.c screensavers_menu.c settings_menu.c sound_menu.c

ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP)
   APPS += tetris.c sokoban.c bounce.c boxes.c icons.c bmp.c
endif

SRCS = button.c dir-win32.c lcd-win32.c panic-win32.c thread-win32.c \
        debug-win32.c kernel.c mpeg.c string-win32.c uisw32.c \
        $(APPS) $(MENUS) $(FIRMSRCS) strtok.c

ifdef MPEG_PLAY
  SRCS += mpegplay.c oss_sound.c bit.c decoder.c fixed.c frame.c huffman.c layer12.c layer3.c stream.c synth.c timer.c version.c
  DEFINES += -DMPEG_PLAY -DFPM_DEFAULT -DHAVE_CONFIG_H
  INCLUDES += -I$(LIBMADDIR)
endif

OBJS := $(SRCS:%.c=$(OBJDIR)/%.o)

all: $(OBJDIR)/uisw32.exe

$(OBJDIR)/uisw32.exe: $(OBJS) $(OBJDIR)/uisw32-res.o
        $(CC) $(OBJS) $(OBJDIR)/uisw32-res.o -o $(OBJDIR)/uisw32.exe $(LDFLAGS)

$(OBJDIR)/uisw32-res.o: uisw32.rc
        $(WINDRES) -i $< -o $_at_

clean:
        $(RM) $(OBJS) *~ core $(TARGET) $(CLIENTS)
        $(RM) -r $(DEPS)

distclean: clean
        $(RM) config.cache

ifdef MPEG_PLAY
$(OBJDIR)/bit.o: $(LIBMADDIR)/bit.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(OBJDIR)/decoder.o: $(LIBMADDIR)/decoder.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(OBJDIR)/fixed.o: $(LIBMADDIR)/fixed.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(OBJDIR)/frame.o: $(LIBMADDIR)/frame.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(OBJDIR)/huffman.o: $(LIBMADDIR)/huffman.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(OBJDIR)/layer12.o: $(LIBMADDIR)/layer12.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(OBJDIR)/layer3.o: $(LIBMADDIR)/layer3.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(OBJDIR)/stream.o: $(LIBMADDIR)/stream.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(OBJDIR)/synth.o: $(LIBMADDIR)/synth.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(OBJDIR)/timer.o: $(LIBMADDIR)/timer.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(OBJDIR)/version.o: $(LIBMADDIR)/version.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(OBJDIR)/mpegplay.o: $(PREVAPPDIR)/common/mpegplay.c
        $(CC) $(CFLAGS) -c $< -o $_at_

endif

$(OBJDIR)/credits.o: $(APPDIR)/credits.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/menu.o: $(APPDIR)/menu.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/main_menu.o: $(APPDIR)/main_menu.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/sound_menu.o: $(APPDIR)/sound_menu.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/games_menu.o: $(APPDIR)/games_menu.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/screensavers_menu.o: $(APPDIR)/screensavers_menu.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/settings_menu.o: $(APPDIR)/settings_menu.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/icons.o: $(RECDIR)/icons.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/tetris.o: $(RECDIR)/tetris.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/sokoban.o: $(RECDIR)/sokoban.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/bounce.o: $(RECDIR)/bounce.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/boxes.o: $(RECDIR)/boxes.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/main.o: $(APPDIR)/main.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/wps.o: $(APPDIR)/wps.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/bmp.o: $(RECDIR)/bmp.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/tree.o: $(APPDIR)/tree.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/playlist.o: $(APPDIR)/playlist.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/showtext.o: $(APPDIR)/showtext.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/lcd.o: $(DRIVERS)/lcd.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/power.o: $(DRIVERS)/power.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/chartables.o: $(FIRMWAREDIR)/chartables.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/usb.o: $(FIRMWAREDIR)/usb.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/settings.o: $(APPDIR)/settings.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/id3.o: $(FIRMWAREDIR)/id3.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/debug.o: $(FIRMWAREDIR)/debug.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(OBJDIR)/sprintf.o: $(COMMON)/sprintf.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/strtok.o: $(COMMON)/strtok.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_

$(OBJDIR)/backlight.o: $(FIRMWAREDIR)/backlight.c
        $(CC) $(APPCFLAGS) -c $< -o $_at_


# these ones are simulator-specific

$(OBJDIR)/%.o: %.c
        $(CC) $(CFLAGS) -c $< -o $_at_

$(TARGET): $(OBJS)
        $(CC) -g -o $(TARGET) $(LIBDIRS) $(LDFLAGS) $(OBJS) $(LIBS)

DEPS:=$(OBJDIR)/.deps

$(DEPS)/%.d: %.c
                _at_$(SHELL) -c 'if [ ! -d $(DEPS) ]; then \
                        echo Creating the dependency directory: $(DEPS); \
                        mkdir -p $(DEPS); fi'
                _at_echo "Updating Dependencies for $<"
                _at_$(SHELL) -ec '$(CC) -MM $(CFLAGS) $< \
        |sed '\''s|\($*\)\.o[ :]*|$(OBJDIR)/\1.o $(<:%.c=%.d) : |g'\'' > $_at_; \
        [ -s $_at_ ] || rm -f $_at_'

-include $(SRCS:%.c=$(DEPS)/%.d)
----- End uisimulator/win32/Makefile ------

----- Begin patch ------
Index: firmware/backlight.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/backlight.c,v
retrieving revision 1.9
diff -d -u -r1.9 backlight.c
--- firmware/backlight.c 15 Jul 2002 22:19:49 -0000 1.9
+++ firmware/backlight.c 16 Jul 2002 17:06:43 -0000
_at__at_ -65,7 +65,7 _at__at_
                 PADR &= ~0x40;
 #endif
                 break;
-
+#ifndef SIMULATOR
             case SYS_USB_CONNECTED:
                 /* Tell the USB thread that we are safe */
                 DEBUGF("backlight_thread got SYS_USB_CONNECTED\n");
_at__at_ -74,6 +74,7 _at__at_
                 /* Wait until the USB cable is extracted again */
                 usb_wait_for_disconnect(&backlight_queue);
                 break;
+#endif // SIMULATOR
         }
     }
 }
Index: firmware/common/dir.h
===================================================================
RCS file: /cvsroot/rockbox/firmware/common/dir.h,v
retrieving revision 1.14
diff -d -u -r1.14 dir.h
--- firmware/common/dir.h 15 Jul 2002 22:58:28 -0000 1.14
+++ firmware/common/dir.h 16 Jul 2002 17:06:43 -0000
_at__at_ -54,13 +54,17 _at__at_
 #else // SIMULATOR
 
 #ifdef WIN32
+#ifndef __MINGW32__
+#include <stdio.h>
 #include <io.h>
+#endif // __MINGW32__
 typedef struct DIRtag
 {
     struct dirent fd;
     int handle;
 } DIR;
 #endif // WIN32
+
 #endif // SIMULATOR
 
 #ifndef DIRFUNCTIONS_DEFINED
Index: firmware/common/file.h
===================================================================
RCS file: /cvsroot/rockbox/firmware/common/file.h,v
retrieving revision 1.8
diff -d -u -r1.8 file.h
--- firmware/common/file.h 5 Jul 2002 11:28:20 -0000 1.8
+++ firmware/common/file.h 16 Jul 2002 17:06:43 -0000
_at__at_ -46,8 +46,10 _at__at_
 
 #else
 #ifdef WIN32
+#ifndef __MINGW32__
 #include <io.h>
 #include <stdio.h>
+#endif // __MINGW32__
 #endif // WIN32
 #endif // SIMULATOR
 
Index: tools/configure
===================================================================
RCS file: /cvsroot/rockbox/tools/configure,v
retrieving revision 1.18
diff -d -u -r1.18 configure
--- tools/configure 15 Jul 2002 13:19:00 -0000 1.18
+++ tools/configure 16 Jul 2002 17:06:49 -0000
_at__at_ -17,22 +17,39 _at__at_
 }
 
 simul () {
+##################################################################
+# Figure out win32/x11 GUI
+#
+echo ""
+echo "Build (W)in32 or (X)11 GUI version? (X)"
+
+option=`input`;
+
+case $option in
+ [Ww])
+ simver="win32"
+ ;;
+ *)
+ simver="x11"
+ ;;
+ esac
+
  ##################################################################
  # Figure out where the firmware code is!
  #
 
- simfile="x11/lcd-x11.c" # a file to check for in the uisimulator root dir
+ simfile="$simver/lcd-$simver.c" # a file to check for in the uisimulator root dir
 
  for dir in uisimulator . .. ../uisimulator ../../uisimulator; do
    if [ -f "$dir/$simfile" ]; then
- simdir="$dir/x11"
+ simdir="$dir/$simver"
      break
    fi
  done
 
  if [ -z "$simdir" ]; then
- echo "This script couldn't find your uisimulator/x11 directory. Please enter the"
- echo "full path to your uisimulator/x11 directory here:"
+ echo "This script couldn't find your uisimulator/$simver directory. Please enter the"
+ echo "full path to your uisimulator/$simver directory here:"
 
    simdir=`input`
  fi
Index: uisimulator/win32/stdbool.h
===================================================================
RCS file: /cvsroot/rockbox/uisimulator/win32/stdbool.h,v
retrieving revision 1.2
diff -d -u -r1.2 stdbool.h
--- uisimulator/win32/stdbool.h 19 Jun 2002 20:10:52 -0000 1.2
+++ uisimulator/win32/stdbool.h 16 Jul 2002 17:06:50 -0000
_at__at_ -17,6 +17,11 _at__at_
  *
  ****************************************************************************/
 
+#ifndef __STDBOOL_H__
+#define __STDBOOL_H__ 1
+
 typedef unsigned int bool;
 #define true 1
-#define false 0
\ No newline at end of file
+#define false 0
+
+#endif
Index: uisimulator/win32/uisw32.c
===================================================================
RCS file: /cvsroot/rockbox/uisimulator/win32/uisw32.c,v
retrieving revision 1.6
diff -d -u -r1.6 uisw32.c
--- uisimulator/win32/uisw32.c 15 Jun 2002 10:58:14 -0000 1.6
+++ uisimulator/win32/uisw32.c 16 Jul 2002 17:06:50 -0000
_at__at_ -26,6 +26,10 _at__at_
 #include "thread-win32.h"
 #include "kernel.h"
 
+#ifndef LR_VGACOLOR /* Should be under MINGW32 builds? */
+#define LR_VGACOLOR LR_COLOR
+#endif
+
 // extern functions
 extern void app_main (void *); // mod entry point
 extern void new_key(int key);
_at__at_ -298,4 +302,4 _at__at_
     GUIMessageLoop ();
 
     return GUIDown ();
-}
\ No newline at end of file
+}
Index: uisimulator/win32/uisw32.rc
===================================================================
RCS file: /cvsroot/rockbox/uisimulator/win32/uisw32.rc,v
retrieving revision 1.2
diff -d -u -r1.2 uisw32.rc
--- uisimulator/win32/uisw32.rc 29 May 2002 16:34:39 -0000 1.2
+++ uisimulator/win32/uisw32.rc 16 Jul 2002 17:06:50 -0000
_at__at_ -7,7 +7,9 _at__at_
 //
 // Generated from the TEXTINCLUDE 2 resource.
 //
+#ifndef __MINGW32__
 #include "afxres.h"
+#endif // __MINGW32__
 
 /////////////////////////////////////////////////////////////////////////////
 #undef APSTUDIO_READONLY_SYMBOLS
_at__at_ -17,7 +19,9 _at__at_
 
 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
 #ifdef _WIN32
+#ifndef __MINGW32__
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#endif // __MINGW32__
 #pragma code_page(1252)
 #endif //_WIN32
 

----- End Patch ------


From: Bill Napier <napier_at_pobox.com>
Subject: As Promised, win32 xcompile patch
To: rockbox_at_cool.haxx.se
Date: 02 Jul 2002 12:04:03 -0400
Reply-To: rockbox_at_cool.haxx.se

Basically, I started with the X11 sim makefile and changed it to call
the mingw32 toolchain. There were a couple of other changes that had
to be made in it as well (had to add the resource compling stuff that
the X11 didn't need). I also had to modify some source, but whenever
I did that I tried to #ifdef stuff to not mess with other builds too
much.

So basically, I'm compiling the simulators for win32 on my Linux box
with the gnu (MINGW32) toolchain.

Things that suck: I think there are now at least 3 different ways of
building the win32 simulator. From what I've seen, all of them
incompatiable with the rest. :) There has to be some way of getting
them all to play nicely with each other. By far the simplest method
is to name each of the makefiles "makefile-mingw32" and
"makefile-msvc", etc. and you symlink in the right makefile for your
toolchain. It would be better to just have a single makefile, but I
don't know how to accomplish all that.

Bill
napier_at_pobox.com
Received on 2002-07-30

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy