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=@ 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) 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: # Different destination directories
$Qmkdir static TEST_DIR = static/test
$Qcp -r ils static/ PILOT_DIR = static/pilot
$Q$(foreach file,${CSS_FILES},sed -i 's#resources\.rero\.ch/ils#resources\.rero\.ch/ils/test#g' "static/$(file)" &) O9_DIR = static-o9
$Qsleep 1
$Qtar cfz static.tar.gz --directory=static/ils/ css images
static-pilot.tar.gz: logo-global.pilot.png # Destination files
$Qmkdir static-pilot TEST_CSS_FILES = $(TEST_ORGS:%=$(TEST_DIR)/css/%.css)
$Qcp -r ils static-pilot/ TEST_IMG_FILES = $(TEST_ORGS:%=$(TEST_DIR)/images/logo-%.png)
$Q$(foreach file,${CSS_FILES},sed -i 's#resources\.rero\.ch/ils#resources\.rero\.ch/ils/pilot#g' "static-pilot/$(file)" &) PILOT_CSS_FILES = $(PILOT_ORGS:%=$(PILOT_DIR)/css/%.css)
$Qcp -f logo-global.pilot.png static-pilot/ils/images/logo-global.png PILOT_IMG_FILES = $(PILOT_ORGS:%=$(PILOT_DIR)/images/logo-%.png)
$Qsleep 1 O9_CSS_FILES = $(CSS_FILES:%=$(O9_DIR)/%)
$Qtar cfz static-pilot.tar.gz --directory=static-pilot/ils/ css images 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 # ils/test files
$Qcp -r ils static-o9/ $(TEST_DIR)/css : $(TEST_CSS_FILES)
$Q$(foreach file,${CSS_FILES},sed -i 's#resources\.rero\.ch#o9\.re#g' "static-o9/$(file)" &) $Qmkdir -p $(@D)
$Qsleep 1
$Qtar cfz static-o9.tar.gz --directory=static-o9/ ils $(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: clean:
$Qrm -rf static/ static-pilot/ static-o9/ *.tar.gz $Qrm -rf static/ static-pilot/ static-o9/ *.tar.gz