~rdoering/ubuntu/intrepid/erlang/fix-535090

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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
# ``The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
# retrieved via the world wide web at http://www.erlang.org/.
# 
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
# 
# The Initial Developer of the Original Code is Ericsson Utvecklings AB.
# Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
# AB. All Rights Reserved.''
# 
#     $Id$
#
# Toplevel makefile for building the Erlang system
#

# ----------------------------------------------------------------------

# And you'd think that this would be obvious... :-)
SHELL = /bin/sh

# The top directory in which Erlang is unpacked
ERL_TOP = @ERL_TOP@

# erts (Erlang RunTime System) version
ERTS = @ERTS@

# ----------------------------------------------------------------------

#
# The variables below control where Erlang is installed. They are
# configurable (unless otherwise stated). Some of them are best
# changed by giving special arguments to configure instead of changing
# them in this file. Note: If you change them in Makefile, instead of
# Makefile.in your changes will be lost the next time you run
# configure.
#

# prefix from autoconf, default is /usr/local (must be an absolute path)
prefix      = @prefix@
exec_prefix = @exec_prefix@

# The following can be set in case you install Erlang in a different
# location from where you have configured it to run. This can be
# useful e.g. when installing on a server that stores the files with a
# different path from where the clients access them. Or when building
# rpms.
#INSTALL_PREFIX =
# Naah...override `prefix' instead.

# The directory in which user executables (erl, erlc and erl_call) are put
BINDIR      = $(INSTALL_PREFIX)@bindir@

# The directory which will contain installed Erlang version.
# (ILIBDIR is supposed to be LIBDIR *without* the install prefix)
ERLANG_LIBDIR     = $(INSTALL_PREFIX)@libdir@/erlang
ERLANG_ILIBDIR    = @libdir@/erlang

# You can *not* change these two, they have to stay this way for now.
ERLANG_BINDIR     = $(ERLANG_LIBDIR)/bin
ERLANG_ERTSBINDIR = $(ERLANG_LIBDIR)/$(ERTS)/bin

# The directory in which man pages for above executables are put
ERL_MAN1DIR      = $(INSTALL_PREFIX)@mandir@/man1
ERL_MAN1EXT      = 1

# The directory in which Erlang private man pages are put. In order
# not to clutter up the man namespace these are by default put in the
# Erlang private directory $(ERLANG_ILIBDIR)/man. If you want to
# install the man pages together with the rest give the argument
# "--disable-erlang-mandir" when you run configure, which will set
# MAN_DIR to @mandir@.
#   If you want a special suffix on the manpages set ERL_MANEXT to
# this suffix, e.g. "erl"
ERL_MANDIR       = $(INSTALL_PREFIX)@erl_mandir@
ERL_MANEXT       =

# ----------------------------------------------------------------------

# Must be GNU make!
MAKE    = @MAKE_PROG@

# This should be set to the target "arch-vendor-os"
TARGET  = @TARGET@

# A BSD compatible install program
INSTALL         = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA    = @INSTALL_DATA@
MKSUBDIRS       = ${INSTALL} -d

# Program to create symbolic links
LN_S            = @LN_S@

# Ranlib program, if not needed set to e.g. ":"
RANLIB          = @RANLIB@

# ----------------------------------------------------------------------

# The directories bootsrap and bootstrap_compiler (during primary bootstrap)
# are placed under this directory, typically one might want to set
# this to a fast local filesystem, or, the default, as ERL_TOP
BOOTSTRAP_ROOT = $(ERL_TOP)
# Directories which you need in the path if you wish to run the
# locally built system. (This can be put in front or back of the path
# depending on which system is preferred.)
LOCAL_PATH     = $(ERL_TOP)/erts/bin/$(TARGET):$(ERL_TOP)/erts/bin
ifeq ($(TARGET),win32)
WIN32_WRAPPER_PATH=$(ERL_TOP)/erts/etc/win32/cygwin_tools
BOOT_PREFIX=$(WIN32_WRAPPER_PATH):$(BOOTSTRAP_ROOT)/bootstrap/bin:
else
BOOT_PREFIX=$(BOOTSTRAP_ROOT)/bootstrap/bin:
endif
# ----------------------------------------------------------------------
# Fix up RELEASE_ROOT/TESTROOT havoc
ifeq ($(RELEASE_ROOT),)
ifneq ($(TESTROOT),)
RELEASE_ROOT = $(TESTROOT)
endif
endif


