#!gmake
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the 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
# http://www.mozilla.org/MPL/
#
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****

DEPTH		= ../../..

include $(DEPTH)/config/config.mk

ifndef JAVA_OR_NSJVM
LOCAL_JMC_SUBDIR =  ../jmcgen/include
LOCAL_JMC_SRC_SUBDIR =  ../jmcgen/src
endif

MODULE		= libfont
LIBRARY_NAME	= font

CSRCS		= libfont.c

CPPSRCS		= cdoer.cpp \
		  cf.cpp \
		  cfmi.cpp \
		  cfb.cpp \
		  crc.cpp \
		  f.cpp \
		  fmi.cpp \
		  fb.cpp \
		  rc.cpp \
		  wfSzList.cpp \
		  wffpPeer.cpp \
		  wffpCat.cpp \
		  wfFCache.cpp \
		  wfList.cpp \
		  wfMime.cpp \
		  wfStream.cpp \
		  wfMisc.cpp \
		  wfDlm.cpp \
		  $(NULL)

EXPORTS		= nf.h coremem.h

REQUIRES	= libfont java jtools dbm nspr img layer util pref js htmldlgs security

JMC_GEN		= Mcf Mcfb Mcfmi Mcrc Mcdoer
JMC_GEN_FLAGS	= -cimpl

include $(DEPTH)/config/rules.mk

INCLUDES	+= -I.

SDK_TARGET	= producer-sdk
SDK_NAME	= FontProducer-sdk-v1.0
SDK_DIR		= $(OBJDIR)/$(SDK_TARGET)

ifndef JAVA_OR_NSJVM
export:: 
	@echo "Copying JMC src files from $(LOCAL_JMC_SRC_SUBDIR)/*.c to cwd"
	@for FILE in $(LOCAL_JMC_SRC_SUBDIR)/*.c ;\
	 do \
	   $(NSINSTALL) -t $${FILE} . ;\
	 done
endif

ifneq ($(OS_ARCH),OS2)
export:: 
	@echo "Fixing jmc generated header file : $(JMC_GEN_DIR)/Mcfb.h"
	@ls -l $(JMC_GEN_DIR)/Mcfb.h
	@if fgrep cfbImpl2Object\( $(JMC_GEN_DIR)/Mcfb.h ;\
	then \
		echo "/cfbImpl2Object(\n.s/cfbImpl2Object(/cfbImpl2Object_1(/\n1\n/Object2cfbImpl(\n.s/Object2cfbImpl(/Object2cfbImpl_1(/\nw\nq\n" | (ed $(JMC_GEN_DIR)/Mcfb.h; echo) ;\
		echo "/cfbImpl2Object(\n.s/cfbImpl2Object(/cfbImpl2Object_2(/\n1\n/Object2cfbImpl(\n.s/Object2cfbImpl(/Object2cfbImpl_2(/\nw\nq\n" | (ed $(JMC_GEN_DIR)/Mcfb.h; echo) ;\
		echo "Fixed : $(JMC_GEN_DIR)/Mcfb.h" ;\
	else \
		echo "No fix required. Skipping..." ;\
	fi
endif

$(SDK_TARGET):: $(PRODUCER_SDK_FILES)
	echo "Generating producer sdk..."
	$(NSINSTALL) -m 0444 $(PUBLIC)/libfont/* $(SDK_DIR)/$(SDK_NAME)/include
	$(NSINSTALL) -m 0444 Pcfp.h $(JMC_GEN_DIR)/Mcfp.h $(SDK_DIR)/$(SDK_NAME)/include
	$(NSINSTALL) -m 0444 Pcrf.h $(JMC_GEN_DIR)/Mcrf.h $(SDK_DIR)/$(SDK_NAME)/include
	$(NSINSTALL) -m 0444 $(DEPTH)/include/xp_mem.h $(SDK_DIR)/$(SDK_NAME)/include
	$(NSINSTALL) -m 0444 $(DEPTH)/include/xp_core.h $(SDK_DIR)/$(SDK_NAME)/include
	$(NSINSTALL) -m 0444 $(PUBLIC)/jtools/jmc.h $(SDK_DIR)/$(SDK_NAME)/include
	$(NSINSTALL) -m 0444 $(PUBLIC)/java/jritypes.h $(SDK_DIR)/$(SDK_NAME)/include
	$(NSINSTALL) -m 0444 $(PUBLIC)/java/jri_md.h $(SDK_DIR)/$(SDK_NAME)/include
	$(NSINSTALL) -m 0444 $(PUBLIC)/java/jri.h $(SDK_DIR)/$(SDK_NAME)/include
	$(NSINSTALL) -m 0444 $(PUBLIC)/nspr/prtypes.h $(SDK_DIR)/$(SDK_NAME)/include
	$(NSINSTALL) -m 0444 $(PUBLIC)/nspr/prcpucfg.h $(SDK_DIR)/$(SDK_NAME)/include
	$(NSINSTALL) -m 0664 cfp.c crf.c $(SDK_DIR)/$(SDK_NAME)/src
	$(NSINSTALL) -m 0444 $(JMC_GEN_DIR)/Mcfp.c $(JMC_GEN_DIR)/Mcrf.c $(SDK_DIR)/$(SDK_NAME)/src
	$(NSINSTALL) -m 0444 ../sdk/unix/makefile.sgi $(SDK_DIR)/$(SDK_NAME)/unix
	(cd $(SDK_DIR); tar cvf - $(SDK_NAME)) | gzip -cf > $(OBJDIR)/$(SDK_NAME).tar.gz; rm -rf $(SDK_DIR)
