aboutsummaryrefslogtreecommitdiffstats
path: root/lib/erl_interface/src/Makefile.in
blob: b05d494884d8ea369a31d865912f2fd96116e9f0 (plain) (blame)
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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
#
# %CopyrightBegin%
#
# Copyright Ericsson AB 1997-2018. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# %CopyrightEnd%
#

###########################################################################
##
##  This is a standalone make file for erl_interface. It is
##  to be preprocessed by the configure script and the result
##  is saved into the TARGER directory.
##
##  We use 'vpath' to use plain C file names without the directory
##  part in dependency rules.
##
###########################################################################

.PHONY : debug opt release clean distclean depend

include $(ERL_TOP)/make/target.mk

# ----------------------------------------------------
# Application version and release dir specification
# ----------------------------------------------------
include ../vsn.mk
include $(ERL_TOP)/make/target.mk
include $(TARGET)/eidefs.mk

include $(ERL_TOP)/make/output.mk

EBINDIR=../ebin

APP_FILE= erl_interface.app
APP_SRC= $(APP_FILE).src
APP_TARGET= $(EBINDIR)/$(APP_FILE)

APPUP_FILE= erl_interface.appup
APPUP_SRC= $(APPUP_FILE).src
APPUP_TARGET= $(EBINDIR)/$(APPUP_FILE)

USING_MINGW=@MIXED_CYGWIN_MINGW@
USING_MSYS_VC==@MIXED_MSYS_VC@
USING_CYGWIN_VC==@MIXED_MSYS_VC@
USING_VC=@MIXED_VC@

ifdef TESTROOT
RELEASE_PATH=$(TESTROOT)
else
RELEASE_PATH=$(ERL_TOP)/release/$(TARGET)
endif
RELSYSDIR = $(RELEASE_PATH)/lib/erl_interface-$(EI_VSN)

LDFLAGS = @LDFLAGS@
LIBS = @LIBS@

ifeq ($(TYPE),debug)
PURIFY =
TYPEMARKER = .debug
TYPE_FLAGS = -g -DDEBUG
ifeq ($(TARGET),win32)
LDFLAGS += -g
endif
else
ifeq ($(TYPE),purify)
PURIFY = purify
TYPEMARKER = .purify
TYPE_FLAGS = -DPURIFY -DNO_JUMP_TABLE
else
ifeq ($(TYPE),quantify)
PURIFY = quantify
TYPEMARKER = .quantify
TYPE_FLAGS = -g -O2 -DQUANTIFY
else
ifeq ($(TYPE),purecov)
PURIFY = purecov --follow-child-processes=yes
TYPEMARKER = .purecov
TYPE_FLAGS = -g -DPURECOV -DNO_JUMP_TABLE
else
ifeq ($(TYPE),gcov)
PURIFY =
TYPEMARKER =
TYPE_FLAGS = -DNO_JUMP_TABLE -fprofile-arcs -ftest-coverage
ifeq ($(TARGET),linux)
LIBS += -lgcov
endif
else
PURIFY =
TYPEMARKER =
TYPE_FLAGS =
endif
endif
endif
endif
endif

CC = @CC@
LD = @LD@
AR = @AR@
RANLIB = @RANLIB@

ifeq ($(V),0)
AR_FLAGS=rc
else
AR_FLAGS=rcv
endif

INCFLAGS = -I. -I../include -Iconnect -Iencode -Idecode -Imisc -Iepmd \
	-Iregistry -I$(TARGET) 

ifeq ($(USING_VC),yes)
WARNFLAGS = -Wall
else
WARNFLAGS = @WFLAGS@
endif

CFLAGS = @LIB_CFLAGS@ $(WARNFLAGS) $(INCFLAGS) $(TYPE_FLAGS)
PROG_CFLAGS = @CFLAGS@ $(WARNFLAGS) $(INCFLAGS) $(TYPE_FLAGS) -Ilegacy

ifeq ($(findstring vxworks,$(TARGET)),vxworks)
PROG_CFLAGS += -nostartfiles -Wl,-r,-d
endif


INSTALL = @INSTALL@
INSTALL_DIR = @INSTALL_DIR@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@

# The default library (no extra extension in name) is for Unix with
# thread support if exists.  For windows MD is the default.
#
#   ST  = single threaded (Unix without thread support)
#   MT  = multi threaded (on windows also static linking)
#   MD  = multithreaded dynamic (default for cygwin cc wrapper)
#   MDD = multithreaded dynamic with debug symbols
#
ST_OBJDIR  = $(ERL_TOP)/lib/erl_interface/obj.st$(TYPEMARKER)/$(TARGET)
MT_OBJDIR  = $(ERL_TOP)/lib/erl_interface/obj.mt$(TYPEMARKER)/$(TARGET)
MD_OBJDIR  = $(ERL_TOP)/lib/erl_interface/obj.md$(TYPEMARKER)/$(TARGET)
MDD_OBJDIR = $(ERL_TOP)/lib/erl_interface/obj.mdd$(TYPEMARKER)/$(TARGET)
OBJDIR     = $(ERL_TOP)/lib/erl_interface/obj$(TYPEMARKER)/$(TARGET)
BINDIR     = $(ERL_TOP)/lib/erl_interface/bin/$(TARGET)

# FIXME maybe use this opt and remove (int) cast to is*() functions
# -Wno-char-subscripts
# -Wshadow

vpath %.c connect:encode:decode:misc:epmd:legacy:registry

###########################################################################
#  List targets
###########################################################################

ifeq ($(TARGET),win32)
EXE=.exe
else
EXE=
endif

ifeq ($(USING_VC),yes)
LIBEXT=.lib
LIBPRE=
MTFLAG=-MT

else
LIBEXT=.a
LIBPRE=lib
MTFLAG=

endif

###########################################################################
#  Specify targets names
###########################################################################

ERL_CALL   = $(BINDIR)/erl_call$(EXE)

ifdef THR_DEFS
ST_EILIB   = $(OBJDIR)/$(LIBPRE)ei_st$(LIBEXT)
ST_ERLLIB  = $(OBJDIR)/$(LIBPRE)erl_interface_st$(LIBEXT)
MT_EILIB   = $(OBJDIR)/$(LIBPRE)ei$(LIBEXT)
MT_ERLLIB  = $(OBJDIR)/$(LIBPRE)erl_interface$(LIBEXT)
else
ST_EILIB   = $(OBJDIR)/$(LIBPRE)ei$(LIBEXT)
ST_ERLLIB  = $(OBJDIR)/$(LIBPRE)erl_interface$(LIBEXT)
endif
MD_EILIB   = $(OBJDIR)/$(LIBPRE)ei_md$(LIBEXT)
MDD_EILIB  = $(OBJDIR)/$(LIBPRE)ei_mdd$(LIBEXT)
MD_ERLLIB  = $(OBJDIR)/$(LIBPRE)erl_interface_md$(LIBEXT)
MDD_ERLLIB = $(OBJDIR)/$(LIBPRE)erl_interface_mdd$(LIBEXT)

###########################################################################
#  Specify targets to build
###########################################################################

EXE_TARGETS = \
	$(ERL_CALL)

ifeq ($(USING_VC),yes)

# Windows targets

TARGETS = \
	$(OBJ_TARGETS) \
	$(EXE_TARGETS) \
	$(APP_TARGET)  \
	$(APPUP_TARGET)

OBJ_TARGETS = \
	$(MT_EILIB) \
	$(MD_EILIB) \
	$(MDD_EILIB) \
	$(MT_ERLLIB) \
	$(MD_ERLLIB) \
	$(MDD_ERLLIB)

FAKE_TARGETS = \
	$(OBJDIR)/erl_fake_prog_mt$(EXE) \
	$(OBJDIR)/ei_fake_prog_mt$(EXE) \
	$(OBJDIR)/erl_fake_prog_mt_cxx$(EXE) \
	$(OBJDIR)/ei_fake_prog_mt_cxx$(EXE) \
	$(OBJDIR)/erl_fake_prog_md$(EXE) \
	$(OBJDIR)/ei_fake_prog_md$(EXE) \
	$(OBJDIR)/erl_fake_prog_cxx_md$(EXE) \
	$(OBJDIR)/ei_fake_prog_cxx_md$(EXE) \
	$(OBJDIR)/erl_fake_prog_mdd$(EXE) \
	$(OBJDIR)/ei_fake_prog_mdd$(EXE) \
	$(OBJDIR)/erl_fake_prog_cxx_mdd$(EXE) \
	$(OBJDIR)/ei_fake_prog_cxx_mdd$(EXE) \

else

ifeq ($USING_MINGW,yes)
TARGETS = \
	$(OBJ_TARGETS) \
	$(EXE_TARGETS) \
	$(APP_TARGET)  \
	$(APPUP_TARGET)

OBJ_TARGETS = \
	$(MD_EILIB) \
	$(MD_ERLLIB)

FAKE_TARGETS = \
	$(OBJDIR)/erl_fake_prog_md$(EXE) \
	$(OBJDIR)/ei_fake_prog_md$(EXE) \
	$(OBJDIR)/erl_fake_prog_cxx_md$(EXE) \
	$(OBJDIR)/ei_fake_prog_cxx_md$(EXE) 
