########################################################################
# 
#    	MAKEFILE FOR STAND-ALONE UX CODE APPLICATION.
#
#       EXECUTABLE      is the name of the executable to be created 
#       MAIN            is the .o file containing your main() function
#       INTERFACES      is a list of the generated C code files 
#       APP_OBJS        is a (possibly empty) list of the object code
#                       files that form the non-interface portion of
#                       your application 
#
#       In the first three statements, the variables on the right 
#	of the equal sign will be replaced with their corresponding 
#       values when the makefile is automatically generated. 
#
#  	$Date: 2005-11-16 14:21:06 $ 		$Revision: 1.2 $
# 
# 051111        last modif
#########################################################################


include ../../../local/default.mk


MAIN		= XEchelle.o
INTERFACES	= 	MainShell.o \
	SearchShell.o \
	CalibShell.o \
	file_list.o \
	file_selection.o \
	RebinShell.o \
	lincat_list.o \
	SessionShell.o \
	extin_dialog.o \
	resid_dialog.o \
	HelpShell.o \
	RotateShell.o \
	OrderShell.o \
	BackgroundShell.o \
	ExtractionShell.o \
	SkyShell.o \
	FlatShell.o \
	RespShell.o \
	MergeShell.o 

EXEC		= echelle
EXECUTABLE	= ../../exec/$(EXEC).exe




APPL_OBJS	= midasutil.o alloc.o cb_list.o misc.o splib.o
UX_DIR		= ../../GraphLib/libsrc/$(UIMX)

LINC		= -I../incl -I../../incl

UX_LIBPATH	= -L../../lib

X_CFLAGS	=
MOTIF_CFLAGS	=

CFLAGS		+= $(C_OPT) $(DEBUG) $(GUI_OPT) \
		  $(LINC) -I$(INC) -I$(UX_DIR)/include \
		  $(X_CFLAGS) $(MOTIF_CFLAGS) -DXOPEN_CATALOG \
		  $(XMINC)    $(X11INC)
 
# The following object files are provided to work around a motif bug.
# They are not necessarily needed to compile your application.
LIBPATH		= $(X11_LIBPATH) $(MOTIF_LIBPATH)
XLIB		= $(LIBPATH) $(X_LIBS) $(XOPEN_LIBS)

LLIB		= $(UX_LIBPATH) -lxech -luimx -lcom -L$(LIBDIR) -lxcon -lmidas  
LIBS		= $(LIBDIR)/libmidas.a

OBJS = $(MAIN) $(INTERFACES) $(APPL_OBJS)  

all: $(EXECUTABLE) 

$(EXECUTABLE): $(OBJS) $(LIBS)
	$(LDCC) $(OBJS) $(LLIB) $(XLIB) $(MLIB) $(SLIB) -o $(EXECUTABLE)
	$(STRIP) $(EXECUTABLE)
	@echo "done"

clean:
	$(RM) *.o

clean_exec:
	$(RM) $(EXECUTABLE)


tmp_makefile: makefile
	sed -e 's/^MAIN.*//' \
	    -e 's/^INTERFACES.*//' \
	    -e 's/^CMAIN/MAIN/' \
	    -e 's/^CINTERFACES/INTERFACES/' \
	    -e 's/\([^^]\)\.o/\1\.o/g'  \
	    -e 's/^all: tmp_makefile/all:/' makefile > tmp_makefile
	rm -f makefile
	mv tmp_makefile makefile
