view world/Makefile @ 2506:de2e01e4343b

Large refactoring and cleanup of the build system.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 02 Aug 2023 12:11:49 +0300
parents a01c82b8b7d2
children 6878dbdbc11e
line wrap: on
line source

###
### Includes and settings
###
include ../config.mak
include ../Makefile.maps
include ../Makefile.paths

BINPATH=../bin/
EXEEXT=


ifeq ($(HAVE_CURL),yes)
HTTPGET ?= curl -o
else
ifeq ($(HAVE_WGET),yes)
HTTPGET ?= wget -O
else
ifeq ($(HTTPGET),)
$(error Required utility 'curl' or 'wget' not found in PATH. You can configure HTTPGET variable in config.mak.)
endif
endif
endif


###
### Main targets
###
TARGETS = \
	$(addsuffix .html,$(WORLD_MAPS)) \
	$(addsuffix .ansi,$(WORLD_MAPS)) \
	$(addsuffix .png,$(WORLD_MAPS)) \
	$(addsuffix .htm,$(WORLD_MAPS)) \
	util.js changelog.txt

LOCFILES = $(addsuffix .loc,$(WORLD_MAPS)) special.loc limbo.loc

ifeq ($(HAVE_PHP),yes)
TARGETS += markers.xml
EXTRA_UPLOAD += markers.xml
endif


###
### If no target specified, show some help
###
all:
	@echo "Usage: make <target>"
	@echo "Available targets are as follows:"
	@echo
	@echo "maps    : Build HTML, HTML+JS, PNG image and ANSI format maps."
	@echo "fetch   : Fetch latest raw ASCII map data from bat.org."
	@echo
	@echo "diff    : Do special diff operation between new data (gotten via 'fetch')"
	@echo "          and update .loc files for each continent with new locations."
	@echo "          A diff -u of new and old location files is outputted."
	@echo
	@echo "upload  : Uploads map and loc-files via SCP to server specified in"
	@echo "          ../config.mak"
	@echo
	@echo "gimp    : Execute Gimp with all PNG targets for post-processing."
	@echo "clean   : Delete all the generated files."
	@echo


###
### Targets
###
maps: $(addsuffix .ppm,$(WORLD_MAPS)) $(TARGETS)


changelog.txt: $(addsuffix .map,$(WORLD_MAPS)) \
	$(addsuffix .loc,$(WORLD_MAPS)) \
	$(addprefix ../$(MISC_MAPS_PATH),$(addsuffix .map,$(MISC_MAPS))) \
	$(addprefix ../$(MISC_MAPS_PATH),$(addsuffix .loc,$(MISC_MAPS)))
	@hg up && ( echo '<?xml version="1.0"?>' && echo '<log>' && \
	hg log $+ -M -v -f --template \
	'<logentry revision="{rev}"><author>{author|escape}</author><date>{date|isodate}</date><paths><path>{files}</path></paths><msg>{desc|escape}</msg></logentry>\n' && \
	echo '</log>' ) | \
	iconv -f "iso-8859-1" -t "utf-8" | \
	xsltproc --stringparam strip-prefix "" \
		 --stringparam linelen 80 \
		 --stringparam groupbyday yes \
		 --stringparam include-rev no \
		 "svn2cl.xsl" - | \
	sed 's/world\///g;s/maps\///g;s/Matti .*/Ggr/g;s/Jarkko .*/Jeskko/g' \
	> $@


# Build Batclient markers.xml
markers.xml: $(addsuffix .loc,$(WORLD_MAPS)) $(MKLOC_BIN) ../www/world.inc.php
	php ../src/genbcxml.php $(MKLOC_BIN) ./ ../www/world.inc.php $@


# Upload changed files to site
upload: $(TARGETS) $(LOCFILES) $(EXTRA_UPLOAD)
	$(RSCP) $? $(UPLOAD_URL)
	@touch $@

# Upload only *.loc files
uploc: $(LOCFILES) $(EXTRA_UPLOAD)
	$(RSCP) $+ $(UPLOAD_URL)

# Fetch raw ASCII maps from bat.org to *.new
fetch:
	@for AMAP in $(CONT_MAPS); do echo "Fetching $${AMAP}.new"; $(HTTPGET) "$${AMAP}.new" "$(BATMAPURL)$${AMAP}.txt"; done


# Remove all temporary .diff files
cleardiff:
	$(RM) *.diff

# Diff target - run diff for each .map and .new (fetched via 'fetch' target).
# Finally do 'hg diff' to show changes.
diff: cleardiff $(addsuffix .diff,$(CONT_MAPS))
	@hg diff .

%.js:: ../src/%.js
	@ln -s $< $@

# Clean temporary and generated targets
clean:
	$(RM) $(TARGETS) *.diff *.ppm *.o *.script

srcclean: clean
	$(RM) *~