else
# Unix targets

ifdef THR_DEFS

TARGETS = \
	$(OBJ_TARGETS) \
	$(EXE_TARGETS) \
	$(APP_TARGET)  \
	$(APPUP_TARGET)

OBJ_TARGETS = \
	$(ST_EILIB) \
	$(ST_ERLLIB) \
	$(MT_EILIB) \
	$(MT_ERLLIB)

FAKE_TARGETS = \
	$(ST_OBJDIR)/erl_fake_prog_st$(EXE) \
	$(ST_OBJDIR)/ei_fake_prog_st$(EXE) \
	$(ST_OBJDIR)/erl_fake_prog_cxx_st$(EXE) \
	$(ST_OBJDIR)/ei_fake_prog_cxx_st$(EXE) \
	$(MT_OBJDIR)/erl_fake_prog_mt$(EXE) \
	$(MT_OBJDIR)/ei_fake_prog_mt$(EXE) \
	$(MT_OBJDIR)/erl_fake_prog_mt_cxx$(EXE) \
	$(MT_OBJDIR)/ei_fake_prog_mt_cxx$(EXE)

else

TARGETS = \
	$(OBJ_TARGETS) \
	$(EXE_TARGETS) \
	$(APP_TARGET)  \
	$(APPUP_TARGET)

OBJ_TARGETS = \
	$(ST_EILIB) \
	$(ST_ERLLIB)

FAKE_TARGETS = \
	$(ST_OBJDIR)/erl_fake_prog_st$(EXE) \
	$(ST_OBJDIR)/ei_fake_prog_st$(EXE) \
	$(ST_OBJDIR)/erl_fake_prog_cxx_st$(EXE) \
	$(ST_OBJDIR)/ei_fake_prog_cxx_st$(EXE)

endif

endif

endif
###########################################################################
#  List all source files
###########################################################################

# FIXME do we need dummy here for XX.h that was needed before??

HEADERS = \
	../include/ei.h \
	../include/ei_connect.h \
	../include/eicode.h \
	../include/erl_interface.h

EISOURCES = \
	$(CONNECTSRC) \
	$(DECODESRC) \
	$(ENCODESRC) \
	$(EPMDSRC) \
	$(MISCSRC) \
	$(REGISTRYSRC)

CONNECTSRC = \
	connect/ei_connect.c \
	connect/ei_resolve.c \
	connect/eirecv.c \
	connect/send.c \
	connect/send_exit.c \
	connect/send_reg.c

DECODESRC = \
	decode/decode_atom.c \
	decode/decode_big.c \
	decode/decode_bignum.c \
	decode/decode_binary.c \
	decode/decode_boolean.c \
	decode/decode_char.c \
	decode/decode_double.c \
	decode/decode_fun.c \
	decode/decode_intlist.c \
	decode/decode_list_header.c \
	decode/decode_long.c \
	decode/decode_pid.c \
	decode/decode_port.c \
	decode/decode_ref.c \
	decode/decode_skip.c \
	decode/decode_string.c \
	decode/decode_trace.c \
	decode/decode_tuple_header.c \
	decode/decode_ulong.c \
	decode/decode_version.c \
	$(DECODESRC_LONGLONG)

ifneq ($(findstring vxworks,$(TARGET)),vxworks)
DECODESRC_LONGLONG = \
	decode/decode_longlong.c \
	decode/decode_ulonglong.c
else
DECODESRC_LONGLONG =
endif


ENCODESRC = \
	encode/encode_atom.c \
	encode/encode_big.c \
	encode/encode_bignum.c \
	encode/encode_binary.c \
	encode/encode_boolean.c \
	encode/encode_char.c \
	encode/encode_double.c \
	encode/encode_fun.c \
	encode/encode_list_header.c \
	encode/encode_long.c \
	encode/encode_pid.c \
	encode/encode_port.c \
	encode/encode_ref.c \
	encode/encode_string.c \
	encode/encode_trace.c \
	encode/encode_tuple_header.c \
	encode/encode_ulong.c \
	encode/encode_version.c \
	$(ENCODESRC_LONGLONG)

ifneq ($(findstring vxworks,$(TARGET)),vxworks)
ENCODESRC_LONGLONG = \
	encode/encode_longlong.c \
	encode/encode_ulonglong.c
else
ENCODESRC_LONGLONG =
endif


EPMDSRC = \
	epmd/epmd_port.c \
	epmd/epmd_publish.c \
	epmd/epmd_unpublish.c

