# Generated automatically from Makefile.in by configure.
# Makefile for McStas.
#  
#   This file is part of the McStas neutron ray-trace simulation package
#   Copyright (C) 1997-2004, All rights reserved
#   Risoe National Laborartory, Roskilde, Denmark
#   Institut Laue Langevin, Grenoble, France
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 

SHELL = /bin/sh

prefix = /usr/local
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
srcdir = .
libdir = ${exec_prefix}/lib


DEBUG = -DDEBUG=0
mc_libdir = $(libdir)/mcstas
#DEBUG=

CC = cc
CFLAGS = -fno-common
LDFLAGS= 
DEFS =  -DCC_HAS_PROTOS=1 -DHAVE_STRCASECMP=1 -DHAVE_FDOPEN=1  $(DEBUG)

PERL = /usr/local/bin/perl5

FLEX = flex
FLEXFLAGS=-i

BISON = bison
BISONFLAGS = -v -d

SCILAB = no
MATLAB = no
PGPLOT = /usr/local/bin/pgxwin_server

XTERM = @TERM@

INSTALL=/usr/bin/install -c -o root -g wheel
INSTALL_PROGRAM = install   -o root -g wheel -m 555
INSTALL_DATA = install  -o root -g wheel -m 444


#
# End of configuration section.
#

OBJECTS=instrument.tab.o lex.yy.o debug.o \
	memory.o list.o symtab.o coords.o cexp.o \
	file.o cogen.o port.o

PERLOBJ=gscan.fixpl mcdisplay.fixpl mcplot.fixpl mcresplot.fixpl mcrun.fixpl \
        mcgui.fixpl mcdoc.fixpl mcstas2vitess.fixpl mcconvert.fixpl mcdaemon.fixpl
PERLBIN=gscan mcdisplay mcplot mcresplot mcrun mcgui mcdoc mcstas2vitess mcconvert mcdaemon
BINOBJS=$(PERLOBJ) mcstas

.SUFFIXES: .c .o .pl .fixpl

.c.o:
	$(CC) -I. -I$(srcdir) -c $(CFLAGS) -DMCSTAS='"'$(mc_libdir)'"' $(DEFS) $<

.pl.fixpl:
	sed -e 's+#! /usr/bin/perl+#! '$(PERL)'+' \
	    -e 's+\$MCSTAS::sys_dir = "/usr/local/lib/mcstas"+\$MCSTAS::sys_dir = "'$(mc_libdir)'"+' \
	    < $(srcdir)/$< > $@
	chmod +x $@


all: $(BINOBJS)

mcstas: $(OBJECTS)
	$(CC) -o mcstas $(CFLAGS) $(LDFLAGS) $(OBJECTS) -lm

clean:
	rm -f $(BINOBJS) $(OBJECTS) $(PERLOBJ) TAGS \
	instrument.tab.c instrument.tab.h instrument.output lex.yy.c \
  config.cache Makefile
TAGS:
	etags *.[chly]

