summaryrefslogtreecommitdiff
path: root/Makefile.in
blob: 66a798eccb8eea7f2b026e1a99a4dfe3691efc1c (plain)
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
#######################################################################
# $Header$
#######################################################################

prefix      = @prefix@
exec_prefix = @exec_prefix@
srcdir      = @srcdir@
libdir      = @libdir@

##############################################################################
# Compiler and system configuration
##############################################################################

SHELL       = /bin/sh
CC          = @CC@
CFLAGS      = @CFLAGS@
CXX         = @CXX@
LIBS        = @LIBS@
SWIGLIBS    = @SWIGLIBS@
AR          = @AR@
RANLIB      = @RANLIB@

# Note: Files in `SWIG_LIB' are machine independent so we use `prefix'
# instead of `exec_prefix' or, derivatively, `libdir'.
SWIG_LIB    = @swig_lib@
BIN_DIR     = @bindir@
TARGET      = swig@release_suffix@
SOURCE      = Source
SOURCEDIRS  = `ls $(SOURCE)`

swig: Modules Swig Preprocessor CParse DOH runtime swig.spec
	$(CXX) -o $(TARGET) \
	$(SOURCE)/Modules/libmodules.a \
	$(SOURCE)/CParse/libcparse.a \
	$(SOURCE)/Preprocessor/libcpp.a \
	$(SOURCE)/Swig/libswig.a \
	$(SOURCE)/DOH/libdoh.a @SWIGLIBS@

Modules: Source/Include/swigconfig.h
	@cd $(SOURCE)/Modules; $(MAKE)

Swig: Source/Include/swigconfig.h
	@cd $(SOURCE)/Swig; $(MAKE)

Preprocessor: Source/Include/swigconfig.h
	@cd $(SOURCE)/Preprocessor; $(MAKE)

CParse: Source/Include/swigconfig.h
	@cd $(SOURCE)/CParse; $(MAKE)

swig.spec: swig.spec.in config.status
	@CONFIG_HEADERS= CONFIG_LINKS= CONFIG_FILES=swig.spec $(SHELL) ./config.status

DOH: Source/Include/swigconfig.h
	@cd $(SOURCE)/DOH; $(MAKE)

.PHONY: SWIG1.1 Modules Swig Preprocessor DOH runtime

#####################################################################
# All the languages SWIG speaks (when it wants to)
#####################################################################

skip-tcl	= [ -z "@TCLINCLUDE@" -o -z "@TCLLIB@" ]
skip-perl	= [ -z "@PERL@" -o -z "@PERL5EXT@" ]
skip-python	= [ -z "@PYINCLUDE@" -o -z "@PYLIB@" ]
skip-java	= [ -z "@JAVA@" -o -z "@JAVAC@" -o -z "@JAVAINC@" ]
skip-guile	= [ -z "@GUILEINCLUDE@" -o -z "@GUILELIB@" ]
skip-mzscheme	= [ -z "@MZC@" ]
skip-ruby	= [ -z "@RUBY@" -o -z "@RUBYINCLUDE@" -o -z "@RUBYLIB@" ]
skip-php4	= [ -z "@PHP4@" -o -z "@PHP4INC@" ]
skip-ocaml      = [ -z "@OCAMLBIN@" -o -z "@OCAMLINC@" ]
skip-pike       = [ -z "@PIKE@" -o -z "@PIKEINCLUDE@" ]

#####################################################################
# Runtime libraries
#####################################################################

runtime:
	@-$(skip-tcl)      || (cd Runtime; $(MAKE) tcl)
	@-$(skip-python)   || (cd Runtime; $(MAKE) python)
	@-$(skip-perl)     || (cd Runtime; $(MAKE) perl5)
	@-$(skip-ruby)     || (cd Runtime; $(MAKE) ruby)
	@-$(skip-guile)    || (cd Runtime; $(MAKE) guile)
	@-$(skip-mzscheme) || (cd Runtime; $(MAKE) mzscheme)
	@-$(skip-php4)     || (cd Runtime; $(MAKE) php4)
	@-$(skip-ocaml)    || (cd Runtime; $(MAKE) ocaml)
#	@-$(skip-pike)     || (cd Runtime; $(MAKE) pike)

#####################################################################
# CHECK
#####################################################################

ACTION = check

chk-set-swiglib		= SWIG_LIB=@ROOT_DIR@/Lib
chk-set-runtimelib	= RUNTIMEDIR=@ROOT_DIR@/Runtime/.libs
chk-set-swig		= SWIG=@ROOT_DIR@/$(TARGET)

chk-set-env = $(chk-set-swiglib) $(chk-set-swig) $(chk-set-runtimelib)

chk = $(MAKE) -k -s $(chk-set-env) $(ACTION)

