# -*- Makefile -*-
#
#  MICO --- an Open Source CORBA implementation
#  Copyright (c) 1997-2001 by The Mico Team
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Library General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
#
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Library General Public License for more details.
#
#  You should have received a copy of the GNU Library General Public
#  License along with this library; if not, write to the Free
#  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#  For more information, visit the MICO Home Page at
#  http://www.mico.org/
#

prefix		= /usr/pkg
exec_prefix	= ${prefix}
SRCDIR		= /tmp/pkgbuild/devel/mico/work.earmv6hf/mico/.
INSTDIR		= /usr/pkg
SHARED_INSTDIR	= /usr/pkg/share

OSTYPE          = unix
# We need the compiler type, not just the os
HAVE_MINGW	= 
HAVE_CYGWIN	= 

HAVE_REPO	= no
HAVE_PRELINK	= no
HAVE_JDK	= no
HAVE_SHARED	= yes
HAVE_STATIC	= yes
HAVE_DYNAMIC	= yes
HAVE_FINAL	= no
HAVE_NAMESPACE  = yes
HAVE_EXCEPTIONS = yes
HAVE_SHARED_EXCEPTS = yes
HAVE_ORB_EXCEPTS = yes
HAVE_THREADS	= yes
HAVE_QT		= no
HAVE_GTK        = no
HAVE_X11	= no
HAVE_TCL	= no
HAVE_SSL	= yes
HAVE_PGSQL      = no
HAVE_BLUETOOTH  = no
HAVE_MEMCHECK   = no
USE_MEMTRACE    = no

USE_CCM		= no
USE_NAMING	= yes
USE_EVENTS	= yes
USE_STREAMS	= no
USE_RELSHIP	= no
USE_PROPERTY	= yes
USE_TRADER      = no
USE_TIME	= yes
USE_CSL2        = no
USE_CSIV2	= yes
USE_LIFE	= no
USE_EXTERN	= no
USE_WIRELESS	= no
USE_WIRELESS_HOME	= no
USE_WIRELESS_ACCESS	= no
USE_WIRELESS_TERMINAL	= no

USE_PCH_DIR	= no

SHELL           = /bin/sh
RANLIB          = ranlib
AR              = ar
ARFLAGS		= rc
FLEX            = flex
BISON           = yacc
TCLSH		= tclsh
MOC		= 
CXX		= c++ 
PICFLAGS	= -DPIC -fPIC
NOPICFLAGS	=
EHFLAGS		= 
EHOPTFLAGS	= 
NOEHFLAGS	= -fno-exceptions
DLFLAGS		= 
CPPFLAGS	= -I/usr/pkg/include
CXXFLAGS	=   -O2  -Wall -D_FORTIFY_SOURCE=2 -I/usr/pkg/include -D_REENTRANT -D_THREAD_SAFE 
PCHFLAGS	= 
PRELINK_FLAG	= 
CC		= gcc
CFLAGS		= -O2  -Wall -D_FORTIFY_SOURCE=2 -I/usr/pkg/include 
X_CFLAGS	= 
X_LIBS		= 
QT_CXXFLAGS	= 
QT_LIBS		= 
GTK_CFLAGS      = 
GTK_LIBS        = 
TCL_LIBS        = 
PURE_LDFLAGS	= -L/usr/pkg/lib -Wl,-R/usr/pkg/lib 
LDFLAGS		= $(PURE_LDFLAGS) $(DLFLAGS)
LDSO		= $(SRCDIR)/admin/mico-shld
LDSOFLAGS	= -fPIC
SOEXT		= so
POSTLD		= true
RM              = rm -f
LN		= ln -f -s
MKDIR           = mkdir
JAVAC           = javac
JCUP            = java java_cup.Main
LATEX		= latex
BIBTEX		= bibtex
DVIPS		= dvips
DVIPDFM		= dvipdfm
LATEX2HTML	= latex2html
FIG2DEV		= fig2dev
MKFAQ           = $(SRCDIR)/admin/mkfaq
IDL		= $(SRCDIR)/idl/idl
IDLGEN		= $(SRCDIR)/idl/idl
CCMGEN          = $(SRCDIR)/ccm/mico-ccm
MKDEPEND	= $(SRCDIR)/admin/mkdepend
# on some Solaris systems strip does not support ELF binaries ...
IBINCMD         = $(SRCDIR)/admin/install-sh -c -m 755
# mode 555 is a tribute to HP-UX
ILIBCMD         = $(SRCDIR)/admin/install-sh -c -m 555
IMANCMD         = $(SRCDIR)/admin/install-sh -c -m 644
IINCCMD         = $(SRCDIR)/admin/install-sh -c -m 644
IDIRCMD         = $(SRCDIR)/admin/mkinstalldirs
ISCRIPTCMD      = $(SRCDIR)/admin/install-sh -c -m 755
ISRCCMD         = $(SRCDIR)/admin/install-sh -c -m 644