MISCSRC = \
	misc/ei_decode_term.c \
	misc/ei_format.c \
	misc/ei_locking.c \
	misc/ei_malloc.c \
	misc/ei_portio.c \
	misc/ei_printterm.c \
	misc/ei_pthreads.c \
	misc/ei_trace.c \
	misc/ei_x_encode.c \
	misc/eimd5.c \
	misc/get_type.c \
	misc/show_msg.c \
	misc/ei_compat.c \
	misc/ei_init.c

REGISTRYSRC = \
	registry/hash_dohash.c \
	registry/hash_foreach.c \
	registry/hash_freetab.c \
	registry/hash_insert.c \
	registry/hash_isprime.c \
	registry/hash_lookup.c \
	registry/hash_newtab.c \
	registry/hash_remove.c \
	registry/hash_resize.c \
	registry/hash_rlookup.c \
	registry/reg_close.c \
	registry/reg_delete.c \
	registry/reg_dirty.c \
	registry/reg_dump.c \
	registry/reg_free.c \
	registry/reg_get.c \
	registry/reg_getf.c \
	registry/reg_geti.c \
	registry/reg_getp.c \
	registry/reg_gets.c \
	registry/reg_make.c \
	registry/reg_open.c \
	registry/reg_purge.c \
	registry/reg_resize.c \
	registry/reg_restore.c \
	registry/reg_set.c \
	registry/reg_setf.c \
	registry/reg_seti.c \
	registry/reg_setp.c \
	registry/reg_sets.c \
	registry/reg_stat.c \
	registry/reg_tabstat.c

ERLSOURCES = \
	legacy/decode_term.c \
	legacy/encode_term.c \
	legacy/erl_connect.c \
	legacy/erl_error.c \
	legacy/erl_eterm.c \
	legacy/erl_fix_alloc.c \
	legacy/erl_format.c \
	legacy/erl_malloc.c \
	legacy/erl_marshal.c \
	legacy/erl_resolve.c \
	legacy/erl_timeout.c \
	legacy/global_names.c \
	legacy/global_register.c \
	legacy/global_unregister.c \
	legacy/global_whereis.c

SOURCES = $(EISOURCES) $(ERLSOURCES)

NEVERUSED = \
	whereis.c \
	ei_send.c \
	ei_send_reg.c \
	send_link.c

ERLCALL = \
	prog/erl_call.c \
	prog/erl_start.c


# Note that encode/decode_term.c defines ei functions that is
# located in the erl_interface library, not ei library.

ST_EIOBJECTS  = $(addprefix $(ST_OBJDIR)/,$(notdir $(EISOURCES:.c=.o)))
ST_ERLOBJECTS = $(addprefix $(ST_OBJDIR)/,$(notdir $(ERLSOURCES:.c=.o)))
MT_EIOBJECTS  = $(addprefix $(MT_OBJDIR)/,$(notdir $(EISOURCES:.c=.o)))
MT_ERLOBJECTS = $(addprefix $(MT_OBJDIR)/,$(notdir $(ERLSOURCES:.c=.o)))
MD_EIOBJECTS  = $(addprefix $(MD_OBJDIR)/,$(notdir $(EISOURCES:.c=.o)))
MD_ERLOBJECTS = $(addprefix $(MD_OBJDIR)/,$(notdir $(ERLSOURCES:.c=.o)))
MDD_EIOBJECTS  = $(addprefix $(MDD_OBJDIR)/,$(notdir $(EISOURCES:.c=.o)))
MDD_ERLOBJECTS = $(addprefix $(MDD_OBJDIR)/,$(notdir $(ERLSOURCES:.c=.o)))

###########################################################################
#  Main targets
###########################################################################

# FIXME this assumes execution order
# FIXME move up and add exe prefix if needed....

debug opt: $(TARGETS)

docs:

tests:

clean:
	rm -f $(ST_EIOBJECTS)  $(ST_ERLOBJECTS)  $(ST_EILIB)  $(ST_ERLLIB)
	rm -f $(MT_EIOBJECTS)  $(MT_ERLOBJECTS)  $(MT_EILIB)  $(MT_ERLLIB)
	rm -f $(MD_EIOBJECTS)  $(MD_ERLOBJECTS)  $(MD_EILIB)  $(MD_ERLLIB)
	rm -f $(MDD_EIOBJECTS) $(MDD_ERLOBJECTS) $(MDD_EILIB) $(MDD_ERLLIB)
	rm -f $(ERL_CALL)
	rm -f $(FAKE_TARGETS)
	rm -f $(APP_TARGET)
	rm -f $(APPUP_TARGET)

distclean: clean
	rm -f config.h config.log config.status configure


###########################################################################
#  FIXME move this VxWorks stuff to configure or something
###########################################################################

