File: Makefile.mmake

package info (click to toggle)
lib-dom-java 0.19990107-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 388 kB
  • ctags: 831
  • sloc: java: 997; makefile: 41
file content (223 lines) | stat: -rw-r--r-- 4,850 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#
# Makefile created at Fri Nov  5 14:47:26 1999, by mmake
#

# Programs (with common options):
SHELL		= /bin/sh
RM              = rm -f
MV              = mv -f
SED		= sed
XARGS		= xargs
CAT		= cat
FIND            = find
CPP		= cpp -C -P

INSTALL         = install
INSTALL_PROG    = $(INSTALL) -m $(MODE_PROGS)
INSTALL_FILE    = $(INSTALL) -m $(MODE_FILES)
INSTALL_DIR     = $(INSTALL) -m $(MODE_DIRS) -d

# Install modes 
MODE_PROGS      = 755
MODE_FILES      = 644
MODE_DIRS       = 755

# Build programs
JAVAC           = jikes
JAVADOC         = javadoc
JAR             = jar

# Build flags
JAVAC_FLAGS     = 
JAVADOC_FLAGS   = -version -author
JAR_FLAGS       = cvf0
JIKES_DEP_FLAG	= +M


# Where to start installing the class files
CLASS_LIBDIR	= 

# The directory to install the jar file in
JAR_LIBDIR	= 

# The directory to install html files generated by javadoc
DOCDIR          = build/doc


# The dependency graph file
MAKEFILE_DEPEND	= makefile.dep

# The name of the jar file to install
JAR_FILE        = 

# 
# The VERSION variable below should be set to a value 
# that will be tested in the .xjava code. 
# 
VERSION		= CHANGE_ME


# ------------------------------------------------------------------- #


# Packages we should compile
PACKAGES = \
	org.w3c.dom \
	org.w3c.dom.html




# A marker variable for the top level directory
TOPLEVEL        = .

# Subdirectories with java files:
JAVA_DIRS	= $(subst .,/,$(PACKAGES)) $(TOPLEVEL)

# All the .xjava source files:
XJAVA_SRC	= $(foreach dir, $(JAVA_DIRS), $(wildcard $(dir)/*.xjava))

# All the xjava files to build
XJAVA_OBJS	= $(XJAVA_SRC:.xjava=.java)

# All the .java source files:
JAVA_SRC	= $(foreach dir, $(JAVA_DIRS), $(wildcard $(dir)/*.java))
JAVA_SRC	:= $(JAVA_SRC) $(XJAVA_OBJS)

# Dependency files:
DEPEND_OBJS      = $(JAVA_SRC:.java=.u)

# Objects that should go into the jar file. (find syntax)
JAR_OBJS         = \( -name '*.class' -o -name '*.gif' -o -name "*.au" \)

# All the .java source files we should build:
JAVA_OBJS	= $(XJAVA_OBJS:.java=.class) $(JAVA_SRC:.java=.class)

# All the java .class files we should install (including inner classes):
JAVA_INSTALL_OBJS= $(foreach dir, $(JAVA_DIRS), $(wildcard $(dir)/*.class))

# ------------------------------------------------------------------- #


# Courtesy reint@sys.sol.no:
# Used in $(foreach ...) to check exit value and add a newline in the
# shell commands.  Keep exactly as it is, including the empty line!
define check-exit
|| exit 1

endef

define check-exit-or-clean
|| { $(RM) $@; exit 1; }

endef

# -----------
# Build Rules
# -----------

%.java: %.xjava
	$(CPP) -D$(VERSION) $< $@

%.class: %.java
	$(JAVAC) $(JAVAC_FLAGS) $<

%.jar: $(JAVA_OBJS)
	$(FIND) $(TOPLEVEL) $(JAR_OBJS) -print | $(XARGS) \
	$(JAR) $(JAR_FLAGS) $(JAR_FILE) 

%.u: %.java
	$(JAVAC) $(JIKES_DEP_FLAG) $<


# -------
# Targets
# -------

.PHONY : clean all doc jar install src


all:	src

src:	$(JAVA_OBJS)

help:
	@echo "Usage: make [ src | jar | install | doc | clean | depend ]"

install:
	@echo "Run 'make install-jar' to install a jar file, or run "
	@echo "'make install-classes' to install all classes"


ifneq ($(strip $(JAR_FILE)),)
jar:  $(JAR_FILE)

install-jar: $(JAR_FILE)
	$(INSTALL_DIR) $(JAR_LIBDIR)
	$(INSTALL_FILE) $(JAR_FILE) $(JAR_LIBDIR)
else
install-jar jar: 
	@echo "You must specify a name for the jar file before running"
	@echo "install-jar or jar. See the JAR_FILE variable in the Makefile"
endif


ifneq ($(strip $(CLASS_LIBDIR)),)
install-classes:: $(JAVA_OBJS)
	$(INSTALL_DIR) $(CLASS_LIBDIR)
	$(foreach dir, $(JAVA_DIRS), \
		$(INSTALL_DIR) $(CLASS_LIBDIR)/$(dir) $(check-exit))
	$(foreach file, $(JAVA_INSTALL_OBJS), \
		$(INSTALL_FILE) $(file) $(CLASS_LIBDIR)/$(file) \
	$(check-exit))
else
install-classes: 
	@echo "Install dir for classes is not defined. See CLASS_LIBDIR"
endif


ifeq ($(findstring jikes,$(JAVAC)),jikes)
depend: $(DEPEND_OBJS)
	( $(CAT) $(DEPEND_OBJS) | $(SED) '/java/d' > $(MAKEFILE_DEPEND); \
	  $(RM) $(DEPEND_OBJS); )
else
depend: 
	@echo "You must use the jikes compiler to create a dependency graph"
endif


ifneq ($(strip $(PACKAGES)),)
doc:	$(JAVA_SRC)
	$(JAVADOC) -d $(DOCDIR) $(JAVADOC_FLAGS) $(PACKAGES)
else
doc:
	@echo "You must put your source files in package(s) to run"\
	       "make doc"
endif


clean::
	$(FIND) . \( -name '*~' -o -name '#*' \) -exec $(RM) {} \;
	$(FIND) . -name '*.class' -exec $(RM) {} \;


ifeq ($(shell test -d $(DOCDIR) && echo "true"),true)
clean::
	#$(FIND) $(DOCDIR) -name '*.html' -exec $(RM) {} \;
endif

ifneq ($(strip $(XJAVA_SRC)),)
clean::
	$(RM) $(XJAVA_OBJS)
endif



# ----------------------------------------
# Include the dependency graph if it exist
# ----------------------------------------
DEPEND	= $(shell test -r $(MAKEFILE_DEPEND) && echo "true")
ifeq ($(DEPEND),true)
	include $(MAKEFILE_DEPEND)
endif