# ----------------------------------------------------------------------

# A default for the release_tests, not same target dir as release.
# More TESTROOT havoc...
ifeq ($(TESTSUITE_ROOT),)
ifneq ($(TESTROOT),)
TESTSUITE_ROOT = $(TESTROOT)
else
TESTSUITE_ROOT = $(ERL_TOP)/release/tests
endif
endif

#
# The steps to build a working system are:
#   * build an emulator
#   * setup the erl and erlc program in bootstrap/bin
#   * build additional compilers and copy them into bootstrap/lib
#   * use the bootstrap erl and erlc to build all the libs
#
all: all_bootstraps \
     libs local_setup

# With all bootstraps we mean all bootstrapping that is done when
# the system is delivered in open source, the primary
# bootstrap is not included, it requires a pre built emulator...
all_bootstraps: depend emulator \
     bootstrap_setup \
     secondary_bootstrap_build secondary_bootstrap_copy \
     tertiary_bootstrap_build tertiary_bootstrap_copy \
     fourth_bootstrap_build fourth_bootstrap_copy 

#
# Use these targets when you want to use the erl and erlc
# binaries in your PATH instead of those created from the
# pre-compiled Erlang modules under bootstrap/.
#
ifeq ($(findstring ose,$(TARGET)),ose)
noboot:
	$(MAKE) BOOT_PREFIX= emulator libs
else
noboot:
	$(MAKE) BOOT_PREFIX= emulator libs local_setup
endif
noboot_install:
	$(MAKE) BOOT_PREFIX= install

.PHONY: release release_docs

release:
ifeq ($(OTP_SMALL_BUILD),true)
	cd $(ERL_TOP)/lib  && $(MAKE) TESTROOT=$(RELEASE_ROOT) release
else
	cd $(ERL_TOP)/lib  && $(MAKE) BUILD_ALL=1 TESTROOT=$(RELEASE_ROOT) release
endif
	cd $(ERL_TOP)/erts && $(MAKE) BUILD_ALL=1 TESTROOT=$(RELEASE_ROOT) release

# ---------------------------------------------------------------
# Target only used when building commercial ERTS patches
# ---------------------------------------------------------------
release_docs:
ifeq ($(OTP_SMALL_BUILD),true)
	cd $(ERL_TOP)/lib  && $(MAKE) TESTROOT=$(RELEASE_ROOT) release_docs
else
	cd $(ERL_TOP)/lib  && $(MAKE) BUILD_ALL=1 TESTROOT=$(RELEASE_ROOT) release_docs
endif
	cd $(ERL_TOP)/erts && $(MAKE) BUILD_ALL=1 TESTROOT=$(RELEASE_ROOT) release_docs


# ----------------------------------------------------------------------
ERLANG_EARS=$(BOOTSTRAP_ROOT)/bootstrap/erts
ELINK=$(BOOTSTRAP_ROOT)/bootstrap/erts/bin/elink
BOOT_BINDIR=$(BOOTSTRAP_ROOT)/bootstrap/erts/bin
BEAM_EVM=$(ERL_TOP)/bin/$(TARGET)/beam_evm
BOOTSTRAP_COMPILER  =  $(BOOTSTRAP_ROOT)/bootstrap_compiler

build_boot:
	cd erts/boot/src && ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
		$(MAKE) opt

emulator:
	cd erts && ERL_TOP=$(ERL_TOP) $(MAKE) NO_START_SCRIPTS=true $(TYPE)