# FIXME depend on $(TARGET)/Makefile ???

ifeq ($(findstring vxworks,$(TARGET)),vxworks)
$(TARGET)/config.h:
	$(gen_verbose)
	$(V_at)echo "/* Generated by Makefile */" > $@
	$(V_at)echo "#define HAVE_STRERROR 1" >> $@
	$(V_at)echo "#define HAVE_SOCKLEN_T 1" >> $@
endif

###########################################################################
#  Default rules, normal and threaded
###########################################################################

$(ST_OBJDIR)/%.o: %.c
	$(V_CC) $(CFLAGS) -c $< -o $@

$(MT_OBJDIR)/%.o: %.c
	$(V_CC) $(MTFLAG) $(CFLAGS) $(THR_DEFS) -c $< -o $@

$(MD_OBJDIR)/%.o: %.c
	$(V_CC) -MD $(CFLAGS) $(THR_DEFS) -c $< -o $@

$(MD_OBJDIR)/%.o: %.c
	$(V_CC) -MD $(CFLAGS) $(THR_DEFS) -c $< -o $@

$(MDD_OBJDIR)/%.o: %.c
	$(V_CC) -MDd $(CFLAGS) $(THR_DEFS) -c $< -o $@

###########################################################################
#  Create directories
###########################################################################

_create_dirs := $(shell mkdir -p $(EBINDIR) $(BINDIR) $(OBJDIR) $(ST_OBJDIR) $(MT_OBJDIR) $(MD_OBJDIR) $(MDD_OBJDIR))

###########################################################################
#  Special rules
###########################################################################

$(APP_TARGET): $(APP_SRC) ../vsn.mk
	$(vsn_verbose)sed -e 's;%VSN%;$(ERL_INTERFACE_VSN);' $< > $@
$(APPUP_TARGET): $(APPUP_SRC) ../vsn.mk
	$(vsn_verbose)sed -e 's;%VSN%;$(ERL_INTERFACE_VSN);' $< > $@

ifeq ($(TARGET),win32)

# Windows archive creation

$(ST_EILIB) : $(ST_EIOBJECTS)
	$(V_AR) -out:$@ $(ST_EIOBJECTS)
	$(V_RANLIB) $@

$(ST_ERLLIB) : $(ST_ERLOBJECTS)
	$(V_AR) -out:$@ $(ST_ERLOBJECTS)
	$(V_RANLIB) $@

$(MT_EILIB) : $(MT_EIOBJECTS)
	$(V_AR) -out:$@ $(MT_EIOBJECTS)
	$(V_RANLIB) $@

$(MT_ERLLIB) : $(MT_ERLOBJECTS)
	$(V_AR) -out:$@ $(MT_ERLOBJECTS)
	$(V_RANLIB) $@

$(MD_EILIB) : $(MD_EIOBJECTS)
	$(V_AR) -out:$@ $(MD_EIOBJECTS)
	$(V_RANLIB) $@

$(MD_ERLLIB) : $(MD_ERLOBJECTS)
	$(V_AR) -out:$@ $(MD_ERLOBJECTS)
	$(V_RANLIB) $@

$(MDD_EILIB) : $(MDD_EIOBJECTS)
	$(V_AR) -out:$@ $(MDD_EIOBJECTS)
	$(V_RANLIB) $@

$(MDD_ERLLIB) : $(MDD_ERLOBJECTS)
	$(V_AR) -out:$@ $(MDD_ERLOBJECTS)
	$(V_RANLIB) $@

else

# Unix archive creation

$(ST_EILIB) : $(ST_EIOBJECTS)
	$(V_at)rm -f $@
	$(V_AR) $(AR_FLAGS) $@ $(ST_EIOBJECTS)
ifdef RANLIB
	$(V_RANLIB) $@
endif

$(ST_ERLLIB) : $(ST_ERLOBJECTS)
	$(V_at)rm -f $@
	$(V_AR) $(AR_FLAGS) $@ $(ST_ERLOBJECTS)
ifdef RANLIB
	$(V_RANLIB) $@
endif

$(MT_EILIB) : $(MT_EIOBJECTS)
	$(V_at)rm -f $@
	$(V_AR) $(AR_FLAGS) $@ $(MT_EIOBJECTS)
ifdef RANLIB
	$(V_RANLIB) $@
endif

$(MT_ERLLIB) : $(MT_ERLOBJECTS)
	$(V_at)rm -f $@
	$(V_AR) $(AR_FLAGS) $@ $(MT_ERLOBJECTS)
ifdef RANLIB
	$(V_RANLIB) $@
endif

endif

