50d05f91 |
1 | #!/bin/sh |
2 | ############################################################################# |
3 | # alibtool - a shell script to help makeing modules for AliRoot Makefile |
4 | ############################################################################# |
5 | # |
6 | # modification history |
7 | # $Log$ |
8 | # |
9 | # SYNOPSIS |
10 | # alirun <command> <commandparameters> |
11 | # |
12 | # command must be one of the following: |
13 | # |
14 | # mkmodule |
15 | # depend |
16 | # dependF |
17 | # |
18 | # |
19 | # DESCRIPTION |
20 | # |
21 | # 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 |
22 | # |
23 | # alibtool mkmoudle STEER > STEER/module.mk |
24 | # |
25 | # The command is one of the following |
26 | # |
27 | # depend |
28 | # Makes the dependencies for the file specified as second argument (c and cxx files) |
29 | # |
30 | # dependF |
31 | # Makes the dependencies for the file specified as second argument (fortran files) |
32 | # |
33 | # mkmoudle |
34 | # Creates the module.mk for the the given directory specified as the second argument. |
35 | # |
36 | # MKMOUDLE |
37 | # |
38 | # 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@. |
39 | # |
40 | # PKG FILES |
41 | # |
42 | # |
43 | # 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 $ALICE_ROOT/lib/tgt_$ALICE_TARGET/libminicern.so the variable ELIBSDIR would be set to lib/tgt_$ALICE_TARGET and ELIBS = minicern. 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. |
44 | # |
45 | # |
46 | # DEPEND |
47 | # |
48 | # 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. |
49 | # |
50 | # |
51 | # DEPENDF |
52 | # |
53 | # The same as depend, but for fortran files. |
54 | # |
55 | #C< |
56 | ########################################################################### |
57 | |
58 | |
59 | MkDepend() |
60 | { |
61 | rmkdepend -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' |
62 | } |
63 | MkDependF() |
64 | { |
65 | rmkdepend -f- -Y -w 3000 -- $* | sed -e "s@^\(.*\)\/\(.*\)\.o:@\1\/tgt_${ALICE_TARGET}\/\2.d \1\/tgt_${ALICE_TARGET}/\\2.o:@" -e 's@^#.*$@@' -e '/^$/d' |
66 | } |
67 | |
68 | MkModule() |
69 | { |
70 | module=$1 |
71 | #This one gets all the library pkg files |
72 | tempo=`find ${module} -name "lib*.pkg" | sed -e "sQ${module}/libQQ" -e "sQ\.pkgQQ"` |
73 | |
74 | echo "#**************************************************************************"; |
75 | echo "#**** This file is automatically generated from the mkmodules script *****"; |
76 | echo "#**** DO NOT EDIT!! *****"; |
77 | echo "#**************************************************************************"; |
78 | echo |
79 | for i in $tempo; do |
80 | package=$i; |
81 | type=lib; |
82 | MkModuleLib $package |
83 | done; |
84 | |
85 | #This one gets all the binary(executable) pkg files |
86 | tempo=`find ${module} -name "bin*.pkg" | sed -e "sQ${module}/binQQ" -e "sQ\.pkgQQ"` |
87 | |
88 | for i in $tempo; do |
89 | package=$i; |
90 | type=bin; |
91 | MkModuleLib $package |
92 | done; |
93 | |
94 | } |
95 | |
96 | MkModuleLib() |
97 | { |
98 | file=$module/$type$i.pkg |
99 | cat build/header.tpl | sed -e "sQ\@MODULE@Q${module}Qg" -e "sQ@PACKAGE@Q${package}Qg" -e "sQ\@TYPE@Q${type}Qg" |
100 | echo; |
101 | cat $file; |
102 | echo; |
103 | cat build/module.tpl | sed -e "sQ\@MODULE@Q${module}Qg" -e "sQ@PACKAGE@Q${package}Qg" -e "sQ\@TYPE@Q${type}Qg" |
104 | |
105 | } |
106 | |
107 | case $1 in |
108 | depend) |
109 | MkDepend $2 |
110 | ;; |
111 | dependF) |
112 | MkDependF $2 |
113 | ;; |
114 | mkmodule) |
115 | MkModule $2 |
116 | ;; |
117 | esac; |
118 | |
119 | |
120 | |
121 | |
122 | |
123 | |
124 | |
125 | |
126 | |
127 | |
128 | |
129 | |
130 | |
131 | |
132 | |
133 | |
134 | |
135 | |