libs:
ifeq ($(OTP_SMALL_BUILD),true)
	cd lib && \
	  ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
		$(MAKE) opt
else
	cd lib && \
	  ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
		$(MAKE) opt BUILD_ALL=true
endif
kernel:
	cd lib/kernel && \
	  ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
		$(MAKE) opt BUILD_ALL=true

hlib:
	cd lib/hipe && \
	  ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
		$(MAKE) opt BUILD_ALL=true

dep depend:
	cd erts/emulator && ERL_TOP=$(ERL_TOP) $(MAKE) generate depend

# Creates "erl" and "erlc" in bootstrap/bin which uses the precompiled 
# libraries in the bootstrap directory

# ----------------------------------------------------------------------
# Bootstraps... 
# ----------------------------------------------------------------------
ifeq ($(TARGET),win32)
bootstrap_setup:
	@rm -f $(BOOTSTRAP_ROOT)/bootstrap/bin/erl.exe \
		$(BOOTSTRAP_ROOT)/bootstrap/bin/erlc.exe \
		$(BOOTSTRAP_ROOT)/bootstrap/bin/erl.ini \
		$(BOOTSTRAP_ROOT)/bootstrap/bin/beam.dll
	make_bootstrap_ini.sh $(BOOTSTRAP_ROOT)/bootstrap \
		$(ERL_TOP)/bin/$(TARGET)
	@cp $(ERL_TOP)/bin/$(TARGET)/erlc.exe \
		$(BOOTSTRAP_ROOT)/bootstrap/bin/erlc.exe
	@cp $(ERL_TOP)/bin/$(TARGET)/erl.exe \
		$(BOOTSTRAP_ROOT)/bootstrap/bin/erl.exe
else
bootstrap_setup:
	@rm -f $(BOOTSTRAP_ROOT)/bootstrap/bin/erl \
		$(BOOTSTRAP_ROOT)/bootstrap/bin/erlc
	@sed	-e "s;%FINAL_ROOTDIR%;$(BOOTSTRAP_ROOT)/bootstrap;"   \
		-e "s;\$$ROOTDIR/erts-.*/bin;$(ERL_TOP)/bin/$(TARGET);"    \
		-e "s;EMU=.*;EMU=beam$(TYPEMARKER);" \
	        $(ERL_TOP)/erts/etc/unix/erl.src.src > \
			$(BOOTSTRAP_ROOT)/bootstrap/bin/erl
	@cp $(ERL_TOP)/bin/$(TARGET)/erlc $(BOOTSTRAP_ROOT)/bootstrap/bin/erlc
	@chmod 755 $(BOOTSTRAP_ROOT)/bootstrap/bin/erl \
		$(BOOTSTRAP_ROOT)/bootstrap/bin/erlc
endif


secondary_bootstrap_build:
	cd lib && \
	  ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
		$(MAKE) opt SECONDARY_BOOTSTRAP=true

