summaryrefslogtreecommitdiff
path: root/Makefile
blob: cea4e6169f567acd50afe8e4fb3ffb0018f19666 (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
# make all: 		make bytecode archive
# make opt: 		make native archive
# make install: 	install bytecode archive, and if present, native archive
# make uninstall: 	uninstall package
# make clean: 		remove intermediate files
# make distclean: 	remove any superflous files
# make release: 	cleanup, create archive, tag CVS module 
#			(for developers)

#----------------------------------------------------------------------
# specific rules for this package:

OBJECTS  = xstr_split.cmo xstr_search.cmo xstr_match.cmo
XOBJECTS = xstr_split.cmx xstr_search.cmx xstr_match.cmx
ARCHIVE  = xstr.cma
XARCHIVE = xstr.cmxa
NAME     = xstr
#REQUIRES =
UNSAFE   =
DESTDIR =

# you may try this: (0% to 10% faster)
#UNSAFE   = -unsafe

all: $(ARCHIVE)

opt: $(XARCHIVE)

$(ARCHIVE): $(OBJECTS)
	$(OCAMLC) -a -o $(ARCHIVE) $(OBJECTS)

$(XARCHIVE): $(XOBJECTS)
	$(OCAMLOPT) -a -o $(XARCHIVE) $(XOBJECTS)

#----------------------------------------------------------------------
# general rules:

OPTIONS   =
OCAMLC    = ocamlc -g $(UNSAFE) $(OPTIONS) $(ROPTIONS)
OCAMLOPT  = ocamlopt $(UNSAFE) $(OPTIONS) $(ROPTIONS)
OCAMLDEP  = ocamldep $(OPTIONS)
OCAMLFIND = ocamlfind

depend: *.ml *.mli
	$(OCAMLDEP) *.ml *.mli >depend

#depend.pkg: Makefile
#	$(OCAMLFIND) use -p ROPTIONS= $(REQUIRES) >depend.pkg

.PHONY: install
install: all
	if [ ! -d $(DESTDIR) ] ; then mkdir -p $(DESTDIR) ; fi
	{ test ! -f $(XARCHIVE) || extra="*.cmxa *.a"; }; \
	$(OCAMLFIND) install -destdir $(DESTDIR) $(NAME) *.mli *.cmi *.cma META $$extra

.PHONY: uninstall
uninstall:
	$(OCAMLFIND) remove $(NAME)

.PHONY: clean
clean:
	rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa
	$(MAKE) -C speed clean

.PHONY: distclean
distclean: clean
	rm -f *~ depend depend.pkg
	rm -f speed/*~

RELEASE: META
	awk '/version/ { print substr($$3,2,length($$3)-2) }' META >RELEASE

.PHONY: dist
dist: RELEASE
	r=`head -1 RELEASE`; cd ..; gtar czf $(NAME)-$$r.tar.gz --exclude='*/CVS*' --exclude="*/depend.pkg" --exclude="*/depend" $(NAME)

.PHONY: tag-release
tag-release: RELEASE
	r=`head -1 RELEASE | sed -e s/\\\./-/g`; cd ..; cvs tag -F $(NAME)-$$r $(NAME)

.PHONY: release
release: distclean
	$(MAKE) tag-release
	$(MAKE) dist

.ml.cmx:
	$(OCAMLOPT) -c $<

.ml.cmo:
	$(OCAMLC) -c $<

.mli.cmi:
	$(OCAMLC) -c $<

.SUFFIXES: .cmo .cmi .cmx .ml .mli

include depend
#include depend.pkg