###########################################################################
#  erl_call   FIXME how to avoid explicit -lsocket on winows??? 
###########################################################################

ifeq ($(TARGET),win32)
$(ERL_CALL): $(ERLCALL) ../include/ei.h $(MD_EILIB)
	$(ld_verbose)$(PURIFY) $(CC) -MD $(PROG_CFLAGS) $(THR_DEFS) -o $@ $(ERLCALL) \
		-L$(OBJDIR) -lei_md $(THR_LIBS) $(LIBS) -lsocket
else
ifeq ($(findstring vxworks,$(TARGET)),vxworks)
$(ERL_CALL): $(ST_OBJDIR)/erl_call.o $(ST_OBJDIR)/erl_start.o ../include/ei.h $(ST_EILIB)
	$(V_LD) -r -d -o $@ $(ST_OBJDIR)/erl_call.o $(ST_OBJDIR)/erl_start.o -L$(OBJDIR) -lei $(LIBS)

$(ST_OBJDIR)/erl_call.o: prog/erl_call.c
	$(V_CC) $(CFLAGS) -c $< -o $@

$(ST_OBJDIR)/erl_start.o: prog/erl_start.c
	$(V_CC) $(CFLAGS) -c $< -o $@

else
ifdef THR_DEFS
$(ERL_CALL): $(ERLCALL) ../include/ei.h $(MT_EILIB)
	$(ld_verbose)$(PURIFY) $(CC) $(PROG_CFLAGS) $(THR_DEFS) $(LDFLAGS) -o $@ $(ERLCALL) \
		-L$(OBJDIR) -lei $(THR_LIBS) $(LIBS)
else
$(ERL_CALL): $(ERLCALL) ../include/ei.h $(ST_EILIB)
	$(ld_verbose)$(PURIFY) $(CC) $(PROG_CFLAGS) $(LDFLAGS) -o $@ $(ERLCALL) \
		-L$(OBJDIR) -lei $(LIBS)
endif
endif
endif

###########################################################################
#  Fake application targets used to test header files and linking
###########################################################################

check: $(FAKE_TARGETS)

ifndef THR_DEFS
$(ST_OBJDIR)/erl_fake_prog_st$(EXE): prog/erl_fake_prog.c $(ST_ERLLIB) $(ST_EILIB)
	$(V_CC) $(PROG_CFLAGS) -o $@ $< -L$(OBJDIR) -lerl_interface -lei \
		$(LIBS)

$(ST_OBJDIR)/ei_fake_prog_st$(EXE): prog/ei_fake_prog.c $(ST_EILIB)
	$(V_CC) $(PROG_CFLAGS) -o $@ $< -L$(OBJDIR) -lei $(LIBS)

$(ST_OBJDIR)/erl_fake_prog_cxx_st$(EXE): prog/erl_fake_prog.c \
		$(ST_ERLLIB) $(ST_EILIB)
	$(V_CC) $(PROG_CFLAGS) -o $@ -xc++ $< -L$(OBJDIR) \
		-lerl_interface -lei $(LIBS)

$(ST_OBJDIR)/ei_fake_prog_cxx_st$(EXE): prog/ei_fake_prog.c $(ST_EILIB)
	$(V_CC) $(PROG_CFLAGS) -o $@ -xc++ $< -L$(OBJDIR) -lei $(LIBS)

else

$(ST_OBJDIR)/erl_fake_prog_st$(EXE): prog/erl_fake_prog.c $(ST_ERLLIB) $(ST_EILIB)
	$(V_CC) $(PROG_CFLAGS) -o $@ $< -L$(OBJDIR) -lerl_interface_st -lei_st \
		$(LIBS)

$(ST_OBJDIR)/ei_fake_prog_st$(EXE): prog/ei_fake_prog.c $(ST_EILIB)
	$(V_CC) $(PROG_CFLAGS) -o $@ $< -L$(OBJDIR) -lei_st $(LIBS)

$(ST_OBJDIR)/erl_fake_prog_cxx_st$(EXE): prog/erl_fake_prog.c \
		$(ST_ERLLIB) $(ST_EILIB)
	$(V_CC) $(PROG_CFLAGS) -o $@ -xc++ $< -L$(OBJDIR) \
		-lerl_interface_st -lei_st $(LIBS)

$(ST_OBJDIR)/ei_fake_prog_cxx_st$(EXE): prog/ei_fake_prog.c $(ST_EILIB)
	$(V_CC) $(PROG_CFLAGS) -o $@ -xc++ $< -L$(OBJDIR) -lei_st $(LIBS)

endif

####

