# $Id: makefile,v 1.7 2001/07/03 12:21:42 amodigli Exp $
############################################################################# 
# .COPYRIGHT:	Copyright (c) 1994 European Southern Observatory,
#		all rights reserved
# .TYPE		Make file
# .NAME		$MIDASHOME/$MIDVERS/pipeline/uves/libsrc/makefile 
# .LANGUAGE	makefile syntax
# .ENVIRONMENT	Unix Systems. 
# .COMMENT	Compiles source files and generates "libphysmod.a" library
#		as well as libuves.a
# .REMARKS
# .AUTHOR       Sebastian Wolf
# .VERSION 1.1	990705:		Implementation
# .VERSION 1.2	990825:		library libuves.a installed
# .VERSION 1.3	990928:		clean_exec: included
# .VERSION 1.4	991021:		libphysmod.a should contain ONLY physmod.o and
#				messages.o
#############################################################################
# $Name:  $
# $Revision: 1.7 $
# $Log: makefile,v $
# Revision 1.7  2001/07/03 12:21:42  amodigli
# Fixed small portability bug:
# MEXE . (was ./)
#
# Revision 1.6  2001/05/18 11:00:16  amodigli
# Added entry to source a completely
# commented makefile to eventually allow
# (uncommenting at user own risk the proper
# section) to purify/quantify pipe modules
#
# Revision 1.5  2001/01/04 13:23:03  amodigli
# Added Id, Name, Revision, Log conf. control info
#
#############################################################################


# DEFINITIONS:

include $(MIDASHOME)/$(MIDVERS)/local/default.mk

# The next line allow to purify/quantify sources modules
# normally the sourced makefile is all commented 
# see it for further warings
include ../../Install/purify-quantify.mk

CFLAGS = $(C_OPT) $(DEBUG) $(SYS) -I$(INC) -I$(LINC)
#
# libraries to be created:
# (1) physical model (UVES)
# (2) utilities for uves context programms
#	following subroutines are a copy of the Numerical Recipes:
#	covsrt, gaussj, mrqcof, mrqmin, nrutil, polint
#
LIBNAM1 = physmod
LIBNAM2 = uves
LIBNAM3 = numrec

LIB1	= $(LLIBDIR)/lib$(LIBNAM1).a
LIB2	= $(LLIBDIR)/lib$(LIBNAM2).a
LIB3	= $(LLIBDIR)/lib$(LIBNAM3).a
LLIB    = -L$(LLIBDIR) -l$(LIBNAM1) -l$(LIBNAM2) -L$(LIBDIR) -lmidas -lm

MEXE    =	.
#
# objects
#
OBJ1 =	messages.o \
	physmod.o


OBJ2 =	matrix.o \
	messages.o \
	sort.o \
	statistics.o \
	table_io.o

OBJ3 =	covsrt.o \
	f_gaussj.o \
	gaussj.o \
	gauss_fit.o \
	lsfit.o \
	lfit.o \
	mrqcof.o \
	mrqmin.o \
	nrutil.o \
	nonlfit.o \
	polint.o 
#
# executables
#
#EXE = example.exe

# DEPENDENCIES:

all: $(MEXE)/example.exe $(MEXE)/example_2.exe $(LIB1) $(LIB2) $(LIB3) 

$(LIB1) :: $(OBJ1) $(LINC)/physmod.h $(LINC)/messages.h
	$(AR) $(AR_OPT) $(LIB1) $(OBJ1)
	$(RANLIB) $(LIB1)

$(LIB2) :: $(OBJ2) $(LINC)/messages.h
	$(AR) $(AR_OPT) $(LIB2) $(OBJ2)
	$(RANLIB) $(LIB2)

$(LIB3) :: $(OBJ3) $(LINC)/nrutil.h
	$(AR) $(AR_OPT) $(LIB3) $(OBJ3)
	$(RANLIB) $(LIB3)

physmod.o: $(LINC)/physmod.h $(LINC)/messages.h


clean:
	rm -f $(OBJ1) $(OBJ2) $(OBJ3)

clean_exec:
	rm -f $(LIB1) $(LIB2)

$(MAKEFILE_VMS): makefile
	$(MAKE_VMS)



#Example how to include the library:

$(MEXE)/example.exe: example.o $(LIB1) $(LIB2) $(LIB) $(LINC)
	$(LDCC) example.o $(LLIB)  $(SLIB) -o $@
	$(STRIP) $@

$(MEXE)/example_2.exe:  example_2.o $(LIB1) $(LIB2) $(LIB) $(LINC)
	$(LDCC) example_2.o $(LLIB) $(SLIB) -o $@
	$(STRIP) $@

	
