changeset 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 653120d50ed9
files Makefile.gen Makefile.maps Makefile.paths config.mak old/Makefile world/Makefile world/Makefile.inc world/config.mak
diffstat 8 files changed, 159 insertions(+), 179 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.gen	Tue Aug 01 16:17:58 2023 +0300
+++ b/Makefile.gen	Wed Aug 02 12:11:49 2023 +0300
@@ -2,22 +2,12 @@
 ### Include configuration
 ###
 include config.mak
+include Makefile.paths
 
 
 ###
 ### Binaries and objects
 ###
-STITCHMAP_BIN=$(BINPATH)stitchmap$(BINEXT)
-COLORMAP_BIN=$(BINPATH)colormap$(BINEXT)
-MKCITYMAP_BIN=$(BINPATH)mkcitymap$(BINEXT)
-DIFFMAP_BIN=$(BINPATH)diffmap$(BINEXT)
-PATCHMAP_BIN=$(BINPATH)patchmap$(BINEXT)
-MKLOC_BIN=$(BINPATH)mkloc$(BINEXT)
-MAP2PPM_BIN=$(BINPATH)map2ppm$(BINEXT)
-COMBINE_BIN=$(BINPATH)combine$(BINEXT)
-MAPSTATS_BIN=$(BINPATH)mapstats$(BINEXT)
-MAPSEARCH_BIN=$(BINPATH)mapsearch$(BINEXT)
-
 LIBLOCFILE_OBJ=$(OBJPATH)liblocfile.o
 LIBMAPUTILS_OBJ=$(OBJPATH)libmaputils.o
 
@@ -77,7 +67,7 @@
 
 
 ###
-### Map targets
+### Misc map targets
 ###
 $(MISC_MAPS_PATH)%.html: $(MISC_MAPS_PATH)%.map $(MISC_MAPS_PATH)%.loc $(MISC_MAPS_PATH)%.desc $(MKCITYMAP_BIN) src/tooltip.js $(MISC_MAPS_PATH)misc.html
 	@$(call DO_CMD,MKCITYMAP,$@,$(MKCITYMAP_BIN) $(MKCITYMAP_OPTS) -h $(MISC_MAPS_PATH)misc.html -t "`cat $(patsubst %.map,%.desc,$<)`" $< $(patsubst %.map,%.loc,$<) `cat $(patsubst %.map,%.opts,$<)` -o "$@")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile.maps	Wed Aug 02 12:11:49 2023 +0300
@@ -0,0 +1,85 @@
+###
+### Intermediate file targets
+###
+%.tmp1: %.map %.loc $(MKLOC_BIN)
+	@echo "MKLOC $@"
+	@$(MKLOC_BIN) $(MKLOC_OPTS) -o $@ -m $< -l $(patsubst %.map,%.loc,$<)
+
+%.tmp2: %.map %.loc $(MKLOC_BIN)
+	@echo "MKLOC $@"
+	@$(MKLOC_BIN) $(MKLOC_OPTS) -N -o $@ -m $< -l $(patsubst %.map,%.loc,$<)
+
+%.tmp3: %.loc $(MKLOC_BIN)
+	@echo "MKLOC $@"
+	@$(MKLOC_BIN) $(MKLOC_OPTS) -M -l $< -o $@
+
+
+###
+### HTML format maps
+###
+%.htm: %.tmp1 %.desc $(COLORMAP_BIN)
+	@echo "COLORMAP $@"
+	@$(COLORMAP_BIN) $(COLORMAP_OPTS) $(COLORMAP_HTML) $(COLORMAP_EXTRA) -t "`cat $(patsubst %.tmp1,%.desc,$<)`" -o $@ $<
+
+%.html: %.tmp2 %.desc %.tmp3 $(COLORMAP_BIN)
+	@echo "COLORMAP $@"
+	@$(COLORMAP_BIN) $(COLORMAP_OPTS) -J $(COLORMAP_HTML) -P $(COLORMAP_EXTRA) -t "`cat $(patsubst %.tmp2,%.desc,$<)`" $< | \
+	sed -e "/@LOCATIONS@/r $(patsubst %.tmp2,%.tmp3,$<)" -e "s/@LOCATIONS@//g" > $@
+
+
+###
+### ANSI text
+###
+%.ansi: %.tmp1 %.desc $(COLORMAP_BIN)
+	@echo "COLORMAP $@"
+	@$(COLORMAP_BIN) $(COLORMAP_OPTS) $(COLORMAP_EXTRA) -f ansi -t "`cat $(patsubst %.tmp1,%.desc,$<)`" -o $@ $<
+
+
+###
+### PNG images
+###
+%.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
+
+
+###
+### Diff target between .map file and .new file. Makes necessary changes in .map and .loc
+###
+%.diff: %.map %.new
+	@echo "DIFFING $< ..."
+	@if $(DIFFMAP_BIN) $(DIFFMAP_OPTS) $+ -o $@ -a; then \
+		echo "PATCHING ..."; \
+		$(MAP2PPM_BIN) $@ -o $@.ppm -d; \
+		$(PATCHMAP_BIN) $< $@ -o $<; \
+	fi
+	@echo "UPDATING LOCATIONS ..."
+	@$(MKLOC_BIN) -v -m $(patsubst %.map,%.new,$<) -l $(patsubst %.map,%.loc,$<) -L -g -o $(patsubst %.map,%.nloc,$<)
+	@diff -ubB $(patsubst %.map,%.loc,$<) $(patsubst %.map,%.nloc,$<) | patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile.paths	Wed Aug 02 12:11:49 2023 +0300
@@ -0,0 +1,13 @@
+###
+### Binary paths
+###
+STITCHMAP_BIN=$(BINPATH)stitchmap$(BINEXT)
+COLORMAP_BIN=$(BINPATH)colormap$(BINEXT)
+MKCITYMAP_BIN=$(BINPATH)mkcitymap$(BINEXT)
+DIFFMAP_BIN=$(BINPATH)diffmap$(BINEXT)
+PATCHMAP_BIN=$(BINPATH)patchmap$(BINEXT)
+MKLOC_BIN=$(BINPATH)mkloc$(BINEXT)
+MAP2PPM_BIN=$(BINPATH)map2ppm$(BINEXT)
+COMBINE_BIN=$(BINPATH)combine$(BINEXT)
+MAPSTATS_BIN=$(BINPATH)mapstats$(BINEXT)
+MAPSEARCH_BIN=$(BINPATH)mapsearch$(BINEXT)
--- a/config.mak	Tue Aug 01 16:17:58 2023 +0300
+++ b/config.mak	Wed Aug 02 12:11:49 2023 +0300
@@ -1,6 +1,19 @@
 ###
 ### Global settings
 ###
+WORLDMAP_FONT_FILE=MonospaceBold.ttf
+WORLDMAP_FONT_SCALE=8.0
+WORLDMAP_UNIT_SIZE=6.0
+WORLDMAP_SCALE=6
+
+MKLOC_OPTS=
+MAP2PPM_OPTS=
+
+#COLORMAP_OPTS=-u "www/urchin.inc.php" -a -C
+COLORMAP_OPTS=-a -C
+COLORMAP_HTML=-f html5
+
+
 # Unfortunately we require Bash for now due to {} brace expansion
 SHELL = /bin/bash
 
@@ -14,10 +27,13 @@
 #LDFLAGS += -lasan
 
 
-#COLORMAP_OPTS=-u "www/urchin.inc.php" -a -C
-COLORMAP_OPTS=-a -C
-COLORMAP_HTML=-f html5
-
+###
+### Detect things
+###
+HAVE_CURL ?= $(shell curl --version > /dev/null 2>&1 && echo "yes")
+HAVE_WGET ?= $(shell wget --version > /dev/null 2>&1 && echo "yes")
+HAVE_PHP ?= $(shell php --version > /dev/null 2>&1 && echo "yes")
+HAVE_GIMP_CONSOLE ?= $(shell gimp-console --version > /dev/null 2>&1 && echo "yes")
 
 # Wget or curl are autodetected but you can force them here
 #HTTPGET ?= curl -o
@@ -27,16 +43,20 @@
 ###
 ### Misc stuff
 ###
-RSCP = rsync -vptogzL -e ssh
-UPLOAD_URL = ccr@tnsp.org:/var/www/tnsp.org/maps/
 CFLAGS += -DTH_PROG_AUTHOR="\"By Matti 'ccr' Hamalainen (C) Copyright 2006-2023 TNSP\""
 CFLAGS += -DTH_PROG_LICENSE="\"This software is distributed under GNU General Public License version 2\""
 
+RSCP = rsync -vptogzL -e ssh
 
-###
-### List of misc map targets
-###
-MISC_MAPS_PATH = misc/
+UPLOAD_URL = ccr@tnsp.org:/var/www/tnsp.org/maps/
+BATMAP_URL = https://www.bat.org/maps/raw/
+
+MISC_MAPS_PATH=misc/
 MISC_MAPS=votk faerieforest lanzia rilynttar lorenchia \
 	esiris esiris2 arelium calythien tyr_farwyn \
 	dortlewall vendace_shore
+
+CONT_MAPS=laenor rothikgen lucentium furnachia desolathya renardy
+WORLD_MAPS=$(CONT_MAPS) tormentas
+
+
--- a/old/Makefile	Tue Aug 01 16:17:58 2023 +0300
+++ b/old/Makefile	Wed Aug 02 12:11:49 2023 +0300
@@ -1,35 +1,31 @@
-#
-# Settings
-#
-MAP_PATH  = ../world/
+###
+### Includes and settings
+###
+include ../config.mak
+include ../Makefile.maps
+include ../Makefile.paths
+
+BINPATH=../bin/
+EXEEXT=
+
+WORLDMAP_PATH  = ../world/
 MAP_SCALE = 10
 COLORMAP_EXTRA = -O
 DIFFMAP_OPTS = -O
 
-include ../config.mak
-include $(MAP_PATH)config.mak
-
-
-#
-# Target rules
-#
 TARGETS=batmap.html batmap.htm batmap.ansi \
 	hcbat.html hcbat.htm hcbat.ansi \
 	batcity.html util.js tooltip.js misc.css
 
+
+###
+### Target rules
+###
 all: $(TARGETS)
 
-include $(MAP_PATH)Makefile.inc
-
 batmap.map: batmap-30-11-2006.txt
 	@ln -s $< $@
 
-title.png: $(MAP_PATH)title.png
-	@ln -s $< $@
-
-MonospaceBold.ttf: $(MAP_PATH)MonospaceBold.ttf
-	@ln -s $< $@
-
 batcity.html: batcity.map batcity.loc tooltip.js ../misc/misc.html misc.css $(MKCITYMAP_BIN)
 	$(MKCITYMAP_BIN) $(MKCITYMAP_OPTS) -h ../misc/misc.html -t "Old BatCity map" $< batcity.loc -o "$@"
 
@@ -39,7 +35,7 @@
 #twomi-batmap.html: twomi-batmap.tmp $(COLORMAP_BIN)
 #	$(COLORMAP_BIN) $(COLORMAP_OPTS) -O $(COLORMAP_HTML) -t "`cat $(patsubst %.tmp,%.desc,$<)`" $< -o $@
 
-hcbat.loc: hcbat.ref mapref.pl $(addprefix $(MAP_PATH),$(addsuffix .loc,$(WORLD_MAPS)))
+hcbat.loc: hcbat.ref mapref.pl $(addprefix $(WORLDMAP_PATH),$(addsuffix .loc,$(WORLD_MAPS)))
 	@if command -v perl > /dev/null; then \
 		echo "Generating $@"; \
 		perl -w ./mapref.pl $+ > $@; \
@@ -48,9 +44,9 @@
 	fi
 
 
-#
-# Special targets
-#
+###
+### Special targets
+###
 %.js:: ../src/%.js
 	@ln -s $< $@
 
@@ -67,4 +63,3 @@
 
 srcclean: clean
 	$(RM) *~
-
--- a/world/Makefile	Tue Aug 01 16:17:58 2023 +0300
+++ b/world/Makefile	Wed Aug 02 12:11:49 2023 +0300
@@ -1,13 +1,13 @@
-include ../config.mak
-include config.mak
-
+###
+### Includes and settings
 ###
-### Detect if we have some things
-###
-HAVE_CURL ?= $(shell curl --version > /dev/null 2>&1 && echo "yes")
-HAVE_WGET ?= $(shell wget --version > /dev/null 2>&1 && echo "yes")
-HAVE_PHP ?= $(shell php --version > /dev/null 2>&1 && echo "yes")
-HAVE_GIMP_CONSOLE ?= $(shell gimp-console --version > /dev/null 2>&1 && echo "yes")
+include ../config.mak
+include ../Makefile.maps
+include ../Makefile.paths
+
+BINPATH=../bin/
+EXEEXT=
+
 
 ifeq ($(HAVE_CURL),yes)
 HTTPGET ?= curl -o
@@ -63,16 +63,11 @@
 
 
 ###
-### Maps
+### Targets
 ###
 maps: $(addsuffix .ppm,$(WORLD_MAPS)) $(TARGETS)
 
-include Makefile.inc
 
-
-###
-### Special targets
-###
 changelog.txt: $(addsuffix .map,$(WORLD_MAPS)) \
 	$(addsuffix .loc,$(WORLD_MAPS)) \
 	$(addprefix ../$(MISC_MAPS_PATH),$(addsuffix .map,$(MISC_MAPS))) \