$(MT_OBJDIR)/erl_fake_prog_mt$(EXE): prog/erl_fake_prog.c \
		$(MT_ERLLIB) $(MT_EILIB)
	$(V_CC) $(MTFLAG) $(PROG_CFLAGS) $(THR_DEFS) -o $@ $< -L$(OBJDIR) \
		-lerl_interface -lei $(THR_LIBS) $(LIBS)

$(MT_OBJDIR)/ei_fake_prog_mt$(EXE): prog/ei_fake_prog.c $(MT_EILIB)
	$(V_CC) $(MTFLAG) $(PROG_CFLAGS) $(THR_DEFS) -o $@ $< \
		-L$(OBJDIR) -lei $(THR_LIBS) $(LIBS)

$(MT_OBJDIR)/erl_fake_prog_mt_cxx$(EXE): prog/erl_fake_prog.c \
		$(MT_ERLLIB) $(MT_EILIB)
	$(V_CC) $(MTFLAG) $(PROG_CFLAGS) $(THR_DEFS) -o $@ -xc++ $< \
		-L$(OBJDIR) -lerl_interface -lei \
		$(THR_LIBS) $(LIBS)

$(MT_OBJDIR)/ei_fake_prog_mt_cxx$(EXE): prog/ei_fake_prog.c $(MT_EILIB)
	$(V_CC) $(MTFLAG) $(PROG_CFLAGS) $(THR_DEFS) -o $@ -xc++ $< \
		-L$(OBJDIR) -lei $(THR_LIBS) $(LIBS)

####

$(MD_OBJDIR)/erl_fake_prog_md$(EXE): prog/erl_fake_prog.c \
		$(MD_ERLLIB) $(MD_EILIB)
	$(V_CC) -MD $(PROG_CFLAGS) $(THR_DEFS) -o $@ $< -L$(OBJDIR) \
		-lerl_interface_r -lei_r $(THR_LIBS) $(LIBS)

$(MD_OBJDIR)/ei_fake_prog_md$(EXE): prog/ei_fake_prog.c $(MD_EILIB)
	$(V_CC) -MD $(PROG_CFLAGS) $(THR_DEFS) -o $@ $< \
		-L$(OBJDIR) -lei_r $(THR_LIBS) $(LIBS)

$(MD_OBJDIR)/erl_fake_prog_md_cxx$(EXE): prog/erl_fake_prog.c \
		$(MD_ERLLIB) $(MD_EILIB)
	$(V_CC) -MD $(PROG_CFLAGS) $(THR_DEFS) -o $@ -xc++ $< \
		-L$(OBJDIR) -lerl_interface_r -lei_r \
		$(THR_LIBS) $(LIBS)

$(MD_OBJDIR)/ei_fake_prog_md_cxx$(EXE): prog/ei_fake_prog.c $(MD_EILIB)
	$(V_CC) -MD $(PROG_CFLAGS) $(THR_DEFS) -o $@ -xc++ $< \
		-L$(OBJDIR) -lei_r $(THR_LIBS) $(LIBS)

####

$(MDD_OBJDIR)/erl_fake_prog_mdd$(EXE): prog/erl_fake_prog.c \
		$(MDD_ERLLIB) $(MDD_EILIB)
	$(V_CC) -MDD $(PROG_CFLAGS) $(THR_DEFS) -o $@ $< -L$(OBJDIR) \
		-lerl_interface_r -lei_r $(THR_LIBS) $(LIBS)

$(MDD_OBJDIR)/ei_fake_prog_mdd$(EXE): prog/ei_fake_prog.c $(MDD_EILIB)
	$(V_CC) -MDD $(PROG_CFLAGS) $(THR_DEFS) -o $@ $< \
		-L$(OBJDIR) -lei_r $(THR_LIBS) $(LIBS)

$(MDD_OBJDIR)/erl_fake_prog_mdd_cxx$(EXE): prog/erl_fake_prog.c \
		$(MDD_ERLLIB) $(MDD_EILIB)
	$(V_CC) -MDD $(PROG_CFLAGS) $(THR_DEFS) -o $@ -xc++ $< \
		-L$(OBJDIR) -lerl_interface_r -lei_r \
		$(THR_LIBS) $(LIBS)

$(MDD_OBJDIR)/ei_fake_prog_mdd_cxx$(EXE): prog/ei_fake_prog.c $(MDD_EILIB)
	$(V_CC) -MDD $(PROG_CFLAGS) $(THR_DEFS) -o $@ -xc++ $< \
		-L$(OBJDIR) -lei_r $(THR_LIBS) $(LIBS)

###########################################################################
#  Create dependency file using gcc -MM
###########################################################################

