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