Hi Andrew,

thanks for your tests and further tunings of my celestia.pro 'install target'. I liked your various additions, notably 
CONFIG_DATA_DIR  and the forgotten touch config.h. etc. In my original celestia.pro I had included the scripts directory but had forgotten to add it to the INSTALLS list, which I have corrected now, since you also had overlooked it.

Your merging of Pat's pkgconfig mechanism with my respective loop code allows to potentially add-in more than 2 syntax variations for the lua.pc file or further constraints as I mentioned earlier.

After testing things again, I committed celestia.pro and my qtappwin.cpp patch, since it seems easier to proceed from where we stand by now...I gave credit to Andrew's and Pat's contributions.

Regards,
Fridger

PS: For some reason I am forced (since some openSuSE updates) to add -lGLU to the standard link line
LIBS += -ljpeg /usr/local/cspice/lib/cspice.a
in celestia.pro, to avoid a respective link error.

Anyone having an idea what might have been going on there?

On 04/01/2012 04:11 PM, Andrew Tribick wrote:
Hello,

Sorry I haven't got round to testing this before now.

The way that automake is doing it is with defining CONFIG_DATA_DIR during compilation. I also prefer the use of the sh script to generated the .desktop file as it provides some level of protection against people deciding to change PREFIX.

The attached diff file incorporates the following:
The celestia.desktop.sh file goes in src/celestia/qt/data. I've been building this using your change to qtappwin.cpp.

Andrew

On 28 March 2012 17:55, Fridger Schrempp <fridger.schrempp@desy.de> wrote:
> Andrew,
>
> after our long qmake versus cmake dispute, I took up the challenge and wrote
> a prototype LINUX install target for celestia.pro and qmake. It works well
> and fast and the code is compact and self-explanatory due to qmake's
> object-based syntax. Let me add here already that many more install-related
> features are announced by Nokia for Qt 3.0.
>
> The coding only took about 30 minutes and this half page is all there is.
> Note that the following code is just added at the end of a /standard/
> celestia.pro from SVN
>
> unix {
>
>     #VARIABLES
>    
>     isEmpty(PREFIX) { PREFIX = /usr/local}
>        
>     BINDIR = $$PREFIX/bin
>     DATADIR =$$PREFIX/share
>     WORKDIR =$$DATADIR/$${TARGET}
>          
>     #MAKE INSTALL
>
>     target.path =$$BINDIR
>    
>     data.path   = $$WORKDIR/data
>     data.files  = $$CATALOG_SOURCE/*
>     flares.path     = $$WORKDIR/textures
>     flares.files   += ../textures/*.jpg ../textures/*.png
>     textures.path   = $$WORKDIR/textures/medres
>     textures.files += $$TEXTURE_SOURCE/*.jpg $$TEXTURE_SOURCE/*.png
>     lores_textures.path  =  $$WORKDIR/textures/lores
>     lores_textures.files += $$LORES_TEXTURE_SOURCE/*.jpg \
>                             $$LORES_TEXTURE_SOURCE/*.png
>     hires_textures.path  =  $$WORKDIR/textures/hires
>     hires_textures.files =  $$HIRES_TEXTURE_SOURCE/*.jpg
>     models.path    = $$WORKDIR/models
>     models.files  += $$MODEL_SOURCE/*.cmod $$MODEL_SOURCE/*.png
>     shaders.path   = $$WORKDIR/shaders
>     shaders.files += $$SHADER_SOURCE/*.vp $$SHADER_SOURCE/*.fp
>     fonts.path     = $$WORKDIR/fonts
>     fonts.files    = $$FONT_SOURCE/*.txf
>     scripts.path   = $$WORKDIR/scripts
>     scripts.files  = ../scripts/*.celx
>     configuration.path = $$WORKDIR
>     configuration.files += $$CONFIGURATION_FILES \
>                            $$CONFIGURATION_SOURCE/guide.cel \
>                            $$CONFIGURATION_SOURCE/demo.cel \
>                            $$CONFIGURATION_SOURCE/controls.txt \
>                            $$CONFIGURATION_SOURCE/COPYING \
>                            $$CONFIGURATION_SOURCE/README \
>                            $$CONFIGURATION_SOURCE/ChangeLog \
>                            $$CONFIGURATION_SOURCE/AUTHORS
>    
>     locale.path = $$WORKDIR/locale
>     locale.files = ../locale/*
>    
>     extras.path = $$WORKDIR/extras
>     extras.files = ../extras/*
>     extras-standard.path = $$WORKDIR/extras-standard
>     extras-standard.files = ../extras-standard/*
>    
>     desktop.path = /usr/share/applications
>     desktop.files += ../src/$${TARGET}.desktop
>
>     icon128.path = /usr/share/icons/hicolor/128x128/apps
>     icon128.files += ../src/celestia/qt/data/celestia.png
>    
>     INSTALLS += target data textures lores_textures hires_textures \
>     flares models shaders fonts locale extras extras-standard configuration
> \
>     desktop icon128
>    
>    }
>
>
>
> The complete celestia.pro is attached. To avoid misunderstandings, here are
> the required steps in short:
>
> 1) use a fresh celestia checkout from SVN and cd to celestia's root dir.
> Replace the celestia.pro file in src/.     Create a dir named 'build' and cd
> to build/. There, type
>
> 2) > qmake -config release ../src/celestia.pro
>      
> Using my new install code, qmake now generates a 'make install' target in
> the resulting Makefile. Next type
>
> 3)  > make
>      > sudo make install          
>
> I have not chosen a particular Linux distro here, but I rather wanted to
> remain /generic/ for now. So I took as BINDIR for the celestia-qt4
> executable /usr/local/bin and correspondingly as working directory
> /usr/local/share/$${TARGET}. Note: the target name of celestia-qt4 prevents
> accidental overwriting ;-).
> Note also that the *.desktop file name and content is different from yours.
> Also the icons directory is chosen as /usr/share/icons/hicolor/128x128/apps.
> All these assignments can be trivially modified in celestia.pro.
>
> The working directory, requires some further explanations. 
>
> By default, in Qt,
>
> working directory = ./    (i.e $PWD)
>
> Hence it takes an environment variable CELESTIA_DATA_DIR to point to another
> one, e.g. /usr/local/share/$${TARGET}. In src/celestia/qt/qtappwin.cpp there
> was a respective bug. While CELESTIA_DATA_DIR is indeed queried from the
> environment, the code in qtappwin.cpp throws an  error message unless
> CELESTIA_DATA_DIR is the empty string!
>
> If it is the empty string, then it is replaced by $PWD (=> "./"). This
> corresponds to the above default assignment. However, if  CELESTIA_DATA_DIR
> is to be NON-empty, an error is thrown! Hence the whole env mechanism didn't
> work. I have attached a simple patch that should be included for  testing.
>
> If celestia is started in a terminal or Qt Creator, the working directory
> actually read by the code is always printed upon startup. This cout<<  debug
> statement will of course be deleted later. Before starting the installed
> celestia-qt4, you need to type (once) in the terminal (or lateron into the
> profile...)
>
>> export CELESTIA_DATA_DIR=/usr/local/share/celestia-qt4
>
> Then start celestia-qt4. You may also type 'export CELESTIA_DATA_DIR='
> whence an error occurs at startup since the executable ceases to find the
> data directory now.
>
> Perhaps anyone knows another method to communicate the data directory.
> Please let me know.
>
> Finally, concerning the uninstall target:
>
> Andrew, you complained that upon uninstalling some system dir was not
> removed since it (fortunately) happened to be non-empty. Well as you know
> there are two UNIX ways of removing directories:
>
> 1) rm -r <dir>
> 2) rmdir <dir>
>
> The first one always removes <dir>, while rmdir that is used in qmake NEVER
> removes non-empty dirs.
> So there is no danger whatsoever.  Perhaps we come across a better way these
> days, but after many careful tests, I am convinced that 'sudo make
> uninstall' is perfectly safe!
>
> In summary, there are a few aspects left for polishing, but things appear to
> work and the required coding is very simple and transparent. As announced by
> Nokia, there is more to come with Qt 3.x.
>
> Fridger
>
>