| 1 | ###############################################################################
|
|---|
| 2 | # airboot-manual.gmk :: Create the airboot.inf OS/2 Help File #
|
|---|
| 3 | # --------------------------------------------------------------------------- #
|
|---|
| 4 | # The manual itself is maintained with Apache Open Office Writer for OS/2. #
|
|---|
| 5 | # This implies the Open Document Format, which in turn implies ZIP compressed #
|
|---|
| 6 | # files. With ODF, the content and markup is separated, so it is possible to #
|
|---|
| 7 | # get the structure and content of the ODF-document use that as the base for #
|
|---|
| 8 | # a Manual in the familiar OS/2 INF format that can be read with (New) View. #
|
|---|
| 9 | # #
|
|---|
| 10 | # This Makefile extracts the 'content.xml' and uses XSLT to create an IPF #
|
|---|
| 11 | # source 'airboot.ipf'. This is then compiled with 'wipfc' to create the #
|
|---|
| 12 | # 'airboot.inf' file. #
|
|---|
| 13 | # #
|
|---|
| 14 | ###############################################################################
|
|---|
| 15 | gnumake.project.name := airboot-manual
|
|---|
| 16 | gnumake.project.target := default
|
|---|
| 17 | gnumake.project.uuid := a84e63e6-8929-11e7-ac7d-dfa0c5e47662
|
|---|
| 18 |
|
|---|
| 19 | # Get the name of this Makefile
|
|---|
| 20 | SELF:=$(lastword $(MAKEFILE_LIST))
|
|---|
| 21 |
|
|---|
| 22 | # Delegate to target 'default' which can specify more than one dependency
|
|---|
| 23 | .DEFAULT_GOAL:=$(gnumake.project.target)
|
|---|
| 24 |
|
|---|
| 25 | #
|
|---|
| 26 | # Global Variables
|
|---|
| 27 | #
|
|---|
| 28 | doctitle=AiR-BOOT User Manual
|
|---|
| 29 | toclevels=123
|
|---|
| 30 | infname=airboot.inf
|
|---|
| 31 | basename=airboot-manual
|
|---|
| 32 | odt.docin=$(basename).odt
|
|---|
| 33 | explode.dir=$(odt.docin:odt=odtx)
|
|---|
| 34 | imgdirprefix=$(explode.dir)
|
|---|
| 35 | transform.sheet=odt2ipf.xsl
|
|---|
| 36 |
|
|---|
| 37 | # =============================================================================
|
|---|
| 38 | # Virtual default target using dependency to invoke other targets
|
|---|
| 39 | # =============================================================================
|
|---|
| 40 | default: info
|
|---|
| 41 | #~ default: all
|
|---|
| 42 | #~ default: build
|
|---|
| 43 | #~ default: rebuild
|
|---|
| 44 | #~ default: package
|
|---|
| 45 | #~ default: clean
|
|---|
| 46 |
|
|---|
| 47 | # =============================================================================
|
|---|
| 48 | # Show information about this sub-project
|
|---|
| 49 | # =============================================================================
|
|---|
| 50 | info:
|
|---|
| 51 | $(info )
|
|---|
| 52 | $(info [$@])
|
|---|
| 53 | @less $(gnumake.project.name).info
|
|---|
| 54 | @echo
|
|---|
| 55 |
|
|---|
| 56 | # =============================================================================
|
|---|
| 57 | # Build everything
|
|---|
| 58 | # -----------------------------------------------------------------------------
|
|---|
| 59 | # When building everything, we want to exclude side effects of incremental
|
|---|
| 60 | # actions. So we delegate to 'rebuild' which does a clean first.
|
|---|
| 61 | # =============================================================================
|
|---|
| 62 | all: rebuild
|
|---|
| 63 |
|
|---|
| 64 | # =============================================================================
|
|---|
| 65 | # Perform all steps to create the AiR-BOOT Manual (incremental)
|
|---|
| 66 | # =============================================================================
|
|---|
| 67 | build::
|
|---|
| 68 | $(info )
|
|---|
| 69 | $(info :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
|
|---|
| 70 | $(info :: BUILDING AiR-BOOT MANUAL ::)
|
|---|
| 71 | $(info :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
|
|---|
| 72 | build:: inf.create
|
|---|
| 73 | $(info )
|
|---|
| 74 | $(info :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
|
|---|
| 75 | $(info :: BUILDING AiR-BOOT MANUAL FINISHED ::)
|
|---|
| 76 | $(info :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
|
|---|
| 77 |
|
|---|
| 78 | # =============================================================================
|
|---|
| 79 | # Perform all steps to create the AiR-BOOT Manual
|
|---|
| 80 | # =============================================================================
|
|---|
| 81 | rebuild::
|
|---|
| 82 | $(info )
|
|---|
| 83 | $(info :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
|
|---|
| 84 | $(info :: COMPLETELY REBUILDING AiR-BOOT MANUAL ::)
|
|---|
| 85 | $(info :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
|
|---|
| 86 | rebuild:: clean build
|
|---|
| 87 |
|
|---|
| 88 | # =============================================================================
|
|---|
| 89 | # Reconstruct the AiR-BOOT Manual from the Exploded Directory
|
|---|
| 90 | # =============================================================================
|
|---|
| 91 | reconstruct::
|
|---|
| 92 | $(info )
|
|---|
| 93 | $(info :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
|
|---|
| 94 | $(info :: RECONSTRUCTING THE AiR-BOOT OPEN-OFFICE DOCUMENT FOR EDITING ::)
|
|---|
| 95 | $(info :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
|
|---|
| 96 | reconstruct::
|
|---|
| 97 | rm -f -v reconstructed.odt
|
|---|
| 98 | bash -c "cd $(explode.dir) && rm -f Pictures/*.bmp && zip -r ../reconstructed.odt . && cd -"
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 | # =============================================================================
|
|---|
| 102 | # Clean all generated files
|
|---|
| 103 | # =============================================================================
|
|---|
| 104 | clean::
|
|---|
| 105 | $(info )
|
|---|
| 106 | $(info :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
|
|---|
| 107 | $(info :: REMOVING ALL GENERATED FILES ::)
|
|---|
| 108 | $(info :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
|
|---|
| 109 | clean::
|
|---|
| 110 | $(info )
|
|---|
| 111 | $(info [$@])
|
|---|
| 112 | @rm -r -f -v $(explode.dir)
|
|---|
| 113 | @rm -f -v $(basename).ipf $(basename).inf
|
|---|
| 114 | @rm -f -v content.xml styles.xml meta.xml
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 | #~ .SECONDEXPANSION:
|
|---|
| 119 |
|
|---|
| 120 | # =============================================================================
|
|---|
| 121 | # Explode the Open Office Writer document
|
|---|
| 122 | # =============================================================================
|
|---|
| 123 | odt.explode: $(explode.dir)/content.xml
|
|---|
| 124 | $(info )
|
|---|
| 125 | $(info [$@] -- [$?])
|
|---|
| 126 |
|
|---|
| 127 | # =============================================================================
|
|---|
| 128 | # Virtual target to translate ODT to IPF using XSLT
|
|---|
| 129 | # =============================================================================
|
|---|
| 130 | ipf.create: $(basename).ipf
|
|---|
| 131 | $(info )
|
|---|
| 132 | $(info [$@] -- [$?])
|
|---|
| 133 |
|
|---|
| 134 | # =============================================================================
|
|---|
| 135 | # Convert the extracted PNG images to OS/2 BMP format
|
|---|
| 136 | # -----------------------------------------------------------------------------
|
|---|
| 137 | # OpenOffice uses the PNG format for embedded images, which are present in the
|
|---|
| 138 | # 'Pictures' directory of the exploded ODT document. The OS/2 INF format can
|
|---|
| 139 | # only handle the OS/2 BMP format, so we convert to PNG images to OS/2 BMP.
|
|---|
| 140 | # This is done using 'gbmconv' from the GBM imaging tools.
|
|---|
| 141 | #
|
|---|
| 142 | # When the ODT is not yet exploded, there are no images yet, so things like
|
|---|
| 143 | # $(wildcard) cannot be used because it would return an empty set. So it is not
|
|---|
| 144 | # directly possible to have the images as dependencies because all macros are
|
|---|
| 145 | # evaluated before they are present.
|
|---|
| 146 | #
|
|---|
| 147 | # To solve this, this 'png.convert' is recursively invoked from the target that
|
|---|
| 148 | # explodes the ODT. Now the images are present and $(wildcard) can be used as
|
|---|
| 149 | # a dependency to invoke the PNG => BMP conversion rule.
|
|---|
| 150 | # =============================================================================
|
|---|
| 151 | png.convert::
|
|---|
| 152 | $(info :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
|
|---|
| 153 | $(info :: CONVERTING PNG IMAGES TO OS/2 BMP FORMAT ::)
|
|---|
| 154 | $(info :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
|
|---|
| 155 | png.convert:: $(patsubst %.png,%.png.bmp,$(wildcard $(explode.dir)/Pictures/*.png))
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 | # =============================================================================
|
|---|
| 159 | # Virtual target for INF file creation
|
|---|
| 160 | # =============================================================================
|
|---|
| 161 | inf.create: $(basename).inf
|
|---|
| 162 | $(info )
|
|---|
| 163 | $(info [$@] -- [$?])
|
|---|
| 164 |
|
|---|
| 165 | # -----------------------------------------------------------------------------
|
|---|
| 166 | # Local formatted copy -- forces explode
|
|---|
| 167 | # -----------------------------------------------------------------------------
|
|---|
| 168 | meta.xml: $(explode.dir)/meta.xml $(odt.docin)
|
|---|
| 169 | $(info )
|
|---|
| 170 | $(info [$@] -- [$?])
|
|---|
| 171 | cat $(explode.dir)/$@ | xsltproc format.xsl - > $@
|
|---|
| 172 |
|
|---|
| 173 | # -----------------------------------------------------------------------------
|
|---|
| 174 | # Local formatted copy -- forces explode
|
|---|
| 175 | # -----------------------------------------------------------------------------
|
|---|
| 176 | styles.xml: $(explode.dir)/styles.xml $(odt.docin)
|
|---|
| 177 | $(info )
|
|---|
| 178 | $(info [$@] -- [$?])
|
|---|
| 179 | cat $(explode.dir)/$@ | xsltproc format.xsl - > $@
|
|---|
| 180 |
|
|---|
| 181 | # -----------------------------------------------------------------------------
|
|---|
| 182 | # Local formatted copy -- forces explode
|
|---|
| 183 | # -----------------------------------------------------------------------------
|
|---|
| 184 | content.xml: $(explode.dir)/content.xml $(odt.docin) styles.xml meta.xml
|
|---|
| 185 | $(info )
|
|---|
| 186 | $(info [$@] -- [$?])
|
|---|
| 187 | cat $(explode.dir)/$@ | xsltproc format.xsl - > $@
|
|---|
| 188 |
|
|---|
| 189 | # -----------------------------------------------------------------------------
|
|---|
| 190 | # Explode the OpenOffice document to a directory -- also converts PNG => BMP
|
|---|
| 191 | # -----------------------------------------------------------------------------
|
|---|
| 192 | $(explode.dir)/content.xml: $(odt.docin)
|
|---|
| 193 | $(info )
|
|---|
| 194 | $(info [$@] -- [$?])
|
|---|
| 195 | unzip -o $(odt.docin) -d $(explode.dir)
|
|---|
| 196 | $(MAKE) -f $(SELF) png.convert
|
|---|
| 197 | touch -r $< $@
|
|---|
| 198 | @cp -a $< $<.bu
|
|---|
| 199 |
|
|---|
| 200 | # -----------------------------------------------------------------------------
|
|---|
| 201 | # Translate the content of the ODT file to IPF using XSLT
|
|---|
| 202 | # -----------------------------------------------------------------------------
|
|---|
| 203 | $(basename).ipf:
|
|---|
| 204 | $(basename).ipf: $(explode.dir)/content.xml $(transform.sheet) content.xml
|
|---|
| 205 | $(info )
|
|---|
| 206 | $(info [$@] -- [$?])
|
|---|
| 207 | #~ cat $< | xsltproc $(transform.sheet) - > $@
|
|---|
| 208 | xsltproc \
|
|---|
| 209 | --stringparam basename "$(basename)" \
|
|---|
| 210 | --stringparam doctitle "$(doctitle)" \
|
|---|
| 211 | --stringparam toclevels "$(toclevels)" \
|
|---|
| 212 | --stringparam imgdirprefix "$(imgdirprefix)" \
|
|---|
| 213 | --stringparam default-font "WarpSans" \
|
|---|
| 214 | $(transform.sheet) $< > $@
|
|---|
| 215 |
|
|---|
| 216 | # -----------------------------------------------------------------------------
|
|---|
| 217 | # Create the AiR-BOOT Manual in INF format
|
|---|
| 218 | # -----------------------------------------------------------------------------
|
|---|
| 219 | $(basename).inf: $(basename).ipf
|
|---|
| 220 | $(info )
|
|---|
| 221 | $(info [$@] -- [$?])
|
|---|
| 222 | $(call owc.env)
|
|---|
| 223 | wipfc -q -i $< -o $@
|
|---|
| 224 | cp -a $@ $(infname)
|
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 | # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|---|
| 228 | # Rule to convert PNG images to OS/2 BMP format
|
|---|
| 229 | # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|---|
| 230 | %.png.bmp: %.png
|
|---|
| 231 | ifdef OS2_SHELL
|
|---|
| 232 | $(info $(notdir $<) => $(notdir $@))
|
|---|
| 233 | @gbmconv $< $@
|
|---|
| 234 | else
|
|---|
| 235 | $(info $(notdir $<) => $(notdir $@))
|
|---|
| 236 | @./gbmconv $< $@
|
|---|
| 237 | endif
|
|---|
| 238 |
|
|---|
| 239 | #
|
|---|
| 240 | # Open Watcom Environment (Linux)
|
|---|
| 241 | #
|
|---|
| 242 | ifndef OS2_SHELL
|
|---|
| 243 | define owc.env
|
|---|
| 244 | $(call owc19.env)
|
|---|
| 245 | endef
|
|---|
| 246 | define owc19.env
|
|---|
| 247 | $(eval export WATCOM:=/vol/devtools/owc19)
|
|---|
| 248 | $(eval export PATH:=$(WATCOM)/binl:$(PATH))
|
|---|
| 249 | $(eval export INCLUDE:=$(WATCOM)/lh:$(INCLUDE))
|
|---|
| 250 | $(eval export EDPATH:=$(WATCOM)/eddat)
|
|---|
| 251 | $(eval export WIPFC:=$(WATCOM)/wipfc)
|
|---|
| 252 | $(eval CC=owcc)
|
|---|
| 253 | endef
|
|---|
| 254 | endif
|
|---|