#

VERSION=10.7.0

# NOTE when changing PREFIX, then newlisp should only run
# run in an environment, where NEWLISPDIR is predefined,
# else NEWLISPDIR will be defined during newlisp startup
# as /usr/share/newlisp which is hardcoded in newlisp.c
prefix=/usr/local
datadir=$(prefix)/share
bindir=$(prefix)/bin
mandir=$(prefix)/share/man

# if prefix is not /usr/local then several places in the file 
# guiserver/newlisp-edit.lsp must change too
GUISERVER = $(prefix)/share/newlisp/guiserver

# this is the standard install in /usr/local/bin and /usr/local/share
# which as to be done as 'root' with supersuser permissions
# for an install in your home directory use make install_home
#
# One-line description for distribution packages: 
# newLISP is a LISP like, general purpose scripting language. 
#
# Longer description for distribution packages: 
# newLISP is a scripting language for developing web applications and programs 
# in general and in the domains of artificial intelligence (AI) and statistics.

install:
	-install -d $(datadir)/newlisp
	-install -d $(datadir)/newlisp/modules
	-install -d $(datadir)/newlisp/util
	-install -d $(datadir)/doc/newlisp
	-rm $(bindir)/newlisp
	-install -m 755  newlisp $(bindir)/newlisp-$(VERSION)
	-ln -s $(bindir)/newlisp-$(VERSION) $(bindir)/newlisp
	-install -m 755 util/newlispdoc $(bindir)/newlispdoc
	-install -m 644 util/syntax.cgi $(datadir)/newlisp/util/syntax.cgi
	-install -m 644 util/newlisp.vim $(datadir)/newlisp/util/newlisp.vim
	-install -m 644 doc/COPYING $(datadir)/doc/newlisp/COPYING
	-install -m 644 doc/CREDITS $(datadir)/doc/newlisp/CREDITS
	-install -m 644 doc/newlisp_manual.html $(datadir)/doc/newlisp/newlisp_manual.html
	-install -m 644 doc/newlisp_index.html $(datadir)/doc/newlisp/newlisp_index.html
	-install -m 644 doc/manual_frame.html $(datadir)/doc/newlisp/manual_frame.html
	-install -m 644 doc/CodePatterns.html $(datadir)/doc/newlisp/CodePatterns.html
	-install -m 644 doc/newLISPdoc.html $(datadir)/doc/newlisp/newLISPdoc.html
	-install -m 644 doc/newLISP-$(VERSION)-Release.html $(datadir)/doc/newlisp/newLISP-$(VERSION)-Release.html
	-install -m 644 doc/newlisp.1 $(mandir)/man1/newlisp.1
	-install -m 644 doc/newlispdoc.1 $(mandir)/man1/newlispdoc.1
	-install -m 644 modules/canvas.lsp $(datadir)/newlisp/modules/canvas.lsp
	-install -m 644 modules/cgi.lsp $(datadir)/newlisp/modules/cgi.lsp
	-install -m 644 modules/crypto.lsp $(datadir)/newlisp/modules/crypto.lsp
	-install -m 644 modules/ftp.lsp $(datadir)/newlisp/modules/ftp.lsp
	-install -m 644 modules/getopts.lsp $(datadir)/newlisp/modules/getopts.lsp
	-install -m 644 modules/gsl.lsp $(datadir)/newlisp/modules/gsl.lsp
	-install -m 644 modules/infix.lsp $(datadir)/newlisp/modules/infix.lsp
	-install -m 644 modules/mysql.lsp $(datadir)/newlisp/modules/mysql.lsp
	-install -m 644 modules/odbc.lsp $(datadir)/newlisp/modules/odbc.lsp
	-install -m 644 modules/plot.lsp $(datadir)/newlisp/modules/plot.lsp
	-install -m 644 modules/pop3.lsp $(datadir)/newlisp/modules/pop3.lsp
	-install -m 644 modules/postgres.lsp $(datadir)/newlisp/modules/postgres.lsp
	-install -m 644 modules/postscript.lsp $(datadir)/newlisp/modules/postscript.lsp
	-install -m 644 modules/smtp.lsp $(datadir)/newlisp/modules/smtp.lsp
	-install -m 644 modules/smtpx.lsp $(datadir)/newlisp/modules/smtpx.lsp
	-install -m 644 modules/sqlite3.lsp $(datadir)/newlisp/modules/sqlite3.lsp
	-install -m 644 modules/stat.lsp $(datadir)/newlisp/modules/stat.lsp
	-install -m 644 modules/unix.lsp $(datadir)/newlisp/modules/unix.lsp
	-install -m 644 modules/xmlrpc-client.lsp $(datadir)/newlisp/modules/xmlrpc-client.lsp
	-install -m 644 modules/zlib.lsp $(datadir)/newlisp/modules/zlib.lsp
	# GUI-Server install
	-install -d $(datadir)/newlisp/guiserver
	-install -d $(datadir)/doc/newlisp/guiserver
	-install -m 755 guiserver/newlisp-edit.lsp $(bindir)/newlisp-edit
	-install -m 644 guiserver/guiserver.jar $(datadir)/newlisp/guiserver.jar
	-install -m 644 guiserver/guiserver.lsp $(datadir)/newlisp/guiserver.lsp
	-install -m 644 guiserver/images/newLISP128.png $(datadir)/newlisp/newLISP128.png
	-install -m 644 guiserver/COPYING $(datadir)/doc/newlisp/guiserver/COPYING
	-install -m 644 guiserver/index-gs.html $(datadir)/doc/newlisp/guiserver/index-gs.html
	-install -m 644 guiserver/guiserver.lsp.html $(datadir)/doc/newlisp/guiserver/guiserver.lsp.html
	-install -m 644 util/newlispdoc.css $(datadir)/doc/newlisp/guiserver/newlispdoc.css
	-install -m 644 guiserver/allfonts-demo.lsp $(datadir)/newlisp/guiserver/allfonts-demo.lsp
	-install -m 644 guiserver/animation-demo.lsp $(datadir)/newlisp/guiserver/animation-demo.lsp
	-install -m 644 guiserver/border-layout-demo.lsp $(datadir)/newlisp/guiserver/border-layout-demo.lsp
	-install -m 644 guiserver/button-demo.lsp $(datadir)/newlisp/guiserver/button-demo.lsp
	-install -m 644 guiserver/clipboard-demo.lsp $(datadir)/newlisp/guiserver/clipboard-demo.lsp
	-install -m 644 guiserver/cursor-demo.lsp $(datadir)/newlisp/guiserver/cursor-demo.lsp
	-install -m 644 guiserver/drag-demo.lsp $(datadir)/newlisp/guiserver/drag-demo.lsp
	-install -m 644 guiserver/font-demo.lsp $(datadir)/newlisp/guiserver/font-demo.lsp
	-install -m 644 guiserver/frameless-demo.lsp $(datadir)/newlisp/guiserver/frameless-demo.lsp
	-install -m 644 guiserver/html-demo.lsp $(datadir)/newlisp/guiserver/html-demo.lsp
	-install -m 644 guiserver/image-demo.lsp $(datadir)/newlisp/guiserver/image-demo.lsp
	-install -m 644 guiserver/midi-demo.lsp $(datadir)/newlisp/guiserver/midi-demo.lsp
	-install -m 644 guiserver/midi2-demo.lsp $(datadir)/newlisp/guiserver/midi2-demo.lsp
	-install -m 644 guiserver/mouse-demo.lsp $(datadir)/newlisp/guiserver/mouse-demo.lsp
	-install -m 644 guiserver/move-resize-demo.lsp $(datadir)/newlisp/guiserver/move-resize-demo.lsp
	-install -m 644 guiserver/pinballs-demo.lsp $(datadir)/newlisp/guiserver/pinballs-demo.lsp
	-install -m 644 guiserver/properties-demo.lsp $(datadir)/newlisp/guiserver/properties-demo.lsp
	-install -m 644 guiserver/rotation-demo.lsp $(datadir)/newlisp/guiserver/rotation-demo.lsp
	-install -m 644 guiserver/scroll-pane-demo.lsp $(datadir)/newlisp/guiserver/scroll-pane-demo.lsp
	-install -m 644 guiserver/shapes-demo.lsp $(datadir)/newlisp/guiserver/shapes-demo.lsp
	-install -m 644 guiserver/sound-demo.lsp $(datadir)/newlisp/guiserver/sound-demo.lsp
	-install -m 644 guiserver/stroke-demo.lsp $(datadir)/newlisp/guiserver/stroke-demo.lsp
	-install -m 644 guiserver/tabs-demo.lsp $(datadir)/newlisp/guiserver/tabs-demo.lsp
	-install -m 644 guiserver/table-demo.lsp $(datadir)/newlisp/guiserver/table-demo.lsp
	-install -m 644 guiserver/textfield-demo.lsp $(datadir)/newlisp/guiserver/textfield-demo.lsp
	-install -m 644 guiserver/textrot-demo.lsp $(datadir)/newlisp/guiserver/textrot-demo.lsp
	-install -m 644 guiserver/widgets-demo.lsp $(datadir)/newlisp/guiserver/widgets-demo.lsp
	-install -m 644 guiserver/word-count.lsp $(datadir)/newlisp/guiserver/word-count.lsp
	-install -m 644 guiserver/uppercase.lsp $(datadir)/newlisp/guiserver/uppercase.lsp


