Archived
1
0

Makefile: improvement to merge pilot and test

* Merges pilot and test into same archive

Co-Authored-by: Olivier DOSSMANN <git@dossmann.net>
This commit is contained in:
Olivier DOSSMANN 2020-01-27 17:33:32 +01:00
parent 4a06def327
commit 0ceb501a6a

111
Makefile
View File

@ -1,31 +1,100 @@
Q=@
# Source directory (CSS files and images)
SRC_DIR = ils
SRC_CSS = $(SRC_DIR)/css
SRC_IMG = $(SRC_DIR)/images
# Source files
CSS_FILES := $(wildcard ils/css/*.css)
IMG_FILES := $(wildcard ils/images/*.png)
all: static.tar.gz static-pilot.tar.gz
# Those we want to keep (some on /test directory, other on /pilot)
TEST_ORGS = global aoste fictive highlands
PILOT_ORGS = global bulle mvs rbnj
static.tar.gz:
$Qmkdir static
$Qcp -r ils static/
$Q$(foreach file,${CSS_FILES},sed -i 's#resources\.rero\.ch/ils#resources\.rero\.ch/ils/test#g' "static/$(file)" &)
$Qsleep 1
$Qtar cfz static.tar.gz --directory=static/ils/ css images
# Different destination directories
TEST_DIR = static/test
PILOT_DIR = static/pilot
O9_DIR = static-o9
static-pilot.tar.gz: logo-global.pilot.png
$Qmkdir static-pilot
$Qcp -r ils static-pilot/
$Q$(foreach file,${CSS_FILES},sed -i 's#resources\.rero\.ch/ils#resources\.rero\.ch/ils/pilot#g' "static-pilot/$(file)" &)
$Qcp -f logo-global.pilot.png static-pilot/ils/images/logo-global.png
$Qsleep 1
$Qtar cfz static-pilot.tar.gz --directory=static-pilot/ils/ css images
# Destination files
TEST_CSS_FILES = $(TEST_ORGS:%=$(TEST_DIR)/css/%.css)
TEST_IMG_FILES = $(TEST_ORGS:%=$(TEST_DIR)/images/logo-%.png)
PILOT_CSS_FILES = $(PILOT_ORGS:%=$(PILOT_DIR)/css/%.css)
PILOT_IMG_FILES = $(PILOT_ORGS:%=$(PILOT_DIR)/images/logo-%.png)
O9_CSS_FILES = $(CSS_FILES:%=$(O9_DIR)/%)
O9_IMG_FILES = $(IMG_FILES:%=$(O9_DIR)/%)
o9: static-o9.tar.gz
# What will be generated
all: static.tar.gz static-o9.tar.gz
static-o9.tar.gz:
$Qmkdir static-o9
$Qcp -r ils static-o9/
$Q$(foreach file,${CSS_FILES},sed -i 's#resources\.rero\.ch#o9\.re#g' "static-o9/$(file)" &)
$Qsleep 1
$Qtar cfz static-o9.tar.gz --directory=static-o9/ ils
# ils/test files
$(TEST_DIR)/css : $(TEST_CSS_FILES)
$Qmkdir -p $(@D)
$(TEST_DIR)/css/%.css : $(SRC_CSS)/%.css
$Qmkdir -p $(@D)
$Qcp "$<" "$@"
$Qsed -i 's#resources\.rero\.ch/ils#resources\.rero\.ch/ils/test#g' "$@"
$(TEST_DIR)/images : $(TEST_IMG_FILES)
$Qmkdir -p $(@D)
$(TEST_DIR)/images/logo-%.png : $(SRC_IMG)/logo-%.png
$Qmkdir -p $(@D)
$Qcp "$<" "$@"
# ils/pilot files
$(PILOT_DIR)/css : $(PILOT_CSS_FILES)
$Qmkdir -p $(@D)
$(PILOT_DIR)/css/%.css : $(SRC_CSS)/%.css
$Qmkdir -p $(@D)
$Qcp "$<" "$@"
$Qsed -i 's#resources\.rero\.ch/ils#resources\.rero\.ch/ils/pilot#g' "$@"
$(PILOT_DIR)/images : $(PILOT_IMG_FILES)
$Qmkdir -p $(@D)
$(PILOT_DIR)/images/logo-global.png: logo-global.pilot.png
$Qmkdir -p $(@D)
$Qcp "$<" "$@"
$(PILOT_DIR)/images/logo-%.png : $(SRC_IMG)/logo-%.png
$Qmkdir -p $(@D)
$Qcp "$<" "$@"
static: $(TEST_DIR)/css $(TEST_DIR)/images $(PILOT_DIR)/css $(PILOT_DIR)/images
static.tar.gz: static
$Qtar cfz "$@" --directory=static/ pilot test
## For o9.re ##
$(O9_DIR)/css : $(O9_CSS_FILES)
$(O9_DIR)/ils/css/%.css : $(SRC_CSS)/%.css
$Qmkdir -p $(@D)
$Qcp "$<" "$@"
$Qsed -i 's#resources\.rero\.ch#o9\.re#g' "$@"
$(O9_DIR)/images : $(O9_IMG_FILES)
$(O9_DIR)/ils/images/%.png : $(SRC_IMG)/%.png
$Qmkdir -p $(@D)
$Qcp "$<" "$@"
$(O9_DIR): $(O9_DIR)/css $(O9_DIR)/images
static-o9.tar.gz: static-o9
$Qtar cfz "$@" --directory=static-o9/ ils
# To clean generated files
.PHONY: clean
clean:
$Qrm -rf static/ static-pilot/ static-o9/ *.tar.gz