1#
2#       System: Structured text retrieval tool sgrep.
3#       Module: Makefile
4#       Author: Pekka Kilpel�inen & Jani Jaakkola
5#       Description: Makefile for building & installing sgrep
6#       Version history: Original version February 1995 by JJ & PK
7#       Copyright: University of Helsinki, Dept. of Computer Science
8
9EXTRA_DIST = sgrep.1 sgrep.lsm sample.sgreprc
10
11DOC_DIST = README AUTHORS COPYING ChangeLog INSTALL NEWS
12
13EDITOR_FILES = $(SOURCES) Makefile.am configure.in ChangeLog NEWS README \
14	acconfig.in
15
16# Sgrep needs to know its share directory
17INCLUDES = -DDATADIR="\"${datadir}\""
18
19bin_PROGRAMS = sgrep
20libsgrep_SOURCES = main.c preproc.c common.c parser.c optimize.c pmatch.c \
21	sgml.c eval.c output.c index.c sysdeps.c sgrep.h sysdeps.h
22sgrep_SOURCES =  $(libsgrep_SOURCES) index_main.c
23
24data_DATA=sample.sgreprc
25man_MANS=sgrep.1
26
27# The rest of this file is my private stuff
28
29BIN_DIST = $(DOC_DIST) $(EXTRA_DIST)
30WIN_BINS = sgrep.exe cygwinb19.dll m4.exe
31BUILD_SYSTEMS = hydra sirppi karhu pneuma
32
33# Some cool rules, which you really should not try at home
34
35windist:
36	rm -f sgrep-$(VERSION).zip
37	zip -l sgrep-$(VERSION).zip $(BIN_DIST)
38	cd win32; zip ../sgrep-$(VERSION).zip $(WIN_BINS)
39	chmod a+r sgrep-$(VERSION).zip
40
41bindist: $(bin_PROGRAMS)
42	-rm -rf $(distdir)
43	mkdir $(distdir)
44	-chmod 777 $(distdir)
45	for file in $(BIN_DIST); do \
46		d=$(srcdir); \
47		test -f $(distdir)/$$file \
48		|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
49		|| cp -p $$d/$$file $(distdir)/$$file; \
50	done
51	for file  in $(bin_PROGRAMS); do \
52		d=$(top_builddir); \
53		test -f $(distdir)/$$file \
54		|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
55		|| cp -p $$d/$$file $(distdir)/$$file; \
56	done
57	$(TAR) cf - $(distdir) | gzip > $(distdir)-`uname -m | sed 's/\//-/g'`-`uname -s`.tar.gz
58	-chmod a+r $(distdir)-`uname -m | sed 's/\//-/g'`-`uname -s`.tar.gz
59	-rm -rf $(distdir)
60
61update-build-directory: dist
62	cat $(distdir).tar.gz | ssh melkki "tee $(distdir).tar.gz | tar zvxf -"
63
64CONFIGURE_OPTIONS = CC=cc; CFLAGS=-O2; export CC; export CFLAGS
65
66build-all-binaries:
67	for i in $(BUILD_SYSTEMS); do \
68		( ssh $$i "cd $(distdir) && mkdir $$i; cd $$i && \
69		sh -c '$(CONFIGURE_OPTIONS); ../configure' && \
70		make" ) & \
71		done; for i in $(BUILD_SYSTEMS); do wait; done
72
73clean-all-binaries:
74	ssh melkki "for i in $(BUILD_SYSTEMS);do rm -rf $(distdir)/"'$$i'"; done"
75
76RELEASE_DIR= /home/ftp/pub/Software/Local/Sgrep
77
78release: dist
79	scp $(distdir).tar.gz melkki:$(RELEASE_DIR)
80
81release-binary: bindist
82	scp $(distdir)-`uname -m | sed 's/\//-/g'`-`uname -s`.tar.gz melkki.cs:$(RELEASE_DIR)
83
84release-winbinary: windist
85	scp $(distdir).zip melkki:$(RELEASE_DIR)
86
87release-all-binaries:
88	for i in $(BUILD_SYSTEMS); do \
89		ssh $$i "cd $(distdir)/$$i && make bindist"; \
90	done
91	for i in $(BUILD_SYSTEMS); do \
92		ssh melkki.cs "cp $(distdir)/$$i/sgrep-*.tar.gz $(RELEASE_DIR)"; \
93	done
94
95edit:
96	xemacs $(EDITOR_FILES) &
97
98# Sometimes while editing and compiling Win32-version of sgrep, the
99# files get littered by unintentional and ugly carriage returns.
100unixify:
101	for i in $(DISTFILES); do sed `printf "s/\r//g"` < $$i > tmpfile; mv tmpfile $$i; done
102
103# These hook exists for building the commercial part of sgrep,
104# the sgrep-library. It is not distributed under GPL and is not
105# available for downloading.
106
107libdist: Makefile.lib
108	$(MAKE) -f Makefile.lib VERSION="$(VERSION)" dist
109
110libclean: Makefile.lib
111	$(MAKE) -f Makefile.lib clean
112
113library: $(SGREP_OBJECTS)
114	@if test -f $(srcdir)/Makefile.lib ; then $(MAKE) -f $(srcdir)/Makefile.lib DEFS='$(DEFS)'; fi
115
116all-local: #library
117
118clean-local:
119	@if test -f $(srcdir)/Makefile.lib ; then $(MAKE) -f $(srcdir)/Makefile.lib clean; fi
120
121distclean-local: clean-local
122maintainer-clean-local: clean-local
123
124