check-aliveness:
	test -x ./$(TARGET)
	./$(TARGET) -version
	./$(TARGET) -help
	@$(skip-tcl)      || ./$(TARGET) -tcl      -help
	@$(skip-perl)     || ./$(TARGET) -perl     -help
	@$(skip-python)   || ./$(TARGET) -python   -help
	@$(skip-java)     || ./$(TARGET) -java     -help
	@$(skip-guile)    || ./$(TARGET) -guile    -help
	@$(skip-mzscheme) || ./$(TARGET) -mzscheme -help
	@$(skip-ruby)     || ./$(TARGET) -ruby     -help
	@$(skip-ocaml)    || ./$(TARGET) -ocaml    -help
	@$(skip-php4)     || ./$(TARGET) -php4     -help
#	@$(skip-pike)     || ./$(TARGET) -pike     -help

check-examples:					\
	check-tcl-examples			\
	check-perl-examples			\
	check-python-examples			\
	check-java-examples			\
	check-guile-examples			\
	check-mzscheme-examples			\
	check-ruby-examples			\
	check-ocaml-examples			\
	check-php4-examples			\
#	check-pike-examples

check-%-examples:
	@passed=true;						\
	dir="Examples/$*";					\
	if $(skip-$*); then					\
	  echo skipping $* $(ACTION);				\
	elif [ ! -f $$dir/check.list ]; then			\
	  echo skipping $* $(ACTION) "(no $$dir/check.list)";	\
	else							\
	  all=`sed '/^#/d' $$dir/check.list`;			\
	  for a in $$all; do					\
	    echo $(ACTION)ing $$dir/$$a;			\
	    (cd $$dir/$$a && $(chk))				\
	    || passed=false;					\
	  done;							\
	fi;							\
	test $$passed = true

check-test-suite:				\
	check-tcl-test-suite			\
	check-perl-test-suite			\
	check-python-test-suite			\
	check-java-test-suite			\
	check-guile-test-suite			\
	check-mzscheme-test-suite		\
	check-ruby-test-suite			\
	check-ocaml-test-suite			\
	check-php4-test-suite			\
#	check-pike-test-suite

check-%-test-suite:
	@passed=true;							\
	dir="Examples/test-suite/$*";					\
	if $(skip-$*); then						\
	  echo skipping $* test-suite $(ACTION);			\
	elif [ ! -d $$dir ]; then					\
	  echo skipping $* test-suite $(ACTION) "(no dir $$dir)";	\
	else								\
	  (cd $$dir && $(chk))						\
	  || passed=false;						\
	fi;								\
	test $$passed = true

gifplot-library:
	@echo $(ACTION)ing Examples/GIFPlot/Lib
	@cd Examples/GIFPlot/Lib ; $(MAKE) -k -s $(ACTION)

check-gifplot:					\
	check-tcl-gifplot			\
	check-perl-gifplot			\
	check-python-gifplot			\
	check-java-gifplot			\
	check-guile-gifplot			\
	check-mzscheme-gifplot			\
	check-ruby-gifplot			\
	check-ocaml-gifplot			\
	check-php4-gifplot			\
#	check-pike-gifplot

check-%-gifplot: gifplot-library
	@passed=true;						\
	up=`Tools/capitalize $*`;				\
	dir="Examples/GIFPlot/$$up";				\
	if $(skip-$*); then					\
	  echo skipping $$up $(ACTION);				\
	elif [ ! -f $$dir/check.list ]; then			\
	  echo skipping $$up $(ACTION) "(no $$dir/check.list)";	\
	else							\
	  all=`sed '/^#/d' $$dir/check.list`;			\
	  for a in $$all; do					\
	    echo $(ACTION)ing $$dir/$$a;			\
	    (cd $$dir/$$a && $(chk))				\
	    || passed=false;					\
	  done;							\
	fi;							\
	test $$passed = true

check: check-aliveness check-examples check-gifplot check-test-suite

#####################################################################
# CLEAN
#####################################################################

clean: clean-objects clean-examples clean-gifplot clean-test-suite

clean-objects:
	@for i in $(SOURCEDIRS) ; \
	do \
	   echo cleaning $(SOURCE)/$$i; \
	   if [ -d $(SOURCE)/$$i -a -f $(SOURCE)/$$i/Makefile ]; then \
		(cd $(SOURCE)/$$i; $(MAKE) -s clean) ; \
	   fi \
	done;
	@echo cleaning Runtime
	@cd Runtime; $(MAKE) -s clean
	@rm -f $(TARGET)

distclean-dead = config.status config.log config.cache swig.spec \
		 @configure_substituted_files@

distclean: clean
	rm -f $(distclean-dead)

