Find out OS version in configure script

2009-04-29 Thread Cornelius Hald
Hi,

I´m wondering what is the recomended way to find out the OS version in my 
configure script?
Do I have to check for library availability and then make a guess or is there 
some test program that I can call or some file with the version name?

I´m trying to build my app using Chinook, Diablo and Fremantle. Therefore I 
need to introduce some #ifdef statements...

Thanks!
Conny

___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: Find out OS version in configure script

2009-04-29 Thread Fred
Cornelius Hald a écrit :
 Hi,
 
 I´m wondering what is the recomended way to find out the OS version in my 
 configure script?
 Do I have to check for library availability and then make a guess or is there 
 some test program that I can call or some file with the version name?
 
 I´m trying to build my app using Chinook, Diablo and Fremantle. Therefore I 
 need to introduce some #ifdef statements...
 
 Thanks!
 Conny
 
 ___
 maemo-developers mailing list
 maemo-developers@maemo.org
 https://lists.maemo.org/mailman/listinfo/maemo-developers


Hi,

I would be also interested to know how I can find out in the postinst 
script if I'm in Fremantle as maemo-select-menu-location is not 
available anymore ...

I suppose I could test for the presence of maemo-select-menu-location ...

Fred
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: Find out OS version in configure script

2009-04-29 Thread Graham Cobb
On Wednesday 29 April 2009 11:02:52 Cornelius Hald wrote:
 I´m wondering what is the recomended way to find out the OS version in my
 configure script? Do I have to check for library availability and then make
 a guess or is there some test program that I can call or some file with the
 version name?

The recommended (at least by me) way is to not use OS **names** at all -- 
names are unreliable (what would your code had done when Diablo was 
introduced if it had been relying on the name Chinook).  The standard way to 
address these sorts of issues in configure scripts is not to try to work out 
the name or version but to look for features you need.

As an example, here is how most of my GPE configure.ac scripts handle this 
today (not yet including Freemantle):

ENABLE_HILDON=false
AC_ARG_ENABLE(hildon,
[  --enable-hildon Enable Hildon GUI],
[
ENABLE_HILDON=true
PKG_CHECK_MODULES(HILDON, hildon-1,
[
AC_DEFINE(HILDON_VER, 2, [Version of hildon libraries])
DEP_MODULES=$DEP_MODULES hildon-fm-2
],
[
AC_DEFINE(HILDON_VER, 0, [Version of hildon 
libraries])
PKG_CHECK_MODULES(HILDON, hildon-lgpl hildon-libs)
DEP_MODULES=$DEP_MODULES hildon-fm
])
DEP_MODULES=$DEP_MODULES libosso
],
[
ENABLE_HILDON=false
])
AC_SUBST(ENABLE_HILDON)
AM_CONDITIONAL(HILDON, test x$ENABLE_HILDON = xtrue)
...
PKG_CHECK_MODULES(DEPS, $DEP_MODULES)


I then use HILDON, HILDON_CFLAGS, HILDON_LIBS, DEPS_CFLAGS and DEPS_LIBS in my 
Makefile.am, for example in lines like:

if HILDON
DEPS_CFLAGS += -DIS_HILDON
endif
...
INCLUDES = $(DEPS_CFLAGS) $(HILDON_CFLAGS) \
  $(SERVERDEPS_CFLAGS) -I$(top_srcdir)/gpe -I$(top_srcdir) \
   -DPREFIX=\@pre...@\ -D_GNU_SOURCE -Wall \
   -DPACKAGE_LOCALE_DIR=\@gpecalendar_locale...@\ \
   -DDBUS_API_SUBJECT_TO_CHANGE
...
gpe_calendar_LDADD = $(DEPS_LIBS) $(HILDON_LIBS) libwidgets.la
...

The .c files make use of the IS_HILDON and the HILDON_VER macros to 
conditionalise code.

I can send you full versions of these files by email if you want, or just 
check out the source package for something like gpe-calendar (where these 
examples came from).

Graham
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: Find out OS version in configure script

2009-04-29 Thread Cornelius Hald
Hi Graham,

On Wed, 2009-04-29 at 13:10 +0100, Graham Cobb wrote:
 On Wednesday 29 April 2009 11:02:52 Cornelius Hald wrote:
  I´m wondering what is the recomended way to find out the OS version in my
  configure script? Do I have to check for library availability and then make
  a guess or is there some test program that I can call or some file with the
  version name?
 
 The recommended (at least by me) way is to not use OS **names** at all -- 
 names are unreliable (what would your code had done when Diablo was 
 introduced if it had been relying on the name Chinook).  The standard way to 
 address these sorts of issues in configure scripts is not to try to work out 
 the name or version but to look for features you need.

thanks for the information. ATM I only need to know if the new app menu
API is available. So I think I'll just check whether the function
hildon_app_menu_new() is available or not. I'll also have a look at the
sources of your GPE programs.

Thanks again!
Conny


___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: Find out OS version in configure script

2009-04-29 Thread Till Harbaum / Lists
Hi,

that's imho what maemo-version is there for. I use it this way:

  PKG_CHECK_EXISTS(maemo-version, [
VERSION=`pkg-config --modversion maemo-version`
AC_MSG_NOTICE([Configuring for Maemo $VERSION])
CFLAGS=$CFLAGS -DMAEMO_VERSION=\\\$VERSION\\\
MAJOR=`echo $VERSION | cut -b1 -`
CFLAGS=$CFLAGS -DMAEMO_VERSION_MAJOR=$MAJOR
  ], [
AC_MSG_ERROR([maemo-version not found])
  ])

And in my program i can then do things like

#if MAEMO_VERSION_MAJOR == 5
  do_something();
#endif

Till


Am Mittwoch 29 April 2009 schrieb Cornelius Hald:
 Hi,
 
 I´m wondering what is the recomended way to find out the OS version in my 
 configure script?
 Do I have to check for library availability and then make a guess or is there 
 some test program that I can call or some file with the version name?
 
 I´m trying to build my app using Chinook, Diablo and Fremantle. Therefore I 
 need to introduce some #ifdef statements...
 
 Thanks!
 Conny
 
 ___
 maemo-developers mailing list
 maemo-developers@maemo.org
 https://lists.maemo.org/mailman/listinfo/maemo-developers
 


___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: Find out OS version in configure script

2009-04-29 Thread Cornelius Hald
Hi Till,

 that's imho what maemo-version is there for. I use it this way:
 
   PKG_CHECK_EXISTS(maemo-version, [
 VERSION=`pkg-config --modversion maemo-version`
 AC_MSG_NOTICE([Configuring for Maemo $VERSION])
 CFLAGS=$CFLAGS -DMAEMO_VERSION=\\\$VERSION\\\
 MAJOR=`echo $VERSION | cut -b1 -`
 CFLAGS=$CFLAGS -DMAEMO_VERSION_MAJOR=$MAJOR
   ], [
 AC_MSG_ERROR([maemo-version not found])
   ])
 
 And in my program i can then do things like
 
 #if MAEMO_VERSION_MAJOR == 5
   do_something();
 #endif

this is what I was looking for. I didn't know that a package called
maemo-version exists. Thanks a lot for the information :)

Just for reference, this is the solution with which I came up:

PKG_CHECK_EXISTS([hildon-1 = 2.1.62], [AC_DEFINE([HILDON_HAS_APP_MENU],
[1], [Does hildon app menu exist])])

Cheers!
Conny


___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers