# BEGIN LICENSE BLOCK
# Version: CMPL 1.1
#
# The contents of this file are subject to the Cisco-style Mozilla Public
# License Version 1.1 (the "License"); you may not use this file except
# in compliance with the License.  You may obtain a copy of the License
# at www.eclipse-clp.org/license.
# 
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
# the License for the specific language governing rights and limitations
# under the License. 
# 
# The Original Code is  The ECLiPSe Constraint Logic Programming System. 
# The Initial Developer of the Original Code is  Cisco Systems, Inc. 
# Portions created by the Initial Developer are
# Copyright (C) 2006 Cisco Systems, Inc.  All Rights Reserved.
# 
# Contributor(s): ___________________________________. 
# 
# END LICENSE BLOCK
#
# Makefile for FlexLM interface
#
# $Id: Makefile.in,v 1.3 2009/07/16 09:11:23 jschimpf Exp $
#

ARCH = @ARCH@
top_srcdir = @top_srcdir@
PREFIX = @prefix@

AUX_ECLIPSE = $(PREFIX)/bin/$(ARCH)/eclipse

CC = @CC@
LD = @LD@
DYLD = @DYLD@
AR = @AR@
CFLAGS = @CFLAGS@
OBJ_SUFFIX = @OBJECTS_SUFFIX@
DYNLDFLAGS = @DYNLDFLAGS@
INSTALL_NAME = @INSTALL_NAME@
FLEXLMDIR = @FLEXLMDIR@

ECLIBS = -L$(PREFIX)/lib/$(ARCH) -leclipse

CPPFLAGS = -I$(PREFIX)/include/$(ARCH) $(@CPPFLAGS_WITH_WITHOUT_FLEXLM@)
CPPFLAGS_WITHOUT_FLEXLM = 
CPPFLAGS_WITH_FLEXLM = -DDHAVE_FLEXLM -I$(FLEXLMDIR)

LIBS_FLEXLM = $(@LIBS_WITH_WITHOUT_FLEXLM@)
LIBS_WITHOUT_FLEXLM=
LIBS_WITH_FLEXLM=$(LIBS_WITH_FLEXLM_$(ARCH))
LIBS_WITH_FLEXLM_i386_nt = $(FLEXLMDIR)/chkstk.s pteclipse.def $(FLEXLMDIR)/lm_new_md.obj $(FLEXLMDIR)/lmgr_md.lib -lcomctl32 -lcomdlg32 -lnetapi32
LIBS_WITH_FLEXLM_sparc_sunos5 = $(FLEXLMDIR)/lm_new.o -L$(FLEXLMDIR) -llmgr
LIBS_WITH_FLEXLM_i386_linux = $(LIBS_WITH_FLEXLM_sparc_sunos5)
LIBS_WITH_FLEXLM_x86_64_linux = $(LIBS_WITH_FLEXLM_sparc_sunos5)
LIBS_WITH_FLEXLM_i386_sunos5 = $(LIBS_WITH_FLEXLM_sparc_sunos5)
LIBS_WITH_FLEXLM_x86_64_sunos5 = $(LIBS_WITH_FLEXLM_sparc_sunos5)

FILES_FLEXLM = $(@FILES_WITH_WITHOUT_FLEXLM@)
FILES_WITHOUT_FLEXLM =
FILES_WITH_FLEXLM = $(PREFIX)/lib/flexlm.eci


PT_SOURCES = bip_pt.c
PT_OBJS = $(PT_SOURCES:.c=.o)

PT_TARGETS = $(PREFIX)/lib/$(ARCH)/pteclipse.$(OBJ_SUFFIX) 


# install is configured as either install_all or install_cross
install:	@MAKE_TARGET@
install_all:	install_cross $(FILES_FLEXLM)
install_cross:	$(PT_TARGETS)


$(PREFIX)/lib/$(ARCH)/pteclipse.$(OBJ_SUFFIX): $(PT_SOURCES)
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $(PT_SOURCES)
	$(DYLD) $(DYNLDFLAGS) $(INSTALL_NAME) -o $@ \
		$(PT_OBJS) \
		$(LIBS_FLEXLM) \
		$(ECLIBS)


clean:	ecoclean archclean
	rm -f $(FILES_WITH_FLEXLM)

archclean:
	rm -f $(PT_TARGETS)

ecoclean:


# general installation rules

PERM = a+r,u+w,go-w
DIRPERM = 2755

.SUFFIXES:	$(SUFFIXES) .ecl .eci .eco

%/.stamp:
	mkdir -p $(@D)
	@/bin/chmod $(DIRPERM) $(@D)
	@touch $@; /bin/chmod $(PERM) $@


$(PREFIX)/lib/%.eci:	%.ecl $(PREFIX)/lib/.stamp
	$(AUX_ECLIPSE) -e 'lib(document),icompile("$(*F)","$(@D)")'
	-@/bin/chmod $(PERM) $@

$(PREFIX)/lib/%.ecl:	%.ecl $(PREFIX)/lib/.stamp
	/bin/cp $< $@
	@/bin/chmod $(PERM) $@

