[OpenSolaris] Building bsnes .034 on OpenSolaris

Archived bsnes development news, feature requests and bug reports. Forum is now located at http://board.byuu.org/
Locked
ephaestos
New Member
Posts: 4
Joined: Mon Aug 18, 2008 9:42 pm

[OpenSolaris] Building bsnes .034 on OpenSolaris

Post by ephaestos »

Hi all,

I quite easily managed to compile bsnes .034 on OpenSolaris 2008.05. I haven't done some strong testing but it has been working quite well for now. The only non working feature is sound output which cannot work because there is no openal nor oss nor alsa out of the box. For those wanting to try it out here are the steps needed :


First the platform on which is was compiled

Code: Select all

edechaux@tecra:~$ prtdiag
System Configuration: TOSHIBA TECRA M9
BIOS Configuration: TOSHIBA Version 2.20 02/29/2008

Code: Select all

edechaux@tecra:~$ psrinfo -v
Status of virtual processor 0 as of: 08/19/2008 00:04:55
  on-line since 08/18/2008 18:35:02.
  The i386 processor operates at 2000 MHz,
	and has an i387 compatible floating point processor.
Status of virtual processor 1 as of: 08/19/2008 00:04:55
  on-line since 08/18/2008 18:35:08.
  The i386 processor operates at 2000 MHz,
	and has an i387 compatible floating point processor.

Code: Select all

edechaux@tecra:~$ prtconf |grep Memory
Memory size: 3063 Megabytes

Code: Select all

edechaux@tecra:~$ uname -a
SunOS tecra 5.11 snv_94 i86pc i386 i86pc Solaris

Then the additional packages I had to install

Code: Select all

pfexec pkg install SUNWgcc
pfexec pkg install SUNWgmake
pfexec pkg install SUNWxwinc
pfexec pkg install SUNWxorg-headers

Interesting stuff are beginning here as we need to edit the makefile. To be honest, I don't know if those edits are done the way they should be. I am not a developer and I don't have much knowledge in makefile writing. If you think it can be done in a better way, please tell me :)

First, as I said earlier, sound does not work so we need to remove the audio.* libraries from being built. Second, as pkg-config is not available, at least on my install, we need to replace the shell command by the actual output taken here from a Ubuntu 8.10 having the pixman part remove as 1/ it is not available on os and 2/ it is not needed.


As a result, my makefile is as follow

Code: Select all

edechaux@tecra:~/Desktop/bsnes/src$ cat Makefile
include lib/nall/Makefile.string
prefix = /usr/local

################
### compiler ###
################

ifneq ($(findstring gcc,$(compiler)),) # GCC family
  flags = -O3 -fomit-frame-pointer -Ilib
  c = $(compiler) $(flags)
  cpp = $(subst cc,++,$(compiler)) $(flags)
  obj = o
  rule = -c $< -o $@
  link = -s
  mkbin = -o$1
  mkdef = -D$1
  mklib = -l$1
else ifeq ($(compiler),cl) # Visual C++
  flags = /nologo /wd4355 /wd4996 /O2 /EHsc /Ilib
  c = cl $(flags)
  cpp = cl $(flags)
  obj = obj
  rule = /c $< /Fo$@
  link = /link
  mkbin = /Fe$1
  mkdef = /D$1
  mklib = $1.lib
else
  unknown_compiler: help;
endif

##########
### os ###
##########

ifeq ($(platform),x) # X11
  ruby = video.glx video.xv video.sdl input.sdl input.x
  link += -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lgio-2.0 -lcairo -lpango-1.0 -lfreetype -lz -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lX11 -lXext
  link += $(call mklib,Xtst)
  delete = rm -f $1
else ifeq ($(platform),win) # Windows
  ruby = video.direct3d video.wgl video.directdraw video.gdi audio.directsound input.directinput
  link += $(if $(findstring mingw,$(compiler)),-mwindows)
  link += $(call mklib,uuid)
  link += $(call mklib,kernel32)
  link += $(call mklib,user32)
  link += $(call mklib,gdi32)
  link += $(call mklib,shell32)
  link += $(call mklib,winmm)
  link += $(call mklib,comdlg32)
  link += $(call mklib,comctl32)
  delete = $(if $(findstring i586-mingw-gcc,$(compiler)),rm -f $1,del $(subst /,\,$1))
else
  unknown_platform: help;
endif

############
### ruby ###
############

rubyflags =
rubyflags += $(if $(findstring .sdl,$(ruby)),`sdl-config --cflags`)

link += $(if $(findstring video.direct3d,$(ruby)),$(call mklib,d3d9))
link += $(if $(findstring video.directdraw,$(ruby)),$(call mklib,ddraw))
link += $(if $(findstring video.glx,$(ruby)),$(call mklib,GL))
link += $(if $(findstring video.wgl,$(ruby)),$(call mklib,opengl32))
link += $(if $(findstring video.xv,$(ruby)),$(call mklib,Xv))
link += $(if $(findstring audio.alsa,$(ruby)),$(call mklib,asound))
link += $(if $(findstring audio.ao,$(ruby)),$(call mklib,ao))
link += $(if $(findstring audio.directsound,$(ruby)),$(call mklib,dsound))
link += $(if $(findstring audio.openal,$(ruby)),$(if $(call streq,$(platform),x),$(call mklib,openal),$(call mklib,openal32)))
link += $(if $(findstring input.directinput,$(ruby)),$(call mklib,dinput8) $(call mklib,dxguid))
link += $(if $(findstring input.sdl,$(ruby)),`sdl-config --libs`)

####################################
### main target and dependencies ###
####################################

objects = main libco hiro ruby libfilter string reader cart cheat \
  memory smemory cpu scpu smp ssmp sdsp ppu bppu snes \
  bsx srtc sdd1 spc7110 cx4 dsp1 dsp2 dsp3 dsp4 obc1 st010

ifeq ($(enable_gzip),true)
  objects += adler32 compress crc32 deflate gzio inffast inflate inftrees ioapi trees unzip zip zutil
  flags += $(call mkdef,GZIP_SUPPORT)
endif

ifeq ($(enable_jma),true)
  objects += jma jcrc32 lzmadec 7zlzma iiostrm inbyte lzma winout
  flags += $(call mkdef,JMA_SUPPORT)
endif

objects := $(patsubst %,obj/%.$(obj),$(objects))
rubydef := $(foreach c,$(subst .,_,$(call strupper,$(ruby))),$(call mkdef,$c))

# Windows resource file
ifeq ($(platform),win)
  ifeq ($(compiler),cl)
    objects += obj/bsnes.res
  else ifneq ($(findstring gcc,$(compiler)),)
    objects += obj/bsnesrc.$(obj)
  endif
endif

################
### implicit ###
################

compile = \
  $(strip \
    $(if $(filter %.c,$<), \
      $(c) $1 $(rule), \
      $(if $(filter %.cpp,$<), \
        $(cpp) $1 $(rule) \
      ) \
    ) \
  )

%.$(obj): $<; $(call compile)

all: build;

############
### main ###
############

obj/main.$(obj): ui/main.cpp ui/* ui/base/* ui/loader/* ui/settings/*
obj/bsnes.res: ui/bsnes.rc; rc /r /foobj/bsnes.res ui/bsnes.rc
obj/bsnesrc.$(obj): ui/bsnes.rc; windres ui/bsnes.rc obj/bsnesrc.$(obj)

#################
### libraries ###
#################

obj/ruby.$(obj): lib/ruby/ruby.cpp lib/ruby/*
	$(call compile,$(rubydef) $(rubyflags))
obj/hiro.$(obj): lib/hiro/hiro.cpp lib/hiro/* lib/hiro/gtk/* lib/hiro/win/*
	$(call compile,$(if $(call streq,$(platform),x),-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/freetype2 -I/usr/include/libpng12))
obj/libco.$(obj):     lib/libco/libco.c lib/libco/*
	$(call compile,-static)
obj/libfilter.$(obj): lib/libfilter/libfilter.cpp lib/libfilter/*
obj/string.$(obj):    lib/nall/string.cpp lib/nall/*

#################
### utilities ###
#################

obj/reader.$(obj): reader/reader.cpp reader/*
obj/cart.$(obj)  : cart/cart.cpp cart/*
obj/cheat.$(obj) : cheat/cheat.cpp cheat/*

##############
### memory ###
##############

obj/memory.$(obj) : memory/memory.cpp memory/*
obj/smemory.$(obj): memory/smemory/smemory.cpp memory/smemory/* memory/smemory/mapper/*

###########
### cpu ###
###########

obj/cpu.$(obj) : cpu/cpu.cpp cpu/*
obj/scpu.$(obj): cpu/scpu/scpu.cpp cpu/scpu/* cpu/scpu/core/* cpu/scpu/dma/* cpu/scpu/memory/* cpu/scpu/mmio/* cpu/scpu/timing/*

###########
### smp ###
###########

obj/smp.$(obj) : smp/smp.cpp smp/*
obj/ssmp.$(obj): smp/ssmp/ssmp.cpp smp/ssmp/* smp/ssmp/core/* smp/ssmp/memory/* smp/ssmp/timing/*

###########
### dsp ###
###########

obj/adsp.$(obj): dsp/adsp/adsp.cpp dsp/adsp/*
obj/bdsp.$(obj): dsp/bdsp/bdsp.cpp dsp/bdsp/*
obj/sdsp.$(obj): dsp/sdsp/sdsp.cpp dsp/sdsp/*

###########
### ppu ###
###########

obj/ppu.$(obj) : ppu/ppu.cpp ppu/*
obj/bppu.$(obj): ppu/bppu/bppu.cpp ppu/bppu/*

############
### snes ###
############

obj/snes.$(obj): snes/snes.cpp snes/* snes/scheduler/* snes/video/* snes/audio/* snes/input/*

#####################
### special chips ###
#####################

obj/bsx.$(obj)    : chip/bsx/bsx.cpp chip/bsx/*
obj/srtc.$(obj)   : chip/srtc/srtc.cpp chip/srtc/*
obj/sdd1.$(obj)   : chip/sdd1/sdd1.cpp chip/sdd1/*
obj/spc7110.$(obj): chip/spc7110/spc7110.cpp chip/spc7110/*
obj/cx4.$(obj)    : chip/cx4/cx4.cpp chip/cx4/*
obj/dsp1.$(obj)   : chip/dsp1/dsp1.cpp chip/dsp1/*
obj/dsp2.$(obj)   : chip/dsp2/dsp2.cpp chip/dsp2/*
obj/dsp3.$(obj)   : chip/dsp3/dsp3.cpp chip/dsp3/*
obj/dsp4.$(obj)   : chip/dsp4/dsp4.cpp chip/dsp4/*
obj/obc1.$(obj)   : chip/obc1/obc1.cpp chip/obc1/*
obj/st010.$(obj)  : chip/st010/st010.cpp chip/st010/*

############
### zlib ###
############

obj/adler32.$(obj) : reader/zlib/adler32.c reader/zlib/*
obj/compress.$(obj): reader/zlib/compress.c reader/zlib/*
obj/crc32.$(obj)   : reader/zlib/crc32.c reader/zlib/*
obj/deflate.$(obj) : reader/zlib/deflate.c reader/zlib/*
obj/gzio.$(obj)    : reader/zlib/gzio.c reader/zlib/*
obj/inffast.$(obj) : reader/zlib/inffast.c reader/zlib/*
obj/inflate.$(obj) : reader/zlib/inflate.c reader/zlib/*
obj/inftrees.$(obj): reader/zlib/inftrees.c reader/zlib/*
obj/ioapi.$(obj)   : reader/zlib/ioapi.c reader/zlib/*
obj/trees.$(obj)   : reader/zlib/trees.c reader/zlib/*
obj/unzip.$(obj)   : reader/zlib/unzip.c reader/zlib/*
obj/zip.$(obj)     : reader/zlib/zip.c reader/zlib/*
obj/zutil.$(obj)   : reader/zlib/zutil.c reader/zlib/*

###########
### jma ###
###########

obj/jma.$(obj)    : reader/jma/jma.cpp reader/jma/*
obj/jcrc32.$(obj) : reader/jma/jcrc32.cpp reader/jma/*
obj/lzmadec.$(obj): reader/jma/lzmadec.cpp reader/jma/*
obj/7zlzma.$(obj) : reader/jma/7zlzma.cpp reader/jma/*
obj/iiostrm.$(obj): reader/jma/iiostrm.cpp reader/jma/*
obj/inbyte.$(obj) : reader/jma/inbyte.cpp reader/jma/*
obj/lzma.$(obj)   : reader/jma/lzma.cpp reader/jma/*
obj/winout.$(obj) : reader/jma/winout.cpp reader/jma/*

###############
### targets ###
###############

build: $(objects)
	$(strip $(cpp) $(call mkbin,../bsnes) $(objects) $(link))

install:
	install -D -m 755 ../bsnes $(DESTDIR)$(prefix)/bin/bsnes
	install -D -m 644 data/bsnes.png $(DESTDIR)$(prefix)/share/icons/bsnes.png

clean:
	-@$(call delete,obj/*.$(obj))
	-@$(call delete,*.res)
	-@$(call delete,*.pgd)
	-@$(call delete,*.pgc)
	-@$(call delete,*.ilk)
	-@$(call delete,*.pdb)
	-@$(call delete,*.manifest)

help:
	@echo "Usage: $(MAKE) platform=(os) compiler=(cc) [options]"
	@echo ""
	@echo "Supported platforms:"
	@echo "  x   - Linux / BSD (x86, x86-64)"
	@echo "  win - Windows (x86, x86-64)"
	@echo ""
	@echo "Supported compilers:"
	@echo "  gcc              - GCC compiler"
	@echo "  mingw32-gcc      - MinGW compiler"
	@echo "  i586-mingw32-gcc - MinGW cross compiler"
	@echo "  cl               - Visual C++"
	@echo ""
	@echo "Available options:"
	@echo "  enable_gzip=[true|false] - Enable ZIP / GZ support (default=false)"
	@echo "  enable_jma=[true|false]  - Enable JMA support (default=false)"
	@echo ""
	@echo "Example: $(MAKE) platform=x compiler=gcc enable_gzip=true"
	@echo ""

To sum up here is a diff between the original makefile and the custom one

Code: Select all

edechaux@tecra:~/Desktop/bsnes/src$ diff ../new/src/Makefile Makefile
37,38c37,38
<   ruby = video.glx video.xv video.sdl audio.openal audio.oss audio.alsa audio.ao input.sdl input.x
<   link += `pkg-config --libs gtk+-2.0`
---
>   ruby = video.glx video.xv video.sdl input.sdl input.x
>   link += -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lgio-2.0 -lcairo -lpango-1.0 -lfreetype -lz -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lX11 -lXext
139c139
< 	$(call compile,$(if $(call streq,$(platform),x),`pkg-config --cflags gtk+-2.0`))
---
> 	$(call compile,$(if $(call streq,$(platform),x),-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/freetype2 -I/usr/include/libpng12))

Last step is to build everything

Code: Select all

edechaux@tecra:~/Desktop/bsnes/src$ /usr/gnu/bin/make platform=x compiler=gcc
g++ -O3 -fomit-frame-pointer -Ilib -c ui/main.cpp -o obj/main.o
gcc -O3 -fomit-frame-pointer -Ilib -static -c lib/libco/libco.c -o obj/libco.o
g++ -O3 -fomit-frame-pointer -Ilib -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/freetype2 -I/usr/include/libpng12 -c lib/hiro/hiro.cpp -o obj/hiro.o
g++ -O3 -fomit-frame-pointer -Ilib -DVIDEO_GLX -DVIDEO_XV -DVIDEO_SDL -DINPUT_SDL -DINPUT_X `sdl-config --cflags` -c lib/ruby/ruby.cpp -o obj/ruby.o
g++ -O3 -fomit-frame-pointer -Ilib -c lib/libfilter/libfilter.cpp -o obj/libfilter.o
g++ -O3 -fomit-frame-pointer -Ilib -c lib/nall/string.cpp -o obj/string.o
g++ -O3 -fomit-frame-pointer -Ilib -c reader/reader.cpp -o obj/reader.o
g++ -O3 -fomit-frame-pointer -Ilib -c cart/cart.cpp -o obj/cart.o
g++ -O3 -fomit-frame-pointer -Ilib -c cheat/cheat.cpp -o obj/cheat.o
g++ -O3 -fomit-frame-pointer -Ilib -c memory/memory.cpp -o obj/memory.o
g++ -O3 -fomit-frame-pointer -Ilib -c memory/smemory/smemory.cpp -o obj/smemory.o
g++ -O3 -fomit-frame-pointer -Ilib -c cpu/cpu.cpp -o obj/cpu.o
g++ -O3 -fomit-frame-pointer -Ilib -c cpu/scpu/scpu.cpp -o obj/scpu.o
g++ -O3 -fomit-frame-pointer -Ilib -c smp/smp.cpp -o obj/smp.o
g++ -O3 -fomit-frame-pointer -Ilib -c smp/ssmp/ssmp.cpp -o obj/ssmp.o
g++ -O3 -fomit-frame-pointer -Ilib -c dsp/sdsp/sdsp.cpp -o obj/sdsp.o
g++ -O3 -fomit-frame-pointer -Ilib -c ppu/ppu.cpp -o obj/ppu.o
g++ -O3 -fomit-frame-pointer -Ilib -c ppu/bppu/bppu.cpp -o obj/bppu.o
g++ -O3 -fomit-frame-pointer -Ilib -c snes/snes.cpp -o obj/snes.o
g++ -O3 -fomit-frame-pointer -Ilib -c chip/bsx/bsx.cpp -o obj/bsx.o
g++ -O3 -fomit-frame-pointer -Ilib -c chip/srtc/srtc.cpp -o obj/srtc.o
g++ -O3 -fomit-frame-pointer -Ilib -c chip/sdd1/sdd1.cpp -o obj/sdd1.o
g++ -O3 -fomit-frame-pointer -Ilib -c chip/spc7110/spc7110.cpp -o obj/spc7110.o
g++ -O3 -fomit-frame-pointer -Ilib -c chip/cx4/cx4.cpp -o obj/cx4.o
g++ -O3 -fomit-frame-pointer -Ilib -c chip/dsp1/dsp1.cpp -o obj/dsp1.o
g++ -O3 -fomit-frame-pointer -Ilib -c chip/dsp2/dsp2.cpp -o obj/dsp2.o
g++ -O3 -fomit-frame-pointer -Ilib -c chip/dsp3/dsp3.cpp -o obj/dsp3.o
g++ -O3 -fomit-frame-pointer -Ilib -c chip/dsp4/dsp4.cpp -o obj/dsp4.o
g++ -O3 -fomit-frame-pointer -Ilib -c chip/obc1/obc1.cpp -o obj/obc1.o
g++ -O3 -fomit-frame-pointer -Ilib -c chip/st010/st010.cpp -o obj/st010.o
g++ -O3 -fomit-frame-pointer -Ilib -o../bsnes obj/main.o obj/libco.o obj/hiro.o obj/ruby.o obj/libfilter.o obj/string.o obj/reader.o obj/cart.o obj/cheat.o obj/memory.o obj/smemory.o obj/cpu.o obj/scpu.o obj/smp.o obj/ssmp.o obj/sdsp.o obj/ppu.o obj/bppu.o obj/snes.o obj/bsx.o obj/srtc.o obj/sdd1.o obj/spc7110.o obj/cx4.o obj/dsp1.o obj/dsp2.o obj/dsp3.o obj/dsp4.o obj/obc1.o obj/st010.o -s -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lgio-2.0 -lcairo -lpango-1.0 -lfreetype -lz -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lX11 -lXext -lXtst -lGL -lXv `sdl-config --libs`

And then ../bsnes :)

Image


Next step is to build openal and an openal enabled bsnes :)


See you
--
Eric
byuu

Post by byuu »

Hi, very neat! So OpenSolaris lacks OSS and OpenAL by default? How about libao? If all three, I have to ask ... what sound system does it use by default?

pkg-config is really nice, but I imagine we can add some tricky rules to determine its presence. I'd prefer not to unroll it as some systems may need different packages.
ephaestos
New Member
Posts: 4
Joined: Mon Aug 18, 2008 9:42 pm

Post by ephaestos »

Well, in fact it seems I am wrong. pkg-config is available in package SUNWgnome-common-devel.

I will try with it when I am home.


Regarding sound, I believe it is Sun Audio engine in opensolaris. I don't think OSS or ALSA will be ported but it seems OpenAL can work. I will also try with libao as it also seems to work.


Regards

--
Eric
ephaestos
New Member
Posts: 4
Joined: Mon Aug 18, 2008 9:42 pm

Post by ephaestos »

Little update. Needed packages are now the following :

Code: Select all

pfexec pkg install SUNWgcc
pfexec pkg install SUNWgmake
pfexec pkg install SUNWxwinc
pfexec pkg install SUNWxorg-headers
pfexec pkg install SUNWgnome-common-devel 
Last package provides (among other) the pkg-config command. So now only the sound output is missing. I have updated the original makefile to add a parameter to disable sound output. Please check :

Code: Select all

include lib/nall/Makefile.string
prefix = /usr/local

################
### compiler ###
################

ifneq ($(findstring gcc,$(compiler)),) # GCC family
  flags = -O3 -fomit-frame-pointer -Ilib
  c = $(compiler) $(flags)
  cpp = $(subst cc,++,$(compiler)) $(flags)
  obj = o
  rule = -c $< -o $@
  link = -s
  mkbin = -o$1
  mkdef = -D$1
  mklib = -l$1
else ifeq ($(compiler),cl) # Visual C++
  flags = /nologo /wd4355 /wd4996 /O2 /EHsc /Ilib
  c = cl $(flags)
  cpp = cl $(flags)
  obj = obj
  rule = /c $< /Fo$@
  link = /link
  mkbin = /Fe$1
  mkdef = /D$1
  mklib = $1.lib
else
  unknown_compiler: help;
endif

##########
### os ###
##########

ifeq ($(platform),x) # X11
  ruby = video.glx video.xv video.sdl input.sdl input.x

  ifeq ($(sound),yes)
    ruby += audio.openal audio.oss audio.alsa audio.ao
  endif

  link += `pkg-config --libs gtk+-2.0`
  link += $(call mklib,Xtst)
  delete = rm -f $1
else ifeq ($(platform),win) # Windows
  ruby = video.direct3d video.wgl video.directdraw video.gdi audio.directsound input.directinput
  link += $(if $(findstring mingw,$(compiler)),-mwindows)
  link += $(call mklib,uuid)
  link += $(call mklib,kernel32)
  link += $(call mklib,user32)
  link += $(call mklib,gdi32)
  link += $(call mklib,shell32)
  link += $(call mklib,winmm)
  link += $(call mklib,comdlg32)
  link += $(call mklib,comctl32)
  delete = $(if $(findstring i586-mingw-gcc,$(compiler)),rm -f $1,del $(subst /,\,$1))
else
  unknown_platform: help;
endif

############
### ruby ###
############

rubyflags =
rubyflags += $(if $(findstring .sdl,$(ruby)),`sdl-config --cflags`)

link += $(if $(findstring video.direct3d,$(ruby)),$(call mklib,d3d9))
link += $(if $(findstring video.directdraw,$(ruby)),$(call mklib,ddraw))
link += $(if $(findstring video.glx,$(ruby)),$(call mklib,GL))
link += $(if $(findstring video.wgl,$(ruby)),$(call mklib,opengl32))
link += $(if $(findstring video.xv,$(ruby)),$(call mklib,Xv))
link += $(if $(findstring audio.alsa,$(ruby)),$(call mklib,asound))
link += $(if $(findstring audio.ao,$(ruby)),$(call mklib,ao))
link += $(if $(findstring audio.directsound,$(ruby)),$(call mklib,dsound))
link += $(if $(findstring audio.openal,$(ruby)),$(if $(call streq,$(platform),x),$(call mklib,openal),$(call mklib,openal32)))
link += $(if $(findstring input.directinput,$(ruby)),$(call mklib,dinput8) $(call mklib,dxguid))
link += $(if $(findstring input.sdl,$(ruby)),`sdl-config --libs`)

####################################
### main target and dependencies ###
####################################

objects = main libco hiro ruby libfilter string reader cart cheat \
  memory smemory cpu scpu smp ssmp sdsp ppu bppu snes \
  bsx srtc sdd1 spc7110 cx4 dsp1 dsp2 dsp3 dsp4 obc1 st010

ifeq ($(enable_gzip),true)
  objects += adler32 compress crc32 deflate gzio inffast inflate inftrees ioapi trees unzip zip zutil
  flags += $(call mkdef,GZIP_SUPPORT)
endif

ifeq ($(enable_jma),true)
  objects += jma jcrc32 lzmadec 7zlzma iiostrm inbyte lzma winout
  flags += $(call mkdef,JMA_SUPPORT)
endif

objects := $(patsubst %,obj/%.$(obj),$(objects))
rubydef := $(foreach c,$(subst .,_,$(call strupper,$(ruby))),$(call mkdef,$c))

# Windows resource file
ifeq ($(platform),win)
  ifeq ($(compiler),cl)
    objects += obj/bsnes.res
  else ifneq ($(findstring gcc,$(compiler)),)
    objects += obj/bsnesrc.$(obj)
  endif
endif

################
### implicit ###
################

compile = \
  $(strip \
    $(if $(filter %.c,$<), \
      $(c) $1 $(rule), \
      $(if $(filter %.cpp,$<), \
        $(cpp) $1 $(rule) \
      ) \
    ) \
  )

%.$(obj): $<; $(call compile)

all: build;

############
### main ###
############

obj/main.$(obj): ui/main.cpp ui/* ui/base/* ui/loader/* ui/settings/*
obj/bsnes.res: ui/bsnes.rc; rc /r /foobj/bsnes.res ui/bsnes.rc
obj/bsnesrc.$(obj): ui/bsnes.rc; windres ui/bsnes.rc obj/bsnesrc.$(obj)

#################
### libraries ###
#################

obj/ruby.$(obj): lib/ruby/ruby.cpp lib/ruby/*
        $(call compile,$(rubydef) $(rubyflags))
obj/hiro.$(obj): lib/hiro/hiro.cpp lib/hiro/* lib/hiro/gtk/* lib/hiro/win/*
        $(call compile,$(if $(call streq,$(platform),x),`pkg-config --cflags gtk+-2.0`))
obj/libco.$(obj):     lib/libco/libco.c lib/libco/*
        $(call compile,-static)
obj/libfilter.$(obj): lib/libfilter/libfilter.cpp lib/libfilter/*
obj/string.$(obj):    lib/nall/string.cpp lib/nall/*

#################
### utilities ###
#################

obj/reader.$(obj): reader/reader.cpp reader/*
obj/cart.$(obj)  : cart/cart.cpp cart/*
obj/cheat.$(obj) : cheat/cheat.cpp cheat/*

##############
### memory ###
##############

obj/memory.$(obj) : memory/memory.cpp memory/*
obj/smemory.$(obj): memory/smemory/smemory.cpp memory/smemory/* memory/smemory/mapper/*

###########
### cpu ###
###########

obj/cpu.$(obj) : cpu/cpu.cpp cpu/*
obj/scpu.$(obj): cpu/scpu/scpu.cpp cpu/scpu/* cpu/scpu/core/* cpu/scpu/dma/* cpu/scpu/memory/* cpu/scpu/mmio/* cpu/scpu/timing/*

###########
### smp ###
###########

obj/smp.$(obj) : smp/smp.cpp smp/*
obj/ssmp.$(obj): smp/ssmp/ssmp.cpp smp/ssmp/* smp/ssmp/core/* smp/ssmp/memory/* smp/ssmp/timing/*

###########
### dsp ###
###########

obj/adsp.$(obj): dsp/adsp/adsp.cpp dsp/adsp/*
obj/bdsp.$(obj): dsp/bdsp/bdsp.cpp dsp/bdsp/*
obj/sdsp.$(obj): dsp/sdsp/sdsp.cpp dsp/sdsp/*

###########
### ppu ###
###########

obj/ppu.$(obj) : ppu/ppu.cpp ppu/*
obj/bppu.$(obj): ppu/bppu/bppu.cpp ppu/bppu/*

############
### snes ###
############

obj/snes.$(obj): snes/snes.cpp snes/* snes/scheduler/* snes/video/* snes/audio/* snes/input/*

#####################
### special chips ###
#####################

obj/bsx.$(obj)    : chip/bsx/bsx.cpp chip/bsx/*
obj/srtc.$(obj)   : chip/srtc/srtc.cpp chip/srtc/*
obj/sdd1.$(obj)   : chip/sdd1/sdd1.cpp chip/sdd1/*
obj/spc7110.$(obj): chip/spc7110/spc7110.cpp chip/spc7110/*
obj/cx4.$(obj)    : chip/cx4/cx4.cpp chip/cx4/*
obj/dsp1.$(obj)   : chip/dsp1/dsp1.cpp chip/dsp1/*
obj/dsp2.$(obj)   : chip/dsp2/dsp2.cpp chip/dsp2/*
obj/dsp3.$(obj)   : chip/dsp3/dsp3.cpp chip/dsp3/*
obj/dsp4.$(obj)   : chip/dsp4/dsp4.cpp chip/dsp4/*
obj/obc1.$(obj)   : chip/obc1/obc1.cpp chip/obc1/*
obj/st010.$(obj)  : chip/st010/st010.cpp chip/st010/*

############
### zlib ###
############

obj/adler32.$(obj) : reader/zlib/adler32.c reader/zlib/*
obj/compress.$(obj): reader/zlib/compress.c reader/zlib/*
obj/crc32.$(obj)   : reader/zlib/crc32.c reader/zlib/*
obj/deflate.$(obj) : reader/zlib/deflate.c reader/zlib/*
obj/gzio.$(obj)    : reader/zlib/gzio.c reader/zlib/*
obj/inffast.$(obj) : reader/zlib/inffast.c reader/zlib/*
obj/inflate.$(obj) : reader/zlib/inflate.c reader/zlib/*
obj/inftrees.$(obj): reader/zlib/inftrees.c reader/zlib/*
obj/ioapi.$(obj)   : reader/zlib/ioapi.c reader/zlib/*
obj/trees.$(obj)   : reader/zlib/trees.c reader/zlib/*
obj/unzip.$(obj)   : reader/zlib/unzip.c reader/zlib/*
obj/zip.$(obj)     : reader/zlib/zip.c reader/zlib/*
obj/zutil.$(obj)   : reader/zlib/zutil.c reader/zlib/*

###########
### jma ###
###########

obj/jma.$(obj)    : reader/jma/jma.cpp reader/jma/*
obj/jcrc32.$(obj) : reader/jma/jcrc32.cpp reader/jma/*
obj/lzmadec.$(obj): reader/jma/lzmadec.cpp reader/jma/*
obj/7zlzma.$(obj) : reader/jma/7zlzma.cpp reader/jma/*
obj/iiostrm.$(obj): reader/jma/iiostrm.cpp reader/jma/*
obj/inbyte.$(obj) : reader/jma/inbyte.cpp reader/jma/*
obj/lzma.$(obj)   : reader/jma/lzma.cpp reader/jma/*
obj/winout.$(obj) : reader/jma/winout.cpp reader/jma/*

###############
### targets ###
###############

build: $(objects)
        $(strip $(cpp) $(call mkbin,../bsnes) $(objects) $(link))

install:
        install -D -m 755 ../bsnes $(DESTDIR)$(prefix)/bin/bsnes
        install -D -m 644 data/bsnes.png $(DESTDIR)$(prefix)/share/icons/bsnes.png

clean:
        -@$(call delete,obj/*.$(obj))
        -@$(call delete,*.res)
        -@$(call delete,*.pgd)
        -@$(call delete,*.pgc)
        -@$(call delete,*.ilk)
        -@$(call delete,*.pdb)
        -@$(call delete,*.manifest)

help:
        @echo "Usage: $(MAKE) platform=(os) compiler=(cc) sound=(no) [options]"
        @echo ""
        @echo "Supported platforms:"
        @echo "  x   - Linux / BSD (x86, x86-64)"
        @echo "  win - Windows (x86, x86-64)"
        @echo ""
        @echo "Supported compilers:"
        @echo "  gcc              - GCC compiler"
        @echo "  mingw32-gcc      - MinGW compiler"
        @echo "  i586-mingw32-gcc - MinGW cross compiler"
        @echo "  cl               - Visual C++"
        @echo ""
        @echo "Sound output"
        @echo "  yes              - Enable sound output"
        @echo "  no               - Disable sound output (default)"
        @echo ""
        @echo "Available options:"
        @echo "  enable_gzip=[true|false] - Enable ZIP / GZ support (default=false)"
        @echo "  enable_jma=[true|false]  - Enable JMA support (default=false)"
        @echo ""
        @echo "Example: $(MAKE) platform=x compiler=gcc sound=yes enable_gzip=true"
        @echo ""
WIth this modification, sound output is disabled by default and need to be enabled with parameter sound=yes.

I am now working on sound.

I also have a little question : Should it work on UltraSparc OpenSolaris ?

Regards.
--
Eric
ephaestos
New Member
Posts: 4
Joined: Mon Aug 18, 2008 9:42 pm

Post by ephaestos »

Version .035 still behave greatly and sound is working !!

I tried the following audio drivers :
  • ¤ Openal, using Blastwave package
    ¤ OSS, using OSS Solaris package
    ¤ ao, build from latest sources
OSS gives the best result by far : I didn't manage to have sound output using openal and ao is very slow and introduce a very noticable delay. Here is ossinfo output :

Code: Select all

edechaux@tecra:~/Desktop/bsnes/src$ ossinfo 
Version info: OSS 4.0 (b1016/200806171344) (0x00040003) 
Platform: SunOS/i86pc 5.11 snv_95 (tecra)

Number of audio devices:	11
Number of audio engines:	15
Number of mixer devices:	1


Device objects
 0: hdaudio0 Intel HD Audio interrupts=678454 (678454)
    HD Audio controller Intel HD Audio
    Vendor ID    0x8086284b
    Subvendor ID 0x11790001
     Codec  0: ALC262 (0x10ec0262/0x11790584)
     Codec  1: Unknown (0x11c11040)
 1: osscore0 OSS common devices
 2: ossusb0 USB audio/MIDI device
 3: sadasupport0 SADA compatibility layer


Mixer devices
 0: High Definition Audio ALC262 (Mixer 0 of device object 0)

Audio devices
HD Audio play speaker             /dev/oss/hdaudio0/pcm0  (device index 0)
HD Audio play headphone           /dev/oss/hdaudio0/pcm1  (device index 1)
HD Audio play pcm                 /dev/oss/hdaudio0/pcm2  (device index 2)
HD Audio play pcm                 /dev/oss/hdaudio0/pcm3  (device index 3)
HD Audio play pcm                 /dev/oss/hdaudio0/pcm4  (device index 4)
HD Audio play pcm                 /dev/oss/hdaudio0/pcm5  (device index 5)
HD Audio play pcm                 /dev/oss/hdaudio0/pcm6  (device index 6)
HD Audio play pcm                 /dev/oss/hdaudio0/pcm7  (device index 7)
HD Audio rec mix                  /dev/oss/hdaudio0/pcmin0  (device index 8)
HD Audio rec mix                  /dev/oss/hdaudio0/pcmin1  (device index 9)
HD Audio rec mix                  /dev/oss/hdaudio0/pcmin2  (device index 10)

As before I had to disable some audio drivers. Here is the makefile diff :

Code: Select all

edechaux@tecra:~/Desktop/bsnes$ diff dist/Makefile src/Makefile 
37c37
<   ruby = video.glx video.xv video.sdl audio.openal audio.oss audio.alsa audio.ao input.sdl input.x
---
>   ruby = video.glx video.xv video.sdl audio.oss input.sdl input.x

Now the only thing that don't work is the joypad : My sinderwinder gamepad USB is seen by the OS but I can't configure anything on it.

Code: Select all

Aug 22 22:57:45 tecra usba: [ID 912658 kern.info] USB 2.0 device (usb45e,7) operating at low speed (USB 1.x) on USB 1.10 root hub: input@1, hid2 at bus address 2
Aug 22 22:57:45 tecra usba: [ID 349649 kern.info] 	Microsoft\256  SideWinder\256 Game Pad USB
Aug 22 22:57:45 tecra genunix: [ID 936769 kern.info] hid2 is /pci@0,0/pci1179,1@1a/input@1
Aug 22 22:57:45 tecra genunix: [ID 408114 kern.info] /pci@0,0/pci1179,1@1a/input@1 (hid2) online
No error is shown anywhere regarding this. Work in progress :)


So, except for the gamepad, bsnes works good on opensolaris. I would not have bet on this !

Regards
--
Eric
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

byuu wrote:Hi, very neat! So OpenSolaris lacks OSS and OpenAL by default? How about libao? If all three, I have to ask ... what sound system does it use by default?
Solaris historically used an OSS like API. Recent versions of Solaris all ship OSS (and the OSS like API as well, which is now deprecated). libao is also available, but not supplied by default, although nothing stops you from installing it.

There's multiple flavors of OpenSolaris, what they have built in is anyone's guess, but OSS and libao should both be installable.

For obvious reasons, ALSA is not available or installable. I heard OpenAL on Solaris is still in its infancy, so I'm not sure what's with that.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Locked