LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2007, 01:34 PM   #1
c0uchm0nster
Member
 
Registered: Nov 2003
Distribution: debian
Posts: 62

Rep: Reputation: 15
Application file structure questions (setup and detection)


I'm working on a cross-platform game and everything's going well so far. The only issue I can't seem to figure out is about *nix distributed file structure (aka every file for a program isn't in the same parent directory).

I've been searching around a while on tldp and google for info/guides on this but I can't find anything more than a generic description of what the folders are for.

How do I a) Write a makefile that will install everything in the right places on multiple distros, and b) tell the exe where these "right places" are?

Thanks.
 
Old 09-23-2007, 03:11 PM   #2
jdiggitydogg
Member
 
Registered: Sep 2007
Posts: 42

Rep: Reputation: 15
there are similarities between many *nixs. i'm sure you've searched the internet and found resources such as this...but posting it up anyway.

http://www.pathname.com/fhs/pub/fhs-2.3.html
http://en.wikipedia.org/wiki/Filesys...archy_Standard
 
Old 09-24-2007, 01:00 PM   #3
c0uchm0nster
Member
 
Registered: Nov 2003
Distribution: debian
Posts: 62

Original Poster
Rep: Reputation: 15
thanks for the reply/links.

I'm aware of the standard system file structure, but aren't there ways to ask the system where it wants certain things? I mean what if a user installs the program for him/herself versus a system-wide install?

thanks
 
Old 09-24-2007, 02:20 PM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Quote:
Originally Posted by c0uchm0nster View Post
thanks for the reply/links.

I'm aware of the standard system file structure, but aren't there ways to ask the system where it wants certain things?
Nope. You have to follow the conventions for a given platform. Typically in your build system you define a PREFIX variable, which usually defaults to /usr/local. Other variables are defined as sub-directories on top of PREFIX, e.g. BINDIR=$PREFIX/bin; DATADIR=$PREFIX/share/$PACKAGENAME and so on.

With this sort of method, it means a lot of programs have to be re-built if the PREFIX changes, although some are written in a way which uses the PREFIX as a default, and maybe looks in an environment variable for other places to check if files were not found in the PREFIX/... location. An example of this is KDE, which checks for the KDEDIRS environment variable at run time and checks this in addition to the compiled-in PREFIX default.

Quote:
Originally Posted by c0uchm0nster View Post
I mean what if a user installs the program for him/herself versus a system-wide install?
If the user is building from source, and the source is built using the GNU autotools method (automake, autoconf and friends), the PREFIX is specified using a standard method in build process, specifically using the --prefix option to the invocation of the configure script:

Code:
./configure --prefix=/opt/myapp --other-build-option
...and then to build the app and install it:
Code:
make
sudo make install
Other projects use other build methods, but most will provide some mechanism to do this.

For users who do not want to build their software themselves (I suppose this must be a lot of people), they must rely on pre-built packages. Then it is the choice of the packager what PREFIX to use. The choice will depend on some policy of the distribution. The FHS which jdiggitydogg linked to describes some reasons for putting things in the various prefixes. Quick and dirty rule of thumb:
  • /usr is used for packages in the core OS / distro
  • /usr/local for other packages
  • /opt/programname for optional and other packages, although strictly speaking these should be statically linked. In practise I tend to use /opt/programname when I'm mucking about with new s/w because it's easy to delete the s/w by removing the directory and all its contents.

Hope that helps,
Matthew.
 
Old 09-25-2007, 02:48 PM   #5
c0uchm0nster
Member
 
Registered: Nov 2003
Distribution: debian
Posts: 62

Original Poster
Rep: Reputation: 15
thanks, thats exactly what i was looking for.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
new hardware detection and setup ahz10 Ubuntu 5 03-18-2006 03:00 PM
Wine directory structure questions Rundi Linux - Software 2 01-03-2005 07:00 PM
newbie file structure questions wogga Linux - Hardware 2 06-08-2004 06:19 AM
3 Questions Regarding File Structure And Sftp aioss Linux - Software 1 10-25-2003 06:39 PM
File Structure Stephanie Linux - General 2 07-19-2001 04:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration