#
#	Fichier	: $RCSfile: Makefile,v $, v $Revision: 1.14 $
#
#	Date	: $Date: 2015/06/25 15:09:04 $
#
#	Auteur	: $Author: barthe $
#
#	Version	: %Z% version %I% de %M% du %G%
#
#	================================================================================
#
#	Makefile for idl_cef Dynamically Loadable Module (DLM)
##

#		Composition des options de compilations
#		---------------------------------------
#
CFLAGS =	$(CDEBUG) $(COPTI) $(CSHARED) -I inc -I $(CISLIB_DIR)/inc -I $(CEFLIB_DIR)/inc -I $(IDL_DIR)/external

###
#		WARNING :
#
#		There is a conflict, as least under Linux, between the CEFLIB library and zlib, 
#		when used with some IDL versions (6.0, 6.3, ???)
#
#		If you encounter such problem, you have to link with idl_mpeg.so rather than 
#		with usual zlib (It seems that idl_mpeg.so is embedding its own zlib library)
#
#		The idl_mpeg.so can be found using one of the 2 possible commands :
#
MPEG_LIB =	$(shell find $(IDL_DIR) -name idl_mpeg.so | head -1)
#
# MPEG_LIB =	$(shell find $(IDL_DIR) -name idl_mpeg.so | tail -1)
#
#		If you are using IDL version <= 5.4 : comment the next line
#		If you are using IDL version >= 7.0 : comment the next line
#
#		--> the library will be linked with usual zlib library (-lz)
#
#		If you are using IDL version 6.0, 6.3, ??? : uncomment the next line
#
#		--> the library will use zlib functions implemented in idl_mpeg.so
#
# ZLIB =	$(MPEG_LIB)
#
#		ANOTHER POSSIBLE PROBLEM:
#
#		If you have to use the MPEG_LIB variable as explained previously, and both 32 and 64 bits
#		version of IDL are installed on your computer, you will find 2 idl_mpeg.so libraries 
#		in the IDL directory tree.
#		
#		In order to fill the MPEG_LIB variable, we are using the Unix find command, 
#		and in this case you will get two response (32 + 64 library)
#
#		You can select one of the 2 possible find commands :
#		- using the head -1 filter to select the first library
#		- using the tail -1 filter to select the second library
#		depending on your processor architecture.	
###

#		Repertoire de recherche des sources
#		----------------------------------
#
VPATH =		src

#		Nom de la librairie
#		-------------------
#
LIB =		bin/idl_cef.so

#		Liste des modules de compilation
#		--------------------------------
#
MODULES =	EXTERNAL

DLM =		bin/idl_cef.dlm


#		Nom des fichiers objets
#		-----------------------
#
OBJS =		$(MODULES:%=obj/%.o) 


#		Diverses cibles de compilation
#		------------------------------
#
all:		init $(LIB) $(DLM)

$(DLM):		$(LIB)
		@IDL_PATH=./pro idl -e "make_dlm"

dlm:		$(DLM)

init:
		mkdir -p obj

clean:
		rm -rf 	obj
		rm -f	.make.state

raz:		clean
		rm -f	$(LIB)
		

#		PARTIE A NE PAS MODIFIER
#		------------------------
#
.SUFFIXES:
.KEEP_STATE:

$(LIB):		$(OBJS) $(CISLIB) $(CEFLIB)
		$(LDSHARED) $(LDFLAGS) -o $@ $(OBJS) $(CEFLIB) $(ZLIB) $(CISLIB)

obj/%.o:	%.c
		$(CC) -c $(CFLAGS) $< -o $@

obj/%.o:	%.for
		$(FC) -c $(FFLAGS) $< -o $@
