view world/Makefile @ 2823:38516eb9a5b3 default tip

Cleanup regexp.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 28 Apr 2024 16:06:34 +0300
parents 7fb4ae35d948
children
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) $(EXTRA_WORLD_MAPS)) \
	$(addsuffix .ansi,$(WORLD_MAPS)) \
	$(addsuffix .png,$(WORLD_MAPS)) \
	$(addsuffix .htm,$(WORLD_MAPS) $(EXTRA_WORLD_MAPS)) \
	worldmap.js changelog.txt

LOCFILES = $(addsuffix .loc,$(WORLD_MAPS) $(EXTRA_WORLD_MAPS)) special.loc limbo.loc
EXTRA_MAP_UPLOAD += $(addsuffix .map,$(WORLD_MAPS) $(EXTRA_WORLD_MAPS))

ifeq ($(HAVE_PHP),yes)
TARGETS += markers.xml
EXTRA_LOC_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
	@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 "clean   : Delete all the generated files."
	@echo


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


%.script: %.map %.loc title.png $(WORLDMAP_FONT_FILE) $(MKLOC_BIN)
	@echo "MKLOC $@"
	@$(MKLOC_BIN) $(MKLOC_OPTS) -S -m $< -l $(patsubst %.map,%.loc,$<) -f $(WORLDMAP_FONT_SCALE) -u $(WORLDMAP_UNIT_SIZE) -s $(WORLDMAP_SCALE) | \
	sed -e "s/@OPTS_START@/-font $(WORLDMAP_FONT_FILE) -pointsize 14 -type TruecolorMatte/g" \
	-e "s/@OPTS_END@/\t-geometry +0+0 title.png -composite -compose screen \\\\\n\t-pointsize 20 -fill white -box none -draw \"text 5,50 \'@PAF@\n\n\n/g" | \
	sed -e "/@PAF@/r $(patsubst %.map,%.desc,$<)" -e "s/@PAF@//g" > $@

%.ppm: %.map
	@echo "MAP2PPM $@"
	@$(MAP2PPM_BIN) $(MAP2PPM_OPTS) -s $(WORLDMAP_SCALE) $(COLORMAP_EXTRA) $< -o $@

ifeq ($(HAVE_GIMP_CONSOLE),yes)
%_rgb.png: %.ppm %.script %.desc
	@echo "PNG $@"
	@/bin/sh $(patsubst %.ppm,%.script,$<) $< $@

%.png: %_rgb.png
	@echo "GIMP $@"
	@gimp-console -c -d -i -b \
	"(let* ( \
	(img (car (file-png-load RUN-NONINTERACTIVE \"$<\" \"$<\"))) \
	(drawable (car (gimp-image-active-drawable img)))) \
	(gimp-convert-indexed img NO-DITHER MAKE-PALETTE 64 FALSE FALSE \"\") \
	(file-png-save2 RUN-NONINTERACTIVE img drawable \"$@\" \"$@\" 0 9 0 0 0 0 0 0 0))" \
	-b '(gimp-quit 0)'
else
%.png: %.ppm %.script %.desc
	@echo "PNG $@"
	@/bin/sh $(patsubst %.ppm,%.script,$<) $< $@
endif


# Fetch raw ASCII maps from bat.org to *.new
fetch:
	@for AMAP in $(CONT_MAPS); do echo "Fetching $${AMAP}.new"; $(HTTPGET) "$${AMAP}.new" "$(BATMAP_URL)$${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 $< $@


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))) \
	../old/hcbat.loc ../old/hcbat.ref ../old/hcbat.map
	@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_LOC_UPLOAD) $(EXTRA_MAP_UPLOAD)
	$(RSCP_COMMAND) $? $(RSCP_UPLOAD_URL)
	@touch $@

# Upload only *.loc files
uploc: $(LOCFILES) $(EXTRA_LOC_UPLOAD)
	$(RSCP_COMMAND) $+ $(RSCP_UPLOAD_URL)

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

srcclean: clean
	$(RM) *~