1#!amake
2#
3# Makefile to compile sswf (Script to SWF) with amake
4# Written by Alexis Wilke for Made to Order Software Corp (c) 2002-2009
5#
6# Copyright (c) 2002-2009 Made to Order Software Corp.
7#
8# Permission is hereby granted, free of charge, to any
9# person obtaining a copy of this software and
10# associated documentation files (the "Software"), to
11# deal in the Software without restriction, including
12# without limitation the rights to use, copy, modify,
13# merge, publish, distribute, sublicense, and/or sell
14# copies of the Software, and to permit persons to whom
15# the Software is furnished to do so, subject to the
16# following conditions:
17#
18# The above copyright notice and this permission notice
19# shall be included in all copies or substantial
20# portions of the Software.
21#
22# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
23# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
25# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
26# EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
29# ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31# SOFTWARE.
32#
33
34#shell if test "`echo {a,b}`" != "a b"; \
35	then \
36		echo "ERROR: your shell does not support the {a,b} syntax;"; \
37		exit 1; \
38	fi
39
40# Let's ensure that all the necessary directories
41# exist from the start; this makes amake happier
42#shell mkdir -p bin lib/pkgconfig tmp/{backup,object}/src/{lib,libas,libasas,libasc,misc,sswf,tools}
43
44# The following doesn't seem to have any effect... AMake still
45# "finds" the grammar in src/sswf instead.
46##shell if ! test -f tmp/object/src/sswf/sswf_grammar.h; \
47##	then touch -t 199901010000 tmp/object/src/sswf/sswf_grammar.h; fi
48
49# Get the version from the libsswf-version.h file
50# (in this way we avoid data duplication)
51#VERSION=x.y.z
52VERSION!=grep "^.define.*\\<SSWF_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*\\).*/\\1/'
53#echo "Working on SSWF version $(VERSION)"
54
55LIBSSWF_VERSION=`grep "^.define.*\\<LIBSSWF_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9][0-9]*:[0-9][0-9]*:[0-9][0-9]*\\).*/\\1/'`
56LIBSSWFC_VERSION=`grep "^.define.*\\<LIBSSWFC_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9][0-9]*:[0-9][0-9]*:[0-9][0-9]*\\).*/\\1/'`
57LIBSSWFAS_VERSION=`grep "^.define.*\\<LIBSSWFAS_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9][0-9]*:[0-9][0-9]*:[0-9][0-9]*\\).*/\\1/'`
58LIBSSWFASAS_VERSION=`grep "^.define.*\\<LIBSSWFASAS_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9][0-9]*:[0-9][0-9]*:[0-9][0-9]*\\).*/\\1/'`
59LIBSSWFASC_VERSION=`grep "^.define.*\\<LIBSSWFASC_VERSION\\>" include/sswf/libsswf-version.h | sed -e 's/.*\\([0-9][0-9]*:[0-9][0-9]*:[0-9][0-9]*\\).*/\\1/'`
60
61
62INSTALL_DIR:=/usr
63
64CINCLUDEPATH:=include tmp/object/src/sswf
65CSUFFIXES:=.c .c++ .cpp .cxx .h .h++ .hpp .s .S .l .y
66
67# By default, build the release now a days
68# Use export DEBUG=1 and export YYDEBUG=1 or specify these on the command
69# line (amake DEBUG=1 YYDEBUG=1)
70DEBUG?=0
71YYDEBUG?=0
72
73SHELL:=/bin/sh
74CC:=gcc
75CXX:=g++
76#if $(DEBUG) == 1
77CFLAGS:=-g -ggdb -Wall -Werror -DDEBUG=$(DEBUG) -DYYDEBUG=$(YYDEBUG) -DSSWF_INTERNAL_ASC=1 -Iinclude
78#else
79CFLAGS:=-O2 -Wall -Werror -DDEBUG=$(DEBUG) -DYYDEBUG=$(YYDEBUG) -DSSWF_INTERNAL_ASC=1 -Iinclude
80#endif
81LD:=ld
82LDFLAGS:=
83COPY:=cp -f
84RM:=rm -rf
85MKDIR:=mkdir -p
86AR:=ar
87YFLAGS:=-t		# enable -t for debug
88BISON:=bison
89SHARED_EXT:=so
90
91#if system(IRIX)
92BISON:=/usr/freeware/bin/bison
93DUMPLIB:=-lm /usr/freeware/lib32/libz.a
94SSWFLIB:=-L/usr/freeware/lib32 lib/libsswf.a lib/libsswf_asas.a \
95		lib/libsswf_as.a -lm /usr/freeware/lib32/libz.a \
96		/usr/freeware/lib32/libjpeg.a
97FT2SSWFLIB:=-L/usr/freeware/lib32 /usr/freeware/lib32/libfreetype.a
98JPG2SWFLIB:=lib/libsswf.a -lm /usr/freeware/lib32/libz.a /usr/freeware/lib32/libjpeg.a
99ASCLIB:=lib/libsswf_as.a
100LDFLAGS+=-woff 131
101CFLAGS+=-DIRIX=1 -I/usr/freeware/include/freetype2
102#elif system(MAC)
103DUMPLIB:=-lm -lz
104SSWFLIB:=lib/libsswf.a lib/libsswf_asas.a lib/libsswf_as.a \
105		-lm -lz -liconv /sw/lib/libjpeg.a
106FT2SSWFLIB:=/sw/lib/freetype2/lib/libfreetype.a -lz
107JPG2SWFLIB:=lib/libsswf.a -lm -lz /sw/lib/libjpeg.a -liconv
108ASCLIB:=lib/libsswf_as.a
109CFLAGS+=-I/sw/include -I/usr/X11R6/include -I/usr/X11R6/include/freetype2
110SHARED_EXT:=dylib
111#else
112DUMPLIB:=-lm -lz
113SSWFLIB:=lib/libsswf.a lib/libsswf_asas.a lib/libsswf_as.a \
114		-lm -lz -ljpeg
115FT2SSWFLIB:=-lfreetype
116JPG2SWFLIB:=lib/libsswf.a -lm -lz -ljpeg
117ASCLIB:=lib/libsswf_as.a
118CFLAGS+=-DIRIX=0 -I/usr/include/freetype2
119#endif
120
121## Some systems change CFLAGS so we need to define that afterward
122CXXFLAGS:=$(CFLAGS)
123
124
125##
126## Reads all the sources and convert to lists of object files
127##
128## Note that at this time I have the Bison .c file generated in the
129## wrong place so it is necessary to get rid of it from the list of
130## source files...
131##
132LIBSRC:=`ls src/lib/*.c++`
133LIBASSRC:=`ls src/libas/*.c++`
134LIBASASSRC:=`ls src/libasas/*.c++`
135SSWFSRCALL:=`ls src/sswf/*.c src/sswf/*.c++ src/sswf/*.y`
136SSWFSRC:=$(SSWFSRCALL:-src/sswf/sswf_grammar.c:-src/sswf/sswf_lexical.c)
137TOOLSSRC:=`ls src/tools/*.c src/tools/*.c++`
138MISCSRC:=`ls src/misc/*.c`
139PCIN_FILES:=`ls *.pc.in`
140
141
142LIBOBJ:=$(LIBSRC:*.c++=tmp/object/*.o:U)
143LIBASOBJ:=$(LIBASSRC:*.c++=tmp/object/*.o:U)
144LIBASASOBJ:=$(LIBASASSRC:*.c++=tmp/object/*.o:U)
145SSWFOBJ:=$(SSWFSRC:*.*=tmp/object/*.o:U)
146TOOLSOBJ:=$(TOOLSSRC:*.*=tmp/object/*.o:U)
147MISCOBJ:=$(MISCSRC:*.*=tmp/object/*.o:U)
148PC_FILES:=$(PCIN_FILES:*.in=lib/pkgconfig/*:U)
149
150
151TOSTRIP:=sswf swf_dump ft2sswf jpg2swf asc
152TOSTRIP_BIN:=$(TOSTRIP:*=bin/*)
153
154
155ALLLIB:= lib/libsswf.a lib/libsswf.$(SHARED_EXT) \
156		lib/libsswf_as.a lib/libsswf_as.$(SHARED_EXT) \
157		lib/libsswf_asas.a lib/libsswf_asas.$(SHARED_EXT) \
158		lib/libsswf_c.a lib/libsswf_c.$(SHARED_EXT) \
159		lib/libsswf_asc.a lib/libsswf_asc.$(SHARED_EXT)
160
161
162
163all: $(TOSTRIP_BIN) $(ALLLIB) $(PC_FILES) .PHONY
164	@echo "All of SSWF V$(VERSION) done!"
165
166version:
167	@echo $(VERSION)
168
169## Tools
170bin/swf_dump: $(.TARGET:bin/*=tmp/object/src/tools/*.o)
171	$(CC) $(CFLAGS) -o $(.TARGET) $(.FIRSTSRC) $(DUMPLIB)
172
173bin/ft2sswf: $(.TARGET:bin/*=tmp/object/src/tools/*.o)
174	$(CC) $(CFLAGS) -o $(.TARGET) $(.FIRSTSRC) $(FT2SSWFLIB)
175
176bin/jpg2swf: $(.TARGET:bin/*=tmp/object/src/tools/*.o) lib/libsswf.a
177	$(CXX) $(CXXFLAGS) -o $(.TARGET) $(.FIRSTSRC) $(JPG2SWFLIB)
178
179bin/asc: $(.TARGET:bin/*=tmp/object/src/tools/*.o) \
180		lib/libsswf_as.a lib/libsswf_asas.a
181	$(CXX) $(CXXFLAGS) -o $(.TARGET) $(.FIRSTSRC) $(ASCLIB)
182
183
184## SSWF
185bin/sswf: $(.TARGET:bin/*=tmp/object/src/sswf/*.o) $(SSWFOBJ) \
186		lib/libsswf.a lib/libsswf_asas.a lib/libsswf_as.a \
187		lib/libsswf_asc.a
188	$(CXX) $(CXXFLAGS) -o $(.TARGET) $(SSWFOBJ) $(SSWFLIB) lib/libsswf_asc.a
189
190
191
192LIBSSWF_H:=include/sswf/libsswf.h include/sswf/libsswf-config.h \
193			include/sswf/libsswf-version.h \
194			include/sswf/libsswf_as.h \
195			include/sswf/libsswf_asas.h
196
197
198
199$(PC_FILES): $(.TARGET:lib/pkgconfig/*=*.in)
200	sed -e 's%@prefix@%/usr%' \
201		-e 's%@exec_prefix@%$${prefix}%' \
202		-e 's%@libdir@%$${exec_prefix}/lib%' \
203		-e 's%@includedir@%$${prefix}/include%' \
204		-e 's%@PACKAGE_VERSION@%$(VERSION)%' \
205			$(.FIRSTSRC) >$(.TARGET)
206
207
208
209lib/libsswf.a: $(LIBOBJ)
210	$(AR) cr $(.TARGET) $(LIBOBJ)
211#if system(MAC)
212	ranlib $(.TARGET)
213#endif
214
215lib/libsswf.$(SHARED_EXT): lib/libsswf-$(VERSION).$(SHARED_EXT)
216	rm -f $(.TARGET)
217	ln -s $(.FIRSTSRC:T) $(.TARGET)
218
219lib/libsswf-$(VERSION).$(SHARED_EXT): $(LIBOBJ)
220#if system(MAC)
221	export MACOSX_DEPLOYMENT_TARGET=10.4
222	g++ -dynamiclib -single_module -Wl,-compatibility_version -Wl,$(shell expr $(LIBSSWF_VERSION:*\:*\:*=*) + 1) \
223		-Wl,-current_version -Wl,$(shell expr $(LIBSSWF_VERSION:*\:*\:*=*) + 1).$(LIBSSWF_VERSION:*\:*\:*=>*) \
224		-install_name /usr/$(.TARGET) -o $(.TARGET) $(LIBOBJ) -liconv -lz /sw/lib/libjpeg.a
225#else
226	$(LD) $(LDFLAGS) -shared -o $(.TARGET) $(LIBOBJ)
227#endif
228
229
230lib/libsswf_as.a: $(LIBASOBJ)
231	$(AR) cr $(.TARGET) $(LIBASOBJ)
232#if system(MAC)
233	ranlib $(.TARGET)
234#endif
235
236lib/libsswf_as.$(SHARED_EXT): lib/libsswf_as-$(VERSION).$(SHARED_EXT)
237	rm -f $(.TARGET)
238	ln -s $(.FIRSTSRC:T) $(.TARGET)
239
240lib/libsswf_as-$(VERSION).$(SHARED_EXT): $(LIBASOBJ)
241#if system(MAC)
242	export MACOSX_DEPLOYMENT_TARGET=10.4
243	g++ -dynamiclib -single_module -Wl,-compatibility_version -Wl,$(shell expr $(LIBSSWFAS_VERSION:*\:*\:*=*) + 1) \
244		-Wl,-current_version -Wl,$(shell expr $(LIBSSWFAS_VERSION:*\:*\:*=*) + 1).$(LIBSSWFAS_VERSION:*\:*\:*=>*) \
245		-install_name /usr/$(.TARGET) -o $(.TARGET) $(LIBASOBJ)
246#else
247	$(LD) $(LDFLAGS) -shared -o $(.TARGET) $(LIBASOBJ)
248#endif
249
250
251lib/libsswf_asas.a: $(LIBASASOBJ)
252	$(AR) cr $(.TARGET) $(LIBASASOBJ)
253#if system(MAC)
254	ranlib $(.TARGET)
255#endif
256
257lib/libsswf_asas.$(SHARED_EXT): lib/libsswf_asas-$(VERSION).$(SHARED_EXT)
258	rm -f $(.TARGET)
259	ln -s $(.FIRSTSRC:T) $(.TARGET)
260
261lib/libsswf_asas-$(VERSION).$(SHARED_EXT): $(LIBASASOBJ)
262#if system(MAC)
263	export MACOSX_DEPLOYMENT_TARGET=10.4
264	g++ -dynamiclib -noprebind -undefined dynamic_lookup -single_module \
265		-Wl,-compatibility_version -Wl,$(shell expr $(LIBSSWFASAS_VERSION:*\:*\:*=*) + 1) \
266		-Wl,-current_version -Wl,$(shell expr $(LIBSSWFASAS_VERSION:*\:*\:*=*) + 1).$(LIBSSWFASAS_VERSION:*\:*\:*=>*) \
267		-install_name /usr/$(.TARGET) -o $(.TARGET) $(LIBASASOBJ)
268#else
269	$(LD) $(LDFLAGS) -shared -o $(.TARGET) $(LIBASASOBJ)
270#endif
271
272
273ALLSRC:=$(LIBSRC) $(LIBASSRC) $(LIBASASSRC) $(SSWFSRC) $(TOOLSSRC) $(MISCSRC)
274ALLCXXOBJ:=$(ALLSRC::*.c++=tmp/object/*.o)
275ALLCOBJ:=$(ALLSRC::*.c=tmp/object/*.o)
276ALLYACCOBJ:=$(ALLSRC::*.y=tmp/object/*.o)
277ALLLEXOBJ:=$(ALLSRC::*.l=tmp/object/*.o)
278
279
280$(ALLCXXOBJ): $(.TARGET:tmp/object/*.o=*.c++:I:src/sswf/sswf_grammar.h=tmp/object/src/sswf/sswf_grammar.h)
281	$(CXX) -c $(CXXFLAGS) -I$(.TARGET:*/[^/]*.o=*) -o $(.TARGET) $(.FIRSTSRC)
282	@$(COPY) $(.FIRSTSRC) $(.FIRSTSRC:*/*/*.*=tmp/backup/*/*)
283
284$(ALLCOBJ): $(.TARGET:tmp/object/*.o=*.c:I)
285	$(CC) -c $(CFLAGS) -o $(.TARGET) $(.FIRSTSRC)
286	@$(COPY) $(.FIRSTSRC) $(.FIRSTSRC:*/*/*.*=tmp/backup/*/*)
287
288tmp/object/src/sswf/%.o: tmp/object/src/sswf/%.c
289	$(CC) -c $(CFLAGS) -Isrc/sswf -o $(.TARGET) $(.IMPSRC)
290
291tmp/object/src/sswf/%.c tmp/object/src/sswf/%.h: src/sswf/%.y $(.TARGET:tmp/object/*.c=*.y:-I) .PRECIOUS
292	$(BISON) -v -d $(YFLAGS) -b $(.TARGET:R) $(.IMPSRC) -o $(.TARGET:*.h=*.c)
293	@$(COPY) $(.IMPSRC) $(.IMPSRC:*/*/*.*=tmp/backup/*/*)
294
295
296
297##
298## Attempt to create all the samples; this is a test to
299## ensure the compiled tools work before I put them on
300## SourceForge and if you want to test your compiled
301## version too!
302##
303SSWF_SAMPLES:= \
304	dyn-button \
305	grid-button \
306	libya \
307	morph \
308	new-anim \
309	scroller \
310	sun-flower \
311	web-site-anim
312
313SSWF_LIBRARY:= \
314	c-samples \
315	check_version \
316	news-samples \
317	showfont
318
319samples test-samples: bin/sswf $(ALLLIB) .PHONY
320	echo "Test the sswf compilations"
321	if ! ( $(subst ",,$(SSWF_SAMPLES:*=cd $(PWD)/samples/* && ./run &&)) echo "Success!" ); then
322		exit 1;
323	fi
324	cd $(PWD)
325	echo "Test the C/C++ compilations"
326	for s in $(SSWF_LIBRARY:*=samples/*)
327	do
328		$(MAKE) -C $$s
329	done
330
331
332# The following targets are only for me to ease the management
333# of the packages on SourceForge
334bin/notes-to-html: $(.TARGET:bin/*=src/misc/*.c:I)
335	$(CC) $(CFLAGS) -o $(.TARGET) $(.FIRSTSRC)
336
337bin/cpp-to-c: $(.TARGET:bin/*=src/misc/*.c++:I)
338	$(CXX) $(CXXFLAGS) -o $(.TARGET) $(.FIRSTSRC)
339
340bin/asc-to-c: $(.TARGET:bin/*=src/misc/*.c++:I) lib/libsswf_as.a
341	$(CXX) $(CXXFLAGS) -o $(.TARGET) $(.FIRSTSRC) lib/libsswf_as.a
342
343tmp/CHANGES.html tmp/NOTES.html: $(.TARGET:tmp/*.html=doc/*.txt) bin/notes-to-html
344	bin/notes-to-html $(.FIRSTSRC) >$(.TARGET)
345
346
347# The following target also generates the header file:
348#
349#	include/sswf/libsswf_c.h
350#
351src/misc/libsswf_c.c++: include/sswf/libsswf.h bin/cpp-to-c
352	bin/cpp-to-c -c src/misc/libsswf_c.c++ $(.FIRSTSRC)
353
354tmp/object/src/misc/libsswf_c.o: src/misc/libsswf_c.c++
355	$(CXX) $(CXXFLAGS) -c -I include -o tmp/object/src/misc/libsswf_c.o $(.FIRSTSRC)
356
357lib/libsswf_c.a: tmp/object/src/misc/libsswf_c.o lib/libsswf.a
358	$(AR) cr $(.TARGET) tmp/object/src/misc/libsswf_c.o
359#if system(MAC)
360	ranlib $(.TARGET)
361#endif
362
363lib/libsswf_c.$(SHARED_EXT): lib/libsswf_c-$(VERSION).$(SHARED_EXT)
364	rm -f $(.TARGET)
365	ln -s $(.FIRSTSRC:T) $(.TARGET)
366
367lib/libsswf_c-$(VERSION).$(SHARED_EXT): tmp/object/src/misc/libsswf_c.o
368#if system(MAC)
369	export MACOSX_DEPLOYMENT_TARGET=10.4
370	g++ -dynamiclib -noprebind -undefined dynamic_lookup -single_module \
371		-Wl,-compatibility_version -Wl,$(shell expr $(LIBSSWFC_VERSION:*\:*\:*=*) + 1) \
372		-Wl,-current_version -Wl,$(shell expr $(LIBSSWFC_VERSION:*\:*\:*=*) + 1).$(LIBSSWFC_VERSION:*\:*\:*=>*) \
373		-install_name /usr/$(.TARGET) -o $(.TARGET) $(.FIRSTSRC)
374#else
375	#$(LD) $(LDFLAGS) -shared -o $(.TARGET) $(.FIRSTSRC)
376	g++ -shared -o $(.TARGET) $(.FIRSTSRC)
377#endif
378
379
380
381# Now I have a way to transform all the system .asc files into
382# a .cpp file to be compiled in a library. That library can then
383# be used to create a compiler with all the ASC files inside the
384# binary.
385src/libasc/asc_strings.c++: include/sswf/libsswf_asc.h bin/asc-to-c
386	bin/asc-to-c `find include -name '*.asc'` >$(.TARGET)
387
388tmp/object/src/libasc/asc_strings.o tmp/object/src/libasc/asc_core.o: src/libasc/$(.STEM).c++
389	$(CXX) $(CXXFLAGS) -c -I include -o $(.TARGET) $(.FIRSTSRC)
390
391lib/libsswf_asc.a: tmp/object/src/libasc/asc_core.o tmp/object/src/libasc/asc_strings.o
392	$(AR) cr $(.TARGET) $(.SOURCES)
393#if system(MAC)
394	ranlib $(.TARGET)
395#endif
396
397lib/libsswf_asc.$(SHARED_EXT): lib/libsswf_asc-$(VERSION).$(SHARED_EXT)
398	rm -f $(.TARGET)
399	ln -s $(.FIRSTSRC:T) $(.TARGET)
400
401lib/libsswf_asc-$(VERSION).$(SHARED_EXT): tmp/object/src/libasc/asc_strings.o tmp/object/src/libasc/asc_core.o
402#if system(MAC)
403	export MACOSX_DEPLOYMENT_TARGET=10.4
404	g++ -dynamiclib -noprebind -undefined dynamic_lookup -single_module \
405		-Wl,-compatibility_version -Wl,$(shell expr $(LIBSSWFASC_VERSION:*\:*\:*=*) + 1) \
406		-Wl,-current_version -Wl,$(shell expr $(LIBSSWFASC_VERSION:*\:*\:*=*) + 1).$(LIBSSWFASC_VERSION:*\:*\:*=>*) \
407		-install_name /usr/$(.TARGET) -o $(.TARGET) $(.SOURCES)
408#else
409	g++ -shared -o $(.TARGET) $(.SOURCES)
410#endif
411
412
413
414# Create all tar balls from Linux to put on SourceForge & m2osw
415# I removed this target because now I need to put many options
416# on the dotar command line anyway!
417#tar: .PHONY
418#	./dotar
419
420# Create a tar ball on IRIX which includes the binaries (tools & libraries)
421MOD_PATH:=modules
422irix-tar: $(TOSTRIP_BIN) $(ALLLIB) .PHONY
423	strip $(TOSTRIP_BIN)
424	-$(RM) arch
425	$(MKDIR) arch/irix/{bin,lib,dist}
426	$(MKDIR) arch/irix/include/sswf
427	for f in $(TOSTRIP_BIN) $(LIBSSWF_H) $(ALLLIB)
428	do
429		$(COPY) $$f arch/irix/$$f
430	done
431	-$(RM) dist
432	$(MKDIR) dist
433	VERSION_NUMBER=`printf "%d%02d%02d" $(VERSION:*.*.*=* * *)`
434	@echo VERSION_NUMBER is $$VERSION_NUMBER
435	sed -e "s/<VERSION>/$(VERSION)/g" -e "s/<VERSION_NUMBER>/$$VERSION_NUMBER/g" dev/sswf-irix.spec >ScriptSWF.spec
436	-$(RM) tmp/ScriptSWF*.idb
437	for f in bin/sswf bin/asc lib/*; do echo "f 0755 root sys usr/$$f $$f BASE" >>tmp/ScriptSWF1.idb; done
438	for f in `find include/sswf/scripts`
439	do
440		if test -d $$f
441		then
442			type=d
443			mode=0755
444		else
445			type=f
446			mode=0444
447		fi
448		echo "$$type $$mode root sys usr/$$f $$f BASE" >>tmp/ScriptSWF1.idb
449	done
450	for f in bin/swf_dump bin/ft2sswf bin/jpg2swf; do echo "f 0755 root sys usr/$$f $$f TOOLS" >>tmp/ScriptSWF1.idb; done
451	-$(RM) tmp/man
452	cp -r doc/man tmp/man
453	for f in tmp/man/man1/*
454	do
455		d=`echo $$f | sed -e 's/\\.1\$//'`
456		mv $$f $$d
457		pack $$d
458		echo "f 0444 root sys usr/share/catman/u_man/cat1/`basename $$d.z` $$d.z MAN" >>tmp/ScriptSWF1.idb
459	done
460	for f in doc/*.txt
461	do
462		if echo $$f | grep -vs INSTALL
463		then
464			echo "f 0444 root sys usr/relnotes/sswf/`basename $$f` $$f NOTES" >>tmp/ScriptSWF1.idb
465		fi
466	done
467	echo "d 0755 root sys usr/share/doc doc DOC" >>tmp/ScriptSWF1.idb
468	echo "d 0755 root sys usr/share/doc/sswf doc DOC" >>tmp/ScriptSWF1.idb
469	echo "d 0755 root sys usr/share/doc/sswf/html doc/html DOC" >>tmp/ScriptSWF1.idb
470	mv doc/man save_man
471	for f in doc/*/[A-Z]*; do
472		if test -d $$f; then
473			type=d
474			mode=0755
475		else
476			type=f
477			mode=0444
478		fi
479		nodoc=`echo $$f | sed -e 's/doc\\///'`
480		echo "$$type $$mode root sys usr/share/doc/sswf/$$nodoc $$f DOC" >>tmp/ScriptSWF2.idb
481	done
482	for f in doc/*/[a-z]* doc/*/*/* doc/*/*/*/*; do
483		if test -d $$f; then
484			type=d
485			mode=0755
486		else
487			type=f
488			mode=0444
489		fi
490		nodoc=`echo $$f | sed -e 's/doc\\///'`
491		echo "$$type $$mode root sys usr/share/doc/sswf/$$nodoc $$f DOC" >>tmp/ScriptSWF3.idb
492	done
493	echo "f 0644 root sys usr/share/src/sswf/sswf-$(VERSION)-src.tar.bz2 ../sswf-$(VERSION)-src.tar.bz2 SRC" >>tmp/ScriptSWF3.idb
494	mv save_man doc/man
495	export LANG=C
496	sort -k5,6 tmp/ScriptSWF?.idb >ScriptSWF.idb
497	echo "gendist -rbase . -sbase . -idb ScriptSWF.idb -spec ScriptSWF.spec -dist dist -creator $$USER -verbose"
498	gendist -rbase . -sbase . -idb ScriptSWF.idb -spec ScriptSWF.spec -dist dist -creator $$USER -verbose
499	(cd dist && chgrp user * && tar cf ../arch/irix/dist/sswf-$(VERSION)-irix-mipsR5k.tardist *)
500	tar cf tmp.tar arch
501	$(MKDIR) $(MOD_PATH)
502	bzip2 -c9 tmp.tar >$(MOD_PATH)/irix-$(VERSION)-bin.tar.bz2
503	-$(RM) arch dist tmp.tar tmp/ScriptSWF*
504
505
506
507
508# The following will install the sswf tools on your system
509install: $(TOSTRIP_BIN) $(ALLLIB) .PHONY
510	# start install strip
511	strip $(TOSTRIP_BIN)
512	# end install strip
513	# start install bin
514	install -d $(INSTALL_DIR)/bin $(INSTALL_DIR)/share/vim/syntax
515	install --mode=go-w,a+rx,u+w bin/sswf bin/swf_dump bin/ft2sswf bin/asc $(INSTALL_DIR)/bin
516	install --mode=go-w,a-x,a+r,u+w misc/sswf.vim $(INSTALL_DIR)/share/vim/syntax
517	# end install bin
518	# start install library
519	install -d $(INSTALL_DIR)/lib $(INSTALL_DIR)/include/sswf
520	install --mode=go-w,a+rx,u+w $(ALLLIB) $(INSTALL_DIR)/lib
521	install --mode=a-x,a+r,go-w,u+w include/sswf/libsswf.h \
522			include/sswf/libsswf-version.h \
523			include/sswf/libsswf-config.h \
524				$(INSTALL_DIR)/include/sswf
525	# end install library
526	# start install scripts
527	install -d $(INSTALL_DIR)/include/sswf/scripts/fonts
528	install --mode=a-x,a+r,go-w,u+w include/sswf/scripts/*.sswf $(INSTALL_DIR)/include/sswf/scripts
529	install --mode=a-x,a+r,go-w,u+w include/sswf/scripts/fonts/*.sswf $(INSTALL_DIR)/include/sswf/scripts/fonts
530	install --mode=a-x,a+r,a-w include/sswf/scripts/fonts/*.txt $(INSTALL_DIR)/include/sswf/scripts/fonts
531	# end install scripts
532	# start install doc
533	install -d $(INSTALL_DIR)/doc/sswf-$(VERSION)/images
534	if test -d doc/html
535	then
536		install --mode=a-x,a+r,go-w,u+w doc/html/*.html $(INSTALL_DIR)/doc/sswf-$(VERSION)
537		install --mode=a-x,a+r,go-w,u+w doc/html/images/* $(INSTALL_DIR)/doc/sswf-$(VERSION)/images
538	fi
539	# end install doc
540	# start install manual
541	if test -d doc/html
542	then
543		install -d $(INSTALL_DIR)/man/man1
544		for m in doc/man/man1/*.1; do \
545			gzip -c9 $$m >$$m.gz; \
546			install --mode=a-x,a+r,go-w,u+w $$m.gz $(INSTALL_DIR)/man/man1; \
547			rm $$m.gz; \
548		done
549	fi
550	# end install manual
551
552
553rpminstall: $(TOSTRIP_BIN) $(ALLLIB) .PHONY
554	strip $(TOSTRIP_BIN)
555	install -d $(bindir) $(libdir) $(includedir)/sswf/scripts/fonts \
556			$(docdir)/sswf-$(VERSION)/images $(mandir)/man1 \
557			$(datadir)/vim/syntax
558	install --mode=go-w,a+rx,u+w sswf swf_dump ft2sswf asc $(bindir)
559	install --mode=go-w,a-w,a+r,u+w sswf.vim $(datadir)/vim/syntax
560	install --mode=go-w,a+rx,u+w $(ALLLIB) $(libdir)
561	install --mode=a-x,a+r,go-w,u+w libsswf.h libsswf-version.h libsswf-config.h \
562							$(includedir)/sswf
563	install --mode=a-x,a+r,go-w,u+w include/sswf/scripts/*.sswf $(includedir)/sswf/scripts
564	install --mode=a-x,a+r,go-w,u+w include/sswf/scripts/fonts/*.sswf $(includedir)/sswf/scripts/fonts
565	install --mode=a-x,a+r,a-w include/sswf/scripts/fonts/*.txt $(includedir)/sswf/scripts/fonts
566	install --mode=a-x,a+r,go-w,u+w *.txt $(docdir)/sswf-$(VERSION)
567	install --mode=a-x,a+r,go-w,u+w doc/*.html $(docdir)/sswf-$(VERSION)
568	install --mode=a-x,a+r,go-w,u+w doc/images/* $(docdir)/sswf-$(VERSION)/images
569	if test -d doc/man
570	then
571		for m in doc/man/man1/*.1; do \
572			gzip -c9 $$m >$$m.gz; \
573			install --mode=a-x,a+r,go-w,u+w $$m.gz $(mandir)/man1; \
574			rm $$m.gz; \
575		done
576	fi
577
578
579# Installation and creation of a virtual disk on Mac OS/X
580macinstall: $(TOSTRIP_BIN) $(ALLLIB) .PHONY
581	@-chmod -R 777 disk
582	rm -rf disk
583	mkdir -p disk/sswf-$(VERSION)/usr/{bin,include,lib,share/doc/sswf-$(VERSION)}
584	cp bin/* disk/sswf-$(VERSION)/usr/bin
585	strip disk/sswf-$(VERSION)/usr/bin/*
586	cp -r include/sswf disk/sswf-$(VERSION)/usr/include
587	cd lib
588	for l in *
589	do
590		if ! test -d $$l
591		then
592			if test -L $$l
593			then
594				ln -sf `basename $$l`-$(VERSION).$(SHARED_EXT) ../disk/sswf-$(VERSION)/usr/lib/$$l
595			else
596				cp $$l ../disk/sswf-$(VERSION)/usr/lib
597			fi
598		fi
599	done
600	cd ..
601	#cp lib/* disk/sswf-$(VERSION)/usr/lib
602	cp -r doc/* disk/sswf-$(VERSION)/usr/share/doc/sswf-$(VERSION)/
603	for f in `find disk -name '*[mM]akefile*'`; do \
604		rm -f $$f; \
605	done
606	cp doc/INSTALL-MACOSX.txt disk/INSTALL.txt
607	ln -s INSTALL.txt disk/README.txt
608	cp dev/install-darwin.sh disk/install.sh
609	cp dev/uninstall-darwin.sh disk/uninstall.sh
610	for f in `find disk`; do \
611		d=`dirname $$f`; \
612		if test -d $$f -o $$d = "disk/sswf-$(VERSION)/usr/bin" -o $$d = "disk/sswf-$(VERSION)/usr/lib"; then \
613			chmod 555 $$f; \
614		else \
615			chmod 444 $$f; \
616		fi; \
617	done
618	chmod 555 disk/install.sh disk/uninstall.sh
619	chmod 700 disk
620	rm -f sswf-$(VERSION)-darwin-powerpc.dmg
621	hdiutil create -ov -quiet -volname "ScriptSWF-$(VERSION)" -anyowners -srcfolder disk -format UDZO sswf-$(VERSION)-darwin-powerpc.dmg
622
623
624# These are the cleaning targets
625clobber: rmtarget .PHONY
626	-$(RM) tmp
627
628clean cleanup: rmtarget .PHONY
629	-$(RM) tmp/object
630
631rmtarget: .PHONY
632	-$(RM) bin lib
633	-find . -name 'core' -exec rm {} \\;
634
635
636## NOTE: remove one '#' to get the echo instructions working
637##echo Info about AMake variables:
638##echo
639##echo LIB: $(LIBOBJ)
640##echo LIBAS: $(LIBASOBJ)
641##echo LIBASAS: $(LIBASASOBJ)
642##echo SSWFSRC: $(SSWFSRC)
643##echo SSWFOBJ: $(SSWFOBJ)
644##echo TOOLS: $(TOOLSOBJ)
645##echo MISC: $(MISCOBJ)
646##echo ALLOBJ: $(ALLCOBJ)
647##echo
648