1 | #!/usr/bin/perl |
---|
2 | # $Id: CreateNewLib.pl 1108 2004-09-28 08:17:29Z pallas $ |
---|
3 | # simple tool to create an empty library structure |
---|
4 | # A. Thea. |
---|
5 | # |
---|
6 | |
---|
7 | use Getopt::Std; |
---|
8 | getopt('nus'); |
---|
9 | |
---|
10 | use POSIX qw(strftime); |
---|
11 | $now_string = strftime "%b, %e %Y", gmtime; |
---|
12 | |
---|
13 | |
---|
14 | $shared = $opt_s; |
---|
15 | $libname = $opt_n; |
---|
16 | |
---|
17 | $libname or die "CreateLibClass: no name defined\n\t usage: CreateNewLib.pl -n name [-s standalone] [-u username]"; |
---|
18 | |
---|
19 | $uid = $<; |
---|
20 | $user = (getpwuid($uid))[6]; |
---|
21 | $user=~s/,.*$//; |
---|
22 | |
---|
23 | if ($opt_u) { |
---|
24 | $user = $opt_u; |
---|
25 | } |
---|
26 | |
---|
27 | $aa = $classname; |
---|
28 | $aa=~y/[a-z]/[A-Z]/; |
---|
29 | |
---|
30 | |
---|
31 | print "creating $libname directory\n"; |
---|
32 | mkdir($libname,0755); |
---|
33 | chdir($libname); |
---|
34 | |
---|
35 | print "creating include directory\n"; |
---|
36 | mkdir("include",0755); |
---|
37 | |
---|
38 | print "creating src directory\n"; |
---|
39 | mkdir("src",0755); |
---|
40 | |
---|
41 | print "creating GNUmakefile\n"; |
---|
42 | open(MK,">GNUmakefile"); |
---|
43 | |
---|
44 | if (!$shared) { |
---|
45 | print MK <<pippo; |
---|
46 | # GNUmakefile for $libname |
---|
47 | # \$Id\$ |
---|
48 | # Author: $user $now_string |
---|
49 | |
---|
50 | |
---|
51 | ############################################################################# |
---|
52 | # ESAF: Euso Simulation and Analysis Framework # |
---|
53 | # # |
---|
54 | # Id: $libname # |
---|
55 | # Package: <packagename> # |
---|
56 | # Coordinator: <coordinator> # |
---|
57 | # # |
---|
58 | ############################################################################# |
---|
59 | |
---|
60 | PACKAGENAME := $libname |
---|
61 | |
---|
62 | ifndef ESAFINSTALL |
---|
63 | ESAFINSTALL = ../../../..#FIXME: ESAFINSTALL relative path |
---|
64 | endif |
---|
65 | |
---|
66 | ESAFPACKAGES = \$(ESAFINSTALL)/packages |
---|
67 | |
---|
68 | # Config parameters |
---|
69 | include \$(ESAFINSTALL)/packages/config.gmk |
---|
70 | |
---|
71 | # Include paths needed for rootcint dictionary generation |
---|
72 | INCLUDES += -I \$(ESAFPACKAGES)/common/base/include |
---|
73 | INCLUDES += -DUSE_VISUALIZATION |
---|
74 | |
---|
75 | # headers and settings needed for the local library compilation |
---|
76 | CXXFLAGS += \$(INCLUDES) |
---|
77 | |
---|
78 | include \$(ESAFINSTALL)/packages/makeso.gmk |
---|
79 | |
---|
80 | pippo |
---|
81 | } else { |
---|
82 | |
---|
83 | print MK <<pippo; |
---|
84 | # GNUmakefile for $libname |
---|
85 | # \$Id\$ |
---|
86 | # $user created $now_string |
---|
87 | # |
---|
88 | |
---|
89 | name := $libname |
---|
90 | nameso := $shared |
---|
91 | |
---|
92 | LIBTARGET := lib\$(nameso).so |
---|
93 | |
---|
94 | ifndef ESAFINSTALL |
---|
95 | ESAFINSTALL = ../../../..#FIXME: ESAFINSTALL relative path |
---|
96 | endif |
---|
97 | |
---|
98 | ESAFPACKAGES = \$(ESAFINSTALL)/packages |
---|
99 | |
---|
100 | include \$(ESAFINSTALL)/packages/config.gmk |
---|
101 | |
---|
102 | CXXFLAGS += -I \$(ESAFPACKAGES)/common/base/include |
---|
103 | CXXFLAGS += -DUSE_VISUALIZATION |
---|
104 | |
---|
105 | linkdef := \$(nameso)LinkDef#FIXME: this is default Dict name |
---|
106 | dict := \$(nameso)Dict#FIXME: this is default Dict name |
---|
107 | libclasses :=#FIXME: Insert here the name of the files of the shared lib. |
---|
108 | |
---|
109 | dicts := \$(patsubst %,%.cc,\$(dict)) |
---|
110 | dicth := \$(patsubst %,%.h,\$(dict)) |
---|
111 | libheaders := \$(patsubst %,include/%.hh,\$(libclasses) \$(linkdef)) |
---|
112 | libsources := \$(patsubst %,src/%.cc,\$(libclasses)) \$(dicts) |
---|
113 | |
---|
114 | include \$(ESAFINSTALL)/packages/common.gmk |
---|
115 | \$(LIBDIR)/\$(LIBTARGET): \$(LIBDIR)/lib\$(name).a |
---|
116 | \@echo Building \$(nameso) dictionary... |
---|
117 | \@rootcint -f \$(dicts) -c \$(libheaders) |
---|
118 | \@echo Building \$(LIBTARGET)... |
---|
119 | \$(CXX) --shared \$(CXXFLAGS) \$(dicts) -L\$(LIBDIR) -l\$(name) -o \$(LIBDIR)/\$(LIBTARGET) |
---|
120 | \@echo Cleaning temporary files... |
---|
121 | \@rm -r \$(dicts) \$(dicth) |
---|
122 | |
---|
123 | |
---|
124 | rootlib: \$(LIBDIR)/\$(LIBTARGET) |
---|
125 | |
---|
126 | pippo |
---|
127 | } |
---|