Re-organise the build.
[emoney] / Makefile
1 ## Makefile for eMoney   -*-Makefile-*-
2 ##
3 ## Copyright (C) 2003 - 2011 Steve Youngs
4 ##
5 ## This file is part of eMoney.
6 ##
7 ## Redistribution and use in source and binary forms, with or without
8 ## modification, are permitted provided that the following conditions
9 ## are met:
10 ##
11 ## 1. Redistributions of source code must retain the above copyright
12 ##    notice, this list of conditions and the following disclaimer.
13 ##
14 ## 2. Redistributions in binary form must reproduce the above copyright
15 ##    notice, this list of conditions and the following disclaimer in the
16 ##    documentation and/or other materials provided with the distribution.
17 ##
18 ## 3. Neither the name of the author nor the names of any contributors
19 ##    may be used to endorse or promote products derived from this
20 ##    software without specific prior written permission.
21 ##
22 ## THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
23 ## IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 ## WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 ## DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 ## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 ## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 ## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 ## BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 ## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 ## OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 ## IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34 PACKAGE = emoney
35 VER = 1.0
36
37 # csh... yell no, we won't go!
38 SHELL = /bin/sh
39
40 # Programs and their flags.
41 ifndef XEMACS
42   XEMACS = sxemacs
43 endif
44 XEMACS_FLAGS = -batch -no-autoloads
45 INSTALL = install
46 PKG_INSTALL = $(INSTALL)
47 TAR = tar
48 TAR_FLAGS = \
49         --create \
50         --owner=0 \
51         --group=0 \
52         --gzip \
53         --file
54
55
56 # Our prefix.  Everything hangs off this.  
57 ifndef PREFIX
58   ifeq ('$(XEMACS)','sxemacs')
59     PREFIX = /usr/local/share/sxemacs/site-packages
60   else
61     PREFIX = /usr/local/lib/xemacs/site-packages
62   endif
63 endif
64
65 # Where the lisp files go.
66 LISP_DIR = $(PREFIX)/lisp/$(PACKAGE)
67
68 # If you want to make a tarball that you can just unpack on all your
69 # PC's you can 'make pkg'.  The 'pkg' target uses these directories to
70 # build the tarball.
71 STAGING = ../build-pkg
72 INFO_STAGING = $(STAGING)/info
73 LISP_STAGING = $(STAGING)/lisp/$(PACKAGE)
74
75
76 ############################################################################
77 ##                No User Configurable Items Below Here                   ##
78 ############################################################################
79
80 SOURCES = $(wildcard ./emoney*.el)
81 OBJECTS = $(SOURCES:.el=.elc)
82 EXTRA_SRC =
83 EXTRA_OBJ = $(wildcard ./auto-autoloads.el*) $(wildcard ./custom-*.el*)
84
85 all:: emoney-version.el compile
86
87 compile: 
88         $(XEMACS) $(XEMACS_FLAGS) -l "build.el"
89
90 emoney-version.el:
91         echo ";;; Automatically generated file -- DO NOT EDIT OR DELETE" > $@
92         echo ";;;###autoload" >> $@
93         echo "(defconst emoney-version" >> $@
94         if [[ -d ".git" && -x `which git 2>/dev/null` ]]; then \
95                 printf '  "%s"' `git describe` >> $@; \
96         else \
97                 echo -n '  "$(VER)"' >> $@; \
98         fi
99         echo ")" >> $@
100         echo "(provide 'emoney-version)" >> $@
101
102 version: emoney-version.el
103
104 install: all
105         $(INSTALL) -d $(LISP_DIR)
106         $(INSTALL) -m 644 $(SOURCES) $(EXTRA_SRC) $(OBJECTS) $(EXTRA_OBJ) \
107                 $(LISP_DIR)
108
109 pkg: all
110         $(PKG_INSTALL) -d $(STAGING) $(LISP_STAGING)
111         $(PKG_INSTALL) -m 644 $(SOURCES) $(EXTRA_SRC) $(OBJECTS) $(EXTRA_OBJ) \
112                 $(LISP_STAGING)
113         (cd $(STAGING); \
114                 $(TAR) $(TAR_FLAGS) $(PACKAGE)-$(VER)-pkg.tar.gz ./*)
115
116 upgrade: uninstall install
117
118 uninstall:: 
119         rm -rf $(LISP_DIR)
120         # rm -f $(INFO_DIR)/$(INFO_FILES)
121
122
123 clean::
124         rm -f $(OBJECTS) \
125                 auto-autoloads.el* custom-*.el*
126
127 distclean: clean
128         rm -f core* *~ TAGS tags emoney-version.el*
129
130 # Developer targets
131 tags: TAGS
132
133 TAGS: $(SOURCES)
134         etags $(SOURCES)
135
136 dist: distclean
137         (cd ../ ; \
138                 $(TAR) $(TAR_FLAGS) $(PACKAGE)-$(VER).tar.gz ./$(PACKAGE)/)
139
140 .PHONY: emoney-version.el version