--- a/world/Makefile.inc	Tue Aug 01 16:17:58 2023 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-###
-### Tool binary paths
-###
-COLORMAP_BIN=$(BINPATH)colormap$(EXEEXT)
-MKLOC_BIN=$(BINPATH)mkloc$(EXEEXT)
-MAP2PPM_BIN=$(BINPATH)map2ppm$(EXEEXT)
-COMBINE_BIN=$(BINPATH)combine$(EXEEXT)
-MKCITYMAP_BIN=$(BINPATH)mkcitymap$(EXEEXT)
-DIFFMAP_BIN=$(BINPATH)diffmap$(EXEEXT)
-PATCHMAP_BIN=$(BINPATH)patchmap$(EXEEXT)
-
-
-###
-### Intermediate file targets
-###
-%.tmp1: %.map %.loc $(MKLOC_BIN)
-	@echo "MKLOC $@"
-	@$(MKLOC_BIN) $(MKLOC_OPTS) -o $@ -m $< -l $(patsubst %.map,%.loc,$<)
-
-%.tmp2: %.map %.loc $(MKLOC_BIN)
-	@echo "MKLOC $@"
-	@$(MKLOC_BIN) $(MKLOC_OPTS) -N -o $@ -m $< -l $(patsubst %.map,%.loc,$<)
-
-%.tmp3: %.loc $(MKLOC_BIN)
-	@echo "MKLOC $@"
-	@$(MKLOC_BIN) $(MKLOC_OPTS) -M -l $< -o $@
-
-
-###
-### HTML format maps
-###
-%.htm: %.tmp1 %.desc $(COLORMAP_BIN)
-	@echo "COLORMAP $@"
-	@$(COLORMAP_BIN) $(COLORMAP_OPTS) $(COLORMAP_HTML) $(COLORMAP_EXTRA) -t "`cat $(patsubst %.tmp1,%.desc,$<)`" -o $@ $<
-
-%.html: %.tmp2 %.desc %.tmp3 $(COLORMAP_BIN)
-	@echo "COLORMAP $@"
-	@$(COLORMAP_BIN) $(COLORMAP_OPTS) -J $(COLORMAP_HTML) -P $(COLORMAP_EXTRA) -t "`cat $(patsubst %.tmp2,%.desc,$<)`" $< | \
-	sed -e "/@LOCATIONS@/r $(patsubst %.tmp2,%.tmp3,$<)" -e "s/@LOCATIONS@//g" > $@
-
-
-###
-### ANSI text
-###
-%.ansi: %.tmp1 %.desc $(COLORMAP_BIN)
-	@echo "COLORMAP $@"
-	@$(COLORMAP_BIN) $(COLORMAP_OPTS) $(COLORMAP_EXTRA) -f ansi -t "`cat $(patsubst %.tmp1,%.desc,$<)`" -o $@ $<
-
-
-###
-### PNG images
-###
-%.script: %.map %.loc title.png $(MAP_FONT) $(MKLOC_BIN)
-	@echo "MKLOC $@"
-	@$(MKLOC_BIN) $(MKLOC_OPTS) -S -m $< -l $(patsubst %.map,%.loc,$<) -f $(MAP_FONT_SCALE) -u $(MAP_UNIT_SIZE) -s $(MAP_SCALE) | \
-	sed -e "s/@OPTS_START@/-font $(MAP_FONT) -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 $(MAP_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
-
-###
-### Diff target between .map file and .new file. Makes necessary changes in .map and .loc
-###
-%.diff: %.map %.new
-	@echo "DIFFING $< ..."
-	@if $(DIFFMAP_BIN) $(DIFFMAP_OPTS) $+ -o $@ -a; then \
-		echo "PATCHING ..."; \
-		$(MAP2PPM_BIN) $@ -o $@.ppm -d; \
-		$(PATCHMAP_BIN) $< $@ -o $<; \
-	fi
-	@echo "UPDATING LOCATIONS ..."
-	@$(MKLOC_BIN) -v -m $(patsubst %.map,%.new,$<) -l $(patsubst %.map,%.loc,$<) -L -g -o $(patsubst %.map,%.nloc,$<)
-	@diff -ubB $(patsubst %.map,%.loc,$<) $(patsubst %.map,%.nloc,$<) | patch
--- a/world/config.mak	Tue Aug 01 16:17:58 2023 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-###
-### Settings
-###
-
-MKLOC_OPTS=
-MAP2PPM_OPTS=
-#COLORMAP_OPTS=-u "../www/urchin.inc.php" -a -C
-COLORMAP_OPTS=-a -C
-
-MAP_FONT=MonospaceBold.ttf
-MAP_FONT_SCALE=8.0
-MAP_UNIT_SIZE=6.0
-MAP_SCALE=6
-
-BINPATH=../bin/
-EXEEXT=
-
-WORLD_MAPS=laenor rothikgen lucentium furnachia desolathya renardy tormentas
-
-CONT_MAPS=laenor rothikgen lucentium furnachia desolathya renardy
-
-BATMAPURL=https://www.bat.org/maps/raw/