Makefile pour developpement multi-OS, multi-variants

crabs_makefile-5.2 ©2003-2008 - Christophe Cazajus (crabs-mettre_le_signe_at-crabs-world.com)

~~ / Prelative.c
Makefile include.LINUX include.SOLARIS include.CGI include.CGI_BIN include.XPI xpi_rdf.xsl Pdepend.c Pinfo.c PrelativeHome.c PrelativePath.c Pprojetgpl.c Prelative.c PinfoGPL.sh PgenInfo_c.sh PenvProjet.sh Pinfo2html.sh Pinstall.sh PgenInfo_include.sh projet.env crabs_mk.sh crabs_mk.csh fr/crabs_makefile.po Makefile.SOLARIS
    1 /*
    2 **=============================================================================
    3 ** crabs_makefile-5.2 : Makefile pour developpement multi-OS, multi-variants
    4 ** Copyright (C) 2003-2008 : Christophe Cazajus (crabs-mettre_le_signe_at-crabs-world.com)
    5 **
    6 ** Ce source fait partie d'un projet logiciel libre. Vous pouvez le distribuer
    7 ** et/ou le modifier en respectant les termes de la GNU General Public License
    8 ** version 2 ou (suite a votre propre choix) une version ulterieure.
    9 **
   10 ** Ce programme est distribue dans l'espoir qu'il puisse etre utile, mais
   11 ** sans aucune garantie, meme si il est associe a un produit qui vous en
   12 ** propose une. Conformez-vous a la GNU General Public License pour avoir
   13 ** plus de precisions.
   14 **
   15 ** L'auteur ne peut etre tenu responsable de l'utilisation faite des
   16 ** composantes associees a ce projet (en partie ou dans leur totalite).
   17 **
   18 ** Une copie du fichier de la GNU GPL est fournie dans le repertoire DOC
   19 ** de ce projet sous le nom gnu_gpl.txt
   20 **
   21 **=============================================================================
   22 */
   23 /*
   24 ** Prelative racine fichier
   25 **    donne le chemin permettant d'aller de "racine" a "fichier"
   26 */
   27 #include <locale.h>
   28 #include <libintl.h>
   29 #include <unistd.h>
   30 #include <stdio.h>
   31 #include <stdlib.h>
   32 #include <string.h>
   33 
   34 int main( int argc, char **argv )
   35     {
   36     char        root    [2048]  ;
   37     char        file    [2048]  ;
   38     char        resu    [2048]  ;
   39     char*       pt_r            ;
   40     char*       pt_f            ;
   41     char*       pt_rs           ;
   42     char*       pt_fs           ;
   43 
   44     setlocale( LC_ALL, "" ) ; textdomain( "libc" ) ;
   45     if ( getenv( "CRABS_LOCALE") )
   46         {
   47         bindtextdomain( "crabs_makefile", getenv( "CRABS_LOCALE" ) ) ;
   48         textdomain( "crabs_makefile" ) ;
   49         }
   50 
   51     if ( argc < 2 )
   52         {
   53         fprintf( stderr,
   54             gettext("%s root_path file_path : missing argument\n" ),
   55             *argv ) ;
   56         return 1 ;
   57         }
   58     realpath( argv[1], root ) ; realpath( argv[2], file ) ;
   59 
   60     /* tout ce qui est commun */
   61     for( pt_r=strtok_r(root,"/",&pt_rs), pt_f=strtok_r(file,"/",&pt_fs);
   62         pt_r && pt_f ;
   63         pt_r=strtok_r(0,"/",&pt_rs), pt_f=strtok_r(0,"/",&pt_fs) )
   64         if ( strcmp( pt_r, pt_f ) ) break ;
   65 
   66     if ( pt_r || pt_f )
   67         {
   68         strcpy( resu, "" ) ;
   69         if ( pt_r )
   70             {
   71             strcpy( resu, ".." ) ;
   72             while( pt_r=strtok_r(0,"/",&pt_rs) ) strcat( resu, "/.." ) ;
   73             }
   74         if ( pt_f )
   75             {
   76             // ici pt_r est null
   77             if ( *resu ) strcat( resu, "/" ) ;
   78             strcat( resu, pt_f ) ;
   79             while( pt_f=strtok_r(0,"/",&pt_fs) )
   80                 {
   81                 strcat( resu, "/" ) ;
   82                 strcat( resu, pt_f ) ;
   83                 }
   84             }
   85         }
   86     else
   87         strcpy( resu, "." ) ;
   88     puts( resu ) ;
   89     return 0;
   90     }
   91 
Makefile include.LINUX include.SOLARIS include.CGI include.CGI_BIN include.XPI xpi_rdf.xsl Pdepend.c Pinfo.c PrelativeHome.c PrelativePath.c Pprojetgpl.c Prelative.c PinfoGPL.sh PgenInfo_c.sh PenvProjet.sh Pinfo2html.sh Pinstall.sh PgenInfo_include.sh projet.env crabs_mk.sh crabs_mk.csh fr/crabs_makefile.po Makefile.SOLARIS
~~ / Prelative.c

Haut de page

Contacter crabs

Date de génération : 22/09/2011 21:47