2024-09-01 19:41:34 +02:00
|
|
|
# CONFIGURE at least ROOT_DIR and INSTALL_DIR
|
2024-09-01 19:50:59 +02:00
|
|
|
# All paths without trailing slashes
|
2024-09-01 19:41:34 +02:00
|
|
|
|
|
|
|
# Absolute path to the directory containing all image directories as well as the staging directory
|
|
|
|
# eg: ROOT_DIR = /data/images
|
2024-09-01 19:45:55 +02:00
|
|
|
# ROOT_DIR =
|
2024-09-01 19:41:34 +02:00
|
|
|
|
|
|
|
# The URI at which the ROOT_DIR will be served
|
2024-09-01 19:50:59 +02:00
|
|
|
ROOT_PATH = /images
|
2024-09-01 19:41:34 +02:00
|
|
|
|
|
|
|
# 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
|
2024-09-01 19:45:55 +02:00
|
|
|
# INSTALL_DIR =
|
2024-09-01 19:41:34 +02:00
|
|
|
|
|
|
|
|
2024-09-01 23:48:37 +02:00
|
|
|
|
|
|
|
|
2024-09-01 19:41:34 +02:00
|
|
|
# DO NOT CHANGE ANYTHING HERE
|
2024-09-01 23:48:37 +02:00
|
|
|
default: css
|
|
|
|
.PHONY: clean install stop test php css
|
|
|
|
|
|
|
|
# Installation
|
2024-09-02 00:17:32 +02:00
|
|
|
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 ROOT_PATH variable)
|
|
|
|
endif
|
2024-09-01 17:44:31 +02:00
|
|
|
|
|
|
|
SRC_DIR = src
|
2024-09-01 23:48:37 +02:00
|
|
|
_SRC_FLS = config.html config.js index.html index.js imgsort.php style.css style.css.map
|
2024-09-01 19:41:34 +02:00
|
|
|
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
|
|
|
install: $(INSTALL_FLS) imgsort2-nginx.conf imgsort2-php-fpm.conf
|
|
|
|
|
|
|
|
|
|
|
|
$(INSTALL_DIR)/%.php: $(SRC_DIR)/%.php
|
2024-09-01 23:48:37 +02:00
|
|
|
sed 's|$$rootDir = .*|$$rootDir = "$(ROOT_DIR)/";|; s|$$rootPath = .*|$$rootPath = "$(ROOT_PATH)/";|; s|$$stagingDirName = .*|$$stagingDirName = "$(STAGING_DIR)/";|' $< > $@
|
2024-09-01 19:41:34 +02:00
|
|
|
chmod 0744 $@
|
|
|
|
|
|
|
|
$(INSTALL_DIR)/%: $(SRC_DIR)/%
|
|
|
|
install -m 0744 $< $@
|
|
|
|
|
|
|
|
%.conf: $(SRC_DIR)/%.conf
|
2024-09-01 19:50:59 +02:00
|
|
|
sed 's|root = .*|$$root = $(INSTALL_DIR);|; s|location /images/|location $(ROOT_PATH)/|; s|$$alias = .*|alias = $(ROOT_DIR);|' $< > $@
|
|
|
|
chmod 0740 $@
|
2024-09-01 19:41:34 +02:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm $(INSTALL_FLS)
|
|
|
|
|
2024-09-01 23:48:37 +02:00
|
|
|
# Compile the sass
|
|
|
|
css:
|
|
|
|
$(SASS_CMD) --no-indented --no-source-map src/sass/main.sass src/style.css
|
|
|
|
# Testing
|
2024-09-01 17:44:31 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
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
|
2024-09-01 23:48:37 +02:00
|
|
|
|