#**************************************************************
#  
#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
#  
#  Unless required by applicable law or agreed to in writing,
#  software distributed under the License is distributed on an
#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.
#  
#**************************************************************



# --- Targets ------------------------------------------------------

.IF "$(GUI)"=="UNX"
# uppercase and no filename extension for txt
SYSTEXTDOCS=$(foreach,i,$(alllangiso) $(MISC)$/$(GUI)$/README_$i)
SYSHTMLDOCS=$(SYSTEXTDOCS:+".html")
.ELSE		# "$(GUI)"=="UNX"
SYSTEXTDOCS=$(foreach,i,$(alllangiso) $(MISC)$/$(GUI)$/readme_$i.txt)
SYSHTMLDOCS=$(SYSTEXTDOCS:s/.txt/.html/)
.ENDIF		# "$(GUI)"=="UNX"

.IF "$(WITH_LANG)"!=""
MERGEDXRM=$(COMMONMISC)$/$(TARGET)$/readme.xrm
.ELSE		# "$(WITH_LANG)"!=""
MERGEDXRM=.$/readme.xrm
.ENDIF		# "$(WITH_LANG)"!=""

.INCLUDE : target.mk

ALLTAR : $(SYSTEXTDOCS) $(SYSHTMLDOCS)

$(COMMONMISC)$/readme.dtd : ..$/readme.dtd  
	$(MKDIRHIER) $(MISC)$/$(GUI)
	$(COPY) $< $@

virtual : $(MERGEDXRM) $(COMMONMISC)$/readme.dtd $(PRJ)$/docs/readme.xsl

$(MISC)$/readme_text.xsl : virtual
 	$(SED) '' < ..$/readme.xsl > $@

$(MISC)$/$(GUI)$/$(eq,$(GUI),WNT readme README)_%.html : 'virtual'
	@@-$(MKDIRHIER) $(@:d)
	$(XSLTPROC) --nonet --novalid -o $@ \
	--stringparam os1 $(OS)	--stringparam gui1 $(GUI)	--stringparam com1  $(COM) \
	--stringparam cp1 $(CPUNAME)	--stringparam type html	--stringparam lang1 $* \
	..$/readme.xsl	$(MERGEDXRM)
.IF "$(GUI)"=="UNX"
	chmod g+w $(MISC)$/$(GUI)
.ENDIF			# "$(GUI)"=="UNX"

$(MISC)$/$(GUI)$/$(eq,$(GUI),OS2 readme README)_%.html : 'virtual'
	@@-$(MKDIRHIER) $(@:d)
	$(XSLTPROC) --nonet --novalid -o $@ \
	--stringparam os1 $(OS)	--stringparam gui1 $(GUI)	--stringparam com1  $(COM) \
	--stringparam cp1 $(CPUNAME)	--stringparam type html	--stringparam lang1 $* \
	..$/readme.xsl	$(MERGEDXRM)

# no percent-rule to avoid ambiguous inference chains for README_<lang>.html 
$(SYSTEXTDOCS) : $(MISC)$/readme_text.xsl
	@@-$(MKDIRHIER) $(@:d)
	$(XSLTPROC) --nonet --novalid -o $@ \
	--stringparam os1 $(OS)	--stringparam gui1 $(GUI)	--stringparam com1  $(COM) \
	--stringparam cp1 $(CPUNAME)	--stringparam type text	--stringparam lang1 $(@:b:s/readme_//:s/README_//) \
	$<	$(MERGEDXRM)

.IF "$(GUI)"=="UNX"
	chmod g+w $(MISC)$/$(GUI)
.ENDIF			# "$(GUI)"=="UNX"

