Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ jobs:

- run: opam exec -- make all

- run: opam install .

# lint-doc:
# runs-on: ubuntu-latest
# steps:
Expand Down
64 changes: 43 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ distclean: clean.local
# BB different, make files universally accessible, we cannot chown.
INSTALL_CAN_PUT_PERMISSIONS=yes
INSTALL_USER_GROUP=-o $(OCSIGENUSER) -g "$(OCSIGENGROUP)"
INSTALL_MOD_660=660
INSTALL_MOD_644=644
INSTALL_MOD_755=755
INSTALL_MOD_770=770
INSTALL_MOD_750=750
INSTALL_MOD_660=-m 660
INSTALL_MOD_644=-m 644
INSTALL_MOD_755=-m 755
INSTALL_MOD_770=-m 770
INSTALL_MOD_750=-m 750
INSTALL_DIR=$(INSTALL) -d
INSTALL_FILE=$(INSTALL)
# The Unix permission/ownership handling below is meaningless on Windows (the
# OCSIGEN_WINDOWS branch drops modes and ownership anyway), and OCSIGENGROUP is
# empty there, which makes the `grep` check below print a usage error. Skip it.
ifneq ($(OCSIGEN_WINDOWS), yes)
USERNAME=$(shell whoami)
ifneq ($(shell id -u), 0)
ifneq ($(OCSIGENUSER), $(USERNAME))
Expand All @@ -62,38 +68,54 @@ ifneq ($(shell id -u), 0)
endif
ifeq ($(INSTALL_CAN_PUT_PERMISSIONS), no)
INSTALL_USER_GROUP=
INSTALL_MOD_660=666
INSTALL_MOD_644=666
INSTALL_MOD_755=777
INSTALL_MOD_770=777
INSTALL_MOD_750=777
INSTALL_MOD_660=-m 666
INSTALL_MOD_644=-m 666
INSTALL_MOD_755=-m 777
INSTALL_MOD_770=-m 777
INSTALL_MOD_750=-m 777
endif
endif

# On Windows (Cygwin), NTFS does not support Unix permission bits and `install`
# aborts when it fails to chmod the freshly created file or directory. Fall back
# to plain `mkdir -p` / `cp` and drop the mode and ownership flags.
# OCSIGEN_WINDOWS is set by ./configure (see Makefile.config).
ifeq ($(OCSIGEN_WINDOWS), yes)
INSTALL_USER_GROUP=
INSTALL_MOD_660=
INSTALL_MOD_644=
INSTALL_MOD_755=
INSTALL_MOD_770=
INSTALL_MOD_750=
INSTALL_DIR=mkdir -p
INSTALL_FILE=cp
endif

