Makefile 2.53 KB
Newer Older
1 2
# Generic Makefile for Spicey applications

3 4 5 6 7 8
# Definition of the root of the Curry system to be used:
SYSTEM=XXXCURRYHOMEXXX

# Curry bin directory to be used:
export CURRYBIN=$(SYSTEM)/bin

9 10 11 12 13 14
CURRYOPTIONS=:set -time

# Target directory where the compiled cgi programs, style sheets, etc
# should be stored, e.g.: $(HOME)/public_html
WEBSERVERDIR = $(error "Define variable WEBSERVERDIR!")

15
# Executable of the Curry Package Manager CPM:
Michael Hanus 's avatar
Michael Hanus committed
16
CPM := $(CURRYBIN)/cypm
17

18 19 20
# Executable of the curry2cgi:
CURRY2CGI := $(shell which curry2cgi)

21
# The root directory of the sources of the Spicey application:
22 23
SRCDIR := $(CURDIR)/src

24
# The load path for the Spicey application:
25
export CURRYPATH := $(SRCDIR):$(SRCDIR)/Model
26

27 28
############################################################################

29 30
.PHONY: all
all:
31 32 33 34 35 36
	@echo "make: deploy install compile load run clean?"

# Install the packages required by the generated Spicey application:
.PHONY: install
install:
	$(CPM) install
37

38 39 40
# check presence of tools required for deployment and install them:
.PHONY: checkdeploy
checkdeploy:
41 42 43
	@if [ ! -x "$(CURRY2CGI)" ] ; then \
	   echo "Installing required executable 'curry2cgi'..." ; \
           $(CPM) install html2 ; fi
44

45 46 47
# Compile the generated Spicey application:
.PHONY: compile
compile:
48
	$(CURRYBIN)/curry $(CURRYOPTIONS) :load Main :quit
49 50 51 52 53

# Load the generated Spicey application into the Curry system so that
# one can evaluate some expressions:
.PHONY: load
load:
54
	$(CURRYBIN)/curry $(CURRYOPTIONS) :load Main
55 56 57 58 59

# Runs the generated Spicey application by evaluating the main expression.
# This might be useful to test only the initial web page without a web server
.PHONY: run
run:
60
	$(CURRYBIN)/curry $(CURRYOPTIONS) :load Main :eval main :q
61 62 63 64

# Deploy the generated Spicey application, i.e., install it in the
# web directory WEBSERVERDIR:
.PHONY: deploy
65
deploy: checkdeploy
66
	mkdir -p $(WEBSERVERDIR)
67
	$(MAKE) $(WEBSERVERDIR)/spicey.cgi
68
	# copy other files (style sheets, images,...)
69
	cp -r public/* $(WEBSERVERDIR)
70
	chmod -R go+rX $(WEBSERVERDIR)
71
	# recreate directory for storing local session data:
Michael Hanus 's avatar
Michael Hanus committed
72 73 74
	/bin/rm -rf $(WEBSERVERDIR)/sessiondata
	mkdir -p $(WEBSERVERDIR)/sessiondata
	chmod 700 $(WEBSERVERDIR)/sessiondata
75 76 77 78 79

$(WEBSERVERDIR)/spicey.cgi: src/*.curry src/*/*.curry
	$(CPM) exec $(CURRY2CGI) --system="$(SYSTEM)" \
	  -i Controller.SpiceySystem XXXICONTROLLERXXX \
	  -o $@ Main.curry
80

81
# clean up generated the package directory
82 83
.PHONY: clean
clean: 
84 85
	$(CPM) clean

86
# clean everything, including the deployed files
87 88
.PHONY: cleanall
cleanall: clean
89
	/bin/rm -f $(WEBSERVERDIR)/spicey.cgi*