| 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 | |
|---|
| 33 | SHELL = /bin/sh |
|---|
| 34 | |
|---|
| 35 | prefix = @prefix@ |
|---|
| 36 | exec_prefix = @exec_prefix@ |
|---|
| 37 | bindir = @bindir@ |
|---|
| 38 | srcdir = @srcdir@ |
|---|
| 39 | libdir = @libdir@ |
|---|
| 40 | mandir = @mandir@ |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | DEBUG = -DDEBUG=0 |
|---|
| 44 | mc_libdir = $(libdir)/mcstas |
|---|
| 45 | |
|---|
| 46 | CC = @CC@ |
|---|
| 47 | MINGW = @MINGW@ |
|---|
| 48 | CFLAGS = @CFLAGS@ |
|---|
| 49 | LDFLAGS= @LDFLAGS@ |
|---|
| 50 | |
|---|
| 51 | HAVE_QSORT = @HAVE_QSORT@ |
|---|
| 52 | USE_NEXUS = @HAVE_NEXUS@ |
|---|
| 53 | |
|---|
| 54 | DEFS = @DEFS@ $(DEBUG) |
|---|
| 55 | LIBS = @LIBS@ |
|---|
| 56 | |
|---|
| 57 | PERL = @PERL@ |
|---|
| 58 | |
|---|
| 59 | FLEX = flex |
|---|
| 60 | FLEXFLAGS=-i |
|---|
| 61 | |
|---|
| 62 | BISON = bison |
|---|
| 63 | BISONFLAGS = -v -d |
|---|
| 64 | |
|---|
| 65 | SCILAB = @SCILAB@ |
|---|
| 66 | MATLAB = @MATLAB@ |
|---|
| 67 | PGPLOT = @PGPLOT@ |
|---|
| 68 | VRML = @VRMLVIEW@ |
|---|
| 69 | |
|---|
| 70 | WGET = @WGET@ |
|---|
| 71 | |
|---|
| 72 | XTERM = @TERM@ |
|---|
| 73 | |
|---|
| 74 | INSTALL=@INSTALL@ |
|---|
| 75 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ |
|---|
| 76 | INSTALL_DATA = @INSTALL_DATA@ |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | # |
|---|
| 80 | # End of configuration section. |
|---|
| 81 | # |
|---|
| 82 | |
|---|
| 83 | OBJECTS=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 |
|---|
| 86 | COBJECTS=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 | |
|---|
| 90 | PERLOBJ=gscan.fixpl mcdisplay.fixpl mcplot.fixpl mcresplot.fixpl mcrun.fixpl \ |
|---|
| 91 | mcgui.fixpl mcdoc.fixpl mcstas2vitess.fixpl mcconvert.fixpl mcdaemon.fixpl mcformatgui.fixpl |
|---|
| 92 | PERLBIN=gscan mcdisplay mcplot mcresplot mcrun mcgui mcdoc mcstas2vitess mcconvert mcdaemon mcformatgui |
|---|
| 93 | BINOBJS=$(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 | |
|---|
| 107 | all: $(BINOBJS) |
|---|
| 108 | |
|---|
| 109 | mcstas: $(OBJECTS) |
|---|
| 110 | $(CC) -o mcstas $(CFLAGS) $(LDFLAGS) $(DEFS) $(OBJECTS) -lm |
|---|
| 111 | |
|---|
| 112 | mcstas.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 | |
|---|
| 117 | mcformat: |
|---|
| 118 | $(CC) -o mcformat $(CFLAGS) $(LDFLAGS) $(DEFS) mcformat.c -lm $(LIBS) $(USE_NEXUS) |
|---|
| 119 | |
|---|
| 120 | clean: |
|---|
| 121 | rm -f $(BINOBJS) $(OBJECTS) $(PERLOBJ) TAGS \ |
|---|
| 122 | instrument.tab.c instrument.tab.h instrument.output lex.yy.c \ |
|---|
| 123 | config.cache Makefile |
|---|
| 124 | TAGS: |
|---|
| 125 | etags *.[chly] |
|---|
| 126 | |
|---|
| 127 | install: 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 | |
|---|
| 186 | installdirs: |
|---|
| 187 | $(srcdir)/mkinstalldirs $(bindir) $(libdir) $(mc_libdir) $(mandir)/man1 |
|---|
| 188 | |
|---|
| 189 | instrument.tab.o: mcstas.h |
|---|
| 190 | lex.yy.o: mcstas.h instrument.tab.h |
|---|
| 191 | debug.o: mcstas.h |
|---|
| 192 | memory.o: mcstas.h |
|---|
| 193 | symtab.o: mcstas.h |
|---|
| 194 | list.o: mcstas.h |
|---|
| 195 | coords.o: mcstas.h |
|---|
| 196 | cexp.o: mcstas.h |
|---|
| 197 | file.o: mcstas.h |
|---|
| 198 | cogen.o: mcstas.h |
|---|
| 199 | port.o: port.h |
|---|
| 200 | mcformat.o: mcstas.h |
|---|
| 201 | |
|---|
| 202 | instrument.tab.c instrument.tab.h: instrument.y |
|---|
| 203 | $(BISON) $(BISONFLAGS) instrument.y |
|---|
| 204 | |
|---|
| 205 | lex.yy.c: instrument.l |
|---|
| 206 | $(FLEX) $(FLEXFLAGS) instrument.l |
|---|
| 207 | |
|---|
| 208 | # Prefer Scilab over Matlab over PGPLOT |
|---|
| 209 | config: plotter |
|---|
| 210 | plotter: |
|---|
| 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 | |
|---|
| 224 | scilab: |
|---|
| 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 |
|---|
| 227 | matlab: |
|---|
| 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 |
|---|
| 230 | pgplot: |
|---|
| 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 |
|---|
| 233 | vrml: |
|---|
| 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 |
|---|
| 236 | PGPLOT: pgplot |
|---|
| 237 | Matlab: matlab |
|---|
| 238 | Scilab: scilab |
|---|
| 239 | VRML: vrml |
|---|
| 240 | |
|---|
| 241 | install-pgplot: |
|---|
| 242 | cd support/pgplot && ./pgplot.sh && echo "McStas: run './configure; make; make install' again" |
|---|
| 243 | |
|---|
| 244 | install-scilab: |
|---|
| 245 | cd support/scilab && ./scilab.sh && echo "McStas: run './configure; make; make install' again" |
|---|
| 246 | |
|---|
| 247 | test: |
|---|
| 248 | ./mcrun.fixpl --test |
|---|
| 249 | |
|---|
| 250 | uninstall: |
|---|
| 251 | cd $(bindir); rm -f $(BINOBJS) |
|---|
| 252 | rm -rf $(mc_libdir) |
|---|
| 253 | |
|---|
| 254 | reconfigure: |
|---|
| 255 | cd $(mc_libdir)/tools/perl/ |
|---|
| 256 | $(mc_libdir)/tools/perl/mcstas_reconfigure |
|---|
| 257 | |
|---|
| 258 | # Optional auto install of patched perl-Tk package |
|---|
| 259 | tk: |
|---|
| 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 | |
|---|
| 266 | install-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 | |
|---|