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