install.files:
@echo
@echo INSTALL_CAN_PUT_PERMISSIONS: ${INSTALL_CAN_PUT_PERMISSIONS}
## Configuration files
$(INSTALL) -m ${INSTALL_MOD_755} -d $(TEMPROOT)$(CONFIGDIR)/conf.d
${INSTALL} -m ${INSTALL_MOD_644} _build/install/default/etc/ocsigenserver/ocsigenserver.conf.sample $(TEMPROOT)$(CONFIGDIR)/
$(INSTALL_DIR) ${INSTALL_MOD_755} $(TEMPROOT)$(CONFIGDIR)/conf.d
$(INSTALL_FILE) ${INSTALL_MOD_644} _build/install/default/etc/ocsigenserver/ocsigenserver.conf.sample $(TEMPROOT)$(CONFIGDIR)/
[ -f $(TEMPROOT)$(CONFIGDIR)/ocsigenserver.conf ] || \
{ $(INSTALL) -m ${INSTALL_MOD_644} _build/install/default/etc/ocsigenserver/ocsigenserver.conf.sample \
{ $(INSTALL_FILE) ${INSTALL_MOD_644} _build/install/default/etc/ocsigenserver/ocsigenserver.conf.sample \
$(TEMPROOT)$(CONFIGDIR)/ocsigenserver.conf; }
-mv $(TEMPROOT)$(CONFIGDIR)/mime.types $(TEMPROOT)$(CONFIGDIR)/mime.types.old
## Log directory
$(INSTALL) -m ${INSTALL_MOD_644} src/files/mime.types $(TEMPROOT)$(CONFIGDIR)
$(INSTALL) -d -m ${INSTALL_MOD_755} ${INSTALL_USER_GROUP} $(TEMPROOT)$(LOGDIR)
$(INSTALL_FILE) ${INSTALL_MOD_644} src/files/mime.types $(TEMPROOT)$(CONFIGDIR)
$(INSTALL_DIR) ${INSTALL_MOD_755} ${INSTALL_USER_GROUP} $(TEMPROOT)$(LOGDIR)
## Static files
$(INSTALL) -d -m ${INSTALL_MOD_755} ${INSTALL_USER_GROUP} $(TEMPROOT)$(STATICPAGESDIR)
$(INSTALL) -d -m ${INSTALL_MOD_750} ${INSTALL_USER_GROUP} $(TEMPROOT)$(DATADIR)
$(INSTALL) -m ${INSTALL_MOD_644} ${INSTALL_USER_GROUP} \
$(INSTALL_DIR) ${INSTALL_MOD_755} ${INSTALL_USER_GROUP} $(TEMPROOT)$(STATICPAGESDIR)
$(INSTALL_DIR) ${INSTALL_MOD_750} ${INSTALL_USER_GROUP} $(TEMPROOT)$(DATADIR)
$(INSTALL_FILE) ${INSTALL_MOD_644} ${INSTALL_USER_GROUP} \
local/var/www/*.html $(TEMPROOT)$(STATICPAGESDIR)
$(INSTALL) -d -m ${INSTALL_MOD_755} ${INSTALL_USER_GROUP} \
$(INSTALL_DIR) ${INSTALL_MOD_755} ${INSTALL_USER_GROUP} \
$(TEMPROOT)$(STATICPAGESDIR)/ocsigenstuff
$(INSTALL) -m ${INSTALL_MOD_644} ${INSTALL_USER_GROUP} \
$(INSTALL_FILE) ${INSTALL_MOD_644} ${INSTALL_USER_GROUP} \
local/var/www/ocsigenstuff/*.png local/var/www/ocsigenstuff/*.css \
$(TEMPROOT)$(STATICPAGESDIR)/ocsigenstuff
mkdir -p $(TEMPROOT)$(MANDIR)
$(INSTALL) -m ${INSTALL_MOD_644} src/files/ocsigenserver.1 $(TEMPROOT)$(MANDIR)
$(INSTALL_FILE) ${INSTALL_MOD_644} src/files/ocsigenserver.1 $(TEMPROOT)$(MANDIR)

uninstall:
-rm -f $(TEMPROOT)$(CONFIGDIR)/ocsigenserver.conf.sample
Expand Down
30 changes: 30 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,32 @@ while [ "$#" -gt 0 ]; do
esac
done

# Detect a Cygwin/Windows build. cygpath is only available on Cygwin, so its
# presence both identifies the platform and provides the path conversion we
# need: on Windows opam passes Windows-style paths (backslash separators, drive
# letters, and occasionally a stray double quote from an empty argument such as
# `--temproot ""`). The Cygwin shell that runs the install recipes would eat the
# backslashes as escape characters, so normalize every path through cygpath into
# a form it accepts (e.g. D:/a/...). On Unix cygpath is absent and paths are
# left untouched.
if command -v cygpath >/dev/null 2>&1; then
windows=yes
else
windows=no
fi

if [ "$windows" = yes ]; then
for __var in prefix root temproot bindir logdir libdir mandir docdir \
commandpipe sysconfdir staticpagesdir uploaddir datadir full_pwd; do
eval "__val=\$$__var"
__val=`printf '%s' "$__val" | tr -d '"'`
if [ -n "$__val" ]; then
__val=`cygpath -m "$__val" 2>/dev/null || printf '%s' "$__val"`
fi
eval "$__var=\$__val"
done
fi

case "$bindir" in
"") bindir="$prefix/bin";;
esac
Expand Down Expand Up @@ -476,6 +502,10 @@ ocamlinclude=`ocamlfind printconf stdlib`
echo "Writing Makefile.config"
cat <<_EOF_ > $my_pwd/Makefile.config

# Whether this is a Cygwin/Windows build (NTFS cannot apply Unix permissions, so
# install.files falls back to mkdir -p / cp instead of install -m).
OCSIGEN_WINDOWS := $windows

#### External binaries ####

OCAMLFIND := ocamlfind
Expand Down
1 change: 0 additions & 1 deletion ocsigenserver.opam
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ conflicts: [
]
dev-repo: "git+https://github.com/ocsigen/ocsigenserver.git"
x-maintenance-intent: ["(latest)"]
available: os != "win32"
build: [
[
"sh"
Expand Down
1 change: 0 additions & 1 deletion ocsigenserver.opam.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
available: os != "win32"
build: [
[
"sh"
Expand Down
Loading