Code for MUON Station1 (I.Hrivnacova)
[u/mrichter/AliRoot.git] / share / alibtool
CommitLineData
50d05f91 1#!/bin/sh
2#############################################################################
3# alibtool - a shell script to help makeing modules for AliRoot Makefile
4#############################################################################
5#
6# modification history
7# $Log$
b9d0a01d 8# Revision 1.3.6.1 2002/07/09 12:24:49 alibrary
9# Corrections for new MC
10#
11# Revision 1.3 2002/02/22 07:57:35 alibrary
12# Reduce verbose output
13#
15142e2f 14# Revision 1.2 2001/11/14 17:52:48 hristov
15# Updated version of the flat makefiles (J.-E.Revsbech)
16#
d47d6108 17# Revision 1.1 2001/10/09 13:45:57 hristov
18# alibtool is added
19#
50d05f91 20#
21# SYNOPSIS
22# alirun <command> <commandparameters>
23#
24# command must be one of the following:
25#
26# mkmodule
27# depend
28# dependF
29#
30#
31# DESCRIPTION
32#
33# This scipts is called with a primary command and a commandparameter. It generates output on stdout, so normally it is called with a redirection like
34#
35# alibtool mkmoudle STEER > STEER/module.mk
36#
37# The command is one of the following
38#
39# depend
40# Makes the dependencies for the file specified as second argument (c and cxx files)
41#
42# dependF
43# Makes the dependencies for the file specified as second argument (fortran files)
44#
45# mkmoudle
46# Creates the module.mk for the the given directory specified as the second argument.
47#
48# MKMOUDLE
49#
50# When alibtool is called with the mkmodule command it searches the directory given as the second argument for files called *.pkg. If a file (possibly several) is found, it will create a file called module.mk based on these files. For example if running alibtool mkmodule STEER, it will search the STEER directory and create STEER/module.mk based on all .pkg files is STEER directory. If a file called libSTEER.pkg is found, then module.mk will have a section devoted to makeing library libSTEER.so with alle the sourcefiles specified in libSTEER.pkg. If a file called binSTEER.pkg is found the module.mk file will create an executable called STEER. Several *.pkg files can be placed in the same directory. The module.mk files is created on background of build/header.tpl and build/module.mk by variable substituion of variables @MODULE@ @PACKAGE@ and @TYPE@.
51#
52# PKG FILES
53#
54#
b9d0a01d 55# The syntax for the pkg file is very simple. You specify the sources, headers and possibly extra include or link options. The *.pkg files is just inserted "as is" in the module.mk file, so normal Makefile syntax can be used. These variables can be specified: SRCS, FSRCS, CSRCS, HDRS, CHDRS, DHDR, EINCLUDE, ELIBS, ELIBSDIR, PACKFFLAGS, PACKCFLAGS, PACKCXXFLAGS. The first five is just the c++ sources, fortran sources, c sources, c++ headers and c headers. DHDR is the dictionary header and is the LinkDef file. EINCLUDE, ELIBS and ELIBSDIR is extra includedirs, libraries and library search paths. If for example a binary is to be linked against the variable ELIBSDIR would be set to lib/tgt_$ALICE_TARGET. Notice that -L and -l is not needed. If the PACKFFLAGS, PACKCFLAGS or PACKCXXFLAGS is not set it will be set to the default options (Set in config/Makefile.$ALICE_TARGET. For example on Linux GEANT321 has to be compiled without -O options, so a line like PACKFFLAGS := $(filter-out -O%,$(FFLAGS)) is needed.
50d05f91 56#
57#
58# DEPEND
59#
60# If alibtool is called with the depend command it will generate a dependecy file for the sourcefile given as second argument. This only goes for c++ and c files. If dependencies for fortran-fiels is needed, call alibtool with command dependF. The dependencies is made with rmkdepend.
61#
62#
63# DEPENDF
64#
65# The same as depend, but for fortran files.
66#
67#C<
68###########################################################################
69
70
71MkDepend()
72{
73rmkdepend -f- -w 3000 -- -I$ROOTSYS/cint/include $* | sed -e "s@^\(.*\)\/\(.*\)\.o:@\1\/tgt_${ALICE_TARGET}\/\2.d \1\/tgt_${ALICE_TARGET}/\\2.o:@" -e 's@^#.*$@@' -e '/^$/d'
74}
75MkDependF()
76{
77rmkdepend -f- -Y -w 3000 -- $* | sed -e "s@^\(.*\)\/\(.*\)\.o:@\1\/tgt_${ALICE_TARGET}\/\2.d \1\/tgt_${ALICE_TARGET}/\\2.o:@" -e 's@^#.*$@@' -e '/^$/d'
78}
79
80MkModule()
81{
82module=$1
83#This one gets all the library pkg files
84tempo=`find ${module} -name "lib*.pkg" | sed -e "sQ${module}/libQQ" -e "sQ\.pkgQQ"`
85
86echo "#**************************************************************************";
87echo "#**** This file is automatically generated from the mkmodules script *****";
88echo "#**** DO NOT EDIT!! *****";
89echo "#**************************************************************************";
d47d6108 90
50d05f91 91for i in $tempo; do
92 package=$i;
93 type=lib;
94 MkModuleLib $package
95done;
96
97#This one gets all the binary(executable) pkg files
98tempo=`find ${module} -name "bin*.pkg" | sed -e "sQ${module}/binQQ" -e "sQ\.pkgQQ"`
99
100for i in $tempo; do
101 package=$i;
102 type=bin;
103 MkModuleLib $package
104done;
105
d47d6108 106#Now make general bottom for every module (Clean and so on)
107 cat build/clean.tpl | sed -e "sQ\@MODULE@Q${module}Qg"
50d05f91 108}
109
110MkModuleLib()
111{
112 file=$module/$type$i.pkg
113 cat build/header.tpl | sed -e "sQ\@MODULE@Q${module}Qg" -e "sQ@PACKAGE@Q${package}Qg" -e "sQ\@TYPE@Q${type}Qg"
114 echo;
115 cat $file;
116 echo;
117 cat build/module.tpl | sed -e "sQ\@MODULE@Q${module}Qg" -e "sQ@PACKAGE@Q${package}Qg" -e "sQ\@TYPE@Q${type}Qg"
118
119}
120
121case $1 in
122depend)
123 MkDepend $2
124 ;;
125dependF)
126 MkDependF $2
127 ;;
128mkmodule)
129 MkModule $2
130 ;;
131esac;
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149