secondary_bootstrap_copy:
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/ebin ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/ebin ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/include ; fi
	cp -f lib/kernel/ebin/*.beam $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/ebin
	cp -f lib/kernel/include/*.hrl $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/include
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/hipe ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/hipe ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/hipe/ebin ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/hipe/ebin ; fi
	if test -f lib/hipe/ebin/hipe.beam ; then cp lib/hipe/ebin/*.beam $(BOOTSTRAP_ROOT)/bootstrap/lib/hipe/ebin; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/parsetools ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/parsetools ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/parsetools/ebin ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/parsetools/ebin ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/parsetools/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/parsetools/include ; fi
	cp lib/parsetools/ebin/*.beam $(BOOTSTRAP_ROOT)/bootstrap/lib/parsetools/ebin
	cp -f lib/parsetools/include/*.hrl $(BOOTSTRAP_ROOT)/bootstrap/lib/parsetools/include
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/asn1 ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/asn1 ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/asn1/ebin ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/asn1/ebin ; fi
	cp lib/asn1/ebin/*.beam $(BOOTSTRAP_ROOT)/bootstrap/lib/asn1/ebin

tertiary_bootstrap_build:
	cd lib && \
	  ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
		$(MAKE) opt TERTIARY_BOOTSTRAP=true

tertiary_bootstrap_copy:
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/snmp ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/snmp ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/snmp/ebin ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/snmp/ebin ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/snmp/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/snmp/include ; fi
	cp lib/snmp/ebin/*.beam $(BOOTSTRAP_ROOT)/bootstrap/lib/snmp/ebin

fourth_bootstrap_build:
	cd lib && \
	  ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
		$(MAKE) opt FOURTH_BOOTSTRAP=true

fourth_bootstrap_copy:
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/sasl ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/sasl ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/sasl/ebin ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/sasl/ebin ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/sasl/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/sasl/include ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/ic ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/ic ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/ic/ebin ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/ic/ebin ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/ic/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/ic/include ; fi
	cp lib/ic/ebin/*.beam $(BOOTSTRAP_ROOT)/bootstrap/lib/ic/ebin
	cp -f lib/ic/include/*.idl lib/ic/include/*.h $(BOOTSTRAP_ROOT)/bootstrap/lib/ic/include
	cp lib/sasl/ebin/*.beam $(BOOTSTRAP_ROOT)/bootstrap/lib/sasl/ebin

# The first bootstrap build is rarely (never) used in open source, it's
# used to build the shipped bootstrap directory. The Open source bootstrap 
# stages start with secondary bootstrap.
#
# These are the ones used, the other ones (prefixed with old_) are for BC.

# These modules should stay in the kernel directory to make building
# of the emulator possible
KERNEL_PRELOAD    = otp_ring0 init erl_prim_loader prim_inet prim_file erlang

primary_bootstrap:
	@echo "=== Building a bootstrap compiler in $(BOOTSTRAP_ROOT)/bootstrap"
	cd $(ERL_TOP) && \
		$(MAKE) TESTROOT=$(BOOTSTRAP_ROOT)/bootstrap \
		primary_bootstrap_build
	cd $(ERL_TOP) && \
		$(MAKE) TESTROOT=$(BOOTSTRAP_ROOT)/bootstrap \
		primary_bootstrap_copy
	cd $(ERL_TOP)/erts/start_scripts && \
		$(MAKE) TESTROOT=$(BOOTSTRAP_ROOT)/bootstrap bootstrap_scripts	

primary_bootstrap_build: primary_bootstrap_compiler
	test -d $(TESTROOT) || mkdir -p $(TESTROOT)
	cd lib && $(MAKE) ERLC_FLAGS='-pa $(BOOTSTRAP_COMPILER)' \
		BOOTSTRAP=1 opt
	cd lib/kernel/src && $(MAKE) ERLC_FLAGS='-pa $(BOOTSTRAP_COMPILER)' \
		HIPE_ENABLED= opt

primary_bootstrap_compiler: 
	test -d $(BOOTSTRAP_COMPILER) || mkdir -p  $(BOOTSTRAP_COMPILER)
	cd lib/compiler && $(MAKE) BOOTSTRAP=1 opt
	cp -f lib/compiler/ebin/*.beam $(BOOTSTRAP_COMPILER)
	cd lib/compiler && $(MAKE) BOOTSTRAP=1 clean

primary_bootstrap_copy:
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/ebin ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/ebin ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/include ; fi
	cp -f lib/kernel/ebin/*.beam $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/ebin
	cp -f lib/kernel/include/*.hrl $(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/include
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/stdlib ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/stdlib ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/stdlib/ebin ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/stdlib/ebin ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/stdlib/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/stdlib/include ; fi
	cp -f lib/stdlib/ebin/*.beam $(BOOTSTRAP_ROOT)/bootstrap/lib/stdlib/ebin
	cp -f lib/stdlib/include/*.hrl $(BOOTSTRAP_ROOT)/bootstrap/lib/stdlib/include
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/compiler ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/compiler ; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/compiler/ebin ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/compiler/ebin ; fi
	cp -f lib/compiler/ebin/*.beam $(BOOTSTRAP_ROOT)/bootstrap/lib/compiler/ebin
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/orber ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/orber; fi
	if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/orber/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/orber/include; fi
	cp -f lib/orber/include/* $(BOOTSTRAP_ROOT)/bootstrap/lib/orber/include

# To remove modules left by the bootstrap building, but leave (restore)
# the modules in kernel which are needed for an emulator build
KERNEL_PRELOAD_BEAMS=$(KERNEL_PRELOAD:%=$(BOOTSTRAP_ROOT)/bootstrap/lib/kernel/ebin/%.beam)
primary_bootstrap_cleanup:
	cd lib && $(MAKE) BOOTSTRAP=1 clean
	cd lib/kernel/src && $(MAKE) BOOTSTRAP=1 clean
	cp $(KERNEL_PRELOAD_BEAMS) lib/kernel/ebin
	rm -rf $(BOOTSTRAP_COMPILER)

# Creates "erl" and "erlc" scripts in bin/erl which uses the libraries in lib
local_setup:
	@rm -f erts/bin/erl erts/bin/erlc erts/bin/cerl
	@cd erts && \
		ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
		$(MAKE) local_setup



# ----------------------------------------------------------------------
# Build tests
# ---------------------------------------------------------------------

# Start with building the test server
TESTS = test_server

# Tests that can be run on any platform (keep alphabetic order, please)
TESTS +=					\
	asn1_test				\
	compiler_test				\
	emulator_test				\
	epmd_test				\
	erl_interface_test			\
	eva_test				\
	ic_test					\
	inets_test				\
	kernel_test				\
	megaco_test				\
	mnemosyne_test				\
	mnesia_session_test			\
	mnesia_test				\
	observer_test                           \
	orber_test				\
	os_mon_test				\
	otp_mibs_test				\
	pman_test				\
	sasl_test				\
	snmp_test				\
	runtime_tools_test			\
	stdlib_test				\
	system_test				\
	test_server_test

# Tests that can *not* be run on VxWorks
ifneq ($(findstring vxworks,$(TARGET)),vxworks)
TESTS +=					\
	cosTransactions_test			\
	cosEvent_test				\
	cosTime_test				\
	cosNotification_test			\
	cosProperty_test			\
	cosFileTransfer_test			\
	cosEventDomain_test			\
	crypto_test				\
	debugger_test				\
	hipe_test				\
	odbc_test				\
	ssl_test				\
	tools_test				\
	toolbar_test
endif

.PHONY: tests release_tests test_server emulator_test system_test epmd_test

tests release_tests: $(TESTS)

# Build the test_server
test_server:
	cd lib/test_server    && $(MAKE) TESTROOT=$(TESTSUITE_ROOT) release_tests

emulator_test:
	cd erts/emulator/test && $(MAKE) TESTROOT=$(TESTSUITE_ROOT) release_tests

system_test:
	cd erts/test          && $(MAKE) TESTROOT=$(TESTSUITE_ROOT) release_tests

epmd_test:
	cd erts/epmd/test     && $(MAKE) TESTROOT=$(TESTSUITE_ROOT) release_tests

%_test:
	@dir="`echo $@ | sed 's/_test$$//'`"; \
	 cd lib/$$dir/test    && $(MAKE) TESTROOT=$(TESTSUITE_ROOT) release_tests
# Should I also set TESTROOT_DIR=$(TESTSUITE_ROOT)  ?
# ----------------------------------------------------------------------

# ----------------------------------------------------------------------
# Obsolete type of bootstrap where all stages where built with installed sytem 
# shuld no longer be used and is soon to be removed.
# Abbreviations: OC = Old Compiler, NC = New Compiler,
# 		 OE = Old Emulator, NE = New Emulator

old_com_bootstrap: old_bootstrap_nc_for_ne_all_stages old_bootstrap_ne old_bootstrap_scripts

#
# Builds the New Compiler for the New Emulator (using existing erlc
# and possibly new compiler) then copy everything to the release area.
# Use to create the commerciall bootstrap version, which should be obsolete.
#
old_bootstrap_nc_for_ne_all_stages:
	test -d $(TESTROOT) || mkdir -p $(TESTROOT)
	cd lib && $(MAKE) BOOTSTRAP=1 TYPE=release release
	cd lib && $(MAKE) SECONDARY_BOOTSTRAP=1 TYPE=release release
	cd lib && $(MAKE) TERTIARY_BOOTSTRAP=1 TYPE=release release
	cd lib && $(MAKE) FOURTH_BOOTSTRAP=1 TYPE=release release



old_bootstrap_ne:
	cd erts && $(MAKE) release

old_bootstrap_scripts:
	cd erts/start_scripts && $(MAKE) release


# This is one strange name for a target, this actually builds and strips only
# the primary bootstrap, a minimal set of beam files to be able to continue
# bootstrap builds. It's used by other makefiles, so I refrain from
# changing the name right now...
bootstrap_nc_for_ne_no_debug_sym:
	test -d $(TESTROOT) || mkdir -p $(TESTROOT)
	cd lib && $(MAKE) ERLC_FLAGS='-pa $(BOOTSTRAP_COMPILER)' \
		BOOTSTRAP=1 TYPE=release release
	$(ERL_TOP)/erts/emulator/utils/beam_strip $(TESTROOT)/lib/*/ebin/*.beam

# ----------------------------------------------------------------------

#
# Install
#
# Order is important here, don't change it!
#
install: install.dirs install.emulator install.libs install.boot install.Install install.bin

install.emulator:
	cd erts && \
	  ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
	  $(MAKE) TESTROOT=$(ERLANG_LIBDIR) release

install.libs:
ifeq ($(OTP_SMALL_BUILD),true)
	cd lib && \
	  ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
	  $(MAKE) TESTROOT=$(ERLANG_LIBDIR) release 
else
	cd lib && \
	  ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
	  $(MAKE) TESTROOT=$(ERLANG_LIBDIR) BUILD_ALL=true release 
endif

install.boot:
	cd erts/boot/src && ERL_TOP=$(ERL_TOP) PATH=$(BOOT_PREFIX)$${PATH} \
		$(MAKE) release TESTROOT=$(ERLANG_LIBDIR)

install.Install:
	cd $(ERLANG_LIBDIR) && ./Install -minimal $(ERLANG_LIBDIR)

#
# Erlang base public files
#
install.bin:
	rm -f $(BINDIR)/erl $(BINDIR)/erlc \
	      $(BINDIR)/ecc $(BINDIR)/elink $(BINDIR)/ear $(BINDIR)/escript
	${LN_S} $(ERLANG_BINDIR)/erl      $(BINDIR)/erl
	${LN_S} $(ERLANG_BINDIR)/erlc     $(BINDIR)/erlc
	${LN_S} $(ERLANG_BINDIR)/ecc      $(BINDIR)/ecc
	${LN_S} $(ERLANG_BINDIR)/elink    $(BINDIR)/elink
	${LN_S} $(ERLANG_BINDIR)/ear      $(BINDIR)/ear
	${LN_S} $(ERLANG_BINDIR)/escript  $(BINDIR)/escript

#
# Directories needed before we can install
#
install.dirs:
	if test ! -d $(BINDIR) ; then ${MKSUBDIRS} $(BINDIR); fi
	${MKSUBDIRS} $(ERLANG_LIBDIR)
	${MKSUBDIRS} $(ERLANG_LIBDIR)/usr/lib

# ----------------------------------------------------------------------

#
# Clean targets
#

clean:
	rm -f *~ *.bak config.log config.status
	find . -type f -name SKIP -print | xargs $(RM)
	cd erts && ERL_TOP=$(ERL_TOP) $(MAKE) clean
	cd lib  && ERL_TOP=$(ERL_TOP) $(MAKE) clean BUILD_ALL=true

# ----------------------------------------------------------------------