CONFLIBS	= -lssl -lcrypto -lelf -lm  -lpthread 
SHLIBS		= -lpthread
CURSESLIBS	= -lcurses -ltermcap -lssl -lcrypto -lelf -lm  -lpthread
VERSION		= $(shell tr b \. < $(SRCDIR)/VERSION)


ifeq ($(HAVE_SHARED), yes)
export LD_LIBRARY_PATH := $(SRCDIR)/libs:$(LD_LIBRARY_PATH)
export LIBPATH         := $(SRCDIR)/libs:$(LIBPATH)
export SHLIB_PATH      := $(SRCDIR)/libs:$(SHLIB_PATH)
export PATH            := $(SRCDIR)/libs:$(PATH)
export DYLD_LIBRARY_PATH := $(SRCDIR)/libs:$(DYLD_LIBRARY_PATH)
LIBMICO		       = libmico$(VERSION).$(SOEXT)
LIBMICOIR	       = libmicoir$(VERSION).$(SOEXT)
else
LIBMICO		       = libmico$(VERSION).a
LIBMICOIR              = libmicoir$(VERSION).a
endif

ifeq ($(HAVE_SHARED_EXCEPTS), yes)
LIBMICOCOSS	       = libmicocoss$(VERSION).$(SOEXT)
LIBMICOAUX	       = libmicoaux$(VERSION).$(SOEXT)
else
LIBMICOCOSS	       = libmicocoss$(VERSION).a
LIBMICOAUX	       = libmicoaux$(VERSION).a
endif

LDMICO                 = -lmico$(VERSION)
LDMICOIR               = -lmicoir$(VERSION)
LDMICOCOSS             = -lmicocoss$(VERSION)
LDMICOAUX              = -lmicoaux$(VERSION)
LDMICOCCM              = -lmicoccm$(VERSION)

ifeq ($(OSTYPE), windows)
ifeq ($(HAVE_SHARED), yes)
export PATH           := $(SRCDIR)/libs:$(PATH)
NODOTVERSION           = $(shell tr -d \. < $(SRCDIR)/VERSION)
LIBMICO               := mico$(NODOTVERSION).dll
LDMICO                := -lmico$(NODOTVERSION)
LIBMICOIR              = libmicoir$(VERSION).a
LIBMICOAUX	       = libmicoaux$(VERSION).a
LIBMICOCOSS	       = libmicocoss$(VERSION).a
endif
endif

export PATH           := $(SRCDIR)/cpp:$(PATH):.


main_target: all


.SUFFIXES: .java .class .cup .tex .dvi .ps .fig .eps .gif .moc .pic.o .ll .yy
.SUFFIXES: .$(SOEXT)


# delete builtin rules ...
%.c: %.y
%.c: %.l
%.dvi: %.tex
%.o: %.cc

%.pic.o: %.cc
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(PICFLAGS) -c $< -o $@

%.o: %.cc
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(NOPICFLAGS) -c $< -o $@

%.cc: %.ll
	$(FLEX) -B -8 -o$@ $<

%.cc: %.yy
	$(BISON) -d -t -v -o $*.c $<
	mv $*.c $*.cc

%.c: %.y
	$(BISON) -d -t -v -o $*.c $<

%.class: %.java
	$(JAVAC) $<

%.java: %.cup
	$(JCUP) < $<

%.dvi: %.tex
	$(LATEX) $<
	if grep Rerun `basename $< .tex`.log >/dev/null; then $(LATEX) $< ; fi
	if grep citation `basename $< .tex`.aux >/dev/null; then \
		$(BIBTEX) `basename $< .tex`; \
	fi
	$(LATEX) $<
	if grep Rerun `basename $< .tex`.log >/dev/null; then $(LATEX) $< ; fi

%.ps: %.dvi
	$(DVIPS) $< -o $@

%.pdf: %.dvi
	$(DVIPDFM) -o $@ $<

%.eps: %.fig
	$(FIG2DEV) -L ps < $< > $@

%.ps: %.gif
	giftopnm $< | pnmtops -noturn > $@

%.moc: %.cc
	$(MOC) $< -o $@

%.moc: %.h
	$(MOC) $< -o $@