uninstall:
	-rm  $(bindir)/newlisp
	-rm  $(bindir)/newlispdoc
	-rm  $(bindir)/newlisp-edit
	-rm  -rf $(datadir)/newlisp
	-rm  -rf $(datadir)/doc/newlisp
	-rm  $(mandir)/man1/newlisp.1
	-rm  $(mandir)/man1/newlispdoc.1

# installs newLISP in home directory, but without guiserver files except
# documentation. To make guiserver run from ~/share/newlisp. The loading
# from guiserver.lsp at the beginning of a guiserver app and loading
# of guiserver.jar from inside of guiserver.lsp have to be changed.

install_home:
	-install -d $(HOME)/bin
	-install -d $(HOME)/share/newlisp
	-install -d $(HOME)/share/newlisp/modules
	-install -d $(HOME)/share/newlisp/util
	-install -d $(HOME)/share/doc/newlisp/
	-install -d $(HOME)/share/doc/newlisp/guiserver
	-install -d $(HOME)/share/man/man1
	-install -m 755 newlisp $(HOME)/bin/newlisp
	-install -m 755 util/newlispdoc $(HOME)/bin/newlispdoc
	-install -m 644 util/syntax.cgi $(HOME)/share/newlisp/util/syntax.cgi
	-install -m 644 util/newlisp.vim $(HOME)/share/newlisp/util/newlisp.vim
	-install -m 644 guiserver/index-gs.html $(HOME)/share/doc/newlisp/guiserver/index-gs.html
	-install -m 644 guiserver/guiserver.lsp.html $(HOME)/share/doc/newlisp/guiserver/guiserver.lsp.html
	-install -m 644 doc/COPYING $(HOME)/share/doc/newlisp/COPYING
	-install -m 644 doc/COPYING $(HOME)/share/doc/newlisp/guiserver/COPYING
	-install -m 644 doc/CREDITS $(HOME)/share/doc/newlisp/CREDITS
	-install -m 644 doc/newlisp_manual.html $(HOME)/share/doc/newlisp/newlisp_manual.html
	-install -m 644 doc/newlisp_index.html $(HOME)/share/doc/newlisp/newlisp_index.html
	-install -m 644 doc/manual_frame.html $(HOME)/share/doc/newlisp/manual_frame.html
	-install -m 644 doc/CodePatterns.html $(HOME)/share/doc/newlisp/CodePatterns.html
	-install -m 644 doc/newLISPdoc.html $(HOME)/share/doc/newlisp/newLISPdoc.html
	-install -m 644 doc/newLISP-$(VERSION)-Release.html $(HOME)/share/doc/newlisp/newLISP-$(VERSION)-Release.html
	-install -m 644 doc/newlisp.1 $(HOME)/share/man/man1/newlisp.1
	-install -m 644 doc/newlispdoc.1 $(HOME)/share/man/man1/newlispdoc.1
	-install -m 644 modules/canvas.lsp $(HOME)/share/newlisp/modules/canvas.lsp
	-install -m 644 modules/cgi.lsp $(HOME)/share/newlisp/modules/cgi.lsp
	-install -m 644 modules/crypto.lsp $(HOME)/share/newlisp/modules/crypto.lsp
	-install -m 644 modules/ftp.lsp $(HOME)/share/newlisp/modules/ftp.lsp
	-install -m 644 modules/getopts.lsp $(HOME)/share/newlisp/modules/getopts.lsp
	-install -m 644 modules/gsl.lsp $(HOME)/share/newlisp/modules/gsl.lsp
	-install -m 644 modules/infix.lsp $(HOME)/share/newlisp/modules/infix.lsp
	-install -m 644 modules/macro.lsp $(HOME)/share/newlisp/modules/macro.lsp
	-install -m 644 modules/mysql.lsp $(HOME)/share/newlisp/modules/mysql.lsp
	-install -m 644 modules/plot.lsp $(HOME)/share/newlisp/modules/plot.lsp
	-install -m 644 modules/odbc.lsp $(HOME)/share/newlisp/modules/odbc.lsp
	-install -m 644 modules/pop3.lsp $(HOME)/share/newlisp/modules/pop3.lsp
	-install -m 644 modules/postgres.lsp $(HOME)/share/newlisp/modules/postgres.lsp
	-install -m 644 modules/postscript.lsp $(HOME)/share/newlisp/modules/postscript.lsp
	-install -m 644 modules/smtp.lsp $(HOME)/share/newlisp/modules/smtp.lsp
	-install -m 644 modules/smtpx.lsp $(HOME)/share/newlisp/modules/smtpx.lsp
	-install -m 644 modules/sqlite3.lsp $(HOME)/share/newlisp/modules/sqlite3.lsp
	-install -m 644 modules/stat.lsp $(HOME)/share/newlisp/modules/stat.lsp
	-install -m 644 modules/unix.lsp $(HOME)/share/newlisp/modules/unix.lsp
	-install -m 644 modules/xmlrpc-client.lsp $(HOME)/share/newlisp/modules/xmlrpc-client.lsp
	-install -m 644 modules/zlib.lsp $(HOME)/share/newlisp/modules/zlib.lsp


uninstall_home:
	-rm  -rf $(HOME)/share/newlisp
	-rm  -rf $(HOME)/share/doc/newlisp
	-rm  $(HOME)/share/man/man1/newlisp.1
	-rm  $(HOME)/share/man/man1/newlispdoc.1
	-rm $(HOME)/bin/newlisp
	-rm $(HOME)/bin/newlispdoc

