imgsort2/Makefile

84 lines
2.2 KiB
Makefile
Raw Normal View History

2024-09-01 19:41:34 +02:00
# CONFIGURE at least ROOT_DIR and INSTALL_DIR
# Absolute path to the directory containing all image directories as well as the staging directory
# MUST HAVE A TRAILING SLASH
# eg: ROOT_DIR = /data/images
ROOT_DIR = /tmp/gimp/
# The URI at which the ROOT_DIR will be served
# MUST HAVE A TRAILING SLASH
ROOT_PATH = /images/
# Path of the directory containing all the files to be sorted, relative to ROOT_DIR
# eg: STAGING_DIR = .sort
STAGING_DIR = .sort
# Absolute path to the directory into which the application files will be installed
# eg: INSTALL_DIR = /www/imgsort2
INSTALL_DIR = /tmp/imgsort2
# DO NOT CHANGE ANYTHING HERE
ifndef ROOT_DIR
$(error Edit this Makefile and set the ROOT_DIR variable)
endif
ifndef INSTALL_DIR
$(error Edit this Makefile and set the INSTALL_DIR variable)
endif
ifndef STAGING_DIR
$(error Edit this Makefile and set the STAGING_DIR variable)
endif
ifndef ROOT_PATH
$(error Edit this Makefile and set the STAGING_DIR variable)
endif
2024-09-01 17:44:31 +02:00
SRC_DIR = src
2024-09-01 19:41:34 +02:00
_SRC_FLS = config.html config.js index.html index.js imgsort.php style.css
SRC_FLS = $(foreach f,$(_SRC_FLS),$(SRC_DIR)/$(f))
INSTALL_FLS = $(foreach f,$(_SRC_FLS),$(INSTALL_DIR)/$(f))
2024-09-01 17:44:31 +02:00
SASS_CMD = sass --color --load-path=src/sass
2024-09-01 19:41:34 +02:00
default: css
.PHONY: clean install stop test php css
install: $(INSTALL_FLS) imgsort2-nginx.conf imgsort2-php-fpm.conf
$(INSTALL_DIR)/%.php: $(SRC_DIR)/%.php
sed 's|$$rootDir = .*|$$rootDir = "$(ROOT_DIR)";|; s|$$rootPath = .*|$$rootPath = "$(ROOT_PATH)"|; s|$$stagingDirName = .*|$$stagingDirName = "$(STAGING_DIR)";|' @< > $@
chmod 0744 $@
$(INSTALL_DIR)/%: $(SRC_DIR)/%
install -m 0744 $< $@
%.conf: $(SRC_DIR)/%.conf
sed 's|root = .*|$$root = $(INSTALL_DIR);|; s|location /images/|location $(ROOT_PATH)|; s|$$alias = .*|alias = $(ROOT_DIR);|' @< > $@
chmod 0744 $@
$(SED_COMMAND) $< > $@
clean:
rm $(INSTALL_FLS)
2024-09-01 17:44:31 +02:00
# testing
php:
php -S localhost:8000 -t . &
2024-09-01 19:41:34 +02:00
firefox http://localhost:8000/src/index.html
2024-09-01 17:44:31 +02:00
stop:
-killall php
# Compile the sass
css:
$(SASS_CMD) --no-indented src/sass/main.sass src/style.css
2024-09-01 19:41:34 +02:00
TESTDIR = images
# Create a image directory for testing.
# This should work with the default configuration
2024-09-01 17:44:31 +02:00
test:
-@rm -r $(TESTDIR)
2024-09-01 19:41:34 +02:00
-@mkdir -p $(TESTDIR) $(TESTDIR)/.sort
-@cp resources/* $(TESTDIR)/.sort