-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
1004 lines (902 loc) · 34.3 KB
/
Makefile
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
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# For use with GNU make.
# no builtin implicit rules
MAKEFLAGS = --no-builtin-rules --warn-undefined-variables
#-----------------------------------------------------------------------------
ifndef TASK
TASK =#
endif
ifndef SYSNAME
SYSNAME := $(shell uname)
ifeq ($(SYSNAME),)
$(error error with shell command uname)
endif
ifneq ($(filter MINGW32%,$(SYSNAME)),)
SYSNAME=win32
endif
endif
ifndef NODENAME
NODENAME := $(shell uname -n)
ifeq ($(NODENAME),)
$(error error with shell command uname -n)
endif
endif
ifndef MACHNAME
MACHNAME := $(shell uname -m)
ifeq ($(MACHNAME),)
$(error error with shell command uname -m)
endif
endif
ifndef DEBUG
ifndef OPT
OPT := false
endif
ifeq ($(OPT),false)
DEBUG := true
else
DEBUG := false
endif
endif
# set architecture dependent directories and default options
# defaults
INSTRUCTION=$(MACHNAME)
BIN_ARCH_DIR = $(INSTRUCTION)-$(OPERATING_SYSTEM)
LIB_ARCH_DIR = $(INSTRUCTION)-$(ABI)-$(OPERATING_SYSTEM)
ifeq ($(filter-out IRIX%,$(SYSNAME)),)# SGI
# Specify what application binary interface (ABI) to use i.e. 32, n32 or 64
ifndef ABI
ifdef SGI_ABI
ABI := $(patsubst -%,%,$(SGI_ABI))
else
ABI = n32
endif
endif
# Specify which instruction set to use i.e. -mips#
ifndef MIPS
# Using mips3 for most basic version on esu* machines
# as there are still some Indys around.
# Although mp versions are unlikely to need mips3 they are made this way
# because it makes finding library locations easier.
MIPS = 4
ifeq ($(filter-out esu%,$(NODENAME)),)
ifeq ($(ABI),n32)
ifneq ($(DEBUG),false)
MIPS=3
endif
endif
endif
endif
INSTRUCTION := mips
OPERATING_SYSTEM := irix
endif
ifeq ($(SYSNAME),Linux)
OPERATING_SYSTEM := linux
ifeq ($(filter-out i%86,$(MACHNAME)),)
INSTRUCTION := i686
endif
ifneq ($(filter $(INSTRUCTION),i686 ia64 x86_64),)# i686, ia64, x86_64
LIB_ARCH_DIR = $(INSTRUCTION)-$(OPERATING_SYSTEM)# no ABI required
endif
ifndef ABI
ABI=32
ifeq ($(filter-out i%86,$(MACHNAME)),)
ABI=32
endif
ifneq (,$(filter $(MACHNAME),ia64 x86_64))# ia64 or x86_64
ABI=64
endif
endif
endif
ifeq ($(SYSNAME),win32)
ABI=32
INSTRUCTION := i386
OPERATING_SYSTEM := win32
LIB_ARCH_DIR = $(INSTRUCTION)-$(OPERATING_SYSTEM)# no ABI
endif
ifeq ($(SYSNAME),SunOS)
OPERATING_SYSTEM := solaris
endif
ifeq ($(SYSNAME),AIX)
ifndef ABI
ifdef OBJECT_MODE
ifneq ($(OBJECT_MODE),32_64)
ABI = $(OBJECT_MODE)
endif
else
ABI = 32
endif
endif
INSTRUCTION := rs6000
OPERATING_SYSTEM := aix
endif
ifeq ($(SYSNAME),Darwin)
ifeq ($(filter-out i%86,$(MACHNAME)),)
INSTRUCTION = i386
else
ifeq ($(MACHNAME),Power Macintosh)
INSTRUCTION = ppc
else
INSTRUCTION := $(MACHNAME)
endif
endif
ifndef ABI
ABI = 32
endif
OPERATING_SYSTEM = darwin
endif
ifneq ($(DEBUG),false)
DEBUG_SUFFIX = -debug
else
DEBUG_SUFFIX =
endif
#This is now the default build version, each libperlinterpreter.so
#that is found in the lib directories is converted into a base64
#c string (.soh) and included into the interpreter and the one that
#matches the machine that it is running on loaded dynamically at runtime.
#If you want this perl_interpreter to be as portable as possible then
#you will want to provide as many different perl versions to compile
#against as you can.
#If you want to build an old non dynamic loader version you will
#need to override this to false and you must have the corresponding
#static libperl.a
ifndef USE_DYNAMIC_LOADER
DYNAMIC_LOADER_NOT_DEF = true
ifeq ($(SYSNAME),AIX)
#AIX distributions have a static perl and even if I build
#a shared "libperl.a" I cannot seem to dlopen it.
USE_DYNAMIC_LOADER = false
else
ifeq ($(OPERATING_SYSTEM),win32)
#I have not tried to make a dynamic perl interpreter in win32,
#I have not even been including a dynaloader at all so far.
USE_DYNAMIC_LOADER = false
else
DYNAMIC_LOADER_SET = maybe
USE_DYNAMIC_LOADER = maybe# if shared libraries are found
endif
endif
endif
#This routine is recursivly called for each possible dynamic version
#with SHARED_OBJECT set to true. That builds the corresponding
#libperlinterpereter.so
ifndef SHARED_OBJECT
SHARED_OBJECT = false
endif
# Include the static perl library or not
ifndef INCLUDE_PERL
INCLUDE_PERL = false
endif
ifneq ($(INCLUDE_PERL),false)
INCLUDE_PERL_SUFFIX = -includeperl
else
INCLUDE_PERL_SUFFIX =
endif
# ABI string for environment variables
# (for location of perl librarys in execuatable)
ABI_ENV = $(ABI)
ifeq ($(ABI),n32)
ABI_ENV = N32
endif
ifndef CMISS_ROOT
CMISS_ROOT := $(CURDIR)/..
endif
# Location of perl.
# Try to determine from environment.
# !!! if this perl is built with gcc -fPIC and its static library is linked
# into the executable its symbols will be exported and override those in any
# shared library loaded.
# gmake doesn't do what I want with this:
# ifdef CMISS$(ABI_ENV)_PERL
ifneq ($(origin CMISS$(ABI_ENV)_PERL),undefined)
PERL := $(CMISS$(ABI_ENV)_PERL)
else
ifdef CMISS_PERL
PERL := $(CMISS_PERL)
else
# defaults first
PERL = perl# first perl in path
ifeq ($(ABI),64)
# Need a perl of the same ABI
ifeq (,$(filter $(MACHNAME),ia64 x86_64))# not ia64 or x86_64
PERL = perl64
endif
endif
# Specify the perl on some platforms so that everyone builds with the same.
ifeq ($(filter-out IRIX%,$(SYSNAME)),)# SGI
ifeq ($(filter-out esu%,$(NODENAME)),)
ifeq ($(ABI),n32)
PERL = ${CMISS_ROOT}/bin/mips-irix/perl
else
PERL = ${CMISS_ROOT}/bin/mips-irix/perl64
endif
endif
ifeq ($(NODENAME),hpc2)
ifeq ($(ABI),n32)
PERL = ${CMISS_ROOT}/bin/perl
else
PERL = ${CMISS_ROOT}/bin/perl64
endif
endif
# What to oxford NODENAMEs look like?
CMISS_LOCALE ?=
ifeq (${CMISS_LOCALE},OXFORD)
ifeq ($(ABI),n32)
PERL = /usr/paterson/local/bin/perl
else
PERL = /usr/paterson/local64/bin/perl
endif
endif
endif
ifeq ($(SYSNAME),SunOS)
ifeq ($(ABI),32)
PERL = ${CMISS_ROOT}/bin/perl
else
PERL = ${CMISS_ROOT}/bin/$(ABI)/perl
endif
endif
ifeq ($(SYSNAME),win32)
PERL = ${CMISS_ROOT}/perl/bin/perl
endif
ifeq ($(filter-out esp56%,$(NODENAME)),)
PERL = ${CMISS_ROOT}/bin/i686-linux/perl
endif
endif
endif
#Make api directory names and lib name
# There may be an issue with the perl 5.8.1 threaded build if Perl_cmiss calls
# "certain re-entrant system calls". See perldoc perl582delta.
get_perl_api_string = $(shell $1 -MConfig -e 'print join "-", $$Config{api_versionstring}, grep { $$Config{"use$$_"} } qw(threads multiplicity 64bitall longdouble perlio)')
PERL_API_STRING := $(call get_perl_api_string,$(PERL))
ifeq ($(PERL_API_STRING),)
$(error problem with $(PERL))
endif
ifeq ($(SYSNAME),win32)
PERL_ARCHLIB := $(subst \,/,$(shell $(PERL) -MConfig -e 'print "$$Config{installarchlib}\n"'))
PERL_VERSION_ARCHNAME = $(subst \,/,$(shell $(PERL) -MConfig -e 'print "$$Config{api_versionstring}/$$Config{archname}\n"'))
else
PERL_ARCHLIB := $(shell $(PERL) -MConfig -e 'print "$$Config{installarchlib}\n"')
PERL_VERSION_ARCHNAME = $(shell $(PERL) -MConfig -e 'print "$$Config{api_versionstring}/$$Config{archname}\n"')
ifeq ($(SYSNAME),Darwin)
PERL_ARCHLIB := $(subst /Updates,,$(PERL_ARCHLIB))
PERL_ARCHLIB := $(subst /Library,/System/Library,$(PERL_ARCHLIB))
endif
endif
ifeq ($(PERL_ARCHLIB),)
$(error problem with $(PERL))
endif
# $Config{libperl,useshrplib} may be useful. If an archname is required
# $Config{targetarch} || $Config{myarchname} gives perl's Configure's
# interpretation of the archname which could be less distribution specific
# than $Config{archname}.
PERL_CFLAGS := $(shell $(PERL) -MConfig -e 'print "$$Config{ccflags}\n"')
ifeq ($(PERL_CFLAGS),)
$(error problem with $(CFLAGS))
endif
# I don't think there is any point in having a unique name here unless we also
# have a unique name for boot_Perl_cmiss, and building the dso with -Bsymbolic
# should make this unnecessary.
#Mangle the callback name so that we don't pick up the wrong version even when it is accidently visible
ifeq ($(SHARED_OBJECT), true)
CMISS_PERL_CALLBACK_SUFFIX := $(subst .,_,$(PERL_API_STRING))
CMISS_PERL_CALLBACK_SUFFIX := $(subst -,_,$(CMISS_PERL_CALLBACK_SUFFIX))
PERL_CMISS_WORKING_DIR = Perl_cmiss/generated/$(BIN_ARCH_DIR)/$(PERL_API_STRING)
else
CMISS_PERL_CALLBACK_SUFFIX := static
PERL_CMISS_WORKING_DIR = Perl_cmiss/generated/$(BIN_ARCH_DIR)/$(PERL_API_STRING)-static
endif
CMISS_PERL_CALLBACK=cmiss_perl_callback_$(CMISS_PERL_CALLBACK_SUFFIX)
PERL_CMISS_MAKEFILE = $(PERL_CMISS_WORKING_DIR)/Makefile
PERL_CMISS_LIB = $(PERL_CMISS_WORKING_DIR)/auto/Perl_cmiss/Perl_cmiss.a
ifeq ($(TASK),)
ifeq ($(USE_DYNAMIC_LOADER),false)
SHARED_PERL_API_STRINGS=
else # USE_DYNAMIC_LOADER is true or maybe
SHARED_PERL_EXECUTABLES =
ifneq ($(wildcard ${CMISS_ROOT}/perl),)
ifeq ($(SYSNAME),Linux)
ifeq ($(filter-out i%86,$(MACHNAME)),)
SHARED_PERL_EXECUTABLES += $(wildcard $(foreach version,5.6.2 5.8.0 5.10.0,${CMISS_ROOT}/perl/lib/$(version)/i686-linux*/bin/perl))
else
SHARED_PERL_EXECUTABLES += $(wildcard $(foreach version,5.6.2 5.8.0 5.10.0,${CMISS_ROOT}/perl/lib/$(version)/$(MACHNAME)-linux*/bin/perl))
endif
endif
# ifeq ($(SYSNAME),AIX)
# SHARED_PERL_EXECUTABLES += $(wildcard ${CMISS_ROOT}/perl/bin-5.?.?-rs6000-${ABI}*/perl)
# endif
ifeq ($(filter-out IRIX%,$(SYSNAME)),)# SGI
ifeq ($(ABI),64)
SHARED_PERL_EXECUTABLES += $(wildcard $(foreach version,5.6.0 5.8.2,${CMISS_ROOT}/perl/lib/$(version)/irix-$(ABI)*/bin/perl))
else
SHARED_PERL_EXECUTABLES += $(wildcard $(foreach version,5.6.0 5.8.0,${CMISS_ROOT}/perl/lib/$(version)/irix-$(ABI)*/bin/perl))
endif
endif
endif
#Check the CMISS_PERL version isn't already included from CMISS_ROOT perls
#Could additionally check between the versions listed above and also check that
#the executable actually runs.
SHARED_PERL_API_STRINGS := $(foreach perl_executable,$(SHARED_PERL_EXECUTABLES),$(call get_perl_api_string,$(perl_executable)))
ifneq ($(filter-out $(SHARED_PERL_API_STRINGS),$(PERL_API_STRING)),)
# There is no check for the existence of libperl.so as it is not
# required to build. Debian libperl does not put libperl.so in
# $(PERL_ARCHLIB)/CORE but only in /usr/lib, which is checked at run
# time in perl_interpreter_dynamic.c.
SHARED_PERL_EXECUTABLES += ${PERL}
SHARED_PERL_API_STRINGS += $(PERL_API_STRING)
endif
ifeq ($(USE_DYNAMIC_LOADER),maybe)
ifeq ($(SHARED_PERL_EXECUTABLES),)
USE_DYNAMIC_LOADER = false
else
define WRITE_DEBUG_MESSAGE
@echo 'Executables'
$(foreach perl_executable, $(SHARED_PERL_EXECUTABLES), @echo ' $(perl_executable)' )
endef
DYNAMIC_LOADER_MAYBE = true
USE_DYNAMIC_LOADER = true
endif
endif
endif
endif
# if either SHARED_OBJECT is false or INCLUDE_PERL is true, set STATIC_PERL_LIB
SET_STATIC_PERL_LIB = false
ifneq ($(SHARED_OBJECT),true)
SET_STATIC_PERL_LIB = true
else
ifeq ($(INCLUDE_PERL),true)
SET_STATIC_PERL_LIB = true
endif
endif
ifeq ($(SET_STATIC_PERL_LIB),true)
#!!! Ubuntu has a libperl.a in /usr/lib and no link in $(PERL_ARCHLIB)/CORE.
# But how can we know what version /usr/lib/libperl.a corresponds to?
# Assume it is the same as /usr/bin/perl?
# Or /usr/lib/libperl.so is probably more likely to be the same?
STATIC_PERL_LIB = $(firstword $(wildcard $(PERL_ARCHLIB)/CORE/libperl.a) $(wildcard $(PERL_ARCHLIB)/CORE/libperl56.a))
ifneq ($(USE_DYNAMIC_LOADER), true)
ifeq ($(STATIC_PERL_LIB),)
$(error 'Static $(PERL_ARCHLIB)/CORE/libperl.a not found for ${PERL} which is required for a non dynamic loading perl interpreter.')
endif
endif
else
STATIC_PERL_LIB =
endif
PERL_EXP = $(wildcard $(PERL_ARCHLIB)/CORE/perl.exp)
# If we intend to load a shared libperl then we cannot export symbols from a
# static perl (because they will mask those in libperl) so there is no point
# in including DynaLoader.
ifeq ($(USE_DYNAMIC_LOADER), true)
DYNALOADER_LIB =
else
# The DynaLoader lib built with perl is built with -DPERL_CORE because it is
# only intended to be linked with the corresponding libperl.a, and therefore
# does not include the perlapi.h adjustments for binary compatibility.
# (Changes in thrdvar.h between 5.8.0 and 5.8.1 mean that perl libraries built
# with threading have different offsets for the members of struct interpreter.)
#
# If we are building for a shared libperl then the version of the libperl may
# differ from the perl version being used to build our perl_interpreter. To
# maintain binary compatibility for the DynaLoader, it is necessary to build
# a DynaLoader without PERL_CORE defined.
#
# If DynaLoader is built here, then the version from 5.8.7 doesn't build with
# perl 5.6 executables, so at least two different copies may be required. But
# changes in struct interpreter from 5.6.0 to 5.6.2 have been more consistent
# so it is possible that it is not an issue for the 5.005 api. For now build
# perl with the one line change. (see perl/build/Makefile.pl.)
# DYNALOADER_MAKEFILE =
# DYNALOADER_WORKING_DIR =
ifeq ($(SYSNAME),win32)
# there is probably no point in including the dynaloader_lib unless it
# is possible to load binary perl modules from the static perl lib.
DYNALOADER_LIB =
else
# ifeq ($(STATIC_PERL_LIB),)
# DYNALOADER_WORKING_DIR = DynaLoader/generated/$(BIN_ARCH_DIR)/$(PERL_API_STRING)
# DYNALOADER_MAKEFILE = $(DYNALOADER_WORKING_DIR)/Makefile
# DYNALOADER_LIB = $(DYNALOADER_WORKING_DIR)/auto/DynaLoader/DynaLoader.a
# else
# Perl 5.10.0 includes the Dynaloader into libperl, so assume that the library
# is not required if it doesn't exist.
DYNALOADER_LIB = $(wildcard $(PERL_ARCHLIB)/auto/DynaLoader/DynaLoader.a)
# endif
endif
endif
SOURCE_DIR = source
ifneq ($(USE_DYNAMIC_LOADER), true)
ifneq ($(SHARED_OBJECT), true)
SHARED_SUFFIX =
else
SHARED_SUFFIX = -shared
endif
SHARED_LIB_SUFFIX =
else
SHARED_SUFFIX = -dynamic
SHARED_LIB_SUFFIX = -dynamic
endif
WORKING_DIR := generated/$(BIN_ARCH_DIR)/$(PERL_API_STRING)$(DEBUG_SUFFIX)$(SHARED_SUFFIX)
C_INCLUDE_DIRS = $(PERL_ARCHLIB)/CORE $(WORKING_DIR) .
LIBRARY_ROOT_DIR := lib/$(LIB_ARCH_DIR)
LIBRARY_VERSION := $(PERL_API_STRING)$(SHARED_LIB_SUFFIX)
LIBRARY_DIR := $(LIBRARY_ROOT_DIR)/$(LIBRARY_VERSION)
ifneq ($(SHARED_OBJECT), true)
LIBRARY_SUFFIX = .a
else
LIBRARY_SUFFIX = .so
endif
LIBRARY_NAME := libperlinterpreter$(INCLUDE_PERL_SUFFIX)$(DEBUG_SUFFIX)$(LIBRARY_SUFFIX)
LIBRARY := $(LIBRARY_DIR)/$(LIBRARY_NAME)
LIBRARY_LINK := $(LIBRARY_ROOT_DIR)/libperlinterpreter$(INCLUDE_PERL_SUFFIX)$(DEBUG_SUFFIX)$(LIBRARY_SUFFIX)
LIB_EXP := $(patsubst %$(LIBRARY_SUFFIX), %.exp, $(LIBRARY_LINK))
SOURCE_FILES := $(notdir $(wildcard $(SOURCE_DIR)/*.*) )
# DynaLoader module should be same version as library. (It changed
# incompatibly between perl 5.8.3 and 5.8.4.)
# Is there a reason why the other modules are not just taken from the perl?
PMH_FILES := $(patsubst %.pm, %.pmh, $(filter %.pm, $(SOURCE_FILES)))
DYNALOADER_DEFINE :=
ifneq ($(DYNALOADER_LIB),)
DYNALOADER_DEFINE = -DINCLUDE_DYNALOADERPMH
PMH_FILES += DynaLoader.pmh
endif
ifneq ($(STATIC_PERL_LIB),)# have static perl
C_SOURCES := perl_interpreter.c
else
ifeq ($(SHARED_OBJECT),true)
C_SOURCES := perl_interpreter.c
else
C_SOURCES :=
endif
endif
ifeq ($(USE_DYNAMIC_LOADER), true)
C_SOURCES += perl_interpreter_dynamic.c base64.c
endif
C_UNITS := $(basename $(C_SOURCES) )
DEPEND_FILES := $(foreach unit, $(C_UNITS), $(WORKING_DIR)/$(unit).d )
OBJECTS := $(foreach unit, $(C_UNITS), $(WORKING_DIR)/$(unit).o )
C_OBJ := $(WORKING_DIR)/libperlinterpreter.o
#-----------------------------------------------------------------------------
# compiling commands
CC = cc
ifneq ($(OPERATING_SYSTEM), darwin)
LD_SHARED = ld -shared $(CFL_FLGS) $(L_FLGS)
else
LD_SHARED = ld -dylib $(CFL_FLGS) $(L_FLGS)
endif
SHARED_LINK_LIBRARIES =
AR = ar
# Option lists
# (suboption lists become more specific so that later ones overrule previous)
CFLAGS = $(strip $(CFL_FLGS) $(CFE_FLGS) $(CF_FLGS)) '-DCMISS_PERL_CALLBACK=$(CMISS_PERL_CALLBACK)' $(DYNALOADER_DEFINE)
CPPFLAGS := $(addprefix -I, $(C_INCLUDE_DIRS) ) '-DABI_ENV="$(ABI_ENV)"' '-DPERL_VERSION_ARCHNAME="$(PERL_VERSION_ARCHNAME)"' $(DYNALOADER_DEFINE) # -DPERL_NO_SHORT_NAMES
ARFLAGS = -cr
ifneq ($(DEBUG),false)
CFLAGS += $(strip $(DBGCF_FLGS) $(DBGC_FLGS))
else
CFLAGS += $(strip $(OPTCFE_FLGS) $(OPTCF_FLGS) $(OPTC_FLGS))
endif
# suboption lists
CFL_FLGS =# flags for C fortran and linking
L_FLGS =# flags for linking only
CFE_FLGS =# flags for C fortran and linking executables only
CF_FLGS = -c# flags for C and fortran only
DBGCF_FLGS = -g#OPT=false flags for C and fortran
DBGC_FLGS =# OPT=false flags for C only
OPTCFE_FLGS =# OPT=true flags for C and fortran and linking executables
OPTCF_FLGS = -O#OPT=true flags for C and fortran only
OPTC_FLGS =# OPT=true flags for C only
ifeq ($(filter-out IRIX%,$(SYSNAME)),)# SGI
# The following warning means that the execution of the program is seriously
# different from that intended:
# cc-1999 cc: WARNING File = zle_tricky.c, Line = 2145
# "jumping out of a block containing VLAs" is not currently implemented
CFLAGS += -DEBUG:error=1999
CF_FLGS += -use_readonly_const -fullwarn
DBGCF_FLGS += -DEBUG:trap_uninitialized:subscript_check:verbose_runtime
# warning 158 : Expecting MIPS3 objects: ... MIPS4.
L_FLGS += -rdata_shared -DEBUG:error=158
CFL_FLGS = -$(ABI) -mips$(MIPS)
OPTCF_FLGS = -O3 -OPT:Olimit=8000
LD_SHARED += -Bsymbolic
ifeq ($(ABI),n32)
LD_SHARED += -check_registry /usr/lib32/so_locations
else
LD_SHARED += -check_registry /usr/lib64/so_locations
endif
endif
ifeq ($(SYSNAME),Darwin)
L_FLGS += -arch $(INSTRUCTION)
SHARED_LINK_LIBRARIES += -L$(PERL_ARCHLIB)/CORE -lperl
endif
ifeq ($(SYSNAME),Linux)
# ifneq ($(filter $(MACHNAME),ia64 x86_64),)# ia64 or x86_64
ifneq ($(filter $(MACHNAME),ia64),)# ia64 only
# Use Intel compilers if available
# (icc -V sends output to STDERR and exits with error).
ifneq (,$(shell icc -V 2>&1 | grep -i intel))
CC = icc
endif
endif
ifeq ($(CC),icc)
# Intel compilers
CFLAGS += -w2# -Wall
# This doesn't seem to do anything
# ifeq ($(ABI),64)
# CF_FLGS += -size_lp64
# endif
else
CC=gcc
# Wparantheses seems good but our code doesn't do things that way.
# Wunitialized often gives warnings where things are valid.
CFLAGS += -Wall -Wno-parentheses -Wno-uninitialized -fPIC
CPPFLAGS += -Dbool=char -DHAS_BOOL -fPIC
ifeq ($(filter $(INSTRUCTION),i686 ia64),)# not i686 nor ia64
CFE_FLGS += -m$(ABI)
endif
# DBGCF_FLGS = -g3
endif
# Position independent code is only required for shared objects.
ifeq ($(SHARED_OBJECT),true)
CFE_FLGS += -fPIC
# gcc 3.3.3 documentation recommends using the same code generation
# flags when linking shared libraries as when compiling.
# Linker option -Bsymbolic binds references to global symbols to those
# within the shared library, if any. This avoids picking up the symbols
# like boot_Perl_cmiss from the static interpreter.
LD_SHARED = $(CC) -shared -Wl,-Bsymbolic $(CFE_FLGS)
endif
OPTCF_FLGS = -O3
ifeq ($(MACHNAME),ppc64)
ifeq ($(ABI),64)
L_FLGS += -m elf64ppc
# note for ABI=32 -m elf32ppclinux is probably appropriate (but default)
endif
endif
# A (-L $(PERL_ARCHLIB)/CORE) -lperl dependency might be useful here but
# perl_interpreter_dynamic.c needs to be modified so that (the right)
# libperl.so can be found when dlopening the perl_interpreter.
# And we might need to check that soname version numbers don't interfere
# with the ability to load the library as version numbers could depend on
# the distribution.
# But any dynamic symbols in the executable override any loaded from these
# dependencies so there seems no advantage over merely dlopening the right
# libperl before dlopening the perl_interpreter.
SHARED_LINK_LIBRARIES += -lcrypt -ldl
endif
ifeq ($(SYSNAME),win32)
CC = gcc -mms-bitfields
endif
ifeq ($(SYSNAME),SunOS)
# need -xarch=native after -fast
OPTCFE_FLGS += -fast $(CFE_FLGS)
ifeq ($(ABI),64)
CFE_FLGS += -xarch=native64
endif
endif
ifeq ($(SYSNAME),AIX)
# _r for reentrant - without this:
# "...lib/5.8.6/aix-thread-multi-64all/CORE/reentr.h", line 775.16: 1506-007 (S) "struct random_data" is undefined.
CC = xlc_r
# no -qinfo=gen because perl redefines many symbols
CFLAGS += -qinfo=ini:por:pro:trd:tru:use
AR += -X$(ABI)
# may want -qsrcmsg
CF_FLGS += -qfullpath
CFE_FLGS += -q$(ABI) -qarch=auto -qhalt=e
L_FLGS += -b$(ABI)
ifeq ($(ABI),64)
# 1506-743 (I) 64-bit portability: possible change of result through conversion ...
# These don't seem to serious. Truncations are reported separately.
# FD_SET in sys/time.h does this
CF_FLGS += -qwarn64 -qsuppress=1506-743
endif
# lapack's dlamch performs an underflow so we don't check that.
DBGCF_FLGS += -qfullpath -C -qflttrap=inv:en
# -qinitauto for C is bytewise: 7F gives large integers.
DBGC_FLGS += -qinitauto=7F
OPTCF_FLGS = -O3 -qmaxmem=12000 -qtune=auto
OPTC_FLGS += -qnoignerrno
LD_SHARED += -bsymbolic
endif
ifeq ($(SHARED_OBJECT), true)
CPPFLAGS += -DSHARED_OBJECT
endif
ifeq ($(USE_DYNAMIC_LOADER), true)
CPPFLAGS += -DUSE_DYNAMIC_LOADER
endif
SHARED_LINK_LIBRARIES += -lc
CFLAGS += $(PERL_CFLAGS)
ifeq ($(SYSNAME), Darwin)
CFLAGS := $(subst -arch x86_64,,$(CFLAGS))
CFLAGS := $(subst -arch ppc,,$(CFLAGS))
endif
.PHONY : main
vpath $(PERL) $(subst :, ,$(PATH))
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
ifeq ($(TASK),)
#-----------------------------------------------------------------------------
ifeq ($(OPERATING_SYSTEM),win32)
$(warning *******************************)
$(warning This still does not compile win32 out of the box)
$(warning The generated Perl_cmiss Makefile ends up with many \ where there need to be / which seems to work with dmake but the command called from this makefile fails with a -c error but works fine when executed in a shell)
$(warning The library built does not have the perl or Perl_cmiss in it, these only seem to work when linked in the final link)
$(warning *******************************)
$(warning)
endif
.NOTPARALLEL:
TMP_FILES := $(notdir $(wildcard $(WORKING_DIR)/*.* ) )
OLD_FILES := $(filter-out $(PMH_FILES) $(foreach unit,$(C_UNITS),$(unit).%), \
$(TMP_FILES))
.PHONY : tidy clean allclean \
all debug opt debug64 opt64
define VERSION_MESSAGE
@echo ' $(call get_perl_api_string,${perl_executable}) from ${perl_executable}'
endef
ifeq ($(USE_DYNAMIC_LOADER),true)
#Dynamic loading perl interpreter
#Note that the blank line in the define is useful.
define SHARED_BUILD_RULE
$(MAKE) --no-print-directory USE_DYNAMIC_LOADER=false SHARED_OBJECT=true CMISS$(subst n,N,${ABI})_PERL=$(perl_executable)
endef
SHARED_INTERPRETER_BUILDS = $(foreach perl_executable, $(SHARED_PERL_EXECUTABLES), $(SHARED_BUILD_RULE))
ifneq ($(STATIC_PERL_LIB),)
define SUB_WRITE_BUILD_MESSAGE
@echo 'The static fallback perl built into the interpreter is:'
$(foreach perl_executable, $(PERL), $(VERSION_MESSAGE))
endef
else
define SUB_WRITE_BUILD_MESSAGE
@echo
@echo ' YOU HAVE NOT INCLUDED A STATIC FALLBACK PERL SO ANY'
@echo ' EXECUTABLE BUILT WITH THIS PERL INTERPRETER WILL NOT'
@echo ' RUN AT ALL UNLESS ONE OF THE ABOVE VERSIONS OF PERL'
@echo ' IS FIRST IN YOUR PATH.'
endef
endif
define WRITE_BUILD_MESSAGE
@echo
@echo '======================================================'
@echo 'Congratulations, you have built a dynamic perl interpreter.'
@echo ' $(LIBRARY_LINK)'
@echo 'It will work dynamically with the following perl APIs:'
$(foreach perl_executable, $(SHARED_PERL_EXECUTABLES), $(VERSION_MESSAGE))
${SUB_WRITE_BUILD_MESSAGE}
endef
# @echo 'and has compatibility defined for the following versions:'
# @cat compatible_versions.txt
else
SHARED_INTERPRETER_BUILDS =
ifeq ($(SHARED_OBJECT),true)
#This is an intermediate step and so doesn't write a message
WRITE_BUILD_MESSAGE =
else
#Old style static perl interpreter
define WRITE_BUILD_MESSAGE
@echo
@echo '======================================================'
@echo 'You have built a non dynamic loading perl interpreter.'
@echo ' $(LIBRARY_LINK)'
@echo 'It will always run on any machine but will only'
@echo 'be able to load binary perl modules if they are the correct '
@echo 'version. The version you have built with is:'
$(foreach perl_executable, $(PERL), $(VERSION_MESSAGE))
endef
endif
endif
main : $(PERL_CMISS_MAKEFILE) $(WORKING_DIR) $(LIBRARY_DIR)# $(DYNALOADER_MAKEFILE)
ifeq ($(USE_DYNAMIC_LOADER),true)
@echo
@echo 'Doing shared interpreter builds and dyn loader is $(USE_DYNAMIC_LOADER)'
@echo 'init: $(DYNAMIC_LOADER_NOT_DEF), then: $(DYNAMIC_LOADER_SET), and: $(DYNAMIC_LOADER_MAYBE)'
$(WRITE_DEBUG_MESSAGE)
@echo
$(SHARED_INTERPRETER_BUILDS)
endif
@echo
@echo 'Building library ${LIBRARY}'
@echo
ifneq ($(OPERATING_SYSTEM),win32)
$(MAKE) --directory=$(PERL_CMISS_WORKING_DIR) static
# ifneq ($(DYNALOADER_WORKING_DIR),)
# $(MAKE) --directory=$(DYNALOADER_WORKING_DIR) DynaLoader.pm static
# endif
else
#Use dmake as it supports back slashes for paths
cd $(PERL_CMISS_WORKING_DIR) ; unset SHELL ; $(CMISS_ROOT)/perl/build/dmake-4.1pl1-win32/dmake static
endif
$(MAKE) --no-print-directory USE_DYNAMIC_LOADER=$(USE_DYNAMIC_LOADER) \
SHARED_PERL_API_STRINGS='$(SHARED_PERL_API_STRINGS)' TASK=source
$(MAKE) --no-print-directory USE_DYNAMIC_LOADER=$(USE_DYNAMIC_LOADER) \
TASK=library
$(WRITE_BUILD_MESSAGE)
tidy :
ifneq ($(OLD_FILES),)
rm $(foreach file,$(OLD_FILES), $(WORKING_DIR)/$(file) )
endif
$(PERL_CMISS_MAKEFILE) : $(PERL) Perl_cmiss/Makefile.PL
cd Perl_cmiss && CMISS_PERL_CALLBACK=$(CMISS_PERL_CALLBACK) WORKING_DIR=$(subst Perl_cmiss/,,$(PERL_CMISS_WORKING_DIR)) $(PERL) Makefile.PL
# $(DYNALOADER_MAKEFILE) : $(PERL) DynaLoader/Makefile.PL
# cd DynaLoader && WORKING_DIR=$(subst DynaLoader/,,$(DYNALOADER_WORKING_DIR)) $(PERL) Makefile.PL
$(WORKING_DIR) :
mkdir -p $@
$(LIBRARY_DIR) :
mkdir -p $@
clean:
@echo "Cleaning house ..."
-rm -rf Perl_cmiss/generated/$(BIN_ARCH_DIR) generated/$(BIN_ARCH_DIR) $(LIBRARY_ROOT_DIR)
#$(DYNALOADER_WORKING_DIR)
allclean:
@echo "Cleaning all houses ..."
-rm -rf Perl_cmiss/generated generated lib
#DynaLoader/generated/*
debug opt debug64 opt64:
$(MAKE) --no-print-directory DEBUG=$(DEBUG) ABI=$(ABI)
debug debug64: DEBUG=true
opt opt64: DEBUG=false
ifneq (,$(filter $(MACHNAME),ia64 x86_64))# ia64 or x86_64
debug opt: ABI=64
else
ifeq ($(filter-out IRIX%,$(SYSNAME)),) #SGI
debug opt: ABI=n32
else
debug opt: ABI=32
endif
endif
debug64 opt64: ABI=64
all : debug opt
ifneq ($(SYSNAME),Linux)
all: debug64 opt64
endif
update :
cmissmake perl_interpreter
#-----------------------------------------------------------------------------
endif
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
ifeq ($(TASK),source)
#-----------------------------------------------------------------------------
main : $(DEPEND_FILES) \
$(foreach file,$(PMH_FILES), $(WORKING_DIR)/$(file) )
# !!! Todo: include a file that contains the perl version so that version-
# (rather than api-) sensitive files are updated when that changes.
# e.g. Dynaloader module and library.
# include the depend file dependencies
ifneq ($(DEPEND_FILES),)
sinclude $(DEPEND_FILES)
endif
# implicit rules for making the dependency files
# KAT I think Solaris needed nawk rather than awk, but nawk is not usually
# avaiable on Mandrake. I don't have a Sun to try this out so I'll get it
# working with awk on the machines I have.
# wildcard in the .d file removes files that no longer exist
# (that may no longer be needed because they were included in .h files that
# have changed).
$(WORKING_DIR)/%.d : $(SOURCE_DIR)/%.c
makedepend $(CPPFLAGS) -f- -Y $< 2> [email protected] | \
sed -e 's%^$(SOURCE_DIR)\([^ ]*\).o: \(.*\)%$$(WORKING_DIR)\1.o $$(WORKING_DIR)\1.d: $$(wildcard \2)%' > $@
# See if there is a dependency on perl
@if grep /perl\\.h $@ > /dev/null; then set -x; echo '$$(WORKING_DIR)/perl_interpreter.o $$(WORKING_DIR)/perl_interpreter.d: $$(PERL)' >> $@; fi
(grep pmh [email protected] | grep makedepend | awk -F "[ ,]" '{printf("%s.%s:",substr($$4, 1, length($$4) - 2),"o"); for(i = 1 ; i <= NF ; i++) { if (match($$i,"pmh")) printf(" source/%s", substr($$i, 2, length($$i) -2)) } printf("\n");}' | sed -e 's%^$(SOURCE_DIR)\([^ ]*\).o%$$(WORKING_DIR)\1.o $$(WORKING_DIR)\1.d%' | sed -e 's%$(SOURCE_DIR)\([^ ]*\).pmh%$$(WORKING_DIR)\1.pmh%' >> $@)
vpath %.pm $(SOURCE_DIR) $(PERL_ARCHLIB)# $(DYNALOADER_WORKING_DIR)
$(WORKING_DIR)/%.pmh : %.pm
$(PERL) utilities/pm2pmh $< > $@
#Dynamic loader code for putting shared objects into the interpreter
ifeq ($(USE_DYNAMIC_LOADER),true)
ifeq ($(SHARED_PERL_API_STRINGS),)
$(error Missing list of SHARED_PERL_API_STRINGS in source stage)
endif
get_shared_lib_header = $(LIBRARY_ROOT_DIR)/$1/libperlinterpreter$(DEBUG_SUFFIX).soh
SHARED_LIBRARY_HEADERS = $(foreach api_string, $(SHARED_PERL_API_STRINGS),\
$(call get_shared_lib_header,$(api_string)))
UID2UIDH = $(CMISS_ROOT)/utilities/bin/$(BIN_ARCH_DIR)/bin2base64str
.SUFFIXES : .so .soh
# implicit rules for making the objects
%.soh : %.so
$(UID2UIDH) $< $@
#Always regenerate the versions files as they have recorded for
#us the versions that are built into this executable
STATIC_HEADER := $(WORKING_DIR)/static_version.h
DYNAMIC_VERSIONS_HEADER := $(WORKING_DIR)/dynamic_versions.h
VERSION_HEADERS := $(DYNAMIC_VERSIONS_HEADER) $(STATIC_HEADER)
$(DYNAMIC_VERSIONS_HEADER) : $(SHARED_LIBRARY_HEADERS)
{ \
$(foreach api_string, $(SHARED_PERL_API_STRINGS), \
echo 'static char libperlinterpreter$(subst .,_,$(subst -,_,$(api_string)))[] = ' && \
echo '#include "$(call get_shared_lib_header,$(api_string))"' && \
echo ';' && ) \
echo 'static struct Interpreter_library_strings interpreter_strings[] = {' && \
$(foreach api_string, $(SHARED_PERL_API_STRINGS), \
echo '{"$(api_string)", libperlinterpreter$(subst .,_,$(subst -,_,$(api_string))) },' && ) \
echo '};'; \
} > [email protected];
@set -xe && \
if [ ! -f $@ ] || ! diff $@ [email protected] > /dev/null ; then \
mv [email protected] $@ ; \
else \
rm [email protected]; \
fi
# $(foreach compatible_versions,$(wildcard compatible_versions.txt), \
# $(foreach header, $(SHARED_LIBRARY_HEADERS), \
# cat $(compatible_versions) | $(PERL) -ne '{$$version="$(word 3, $(subst /,' ',$(header)))";$$arch="$(word 4, $(subst /,' ',$(header)))";@words = split;if ($$words[2] eq $$version) { $$words[2]=~s/[-.]/_/g;$$archsub=$$arch;$$archsub=~s/[-.]/_/g;printf("{\"%s\",\"%s\", libperlinterpreter%s%s},\n",$$words[0],$$arch,$$words[2],$$archsub)}}' && )) \
$(STATIC_HEADER):
ifeq ($(STATIC_PERL_LIB),)
echo '#define NO_STATIC_FALLBACK' > [email protected];
else
echo '/* undef NO_STATIC_FALLBACK */' > [email protected];
endif
@set -xe && \
if [ ! -f $@ ] || ! diff $@ [email protected] > /dev/null; then \
mv [email protected] $@; \
else \
rm [email protected]; \
fi
#Always build the .new and see if they should be updated.
# .PHONY: version_headers
$(VERSION_HEADERS): force
.PHONY: force
force: ;
# version headers must exist for makedepend
$(DEPEND_FILES): $(DYNAMIC_VERSIONS_HEADER) $(STATIC_HEADER)
endif
#-----------------------------------------------------------------------------
endif
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
ifeq ($(TASK),library)
#-----------------------------------------------------------------------------
main : $(LIBRARY)
#Always update the link for the .a libraries.
ifneq ($(SHARED_OBJECT), true)
if [ -L $(LIBRARY_LINK) ] || [ -e $(LIBRARY_LINK) ] ; then \
rm $(LIBRARY_LINK) ; \
fi
cd $(LIBRARY_ROOT_DIR); ln -s $(LIBRARY_VERSION)/$(LIBRARY_NAME) $(LIBRARY_NAME); cd ../..
endif
# explicit rule for making the library
ifneq ($(SHARED_OBJECT), true)
$(LIBRARY) : $(OBJECTS)
ARCHIVE_MEMBERS := $(OBJECTS)
ifneq ($(STATIC_PERL_LIB),) # have a static perl
LIBRARY_LIBS := $(DYNALOADER_LIB) $(STATIC_PERL_LIB) $(CURDIR)/$(PERL_CMISS_LIB)
$(LIBRARY) : $(LIBRARY_LIBS)
MEMBERS_DIR := $(WORKING_DIR)/archive_members
# Hopefully there are not too many objects for the command line
ARCHIVE_MEMBERS += $(MEMBERS_DIR)/*
# If there is an export file for libperl.a then use it for this library.
ifneq ($(PERL_EXP),)
main : $(LIB_EXP)
$(LIB_EXP) : $(PERL_EXP)
cp -f $^ $@
endif
endif
$(LIBRARY):
ifneq ($(STATIC_PERL_LIB),) # have a static perl
mkdir -p $(MEMBERS_DIR)
# Hopefully none of the libraries have objects of the same name
cd $(MEMBERS_DIR) && \
for lib in $(LIBRARY_LIBS); do $(AR) x $$lib || exit 1; done
endif
$(AR) $(ARFLAGS) [email protected] $(ARCHIVE_MEMBERS)
mv [email protected] $@
ifneq ($(STATIC_PERL_LIB),) # have a static perl
rm -r $(MEMBERS_DIR)
endif
else# shared object
$(LIBRARY) : $(OBJECTS) \
$(DYNALOADER_LIB) $(PERL_CMISS_LIB) $(STATIC_PERL_LIB)
$(LD_SHARED) -o $@ $^ $(SHARED_LINK_LIBRARIES)
endif
# include the object dependencies
ifneq ($(DEPEND_FILES),)
include $(DEPEND_FILES)
endif
# implicit rules for making the objects
$(WORKING_DIR)/%.o : $(SOURCE_DIR)/%.c
ifeq ($(DEBUG),false)
$(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $<
else
# Useful when using the debugger to find out which subroutine of the same name.
[ -L $(@D)/$*.c ] || ln -s $(CURDIR)/$< $(@D)/$*.c
$(CC) -o $@ $(CPPFLAGS) -I$(<D) $(CFLAGS) $(@D)/$*.c
endif
#-----------------------------------------------------------------------------