File: Makefile

package info (click to toggle)
shell 0.2.1-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 540 kB
  • ctags: 376
  • sloc: ml: 1,828; makefile: 160; xml: 133; ansic: 78; sh: 9
file content (153 lines) | stat: -rw-r--r-- 4,379 bytes parent folder | download
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
# make all: 		make bytecode archive
# make opt: 		make native archive
# make world:           make as much as possible
# make findlib-install:	install bytecode archive, and if present, native archive
# make findlib-uninstall: uninstall package
# make conventional-install, conventional-uninstall
# make clean: 		remove intermediate files
# make distclean: 	remove any superflous files
#----------------------------------------------------------------------

# Config:

# INSTALLDIR: directory where to install the files for conventional-install.
# This must be an absolute path.
# Leave this variable empty if you are going to findlib-install.
#INSTALLDIR = /opt/ocaml-3.00/lib
INSTALLDIR = 

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

OBJECTS  = unix_exts.cmo shell_sys.cmo shell.cmo
XOBJECTS = $(OBJECTS:.cmo=.cmx)
COBJECTS = unix_exts_c.o
ARCHIVE  = shell.cma
XARCHIVE = shell.cmxa
CARCHIVE = libshell.a
CLINK    = -lshell
NAME     = shell

world: all try_opt

all: $(ARCHIVE) $(CARCHIVE)

opt: $(XARCHIVE) $(CARCHIVE)

try_opt:
	test ! ocamlopt >/dev/null 2>/dev/null || $(MAKE) opt

$(ARCHIVE): $(OBJECTS)
	if [ -n "$(INSTALLDIR)" ]; then                                      \
		autolink="-ccopt -L$(INSTALLDIR) -cclib $(CLINK)";           \
	else                                                                 \
	        autolink="-cclib $(CLINK)";                                  \
	fi;                                                                  \
	$(OCAMLC) -a -o $(ARCHIVE) $$autolink $(OBJECTS)

$(XARCHIVE): $(XOBJECTS)
	if [ -n "$(INSTALLDIR)" ]; then                                      \
		autolink="-ccopt -L$(INSTALLDIR) -cclib $(CLINK)";           \
	else                                                                 \
	        autolink="-cclib $(CLINK)";                                  \
	fi;                                                                  \
	$(OCAMLOPT) -a -o $(XARCHIVE) $$autolink $(XOBJECTS)

$(CARCHIVE): $(COBJECTS)
	if ocamlmklib; then                                                  \
		ocamlmklib -o shell $(COBJECTS);                             \
	else                                                                 \
		rm -f $(CARCHIVE);                                           \
		ar q $(CARCHIVE) $(COBJECTS);                                \
		ranlib $(CARCHIVE);                                          \
	fi

t: all
	OCAMLPATH=. ocamlfind ocamlmktop -o t -package . -linkpkg

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

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

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

.PHONY: install
install: findlib-install

.PHONY: findlib-install
findlib-install: all
	touch `pwd`/ld.conf
	files=`./collect_files *.mli *.cmi *.cma META *.cmxa *.a *.so` && \
	export CAMLLIB=`pwd`; $(OCAMLFIND) install -destdir $(DESTDIR) $(NAME) $$files

.PHONY: conventional-install
conventional-install: all
	test -n "$(INSTALLDIR)"
	mkdir -p $(INSTALLDIR)
	files=`./collect_files *.mli *.cmi *.cma META *.cmxa *.a *.so` && \
	FILES="$$files packlist-$(NAME)" && \
	echo $$FILES >packlist-$(NAME) && \
	cp $$FILES $(INSTALLDIR)

.PHONY: uninstall
uninstall: findlib-uninstall

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

.PHONY: conventional-uninstall
conventional-uninstall: 
	cd $(INSTALLDIR) && rm -f `cat packlist-$(NAME)`

.PHONY: clean
clean:
	rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *.so

.PHONY: CLEAN
CLEAN: clean
	$(MAKE) -C doc CLEAN

.PHONY: distclean
distclean: clean
	rm -f *~ depend depend.pkg 
	$(MAKE) -C doc distclean


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

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

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

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

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

.c.o:
	$(OCAMLC) -c $<

include depend