aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2020-05-16 12:24:07 -0300
committerSilvio Rhatto <rhatto@riseup.net>2020-05-16 12:24:07 -0300
commitd64d1088f276b7f267921ad30e6179a2bb48c1b2 (patch)
tree6779c7a85ee7740aea98f14f133099f513321353 /Makefile
parent67d2d45d0cdefdd798187c7c1f11cad8afdb1824 (diff)
downloadblog-d64d1088f276b7f267921ad30e6179a2bb48c1b2.tar.gz
blog-d64d1088f276b7f267921ad30e6179a2bb48c1b2.tar.bz2
Makefile: adds serve target (2)
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile50
1 files changed, 50 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..3a988d4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,50 @@
+#
+# Global Makefile - https://templater.fluxo.info
+#
+# This Makefile contains basic, common targets and also includes
+# any Makefile.* available in the current folder.
+#
+
+# Port to serve content
+HTTP_PORT="8000"
+HTTP_SERVER="http.server"
+
+# Base to serve the content
+HTTP_BASE="."
+
+# Set CONTAINER based in what we have available in the system
+# This variable can be user in other, included Makefiles to handle virtualization tasks
+ifeq ($(shell which kvmx > /dev/null && test -s kvmxfile && echo yes), yes)
+ CONTAINER = kvmx
+else ifeq ($(shell which vagrant > /dev/null && test -s Vagrantfile && echo yes), yes)
+ CONTAINER = vagrant
+else ifeq ($(shell which docker > /dev/null && test -s Dockerfile && echo yes), yes)
+ CONTAINER = docker
+else
+ CONTAINER = ''
+endif
+
+# See http://unix.stackexchange.com/questions/32182/simple-command-line-http-server#32200
+# http://php.net/manual/en/features.commandline.webserver.php
+serve:
+ @if [ "$(HTTP_SERVER)" = "SimpleHTTPServer" ]; then cd $(HTTP_BASE) && python -m SimpleHTTPServer $(HTTP_PORT); fi
+ @if [ "$(HTTP_SERVER)" = "ssi_server" ]; then cd $(HTTP_BASE) && PYTHONDONTWRITEBYTECODE=0 ssi_server.py $(HTTP_PORT); fi
+ @if [ "$(HTTP_SERVER)" = "http.server" ]; then cd $(HTTP_BASE) && python3 -m http.server $(HTTP_PORT); fi
+ @if [ "$(HTTP_SERVER)" = "php" ]; then cd $(HTTP_BASE) && php -S localhost:$(HTTP_PORT); fi
+
+# Configure a git post-receive hook
+post_receive:
+ git config receive.denyCurrentBranch ignore
+ test -s bin/post-receive && cd .git/hooks && ln -sf ../../bin/post-receive
+
+# Process any other Makefile whose filename matches Makefile.*
+# See https://www.gnu.org/software/make/manual/html_node/Include.html
+#
+# Some of those files might even contain local customizations/overrides
+# that can be .gitignore'd, like a Makefile.local for example.
+-include Makefile.*
+
+# Customization examples can be as simple as setting variables:
+#CONTAINER = vagrant
+#CONTAINER = docker
+#DESTDIR ?= vendor