1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
|
#
#
#
NULL=
MODULE=xmlsec
SOURCE_DIR=$(top_srcdir)/src
SOURCE_DIR2=$(top_builddir)/src
INCLUDE_DIR=$(top_srcdir)/include
INCLUDE_DIR2=$(top_builddir)/include
SCAN_DIR=$(builddir)
SGML_DIR=$(builddir)/sgml.tmp
EXAMPLES_DIR=$(SGML_DIR)/examples
SOURCE_CODE_DIR=$(builddir)/code
GTKDOC_MKDB_OUTPUT_DIR=$(builddir)/xml
# We need to copy some files to make gkdoc happy that
# everything is in one folder
MAIN_SGML_FILE=$(SGML_DIR)/xmlsec.sgml
MAIN_SGML_SRC_FILE=$(srcdir)/src/xmlsec.sgml
SGML_CHAPTERS_DIR=$(SGML_DIR)/chapters
SGML_CHAPTERS_SRC_DIR=$(srcdir)/src/chapters
EXTRA_DIST = \
$(srcdir)/src \
$(srcdir)/images \
$(srcdir)/style.css \
$(NULL)
SOURCE_FILES_TO_COPY = \
$(srcdir)/src \
$(srcdir)/images \
$(srcdir)/style.css \
$(srcdir)/*.html \
$(srcdir)/*.png \
$(NULL)
CRYPTO_LIBS_LIST = \
openssl \
nss \
gnutls \
gcrypt \
mscrypto \
mscng \
$(NULL)
#
# We need to pre-process original source files
# because gtkdoc does not understand some C features
#
SOURCE_CODE_FILES=\
$(shell find $(SOURCE_DIR) -name '*.c' -print ) \
$(shell find $(SOURCE_DIR2) -name '*.c' -print ) \
$(shell find $(INCLUDE_DIR) -name '*.h' -a ! -name "symbols.h" -print ) \
$(shell find $(INCLUDE_DIR2) -name '*.h' -a ! -name "symbols.h" -print )
EXAMPLES_SOURCE_DIR=$(top_srcdir)/examples
EXAMPLES_SOURCE_FILES=\
$(shell find $(EXAMPLES_SOURCE_DIR) -name '*.c' -print) \
$(shell find $(EXAMPLES_SOURCE_DIR) -name '*.xml' -print)
#
# This script removes gtkdoc crap from final html
#
REMOVE_GTKDOCLINK=$(top_srcdir)/scripts/remove-gtkdoclink.pl
# docs is legacy
all: docs
# if build API docs, then we also have xsltproc
if BUILD_API_DOCS
docs: html-cleanup
else
docs:
@( \
echo "Copying api-docs..."; \
if [ z"$(srcdir)" != z"$(builddir)" -a z"`uname`" != z"Darwin" ]; \
then \
$(CP) -ru $(SOURCE_FILES_TO_COPY) $(builddir)/ ; \
fi \
)
endif
html-cleanup: html
@( echo "Cleaning up result files"; \
$(PERL) $(REMOVE_GTKDOCLINK) `find . -name "*.html" -print` \
)
# need to cleanup "bad" chars
html: sgml $(MAIN_SGML_FILE) $(SGML_CHAPTERS_DIR) xmlsec-index
$(GTKDOC_MKHTML) xmlsec $(MAIN_SGML_FILE)
$(SGML_CHAPTERS_DIR): $(SGML_CHAPTERS_SRC_DIR) $(SGML_CHAPTERS_DIR)/.sentinel
$(CP) -ru $(SGML_CHAPTERS_SRC_DIR)/* $(SGML_CHAPTERS_DIR)
$(MAIN_SGML_FILE): $(MAIN_SGML_SRC_FILE)
$(CP) -u $(MAIN_SGML_SRC_FILE) $(MAIN_SGML_FILE)
#
# Prepeare sgml files from sources for each library. We are also
# doing some "magic" here by automatically adding links to XML DSig and
# XML Enc specification, we also remove "Ptr" from the end of the link
# targets to make more references.
#
# We also fix a bunch of stupid errors from gtkdoc
#
sgml: sgml-base
(for i in `find $(SGML_DIR) -name "*.sgml" -or -name "*.xml" -print` ; do \
echo "Fixing up '$$i'" ; \
cat $$i | \
sed 's!\(<dsig:\)\([^/]*\)\(\/>\)!\<dsig:\2\/\>!g' | \
sed 's!\(<enc:\)\([^/]*\)\(\/>\)!\<enc:\2\/\>!g' | \
sed 's!\(<dsig:\)\(\w*\)\(>\)!\<dsig:\2\/\>!g' | \
sed 's!\(<enc:\)\(\w*\)\(>\)!\<enc:\2\/\>!g' | \
sed 's!\(<dsig:\)\([^/]*\)\(\/>\)!<ulink URL=\"http://www.w3.org/TR/xmldsig-core/#sec-\2\">\1\2\3</ulink>!g' | \
sed 's!\(<enc:\)\([^/]*\)\(\/>\)!<ulink URL=\"http://www.w3.org/TR/xmlenc-core/#sec-\2\">\1\2\3</ulink>!g' | \
sed 's!<para \/>!<para></para>!g' | \
sed 's!linkend=\"\(.*\)Ptr\"!linkend=\"\1\"!g' | \
sed 's!<colspec [^/]*\/>!!g' | \
sed 's!<programlisting language="C"!<programlisting!g' | \
sed 's!\%gtkdocentities;!!g' | \
$(PERL) -pe 's!title>\n!title>!g' | \
$(PERL) -pe 's!title>\n!title>!g' | \
$(PERL) -pe 's!<\/title><\/refsect1>\n!<\/title><para><\/para><\/refsect1>!g' | \
$(PERL) -pe 's!para>\n!para>!g' > \
$$i.tmp; \
mv -f $$i.tmp $$i; \
done);
# gtkdoc-mkdb doesn't support --output-dir thus we have to "hack" it a litle bit
sgml-base: scan $(SGML_DIR)/.sentinel
@( \
echo "Create DocBook files for xmlsec-core" ; \
rm -rf $(GTKDOC_MKDB_OUTPUT_DIR) $(SGML_DIR)/base ; \
$(GTKDOC_MKDB) --module=xmlsec \
--xml-mode \
--main-sgml-file=$(SGML_DIR)/xmlsec-base.sgml \
--source-dir=$(SOURCE_CODE_DIR)/src/base \
--source-dir=$(SOURCE_CODE_DIR)/include/xmlsec/base ; \
mv $(GTKDOC_MKDB_OUTPUT_DIR) $(SGML_DIR)/base ; \
);
@(for i in $(CRYPTO_LIBS_LIST) ; do \
echo "Create DocBook files for xmlsec-$$i" ; \
rm -rf $(GTKDOC_MKDB_OUTPUT_DIR) $(SGML_DIR)/$$i ; \
$(GTKDOC_MKDB) --module=xmlsec-$$i \
--xml-mode \
--main-sgml-file=$(SGML_DIR)/xmlsec-$$i.sgml \
--source-dir=$(SOURCE_CODE_DIR)/src/$$i \
--source-dir=$(SOURCE_CODE_DIR)/include/xmlsec/$$i ; \
mv $(GTKDOC_MKDB_OUTPUT_DIR) $(SGML_DIR)/$$i ; \
done);
scan: SOURCE_CODEs example_sources
@( \
echo "Scanning source code for xmlsec-core" ; \
$(GTKDOC_SCAN) --module=xmlsec \
--rebuild-sections \
--output-dir=$(SCAN_DIR) \
--source-dir=$(SOURCE_CODE_DIR)/src/base \
--source-dir=$(SOURCE_CODE_DIR)/include/xmlsec/base ; \
);
@(for i in $(CRYPTO_LIBS_LIST) ; do \
echo "Scanning source code for xmlsec-$$i" ; \
$(GTKDOC_SCAN) --module=xmlsec-$$i \
--rebuild-sections \
--output-dir=$(SCAN_DIR) \
--source-dir=$(SOURCE_CODE_DIR)/src/$$i \
--source-dir=$(SOURCE_CODE_DIR)/include/xmlsec/$$i ; \
done);
#
# Prepare source files by coping them to "code" folder and
# removing XMLSEC_EXPORT_* stuff that makes gtkdoc crazy
#
SOURCE_CODEs: $(SOURCE_CODE_FILES) $(SOURCE_CODE_DIR)/.sentinel SOURCE_CODEs_cleanup
@echo "Preprocessing source files into '$(SOURCE_CODE_DIR)' ..."
@mkdir -p $(SOURCE_CODE_DIR)/src/base $(SOURCE_CODE_DIR)/include/xmlsec/base
@( \
for i in $(SOURCE_CODE_FILES) ; do \
folder_name=`echo "$$i" | \
sed 's#$(top_srcdir)/##' | \
sed 's#$(top_builddir)/##' | \
sed 's#/[^/]*$$##'`; \
file_name=`echo "$$i" | \
sed 's#.*/##'`; \
mkdir -p "$(SOURCE_CODE_DIR)/$$folder_name"; \
cat "$$i" | \
sed 's/#if.*//' | \
sed 's/#el.*//' | \
sed 's/#end.*//' | \
sed 's/XMLSEC_CRYPTO_EXPORT//' | \
sed 's/XMLSEC_EXPORT_VAR//' | \
sed 's/XMLSEC_EXPORT//' | \
sed 's/XMLSEC_ERRORS_PRINTF_ATTRIBUTE//' > \
$(SOURCE_CODE_DIR)/$$folder_name/$$file_name; \
done);
-@mv -f $(SOURCE_CODE_DIR)/src/*.c $(SOURCE_CODE_DIR)/src/base
-@mv -f $(SOURCE_CODE_DIR)/include/xmlsec/*.h $(SOURCE_CODE_DIR)/include/xmlsec/base
-@rm -f $(SOURCE_CODE_DIR)/include/xmlsec/*/symbols.h
SOURCE_CODEs_cleanup: $(SOURCE_CODE_DIR)/.sentinel
@rm -rf $(SOURCE_CODE_DIR)/*
#
# Create index for all functions. For macros and defines need to add -CAPS suffix
#
xmlsec-index: scan $(SGML_DIR)/.sentinel
@grep -h '<NAME>.*</NAME>' $(SCAN_DIR)/xmlsec-*decl.txt | \
grep -v '<NAME>extern</NAME>' | \
sort -u | \
sed 's#_#-#g' | \
sed 's#<NAME>\([^-]*\)-\([^<]*\)</NAME>#<listitem><para><link linkend=\"\1-\2-CAPS\">\1-\2</link></para></listitem>#g' | \
sed 's#<NAME>\([^<]*\)</NAME>#<listitem><para><link linkend=\"\1\">\1</link></para></listitem>#g' > \
$(SGML_DIR)/xmlsec-index.sgml
#
# The following code converts C example file to sgml RefEntry files.
# We get file title from a string "XML Security Library example: ..."
# which is usually placed at the top of the file. Also all "unsafe" xml
# characters (<, >, &) are escaped.
#
example_sources: $(EXAMPLES_DIR)/.sentinel
@echo "Preprocessing example source files into '$(EXAMPLES_DIR)' ..."
@rm -rf $(EXAMPLES_DIR)/*
@(for i in $(EXAMPLES_SOURCE_FILES) ; do \
file_name=`echo $$i | sed 's#.*/##' | sed 's#\..*$$##'`; \
file_ext=`echo $$i | sed 's#.*/##' | sed 's#.*\.##'`; \
echo Converting $$file_name.$$file_ext to $$file_name.sgml ...; \
file_title=`cat $$i | grep 'XML Security Library example: ' | sed 's#^.*: *##'`; \
echo "<sect2 id=\"xmlsec-example-$$file_name\" >" > \
$(EXAMPLES_DIR)/$$file_name.sgml; \
echo "<title>$$file_name.$$file_ext</title><para><informalexample><programlisting>" >> \
$(EXAMPLES_DIR)/$$file_name.sgml; \
cat $$i | \
sed "s#&#\&#g" | \
sed "s#<#\<#g" | \
sed "s#>#\>#g" >> \
$(EXAMPLES_DIR)/$$file_name.sgml; \
echo "</programlisting></informalexample></para></sect2>" >> \
$(EXAMPLES_DIR)/$$file_name.sgml; \
done);
# A single pattern rule will create all appropriate folders as required
# otherwise make (annoyingly) deletes it
.PRECIOUS: %/.sentinel
%/.sentinel:
@echo "Creating folder '${@D}' ..."
mkdir -p ${@D}
touch $@
dist-hook:
@cp -p $(srcdir)/*.html $(srcdir)/*.png $(distdir)/
(for i in `find $(distdir) -name ".sentinel" -print` ; do \
echo "Removing some files '$$i' before dist ... " ; \
rm $$i ; \
done )
(for i in `find $(distdir) -name "*.sgml.bak" -print` ; do \
echo "Removing some files '$$i' before dist ... " ; \
rm "$$i" ; \
done ; )
clean-local:
-rm -rf $(SOURCE_CODE_DIR) $(EXAMPLES_DIR) $(SCAN_DIR)/*.txt $(SGML_DIR) $(GTKDOC_MKDB_OUTPUT_DIR)
-rm -f *.stamp *.types index.sgml
@( if [ z"$(builddir)" != z"$(srcdir)" ] ; then \
(chmod -R u+w $(builddir)/src || true) && rm -rf $(builddir)/src ; \
(chmod -R u+w $(builddir)/images || true) && rm -rf $(builddir)/images ; \
(chmod -R u+w $(builddir)/*.png || true) && rm -rf $(builddir)/*.png ; \
fi ; )
distclean-local: clean-local
maintainer-clean-local: clean-local
-rm -f *.html
|