clean-examples:
	@$(MAKE) -k -s check-examples ACTION=clean

clean-gifplot:
	@$(MAKE) -k -s check-gifplot ACTION=clean

clean-test-suite:
	@echo cleaning Examples/test-suite
	@$(MAKE) -k -s check-test-suite ACTION=clean

clean-%-examples:
	@$(MAKE) -k -s check-$*-examples ACTION=clean

clean-%-test-suite:
	@$(MAKE) -k -s check-$*-test-suite ACTION=clean

clean-%-gifplot:
	@$(MAKE) -k -s check-$*-gifplot ACTION=clean


#####################################################################
# TARGETS: install & friends
#####################################################################

INSTALL         = install-sh -c
INSTALL_DATA    = ${INSTALL} -m 644
INSTALL_PROGRAM = $(srcdir)/${INSTALL} -m 755
MKINSTDIRS      = $(srcdir)/mkinstalldirs

install: install-main install-lib install-runtime
	@echo "Installation complete"

install-main:
	@echo "Installing $(BIN_DIR)/swig"
	@$(MKINSTDIRS) $(DESTDIR)$(BIN_DIR)
	@if [ -f swig.exe ]; then swig=swig.exe; else swig=$(TARGET); fi; \
	$(INSTALL_PROGRAM) $$swig $(DESTDIR)$(BIN_DIR)/$$swig

lib-languages = tcl perl5 python guile java mzscheme ruby php4 ocaml pike

install-lib:
	@echo "Installing the SWIG library"
	@$(MKINSTDIRS) $(DESTDIR)$(SWIG_LIB)
#	cd $(SWIG_LIB); rm -rf *
	@cd $(srcdir)/Lib; for i in *.i *.swg; \
	    do \
	    echo "Installing Lib/$$i"; \
            ../$(INSTALL_DATA) $$i $(DESTDIR)$(SWIG_LIB)/$$i; \
	    done;
	@for lang in $(lib-languages);				\
	    do							\
	    dst=$(DESTDIR)$(SWIG_LIB)/$$lang;			\
	    $(MKINSTDIRS) $$dst;				\
	    ( cd $(srcdir)/Lib/$$lang;				\
	      doti="`ls *.i 2>/dev/null`";			\
	      dotswg="`ls *.swg 2>/dev/null`";			\
	      if [ -f extra-install.list ]; then		\
		  extra="`sed '/^#/d' extra-install.list`";	\
	      fi;						\
	      files="`echo $$doti $$dotswg $$extra`";		\
	      if [ x"$$files" = x ]; then			\
		  echo "Installing nothing from Lib/$$lang";	\
	      else for file in $$doti $$dotswg $$extra;		\
		  do						\
		  echo "Installing Lib/$$lang/$$file";		\
		  ../../$(INSTALL_DATA) $$file $$dst/$$file;	\
		  done;						\
	      fi );						\
	    done


install-runtime:
	@cd Runtime; $(MAKE) install


#####################################################################
# TARGETS: uninstall & friends
#####################################################################

uninstall: uninstall-main uninstall-lib uninstall-runtime
	@echo "Uninstall complete"

uninstall-main:
	@echo "Uninstalling $(BIN_DIR)/swig"
	@if [ -f swig.exe ]; then                                               \
		rm -f $(DESTDIR)$(BIN_DIR)/swig.exe;   \
	else                                                                    \
		rm -f $(DESTDIR)$(BIN_DIR)/$(TARGET);  \
	fi

uninstall-lib:
	@echo "Uninstalling the SWIG library"
	rm -rf $(DESTDIR)$(SWIG_LIB)/;

uninstall-runtime:
	@cd Runtime; $(MAKE) uninstall


############################################################################
# DIST and other maintenance
############################################################################

# distribution directory
dd = @PACKAGE_NAME@-@PACKAGE_VERSION@
srpm = @PACKAGE_NAME@-@PACKAGE_VERSION@

dist:
	@echo 'Dave, what do you want to do w/ "make dist"?'
	@echo 'See Makefile.in target "dist-suggested" for an idea.'
	@echo '    --thi'
	false

dist-suggested:
	rm -rf $(dd) $(dd).tar.gz
	cvs export -d $(dd) -r HEAD SWIG
	tar cf - $(dd) | gzip --best > $(dd).tar.gz
	rm -rf $(dd)

srcrpm: swig.spec
	rm -fr $(srpm) $(srpm).src.rpm
	cvs export -d $(srpm) -r HEAD SWIG
	cp swig.spec $(srpm)
	tar -cf - $(srpm) | gzip --best > $(srpm).tar.gz
	rm -fr $(srpm)
	rpm -ts $(srpm).tar.gz

# Makefile ends here