root/branches/mcstas-1.x/Makefile.in

Revision 2859, 9.4 KB (checked in by farhi, 2 years ago)

makefile: add make install-apps to set menu entry in Debian systems

Line 
1# Makefile for McStas.
2#
3#   This file is part of the McStas neutron ray-trace simulation package
4#   Copyright (C) 1997-2010, All rights reserved
5#   Risoe National Laborartory, Roskilde, Denmark
6#   Institut Laue Langevin, Grenoble, France
7#
8#   This program is free software; you can redistribute it and/or modify
9#   it under the terms of the GNU General Public License as published by
10#   the Free Software Foundation; version 2 of the License.
11#
12#   This program is distributed in the hope that it will be useful,
13#   but WITHOUT ANY WARRANTY; without even the implied warranty of
14#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15#   GNU General Public License for more details.
16#
17#   You should have received a copy of the GNU General Public License
18#   along with this program; if not, write to the Free Software
19#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21# Available methods for installation
22# make                 normal build
23# make install         normal installation
24# make clean           clean distro
25# make test            distro self-test
26# make plotter         best plotter choice
27# make reconfigure     reconfigure McStas installation (after software update)
28# make install-pgplot  build and install PGPLOT (including perl-PGPLOT)
29# make install-scilab  build and install Scilab
30# make install-apps    install highligh syntax in gedit/kate
31#                          and icon in menu/education (requires administrator permissions)
32
33SHELL = /bin/sh
34
35prefix = @prefix@
36exec_prefix = @exec_prefix@
37bindir = @bindir@
38srcdir = @srcdir@
39libdir = @libdir@
40mandir = @mandir@
41
42
43DEBUG = -DDEBUG=0
44mc_libdir = $(libdir)/mcstas
45
46CC = @CC@
47MINGW = @MINGW@
48CFLAGS = @CFLAGS@
49LDFLAGS= @LDFLAGS@
50
51HAVE_QSORT = @HAVE_QSORT@
52USE_NEXUS = @HAVE_NEXUS@
53
54DEFS = @DEFS@ $(DEBUG)
55LIBS = @LIBS@
56
57PERL = @PERL@
58
59FLEX = flex
60FLEXFLAGS=-i
61
62BISON = bison
63BISONFLAGS = -v -d
64
65SCILAB = @SCILAB@
66MATLAB = @MATLAB@
67PGPLOT = @PGPLOT@
68VRML = @VRMLVIEW@
69
70WGET = @WGET@
71
72XTERM = @TERM@
73
74INSTALL=@INSTALL@
75INSTALL_PROGRAM = @INSTALL_PROGRAM@
76INSTALL_DATA = @INSTALL_DATA@
77
78
79#
80# End of configuration section.
81#
82
83OBJECTS=instrument.tab.o lex.yy.o debug.o \
84        memory.o list.o symtab.o coords.o cexp.o \
85        file.o cogen.o port.o
86COBJECTS=instrument.tab.c lex.yy.c debug.c \
87        memory.c list.c symtab.c coords.c cexp.c \
88        file.c cogen.c port.c
89
90PERLOBJ=gscan.fixpl mcdisplay.fixpl mcplot.fixpl mcresplot.fixpl mcrun.fixpl \
91        mcgui.fixpl mcdoc.fixpl mcstas2vitess.fixpl mcconvert.fixpl mcdaemon.fixpl mcformatgui.fixpl
92PERLBIN=gscan mcdisplay mcplot mcresplot mcrun mcgui mcdoc mcstas2vitess mcconvert mcdaemon mcformatgui
93BINOBJS=$(PERLOBJ) mcstas mcformat
94
95.SUFFIXES: .c .o .pl .fixpl
96
97.c.o:
98        $(CC) -I. -I$(srcdir) -c $(CFLAGS) -DMCSTAS='"'$(mc_libdir)'"' $(DEFS) $<
99
100.pl.fixpl:
101        sed -e 's+#! /usr/bin/perl+#! '$(PERL)'+' \
102            -e 's+\$MCSTAS::sys_dir = "/usr/local/lib/mcstas"+\$MCSTAS::sys_dir = "'$(mc_libdir)'"+' \
103            < $(srcdir)/$< > $@
104        chmod +x $@
105
106
107all: $(BINOBJS)
108
109mcstas: $(OBJECTS)
110        $(CC) -o mcstas $(CFLAGS) $(LDFLAGS) $(DEFS) $(OBJECTS) -lm
111
112mcstas.win32: $(COBJECTS)
113        $(MINGW) -o mcstas.exe -DMCSTAS='"C:\\McStas\\lib"' $(CFLAGS) $(LDFLAGS) $(DEFS) $(COBJECTS) -lm $(USE_NEXUS)
114        $(MINGW) -o mcformat.exe -DMCSTAS='"C:\\McStas\\lib"' $(CFLAGS) $(LDFLAGS) $(DEFS) mcformat.c -lm $(USE_NEXUS)
115
116
117mcformat:
118        $(CC) -o mcformat $(CFLAGS) $(LDFLAGS) $(DEFS) mcformat.c -lm $(LIBS) $(USE_NEXUS)
119
120clean:
121        rm -f $(BINOBJS) $(OBJECTS) $(PERLOBJ) TAGS \
122        instrument.tab.c instrument.tab.h instrument.output lex.yy.c \
123  config.cache Makefile
124TAGS:
125        etags *.[chly]
126
127install: installdirs $(BINOBJS)
128        $(INSTALL_PROGRAM) mcstas $(bindir)/mcstas
129        $(INSTALL_PROGRAM) mcformat $(bindir)/mcformat
130        for pgm in $(PERLBIN); do \
131          $(INSTALL_PROGRAM) $$pgm.fixpl $(bindir)/$$pgm; \
132        done
133        if [ -d $(mc_libdir) ]; then \
134          echo "Moving your old library dir $(mc_libdir) to $(mc_libdir).`date +%Y%m%d_%H.%M`"; \
135          mv -f $(mc_libdir) $(mc_libdir).`date +%Y%m%d_%H.%M`;\
136        fi;
137        $(srcdir)/mkinstalldirs $(mc_libdir)
138        for file in `cd lib; ls`; do \
139          if [ -d lib/$$file ]; then \
140            $(srcdir)/mkinstalldirs $(mc_libdir)/$$file; \
141            for comp in `cd lib/$$file; ls`; do \
142        if [ -f $(mc_libdir)/$$file/$$comp ]; then \
143          echo "Renaming old library element version $(mc_libdir)/$$file/$$comp to $(mc_libdir)/$$file/$$comp.old"; \
144          mv -f $(mc_libdir)/$$file/$$comp $(mc_libdir)/$$file/$$comp.old; \
145        fi; \
146              if [ -d lib/$$file/$$comp ]; then \
147          $(srcdir)/mkinstalldirs $(mc_libdir)/$$file/$$comp; \
148          for tool in `cd lib/$$file/$$comp; ls`; do \
149              if [ -d lib/$$file/$$comp/$$tool ]; then \
150          $(srcdir)/mkinstalldirs $(mc_libdir)/$$file/$$comp/$$tool ; \
151                for subtool in `cd lib/$$file/$$comp/$$tool; ls`; do \
152                  if [ -d lib/$$file/$$comp/$$tool/$$subtool ]; then \
153                     $(srcdir)/mkinstalldirs $(mc_libdir)/$$file/$$comp/$$tool/$$subtool ; \
154                     for subsubtool in `cd lib/$$file/$$comp/$$tool/$$subtool; ls`; do \
155                       $(INSTALL_DATA) lib/$$file/$$comp/$$tool/$$subtool/$$subsubtool $(mc_libdir)/$$file/$$comp/$$tool/$$subtool/$$subsubtool; \
156                     done \
157                  else \
158                    $(INSTALL_DATA) lib/$$file/$$comp/$$tool/$$subtool $(mc_libdir)/$$file/$$comp/$$tool/$$subtool; \
159                  fi; \
160                done \
161              else \
162                $(INSTALL_DATA) lib/$$file/$$comp/$$tool $(mc_libdir)/$$file/$$comp/$$tool; \
163              fi; \
164          done \
165        else \
166                $(INSTALL_DATA) lib/$$file/$$comp $(mc_libdir)/$$file/$$comp; \
167        fi; \
168            done \
169          else \
170            $(INSTALL_DATA) lib/$$file $(mc_libdir)/$$file; \
171          fi \
172        done
173        MCSTAS=$(mc_libdir)
174        export MCSTAS
175        ./mcdoc.fixpl --text
176        $(INSTALL_DATA) *.1 $(mandir)/man1
177        mkdir $(mc_libdir)/tools/perl/modules
178        cd support/Proc-Simple-1.19 && $(PERL) Makefile.PL LIB=$(mc_libdir)/tools/perl/modules PREFIX=$(mc_libdir)/tools/perl/modules && make && make install
179        cd support/Tk-CodeText-0.3.4 && $(PERL) Makefile.PL LIB=$(mc_libdir)/tools/perl/modules PREFIX=$(mc_libdir)/tools/perl/modules && make && make install
180        cd support/Math-Amoeba-0.04 && $(PERL) Makefile.PL LIB=$(mc_libdir)/tools/perl/modules PREFIX=$(mc_libdir)/tools/perl/modules && make && make install
181        chmod a+x $(mc_libdir)/tools/perl/mcstas_reconfigure
182        echo McStas library has been installed in MCSTAS=$(mc_libdir), and binaries in $(bindir)
183        echo "Start McStas with: mcgui or use mcrun for command line simulations"
184        echo "==== Installation finished. Thanks for using McStas ===="
185
186installdirs:
187        $(srcdir)/mkinstalldirs $(bindir) $(libdir) $(mc_libdir) $(mandir)/man1
188
189instrument.tab.o: mcstas.h
190lex.yy.o: mcstas.h instrument.tab.h
191debug.o: mcstas.h
192memory.o: mcstas.h
193symtab.o: mcstas.h
194list.o: mcstas.h
195coords.o: mcstas.h
196cexp.o: mcstas.h
197file.o: mcstas.h
198cogen.o: mcstas.h
199port.o: port.h
200mcformat.o: mcstas.h
201
202instrument.tab.c instrument.tab.h: instrument.y
203        $(BISON) $(BISONFLAGS) instrument.y
204
205lex.yy.c: instrument.l
206        $(FLEX) $(FLEXFLAGS) instrument.l
207
208# Prefer Scilab over Matlab over PGPLOT
209config: plotter
210plotter:
211        if [ $(VRML) != no ]; then \
212                make vrml; \
213        fi; \
214        if [ $(SCILAB) != no ]; then \
215                make scilab; \
216        fi; \
217        if [ $(MATLAB) != no ]; then \
218                make matlab; \
219        fi; \
220        if [ $(PGPLOT) != no ]; then \
221                make pgplot; \
222        fi;
223
224scilab:
225        sed "s/PLOTTER => '.*'./PLOTTER => 'Scilab'\,/" lib/tools/perl/mcstas_config.perl > lib/tools/perl/mcstas_config.perl.tmp
226        mv lib/tools/perl/mcstas_config.perl.tmp lib/tools/perl/mcstas_config.perl
227matlab:
228        sed "s/PLOTTER => '.*'./PLOTTER => 'Matlab'\,/" lib/tools/perl/mcstas_config.perl > lib/tools/perl/mcstas_config.perl.tmp
229        mv lib/tools/perl/mcstas_config.perl.tmp lib/tools/perl/mcstas_config.perl
230pgplot:
231        sed "s/PLOTTER => '.*'./PLOTTER => 'McStas'\,/" lib/tools/perl/mcstas_config.perl > lib/tools/perl/mcstas_config.perl.tmp
232        mv lib/tools/perl/mcstas_config.perl.tmp lib/tools/perl/mcstas_config.perl
233vrml:
234        sed "s/PLOTTER => '.*'./PLOTTER => 'VRML'\,/" lib/tools/perl/mcstas_config.perl > lib/tools/perl/mcstas_config.perl.tmp
235        mv lib/tools/perl/mcstas_config.perl.tmp lib/tools/perl/mcstas_config.perl
236PGPLOT: pgplot
237Matlab: matlab
238Scilab: scilab
239VRML: vrml
240
241install-pgplot:
242        cd support/pgplot && ./pgplot.sh && echo "McStas: run './configure; make; make install' again"
243
244install-scilab:
245        cd support/scilab && ./scilab.sh && echo "McStas: run './configure; make; make install' again"
246
247test:
248        ./mcrun.fixpl --test
249
250uninstall:
251        cd $(bindir); rm -f $(BINOBJS)
252        rm -rf $(mc_libdir)
253
254reconfigure:
255        cd $(mc_libdir)/tools/perl/
256        $(mc_libdir)/tools/perl/mcstas_reconfigure
257
258# Optional auto install of patched perl-Tk package
259tk:
260        if [ $(WGET) != no ]; then \
261                $(WGET) http://www.mcstas.org/download/Tk-804.027_gtk2_patch.tar.gz &&\
262                tar xzvf Tk-804.027_gtk2_patch.tar.gz > /dev/null && \
263                cd Tk-804.027_gtk2_patch && $(PERL) Makefile.PL LIB=$(mc_libdir)/tools/perl/modules PREFIX=$(mc_libdir)/tools/perl/modules && make && make install ;\
264        fi;
265       
266install-apps:
267        if [ -d /usr/share/applications/ ]; then \
268          cp support/Desktop/McStas.desktop /usr/share/applications/; \
269        fi;
270        if [ -d /usr/share/pixmaps/ ]; then \
271          cp support/Desktop/mcstas-icon.png /usr/share/pixmaps/; \
272        fi;
273        if [ -d /usr/share/gtksourceview-1.0/ ]; then \
274          cp lib/editors/mcstas1.lang /usr/share/gtksourceview-1.0/language-specs/; \
275        fi;
276        if [ -d /usr/share/gtksourceview-2.0/ ]; then \
277          cp lib/editors/mcstas2.lang /usr/share/gtksourceview-2.0/language-specs/; \
278        fi;
279        if [ -d /usr/share/apps/katepart/syntax/ ]; then \
280          cp lib/editors/mcstas.xml /usr/share/apps/katepart/syntax/; \
281        fi;
282
Note: See TracBrowser for help on using the browser.