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