install: installdirs $(BINOBJS)
	$(INSTALL_PROGRAM) mcstas $(bindir)/mcstas
	for pgm in $(PERLBIN); do \
	  $(INSTALL_PROGRAM) $$pgm.fixpl $(bindir)/$$pgm; \
	done
	$(srcdir)/mkinstalldirs $(mc_libdir)
	for file in `cd lib; ls`; do \
	  if [ -d lib/$$file ]; then \
	    $(srcdir)/mkinstalldirs $(mc_libdir)/$$file; \
	    for comp in `cd lib/$$file; ls`; do \
        if [ -f $(mc_libdir)/$$file/$$comp ]; then \
          echo "Renaming old library element version $(mc_libdir)/$$file/$$comp to $(mc_libdir)/$$file/$$comp.old"; \
          mv -f $(mc_libdir)/$$file/$$comp $(mc_libdir)/$$file/$$comp.old; \
        fi; \
	      if [ -d lib/$$file/$$comp ]; then \
          $(srcdir)/mkinstalldirs $(mc_libdir)/$$file/$$comp; \
          for tool in `cd lib/$$file/$$comp; ls`; do \
	      if [ -d lib/$$file/$$comp/$$tool ]; then \
          $(srcdir)/mkinstalldirs $(mc_libdir)/$$file/$$comp/$$tool ; \
	        for subtool in `cd lib/$$file/$$comp/$$tool; ls`; do \
		  if [ -d lib/$$file/$$comp/$$tool/$$subtool ]; then \
		     $(srcdir)/mkinstalldirs $(mc_libdir)/$$file/$$comp/$$tool/$$subtool ; \
	             for subsubtool in `cd lib/$$file/$$comp/$$tool/$$subtool; ls`; do \
                       $(INSTALL_DATA) lib/$$file/$$comp/$$tool/$$subtool/$$subsubtool $(mc_libdir)/$$file/$$comp/$$tool/$$subtool/$$subsubtool; \
                     done \
		  else \
                    $(INSTALL_DATA) lib/$$file/$$comp/$$tool/$$subtool $(mc_libdir)/$$file/$$comp/$$tool/$$subtool; \
		  fi; \
                done \
              else \
                $(INSTALL_DATA) lib/$$file/$$comp/$$tool $(mc_libdir)/$$file/$$comp/$$tool; \
	      fi; \
          done \
        else \
	        $(INSTALL_DATA) lib/$$file/$$comp $(mc_libdir)/$$file/$$comp; \
        fi; \
	    done \
	  else \
	    $(INSTALL_DATA) lib/$$file $(mc_libdir)/$$file; \
	  fi \
	done
	./mcdoc.fixpl --text
	mkdir $(mc_libdir)/tools/perl/modules
	cd support/Proc-Simple-1.19 && $(PERL) Makefile.PL LIB=$(mc_libdir)/tools/perl/modules PREFIX=$(mc_libdir)/tools/perl/modules && make && make install 
	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 


installdirs:
	$(srcdir)/mkinstalldirs $(bindir) $(libdir) $(mc_libdir)

instrument.tab.o: mcstas.h
lex.yy.o: mcstas.h instrument.tab.h
debug.o: mcstas.h
memory.o: mcstas.h
symtab.o: mcstas.h
list.o: mcstas.h
coords.o: mcstas.h
cexp.o: mcstas.h
file.o: mcstas.h
cogen.o: mcstas.h
port.o: port.h
mcformat.o: mcstas.h

instrument.tab.c instrument.tab.h: instrument.y
	$(BISON) $(BISONFLAGS) instrument.y

lex.yy.c: instrument.l
	$(FLEX) $(FLEXFLAGS) instrument.l

# Prefer Scilab over Matlab over PGPLOT
config: 
	if [ $(PGPLOT) != no ]; then \
		make pgplot; \
	fi; \
	if [ $(MATLAB) != no ]; then \
		make matlab; \
	fi; \
	if [ $(SCILAB) != no ]; then \
		make scilab; \
	fi; 

scilab:
	sed "s/PLOTTER => '.*'./PLOTTER => 'Scilab'\,/" lib/tools/perl/mcstas_config.perl > lib/tools/perl/mcstas_config.perl.tmp
	mv lib/tools/perl/mcstas_config.perl.tmp lib/tools/perl/mcstas_config.perl
matlab: 
	sed "s/PLOTTER => '.*'./PLOTTER => 'Matlab'\,/" lib/tools/perl/mcstas_config.perl > lib/tools/perl/mcstas_config.perl.tmp
	mv lib/tools/perl/mcstas_config.perl.tmp lib/tools/perl/mcstas_config.perl
pgplot:
	sed "s/PLOTTER => '.*'./PLOTTER => 'McStas'\,/" lib/tools/perl/mcstas_config.perl > lib/tools/perl/mcstas_config.perl.tmp
	mv lib/tools/perl/mcstas_config.perl.tmp lib/tools/perl/mcstas_config.perl

test:
	./mcrun.fixpl --test



syntax highlighted by Code2HTML, v. 0.9.1