depend:
	$(gen_verbose)
	$(V_colon)@echo "Generating dependency file depend.mk..."
	@echo "# Generated dependency rules" > depend.mk;		\
	$(V_CC) $(CFLAGS) -MM $(SOURCES) | 			\
		sed 's&$(TARGET)&\$$\(TARGET\)&g' |			\
		sed 's/^.*:/\$$\(ST_OBJDIR\)\/&/' >> depend.mk;		\
	echo >> depend.mk;						\
	$(CC) $(CFLAGS) -MM $(SOURCES) |				\
		sed 's&$(TARGET)&\$$\(TARGET\)&g' |			\
		sed 's/^.*:/\$$\(MT_OBJDIR\)\/&/' >> depend.mk;		\
	echo >> depend.mk;						\
	$(CC) $(CFLAGS) -MM $(SOURCES) |				\
		sed 's&$(TARGET)&\$$\(TARGET\)&g' |			\
		sed 's/^.*:/\$$\(MD_OBJDIR\)\/&/' >> depend.mk;		\
	echo >> depend.mk;						\
	$(CC) $(CFLAGS) -MM $(SOURCES) |				\
		sed 's&$(TARGET)&\$$\(TARGET\)&g' |			\
		sed 's/^.*:/\$$\(MDD_OBJDIR\)\/&/' >> depend.mk;	\
	echo >> depend.mk

# For some reason this has to be after 'opt' target
include depend.mk

# ----------------------------------------------------
# Release Target
# ---------------------------------------------------- 

EXTRA = \
	INSTALL \
	Makefile \
	Makefile.in \
	README \
	README.internal \
	$(TARGET)/eidefs.mk

release: opt
	$(INSTALL_DIR) "$(RELSYSDIR)/include"
	$(INSTALL_DIR) "$(RELSYSDIR)/lib"
	$(INSTALL_DIR) "$(RELSYSDIR)/bin"
	$(INSTALL_DIR) "$(RELSYSDIR)/ebin"
	$(INSTALL_DIR) "$(RELSYSDIR)/src/auxdir"
	$(INSTALL_DIR) "$(RELSYSDIR)/src/connect"
	$(INSTALL_DIR) "$(RELSYSDIR)/src/decode"
	$(INSTALL_DIR) "$(RELSYSDIR)/src/encode"
	$(INSTALL_DIR) "$(RELSYSDIR)/src/epmd"
	$(INSTALL_DIR) "$(RELSYSDIR)/src/legacy"
	$(INSTALL_DIR) "$(RELSYSDIR)/src/misc"
	$(INSTALL_DIR) "$(RELSYSDIR)/src/prog"
	$(INSTALL_DIR) "$(RELSYSDIR)/src/registry"
	$(INSTALL_DIR) "$(RELEASE_PATH)/usr/include"
	$(INSTALL_DIR) "$(RELEASE_PATH)/usr/lib"
	$(INSTALL_DATA) $(APP_TARGET)  "$(RELSYSDIR)/ebin/$(APP_FILE)"
	$(INSTALL_DATA) $(APPUP_TARGET)  "$(RELSYSDIR)/ebin/$(APPUP_FILE)"
	$(INSTALL_DATA) $(HEADERS)     "$(RELSYSDIR)/include"
	$(INSTALL_DATA) $(HEADERS)     "$(RELEASE_PATH)/usr/include"
	$(INSTALL_DATA) $(OBJ_TARGETS) "$(RELSYSDIR)/lib"
	$(INSTALL_DATA) $(OBJ_TARGETS) "$(RELEASE_PATH)/usr/lib"
ifneq ($(EXE_TARGETS),)
	$(INSTALL_PROGRAM) $(EXE_TARGETS) "$(RELSYSDIR)/bin"
endif
	$(INSTALL_DATA) $(EXTRA)        "$(RELSYSDIR)/src"
	$(INSTALL_DATA) connect/*.[ch]  "$(RELSYSDIR)/src/connect"
	$(INSTALL_DATA) decode/*.[ch]   "$(RELSYSDIR)/src/decode"
	$(INSTALL_DATA) encode/*.[ch]   "$(RELSYSDIR)/src/encode"
	$(INSTALL_DATA) epmd/*.[ch]     "$(RELSYSDIR)/src/epmd"
	$(INSTALL_DATA) misc/*.[ch]     "$(RELSYSDIR)/src/misc"
	$(INSTALL_DATA) registry/*.[ch] "$(RELSYSDIR)/src/registry"
	$(INSTALL_DATA) legacy/*.[ch]   "$(RELSYSDIR)/src/legacy"
	$(INSTALL_DATA) prog/*.[ch]     "$(RELSYSDIR)/src/prog"

release_docs:

release_tests:

xmllint: