Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Saner unix install  (Read 5136 times)

0 Members and 1 Guest are viewing this topic.

reduz

  • Newbie
  • *
  • Posts: 12
    • View Profile
Saner unix install
« on: September 20, 2008, 06:13:34 pm »
Hi! This is a request for a saner unix install,
Is there any hope of autotools , dependency detection, pkg-config support, debian friendly building, etc? Also any hopes of pestering distro mantainers to package it?

Because otherwise distributing something for unix using SFML is pretty difficult..

reduz

  • Newbie
  • *
  • Posts: 12
    • View Profile
Also
« Reply #1 on: September 20, 2008, 06:49:37 pm »
adding to that, the build system and sources for some reason seem to be linux only, so compilig under bsd or opensolaris didn't work for me.

christoph

  • Full Member
  • ***
  • Posts: 102
    • View Profile
    • http://www.christoph-egger.org
Saner unix install
« Reply #2 on: September 20, 2008, 10:36:28 pm »
Why build on debian? You can install the packages debian ships. libsfml is available in lenny or newer ;)

EDIT://
Concering *BSD -- I would be interested, too and in fact am considering to do some work on it

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Saner unix install
« Reply #3 on: September 21, 2008, 11:23:55 am »
Hi

I'm not a huge fan of autotools etc. It just makes things much more complicated, especially on Windows when you don't want to use cygwin. Many Windows users (including me) just give up compiling a library when you can't just open the source files and compile them.
While everything can be done with makefile and preprocessor, I really don't want to use such tools.

Besides, I'm not a Linux user and my point of view is definitely biased ;)
So, the question is : what would be the benefits of using autotools (except that it will scare Windows users and make me unable to maintain the Linux build) ? Do the Debian packages use anything else than the provided makefiles ?

Quote
adding to that, the build system and sources for some reason seem to be linux only, so compilig under bsd or opensolaris didn't work for me.

I'd like to know which errors you got, I really don't know what in SFML is specific to Linux.
Laurent Gomila - SFML developer

reduz

  • Newbie
  • *
  • Posts: 12
    • View Profile
Saner unix install
« Reply #4 on: September 21, 2008, 05:52:47 pm »
Quote from: "Laurent"


Besides, I'm not a Linux user and my point of view is definitely biased ;)
So, the question is : what would be the benefits of using autotools (except that it will scare Windows users and make me unable to maintain the Linux build) ? Do the Debian packages use anything else than the provided makefiles ?


Currently, the debian packaging is there, but it's not very usable to developers because it has no way to inform them where SFML is located.
So, let me give you a brief on what i believe should be the correct way to distribute SFML for unix systems.

Originally, the only "correct" way to distribute a package was using autotools.  As you know, libraries and includes in unix systems can be installed anywhere, like /usr/include /usr/local/include , /opt/pkg/include/ or even the bizarrre locations in OSX. This proved to be a mess when distributing a library because whoever was going to use it had to know where your favorite unix installed it.

Because of this, autotools introduced a system where your library provided "Scripts" written in a strange mixture of M4/sh that, when running autoconf would include them into the configure phase.  This way, scripts would detect where the library is.
This system was in place for more than a decade or two. it "worked" but sice autotools is a mess, a lot of projects either had no choice or didn't use it and wrote their own library detection code (checking common install paths or forcing the user to tell where libraries were installed). Until a few years ago, this was the only choice.

Fortunately, and now backed by the freedesktop people, an extremely handy tool called pkg-config was developed. pkg-config is very simple script where you can query information about your app, given it's unique unix name.  

http://pkg-config.freedesktop.org/wiki/

So, transforming sfml to use pkg-config shoudl be easy and straightforward.
You can keep using makefiles if you like, just the way you are now, or move to something more advanced such as scons, but the procedure is the same.

1) Check for the existence of pkg-config. pkg-config should be available in the path normally when invoked, if not, fail.

2) Check for the existence of every dependence using pkg-config. All sfml dependencies are already in pkg-config database, so just run similar to:

pkg-config openal --exists
pkg-config openal --atleast-version=0.0.5
(or a version you know it's compatible)

and check the program exit status value for 0 , if not 0 then it means openal is either not installed, or not the version needed by sfml, so fail compilation.

then, you must request pkg-config the compiler and linker flags to use the library with

pkg-config openal --cflags
pkg-config openal --libs

and add them to our CXXFLAGS / LIBS in the makefile.

So, finally, when you are done compiling and you are asked to "make install", you must generate and install (besides includes and libs) an "sfml.pc" file in $(PREFIX)/lib/pkgconfig that will inform applications compiling against SFML where the library is located and how to compile against it. It's simple!

Right now the debian install doesn't include pkg-config info, so it's pretty useless even if debianized.

Also, another feature of pkg-config is that it helps you when you want to upgrade your library and break api compatibility. Imagine you want to make SFML 2.0 . just make pkg-config provide a "sfml2" package, and include /usr/include/SFML2 and link against libsfml-audio2.so for example.

About build system, if you want to use something more complex than makefiles (but not nearly as messy as autotools) , that will also run under windows/mac using native compilers i'd recommend you to take look at:

scons (a python framework, the most advanced build system and used by most complex projects today)
cmake (a metabuild system that generates makefiles)
omake (a build system a bit similar to scons based on make syntax)

Well, hope any of this is of use.

Cheers!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Saner unix install
« Reply #5 on: September 21, 2008, 08:03:46 pm »
Thanks for the big explanation :)

I won't do it myself because my Linux skills are too bad, but I'll welcome anyone wanting to do it, if :
- It has no impact on the part I'm maintaining (makefiles)
- It can be maintained easily, and I won't be in troubles if the maintainer disappears one day

Regarding the build system, I was previously using CMake but I prefer maintaining each IDE / compiler project files. It involves more work but I have more control on them. Again, I think it's more a matter of keeping the Windows part simple / clean, and not scary / ugly.
Laurent Gomila - SFML developer

Kingdom of Fish

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Saner unix install
« Reply #6 on: December 28, 2008, 09:40:50 am »
Well, I have a small suggestion for how  to have pkg-config support for the c++ version (this patch also includes a small fix for the samples to compile on my machine too):

Code: [Select]

Index: src/SFML/Makefile
===================================================================
--- src/SFML/Makefile (revision 964)
+++ src/SFML/Makefile (working copy)
@@ -30,6 +30,7 @@
 export DESTDIR    = /usr
 export DESTLIBDIR = $(DESTDIR)/lib
 export DESTINCDIR = $(DESTDIR)/include
+export PKGDIR     = $(DESTLIBDIR)/pkgconfig
 
 all: sfml-system sfml-window sfml-network sfml-graphics sfml-audio
 
@@ -59,4 +60,5 @@
 install:
  @(mkdir -p $(DESTLIBDIR))
  @(mkdir -p $(DESTINCDIR))
+ @($(CP) sfml.pc $(PKGDIR)/ && $(CP) sfml-network.pc $(PKGDIR)/ && $(CP) sfml-audio.pc $(PKGDIR)/)
  @(cd ./System && $(MAKE) $@ && cd ../Window && $(MAKE) $@ && cd ../Network && $(MAKE) $@ && cd ../Graphics && $(MAKE) $@ && cd ../Audio && $(MAKE) $@ && $(CP) -r ../../../include/SFML/ $(DESTINCDIR)/)
Index: samples/sockets/Sockets.cpp
===================================================================
--- samples/sockets/Sockets.cpp (revision 964)
+++ samples/sockets/Sockets.cpp (working copy)
@@ -6,6 +6,12 @@
 
 
 ////////////////////////////////////////////////////////////
+// Definitions
+////////////////////////////////////////////////////////////
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+
+
+////////////////////////////////////////////////////////////
 // Function prototypes
 // (I'm too lazy to put them into separate headers...)
 ////////////////////////////////////////////////////////////
Index: samples/voip/VoIP.cpp
===================================================================
--- samples/voip/VoIP.cpp (revision 964)
+++ samples/voip/VoIP.cpp (working copy)
@@ -1,4 +1,3 @@
-
 ////////////////////////////////////////////////////////////
 // Headers
 ////////////////////////////////////////////////////////////
@@ -6,6 +5,18 @@
 #include <iostream>
 
 
+////////////////////////////////////////////////////////////
+// Definitions
+////////////////////////////////////////////////////////////
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+
+
 ////////////////////////////////////////////////////////////
 // Function prototypes
 // (I'm too lazy to put them into separate headers...)


src/SFML/sfml.pc
Code: [Select]

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: SFML
Description: Simple and Fast Multimedia Library
Version: 1.4
Requires: gl
Libs: -L${libdir} -lsfml-graphics -lsfml-system -lsfml-window -lGLU -lGL
Cflags: -I${includedir}


src/SFML/sfml-network.pc
Code: [Select]

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: SFML Network
Description: Simple and Fast Multimedia Library
Version: 1.4
Requires: sfml
Libs: -L${libdir} -lsfml-network
Cflags: -I${includedir}


src/SFML/sfml-audio.pc
Code: [Select]

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: SFML Audio
Description: Simple and Fast Multimedia Library
Version: 1.4
Requires: sfml
Libs: -L${libdir} -lsfml-audio
Cflags: -I${includedir}

 

anything