# Unix gmake Makefile for VITESS modules
# generated by
# mmake.pl u
#
#
# compile hosts to use
# Linux : dixi3
# SunOS : dsapp3
# OSF1  : darling


INSTDIR = ../MODULES/

ALL = ascii2bin \
eval_elast \
monitor1 \
mon2_div \
mon2_pos \
mon2_posdiv \
mon2_tofwl \
mon2_wldiv \
velselect \
writeout \
gener_batch \
lattice_dist \
mirror_coating \
surface_file \
guide_shape \
chopper_disc \
chopper_fermi \
collimator_soller \
source \
spacewindow \
spacewindow_multiple \
space \
detector \
eval_inelast \
frame \
guide \
monitorpol_1d \
monitorpol_pos \
monochr_analyser \
polariser_sm \
polariser_he3 \
flipper_coil \
pol_mirror \
precessionfield \
rotating_field \
flipper_gradient \
resonator_drabkin \
sample_elasticisotr \
sample_inelast \
sample_reflectom \
define_direction \
sample_singcryst \
cas_v40 \
sample_powder \
sample_s_q \
sample_sans \
bender \
visual \
sm_ensemble \
dist_time \
chop_phases \
standard_deviation \
direct_view

TOOL = init.o general.o message.o
ITOOL = intersection.o $(TOOL)
MTOOL = matrix.o $(ITOOL)
STOOL = sample.o $(MTOOL)

SYS = $(shell uname)
CFLAGS = -O3 -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

GRAOPT = -DDO_X11 -DDO_GIF -DVT_GRAPH -I.
ifeq ($(SYS),SunOS)
CCOMP = /net/bin/gcc
CC = $(CCOMP) $(CFLAGS)
GRALIB = $(GRAOPT) -Ig2/SunOS  -Lg2/SunOS -lg2 -L/net/usr/lib -L/usr/openwin/lib -R/usr/openwin/lib -L/usr/local/libll -lm -lX11 -lgd -lpng
endif

ifeq ($(SYS),OSF1)
CCOMP = /net/bin/gcc
CC = $(CCOMP) -DOSF $(CFLAGS)
GRALIB = $(GRAOPT) -Ig2/OSF1 -Lg2/OSF1  -L/net/usr/lib -lg2 -lX11 -lm -lgd -lpng
endif

ifeq ($(SYS),Linux)
CCOMP = gcc
CC = $(CCOMP) $(CFLAGS)
GRALIB = $(GRAOPT) -Ig2/Linux -Lg2/Linux -L/usr/X11R6/lib -L/usr/local/lib -lX11 -lg2 -lgd -lpng -lz -lfreetype -lXpm -lttf -lm
endif

LIBS = -lm

.KEEP_STATE :

all: $(ALL)
	strip $^
spacewindow_multiple : spacewindow_multiple.c bender_inter_data.c $(ITOOL)
	$(CC) -o $@ $^ $(LIBS)

sample_reflectom : sample_reflectom.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

rotating_field : rotating_field.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

resonator_drabkin : resonator_drabkin.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

chop_phases : chop_phases.c 
	$(CC) -o $@ $^ $(LIBS)

spacewindow : spacewindow.c bender_inter_data.c $(ITOOL)
	$(CC) -o $@ $^ $(LIBS)

sample_inelast : sample_inelast.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

polariser_he3 : polariser_he3.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

flipper_coil : flipper_coil.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

lattice_dist : lattice_dist.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

mon2_tofwl : mon2_tofwl.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

monitorpol_pos : monitorpol_pos.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

eval_elast : eval_elast.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

velselect : velselect.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

visual : visual.c cpgplot.c $(TOOL)
	$(CC) -o $@ $^ $(GRALIB)

eval_inelast : eval_inelast.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

standard_deviation : standard_deviation.c 
	$(CC) -o $@ $^ $(LIBS)

guide : guide.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

bender : bender.c bendtest.c bendchtr.c bendertr.c bender_inter_data.c cpgplot.c $(ITOOL)
	$(CC) -o $@ $^ $(GRALIB)

sm_ensemble : sm_ensemble.c cpgplot.c $(MTOOL)
	$(CC) -o $@ $^ $(GRALIB)

sample_sans : sample_sans.c $(STOOL)
	$(CC) -o $@ $^ $(LIBS)

writeout : writeout.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

detector : detector.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

sample_s_q : sample_s_q.c sq_calc.c $(STOOL)
	$(CC) -o $@ $^ $(LIBS)

source : source.c src_modchar.c $(ITOOL)
	$(CC) -o $@ $^ $(LIBS)

precessionfield : precessionfield.c magneticmap.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

collimator_soller : collimator_soller.c $(ITOOL)
	$(CC) -o $@ $^ $(LIBS)

gener_batch : gener_batch.c gener_fct.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

sample_singcryst : sample_singcryst.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

frame : frame.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

chopper_disc : chopper_disc.c bender_inter_data.c $(ITOOL)
	$(CC) -o $@ $^ $(LIBS)

ascii2bin : ascii2bin.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

dist_time : dist_time.c cpgplot.c $(TOOL)
	$(CC) -o $@ $^ $(GRALIB)

mon2_pos : mon2_pos.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

sample_elasticisotr : sample_elasticisotr.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

monochr_analyser : monochr_analyser.c ma_functions.c ma_geom.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

mon2_div : mon2_div.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

flipper_gradient : flipper_gradient.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

pol_mirror : pol_mirror.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

mirror_coating : mirror_coating.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

direct_view : direct_view.c 
	$(CC) -o $@ $^ $(LIBS)

sample_powder : sample_powder.c $(STOOL)
	$(CC) -o $@ $^ $(LIBS)

mon2_wldiv : mon2_wldiv.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

space : space.c $(ITOOL)
	$(CC) -o $@ $^ $(LIBS)

surface_file : surface_file.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

polariser_sm : polariser_sm.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

cas_v40 : cas_v40.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

monitorpol_1d : monitorpol_1d.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

guide_shape : guide_shape.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

define_direction : define_direction.c $(MTOOL)
	$(CC) -o $@ $^ $(LIBS)

monitor1 : monitor1.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

mon2_posdiv : mon2_posdiv.c $(TOOL)
	$(CC) -o $@ $^ $(LIBS)

chopper_fermi : chopper_fermi.c $(ITOOL)
	$(CC) -o $@ $^ $(LIBS)

Move:
	a=_$(SYS) ; h=$(INSTDIR) ; for l in $(ALL) ; do mv $$l $$h$$l$$a ; done
	rm *.o
Copy:
	a=_$(SYS) ; h=$(INSTDIR) ; for l in $(ALL) ; do cp $$l $$h$$l$$a ; done

clean :
	rm *.o $(ALL)
