-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
3120 lines (2713 loc) · 124 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
#
# This GNU make makefile has been tested on:
# Linux (x86 & Sparc & PPC)
# Android (Termux)
# OS X
# Solaris (x86 & Sparc) (gcc and Sun C)
# OpenBSD
# NetBSD
# FreeBSD
# HP-UX
# AIX
# Windows (MinGW & cygwin) - deprecated (maybe works, maybe not)
# Linux x86 targeting Android (using agcc script)
# Haiku x86 (with gcc4)
#
# Android targeted builds should invoke GNU make with GCC=agcc on
# the command line.
#
# In general, the logic below will detect and build with the available
# features which the host build environment provides.
#
# Dynamic loading of libpcap is the preferred default behavior if pcap.h
# is available at build time. Support to statically linking against libpcap
# is deprecated and may be removed in the future. Static linking against
# libpcap can be enabled if GNU make is invoked with USE_NETWORK=1 on the
# command line.
#
# Some platforms may not have vendor supplied libpcap available. HP-UX is
# one such example. The packages which are available for this platform
# install include files and libraries in user specified directories. In
# order for this makefile to locate where these components may have been
# installed, gmake should be invoked with LPATH=/usr/lib:/usr/local/lib
# defined (adjusted as needed depending on where they may be installed).
#
# In the unlikely event that someone wants to build network capable
# simulators without networking support, invoking GNU make with
# NONETWORK=1 on the command line will do the trick.
#
# By default, video support is enabled if the SDL2 development
# headers and libraries are available. To force a build without video
# support, invoke GNU make with NOVIDEO=1 on the command line.
#
# The default build will build compiler optimized binaries.
# If debugging is desired, then GNU make can be invoked with
# DEBUG=1 on the command line.
#
# When building compiler optimized binaries with the gcc or clang
# compilers, invoking GNU make with LTO=1 on the command line will
# cause the build to use Link Time Optimization to maximally optimize
# the results. Link Time Optimization can report errors which aren't
# otherwise detected and will also take significantly longer to
# complete. Additionally, non debug builds default to build with an
# optimization level of -O2. This optimization level can be changed
# by invoking GNU make with OPTIMIZE=-O3 (or whatever optimize value
# you want) on the command line if desired.
#
# The default setup will fail simulator build(s) if the compile
# produces any warnings. These should be cleaned up before new
# or changed code is accepted into the code base. This option
# can be overridden if GNU make is invoked with WARNINGS=ALLOWED
# on the command line.
#
# The default build will run per simulator tests if they are
# available. If building without running tests is desired,
# then GNU make should be invoked with TESTS=0 on the command
# line.
#
# The default build will compile all input source files with a
# single compile and link operation. This is most optimal when
# building all simulators or just a single simulator which you
# merely plan to run. If you're developing new code for a
# simulator, it is more efficient to compile each source module
# into it's own object and then to link all the objects into the
# simulator binary. This allows only the changed modules to be
# compiled instead of all of the input files resulting in much
# quicker builds during active simulator development. GNU make
# can be invoked with BUILD_SEPARATE=1 on the command line (or
# defined as an exported environment variable) and separate
# objects will be built and linked into the resulting simulator.
#
# The default make output will show the details of each compile
# and link command executed. GNU make can be invoked with QUIET=1
# on the command line (or defined as an exported environment
# variable) a summary of the executed command will be displayed
# in the make output.
#
# Default test execution will produce summary output. Detailed
# test output can be produced if GNU make is invoked with
# TEST_ARG=-v on the command line.
#
# simh project support is provided for simulators that are built with
# dependent packages provided with the or by the operating system
# distribution OR for platforms where that isn't directly available
# (OS X/macOS) by packages from specific package management systems
# (HomeBrew or MacPorts). Users wanting to build simulators with locally
# built dependent packages or packages provided by an unsupported package
# management system may be able to override where this procedure looks
# for include files and/or libraries. Overrides can be specified by define
# exported environment variables or GNU make command line arguments which
# specify INCLUDES and/or LIBRARIES.
# Each of these, if specified, must be the complete list include directories
# or library directories that should be used with each element separated by
# colons. (i.e. INCLUDES=/usr/include/:/usr/local/include/:...)
# If this doesn't work for you and/or you're interested in using a different
# ToolChain, you're free to solve this problem on your own. Good Luck.
#
# Some environments may have the LLVM (clang) compiler installed as
# an alternate to gcc. If you want to specifically build with the
# clang compiler, you should invoke make with GCC=clang on the make command
# line.
#
# Internal ROM support can be disabled if GNU make is invoked with
# DONT_USE_ROMS=1 on the command line.
#
# For linting (or other code analyzers) make may be invoked similar to:
#
# make GCC=cppcheck CC_OUTSPEC= LDFLAGS= CFLAGS_G="--enable=all --template=gcc" CC_STD=--std=c99
#
ifeq (0,$(MAKELEVEL)) # recursive individual target build logic is end of this makefile
#
# CC Command (and platform available options). (Poor man's autoconf)
#
ifneq (,${GREP_OPTIONS})
$(info GREP_OPTIONS is defined in your environment.)
$(info )
$(info This variable interfers with the proper operation of this script.)
$(info )
$(info The GREP_OPTIONS environment variable feature of grep is deprecated)
$(info for exactly this reason and will be removed from future versions of)
$(info grep. The grep man page suggests that you use an alias or a script)
$(info to invoke grep with your preferred options.)
$(info )
$(info unset the GREP_OPTIONS environment variable to use this makefile)
$(error 1)
endif
ifneq ($(findstring Windows,${OS}),)
$(info *** Warning *** Compiling simh simulators with MinGW or cygwin is deprecated and)
$(info *** Warning *** may not complete successfully or produce working simulators. If)
$(info *** Warning *** building simulators completes, they may not be fully functional.)
$(info *** Warning *** It is recommended to use one of the free Microsoft Visual Studio)
$(info *** Warning *** compilers which provide fully functional simulator capabilities.)
ifeq ($(findstring .exe,${SHELL}),.exe)
# MinGW
export WIN32 := 1
# Tests don't run under MinGW
export TESTS := 0
export RM = del /f /q
export MKDIR = mkdir
export OSTYPE = MinGW
ifneq (,$(strip $(shell $(MAKE) --version 2>NUL)))
GNUMake=$(strip $(shell $(MAKE) --version | findstr /C:"GNU Make"))
export GNUMakeVERSION=$(strip $(shell for /F "tokens=3" %%i in ("$(GNUMake)") do echo %%i))
else
# Nothing useful returned from MinGW GNU Make 3.82.90, make sure to set this version
export GNUMakeVERSION=3.82.90
endif
else # Msys or cygwin
ifeq (MINGW,$(findstring MINGW,$(shell uname)))
$(info *** This makefile can not be used with the Msys bash shell)
$(error Use build_mingw.bat ${MAKECMDGOALS} from a Windows command prompt)
endif
endif
else
export GNUMakeVERSION = $(shell ($(MAKE) --version /dev/null 2>&1 | grep 'GNU Make' | awk '{ print $$3 }'))
ifeq (old,$(shell $(MAKE) --version /dev/null 2>&1 | grep 'GNU Make' | awk '{ if ($$3 < "3.81") {print "old"} }'))
$(warning *** Warning *** GNU Make Version $(GNUMakeVERSION) is too old to)
$(warning *** Warning *** fully process this makefile)
endif
export MKDIR = mkdir -p
export OSTYPE = $(shell uname)
endif
ifeq ($(WIN32),)
SIM_MAJOR=$(shell grep SIM_MAJOR sim_rev.h | awk '{ print $$3 }')
else
SIM_MAJOR=$(shell for /F "tokens=3" %%i in ('findstr /c:"SIM_MAJOR" sim_rev.h') do echo %%i)
endif
# Assure that only BUILD_SEPARATE=1 will cause separate compiles
ifeq (,$(BUILD_SEPARATE))
override BUILD_SEPARATE=
endif
export BUILD_SEPARATE
ifeq (,$(QUIET))
override QUIET=
endif
export QUIET
BUILD_SINGLE := ${MAKECMDGOALS} $(BLANK_SUFFIX)
BUILD_MULTIPLE_VERB = is
MAKECMDGOALS_DESCRIPTION = the $(MAKECMDGOALS) simulator
# building the pdp1, pdp11, tx-0, or any microvax simulator could use video support
ifneq (3,${SIM_MAJOR})
ifneq (,$(or $(findstring XXpdp1XX,$(addsuffix XX,$(addprefix XX,${MAKECMDGOALS}))),$(findstring pdp11,${MAKECMDGOALS}),$(findstring tx-0,${MAKECMDGOALS}),$(findstring microvax1,${MAKECMDGOALS}),$(findstring microvax2,${MAKECMDGOALS}),$(findstring microvax3900,${MAKECMDGOALS}),$(findstring microvax2000,${MAKECMDGOALS}),$(findstring vaxstation3100,${MAKECMDGOALS}),$(findstring XXvaxXX,$(addsuffix XX,$(addprefix XX,${MAKECMDGOALS})))))
VIDEO_USEFUL = true
endif
# building the besm6 needs both video support and fontfile support
ifneq (,$(findstring besm6,${MAKECMDGOALS}))
VIDEO_USEFUL = true
BESM6_BUILD = true
endif
# building the Imlac needs video support
ifneq (,$(findstring imlac,${MAKECMDGOALS}))
VIDEO_USEFUL = true
endif
# building the TT2500 needs video support
ifneq (,$(findstring tt2500,${MAKECMDGOALS}))
VIDEO_USEFUL = true
endif
# building the PDP6, KA10 or KI10 needs video support
ifneq (,$(or $(findstring pdp6,${MAKECMDGOALS}),$(findstring pdp10-ka,${MAKECMDGOALS}),$(findstring pdp10-ki,${MAKECMDGOALS})))
VIDEO_USEFUL = true
endif
# building the AltairZ80 could use video support
ifneq (,$(findstring altairz80,${MAKECMDGOALS}))
VIDEO_USEFUL = true
endif
endif
# building the SEL32 networking can be used
ifneq (,$(findstring sel32,${MAKECMDGOALS}))
NETWORK_USEFUL = true
endif
# building the PDP-7 needs video support
ifneq (,$(findstring pdp7,${MAKECMDGOALS}))
VIDEO_USEFUL = true
endif
# building the pdp11, any pdp10, any 3b2, or any vax simulator could use networking support
ifneq (,$(findstring pdp11,${MAKECMDGOALS})$(findstring pdp10,${MAKECMDGOALS})$(findstring vax,${MAKECMDGOALS})$(findstring frontpaneltest,${MAKECMDGOALS})$(findstring infoserver,${MAKECMDGOALS})$(findstring 3b2,${MAKECMDGOALS})$(findstring all,${MAKECMDGOALS}))
NETWORK_USEFUL = true
ifneq (,$(findstring all,${MAKECMDGOALS}))
BUILD_MULTIPLE = s
BUILD_MULTIPLE_VERB = are
VIDEO_USEFUL = true
BESM6_BUILD = true
MAKECMDGOALS_DESCRIPTION = everything
endif
else
ifeq (${MAKECMDGOALS},)
# default target is all
NETWORK_USEFUL = true
VIDEO_USEFUL = true
BUILD_MULTIPLE = s
BUILD_MULTIPLE_VERB = are
BUILD_SINGLE := all $(BUILD_SINGLE)
BESM6_BUILD = true
MAKECMDGOALS_DESCRIPTION = everything
endif
endif
ifneq (,$(and $(word 1,${MAKECMDGOALS}),$(word 2,${MAKECMDGOALS})))
BUILD_MULTIPLE = s
BUILD_MULTIPLE_VERB = are
MAKECMDGOALS_DESCRIPTION = the $(MAKECMDGOALS) simulators
endif
# someone may want to explicitly build simulators without network support
ifneq ($(NONETWORK),)
NETWORK_USEFUL =
endif
# ... or without video support
ifneq ($(NOVIDEO),)
VIDEO_USEFUL =
endif
find_exe = $(abspath $(strip $(firstword $(foreach dir,$(strip $(subst :, ,${PATH})),$(wildcard $(dir)/$(1))))))
find_lib = $(firstword $(abspath $(strip $(firstword $(foreach dir,$(strip ${LIBPATH}),$(foreach ext,$(strip ${LIBEXT}),$(wildcard $(dir)/lib$(1).$(ext))))))))
find_include = $(abspath $(strip $(firstword $(foreach dir,$(strip ${INCPATH}),$(wildcard $(dir)/$(1).h)))))
ifeq (Darwin,$(OSTYPE))
ifeq (/usr/local/bin/brew,$(call find_exe,brew))
PKG_MGR = HOMEBREW
PKG_CMD = brew install
else
ifeq (/opt/local/bin/port,$(call find_exe,port))
PKG_MGR = MACPORTS
PKG_CMD = port install
endif
endif
endif
ifneq (,$(and $(findstring Linux,$(OSTYPE)),$(call find_exe,apt-get)))
ifneq (Android,$(shell uname -o))
PKG_MGR = APT
else
PKG_MGR = TERMUX
endif
PKG_CMD = apt-get install
endif
ifneq (,$(and $(findstring Linux,$(OSTYPE)),$(call find_exe,yum)))
PKG_MGR = YUM
PKG_CMD = yum install
endif
ifneq (,$(and $(findstring Linux,$(OSTYPE)),$(call find_exe,zypper)))
PKG_MGR = ZYPPER
PKG_CMD = zypper install
endif
ifneq (,$(and $(findstring NetBSD,$(OSTYPE)),$(call find_exe,pkgin)))
PKG_MGR = PKGSRC
PKG_CMD = pkgin install
PKG_NO_SUDO = YES
endif
ifneq (,$(and $(findstring FreeBSD,$(OSTYPE)),$(call find_exe,pkg)))
PKG_MGR = PKGBSD
PKG_CMD = pkg install
PKG_NO_SUDO = YES
endif
ifneq (,$(and $(findstring OpenBSD,$(OSTYPE)),$(call find_exe,pkg_add)))
PKG_MGR = PKGADD
PKG_CMD = pkg_add
PKG_NO_SUDO = YES
PKG_SHELL_READ_CANT_PROMPT = YES
endif
# Dependent packages
DPKG_COMPILER = 1
DPKG_PCAP = 2
DPKG_VDE = 3
DPKG_PCRE = 4
DPKG_EDITLINE = 5
DPKG_SDL = 6
DPKG_PNG = 7
DPKG_ZLIB = 8
DPKG_SDL_TTF = 9
DPKG_GMAKE = 10
ifneq (3,${SIM_MAJOR})
# Platform Pkg Names COMPILER PCAP VDE PCRE EDITLINE SDL PNG ZLIB SDL_TTF GMAKE CURL
PKGS_SRC_HOMEBREW = - - vde pcre libedit sdl2 libpng zlib sdl2_ttf make -
PKGS_SRC_MACPORTS = - - vde2 pcre libedit libsdl2 libpng zlib libsdl2_ttf gmake -
PKGS_SRC_APT = gcc libpcap-dev libvdeplug-dev libpcre3-dev libedit-dev libsdl2-dev libpng-dev - libsdl2-ttf-dev - curl
PKGS_SRC_YUM = gcc libpcap-devel - pcre-devel libedit-devel SDL2-devel libpng-devel zlib-devel SDL2_ttf-devel - -
PKGS_SRC_ZYPPER = gcc libpcap-devel - pcre-devel libedit-devel libSDL2-devel libpng16-devel zlib-devel libSDL2_ttf-devel make -
PKGS_SRC_PKGSRC = - - - pcre editline SDL2 png zlib SDL2_ttf gmake -
PKGS_SRC_PKGBSD = - - - pcre libedit sdl2 png - sdl2_ttf gmake -
PKGS_SRC_PKGADD = - - - pcre - sdl2 png - sdl2-ttf gmake -
PKGS_SRC_TERMUX = - libpcap - - - sdl2 - - - - -
ifneq (0,$(TESTS))
ifneq (,${TEST_ARG})
export TEST_ARG
TESTING_FEATURES = - Per simulator tests will be run with argument: ${TEST_ARG}
else
TESTING_FEATURES = - Per simulator tests will be run
endif
else
TESTING_FEATURES = - Per simulator tests will be skipped
endif
else
# simh v3 has minimal external dependencies
# Platform Pkg Names COMPILER PCAP VDE PCRE EDITLINE SDL PNG ZLIB SDL_TTF GMAKE
PKGS_SRC_HOMEBREW = - - vde - libedit - - - - -
PKGS_SRC_MACPORTS = - - vde2 - libedit - - - - -
PKGS_SRC_APT = gcc libpcap-dev libvdeplug-dev - libedit-dev - - - - -
PKGS_SRC_YUM = gcc libpcap-devel - - libedit-devel - - - - -
PKGS_SRC_PKGSRC = - - - - editline - - - - -
PKGS_SRC_PKGBSD = - - - - libedit - - - - -
PKGS_SRC_PKGADD = - - - - - - - - - -
endif
ifeq (${WIN32},) #*nix Environments (&& cygwin)
# OSNAME is used in messages to indicate the source of libpcap components
OSNAME = $(OSTYPE)
ifeq (SunOS,$(OSTYPE))
export TEST = /bin/test
else
export TEST = test
endif
override AUTO_INSTALL_PACKAGES:=$(and $(AUTO_INSTALL_PACKAGES),$(or $(findstring HOMEBREW,$(PKG_MGR)),$(shell if $(TEST) -r /dev/mem; then echo running_as_root; fi)))
ifeq (${GCC},)
ifeq (,$(call find_exe,gcc))
ifneq (clang,$(findstring clang,$(and $(call find_exe,cc),$(shell cc -v /dev/null 2>&1 | grep 'clang'))))
$(info *** Warning *** Using local cc since gcc isn't available locally.)
$(info *** Warning *** You may need to install gcc to build working simulators.)
endif
GCC = cc
NEEDED_PKGS += DPKG_COMPILER
else
GCC = gcc
endif
endif
ifeq (CYGWIN,$(findstring CYGWIN,$(OSTYPE))) # uname returns CYGWIN_NT-n.n-ver
OSTYPE = cygwin
OSNAME = windows-build
endif
ifeq (Darwin,$(OSTYPE))
ifeq (,$(call find_exe,port)$(call find_exe,brew))
$(info *** Info *** simh dependent packages on macOS must be provided by either the)
$(info *** Info *** HomeBrew package system or by the MacPorts package system.)
$(info *** Info *** Neither of these seem to be installed on the local system.)
$(info *** Info ***)
ifeq (,$(INCLUDES)$(LIBRARIES))
$(info *** Info *** Users wanting to build simulators with locally built dependent)
$(info *** Info *** packages or packages provided by an unsupported package)
$(info *** Info *** management system may be able to override where this procedure)
$(info *** Info *** looks for include files and/or libraries. Overrides can be)
$(info *** Info *** specified by defining exported environment variables or GNU make)
$(info *** Info *** command line arguments which specify INCLUDES and/or LIBRARIES.)
$(info *** Info *** If this works, that's great, if it doesn't you are on your own!)
else
$(info *** Warning *** Attempting to build on macOS with:)
$(info *** Warning *** INCLUDES defined as $(INCLUDES))
$(info *** Warning *** and)
$(info *** Warning *** LIBRARIES defined as $(LIBRARIES))
endif
endif
endif
ifeq (,$(shell ${GCC} -v /dev/null 2>&1 | grep 'clang'))
GCC_VERSION = $(shell ${GCC} -v /dev/null 2>&1 | grep 'gcc version' | awk '{ print $$3 }')
COMPILER_NAME = GCC Version: $(GCC_VERSION)
ifeq (,$(GCC_VERSION))
ifeq (SunOS,$(OSTYPE))
ifneq (,$(shell ${GCC} -V 2>&1 | grep 'Sun C'))
SUNC_VERSION = $(shell ${GCC} -V 2>&1 | grep 'Sun C')
COMPILER_NAME = $(wordlist 2,10,$(SUNC_VERSION))
CC_STD = -std=c99
endif
endif
ifeq (HP-UX,$(OSTYPE))
ifneq (,$(shell what `which $(firstword ${GCC}) 2>&1`| grep -i compiler))
COMPILER_NAME = $(strip $(shell what `which $(firstword ${GCC}) 2>&1` | grep -i compiler))
CC_STD = -std=gnu99
endif
endif
else
OS_CCDEFS += $(if $(findstring ALLOWED,$(WARNINGS)),,-Werror)
ifeq (,$(findstring ++,${GCC}))
CC_STD = -std=gnu99
else
export CPP_BUILD = 1
endif
endif
else
OS_CCDEFS += $(if $(findstring ALLOWED,$(WARNINGS)),,-Werror)
ifeq (Apple,$(shell ${GCC} -v /dev/null 2>&1 | grep 'Apple' | awk '{ print $$1 }'))
COMPILER_NAME = $(shell ${GCC} -v /dev/null 2>&1 | grep 'Apple' | awk '{ print $$1 " " $$2 " " $$3 " " $$4 }')
CLANG_VERSION = $(word 4,$(COMPILER_NAME))
else
COMPILER_NAME = $(shell ${GCC} -v /dev/null 2>&1 | grep 'clang version' | awk '{ print $$1 " " $$2 " " $$3 }')
CLANG_VERSION = $(word 3,$(COMPILER_NAME))
ifeq (,$(findstring .,$(CLANG_VERSION)))
COMPILER_NAME = $(shell ${GCC} -v /dev/null 2>&1 | grep 'clang version' | awk '{ print $$1 " " $$2 " " $$3 " " $$4 }')
CLANG_VERSION = $(word 4,$(COMPILER_NAME))
endif
endif
ifeq (,$(findstring ++,${GCC}))
CC_STD = -std=c99
else
export CPP_BUILD = 1
OS_CCDEFS += -Wno-deprecated
endif
endif
ifeq (git-repo,$(shell if ${TEST} -e ./.git; then echo git-repo; fi))
GIT_REPO=1
GIT_PATH=$(strip $(call find_exe,git))
ifeq (,$(GIT_PATH))
$(error building using a git repository, but git is not available)
endif
endif
ifeq (got-repo,$(shell if ${TEST} -e ./.got; then echo got-repo; fi))
GIT_PATH=$(strip $(call find_exe,git))
ifeq (,$(GIT_PATH))
$(error building using a got repository, but git is not available)
endif
ifeq (,$(file <.got/repository))
$(error building using a got repository, but git repository is not available)
endif
REPO_PATH=-C $(file <.got/repository)
GIT_REPO=1
endif
ifneq (,$(and $(GIT_REPO),$(GIT_PATH)))
ifeq (commit-id-exists,$(shell if ${TEST} -e .git-commit-id; then echo commit-id-exists; fi))
CURRENT_FULL_GIT_COMMIT_ID=$(strip $(shell grep 'SIM_GIT_COMMIT_ID' .git-commit-id | awk '{ print $$2 }'))
CURRENT_GIT_COMMIT_ID=$(word 1,$(subst +, , $(CURRENT_FULL_GIT_COMMIT_ID)))
ACTUAL_GIT_COMMIT_ID=$(strip $(shell git $(REPO_PATH) log -1 --pretty="%H"))
ifneq ($(CURRENT_GIT_COMMIT_ID),$(ACTUAL_GIT_COMMIT_ID))
NEED_COMMIT_ID = need-commit-id$(shell touch scp.c)
# make sure that the invalidly formatted .git-commit-id file wasn't generated
# by legacy git hooks which need to be removed.
$(shell $(RM) .git/hooks/post-checkout .git/hooks/post-commit .git/hooks/post-merge)
endif
else
NEED_COMMIT_ID = need-commit-id$(shell touch scp.c)
endif
ifneq (,$(if $(REPO_PATH),$(shell got status -S ?),$(shell git update-index --refresh --)))
ifeq (,$(findstring +uncommitted-changes,$(CURRENT_FULL_GIT_COMMIT_ID)))
GIT_EXTRA_FILES=+uncommitted-changes$(shell touch scp.c)
else
GIT_EXTRA_FILES=+uncommitted-changes
endif
endif
ifneq (,$(or $(NEED_COMMIT_ID),$(GIT_EXTRA_FILES)))
isodate=$(shell git $(REPO_PATH) log -1 --pretty="%ai"|sed -e 's/ /T/'|sed -e 's/ //')
$(shell git $(REPO_PATH) log -1 --pretty="SIM_GIT_COMMIT_ID %H$(GIT_EXTRA_FILES)%nSIM_GIT_COMMIT_TIME $(isodate)" >.git-commit-id)
endif
endif
SIM_BUILD_OS_VERSION= -DSIM_BUILD_OS_VERSION="$(shell uname -a|sed 's/,//g')"
LTO_EXCLUDE_VERSIONS =
PCAPLIB = pcap
ifeq (agcc,$(findstring agcc,${GCC})) # Android target build?
OS_CCDEFS += -D_GNU_SOURCE -DSIM_ASYNCH_IO
OS_LDFLAGS = -lm
else # Non-Android (or Native Android) Builds
ifeq (,$(INCLUDES)$(LIBRARIES))
INCPATH:=$(shell LANG=C; ${GCC} -x c -v -E /dev/null 2>&1 | grep -A 10 '> search starts here' | grep '^ ' | tr -d '\n')
ifeq (,${INCPATH})
INCPATH:=/usr/include
endif
LIBPATH:=/usr/lib
else
$(info *** Warning ***)
ifeq (,$(INCLUDES))
INCPATH:=$(shell LANG=C; ${GCC} -x c -v -E /dev/null 2>&1 | grep -A 10 '> search starts here' | grep '^ ' | tr -d '\n')
else
$(info *** Warning *** Unsupported build with INCLUDES defined as: $(INCLUDES))
INCPATH:=$(strip $(subst :, ,$(INCLUDES)))
UNSUPPORTED_BUILD := include
endif
ifeq (,$(LIBRARIES))
LIBPATH:=/usr/lib
else
$(info *** Warning *** Unsupported build with LIBRARIES defined as: $(LIBRARIES))
LIBPATH:=$(strip $(subst :, ,$(LIBRARIES)))
ifeq (include,$(UNSUPPORTED_BUILD))
UNSUPPORTED_BUILD := include+lib
else
UNSUPPORTED_BUILD := lib
endif
endif
$(info *** Warning ***)
endif
OS_CCDEFS += -D_GNU_SOURCE
GCC_OPTIMIZERS_CMD = ${GCC} -v --help 2>&1
GCC_WARNINGS_CMD = ${GCC} -v --help 2>&1
LD_ELF = $(shell echo | ${GCC} -E -dM - | grep __ELF__)
ifeq (Darwin,$(OSTYPE))
OSNAME = OSX
LIBEXT = dylib
ifneq (include,$(findstring include,$(UNSUPPORTED_BUILD)))
INCPATH:=$(shell LANG=C; ${GCC} -x c -v -E /dev/null 2>&1 | grep -A 10 '> search starts here' | grep '^ ' | grep -v 'framework directory' | tr -d '\n')
endif
ifeq (incopt,$(shell if ${TEST} -d /opt/local/include; then echo incopt; fi))
INCPATH += /opt/local/include
OS_CCDEFS += -I/opt/local/include
endif
ifeq (libopt,$(shell if ${TEST} -d /opt/local/lib; then echo libopt; fi))
LIBPATH += /opt/local/lib
OS_LDFLAGS += -L/opt/local/lib
endif
ifeq (HomeBrew,$(or $(shell if ${TEST} -d /usr/local/Cellar; then echo HomeBrew; fi),$(shell if ${TEST} -d /opt/homebrew/Cellar; then echo HomeBrew; fi)))
ifeq (local,$(shell if $(TEST) -d /usr/local/Cellar; then echo local; fi))
HBPATH = /usr/local
else
HBPATH = /opt/homebrew
endif
INCPATH += $(foreach dir,$(wildcard $(HBPATH)/Cellar/*/*),$(realpath $(dir)/include))
LIBPATH += $(foreach dir,$(wildcard $(HBPATH)/Cellar/*/*),$(realpath $(dir)/lib))
endif
else
ifeq (Linux,$(OSTYPE))
ifeq (Android,$(shell uname -o))
ANDROID_API=$(shell getprop ro.build.version.sdk)
ANDROID_VERSION=$(shell getprop ro.build.version.release)
OS_CCDEFS += -DSIM_BUILD_OS=" On Android Version $(ANDROID_VERSION) sdk=$(ANDROID_API)"
ifeq (,$(shell clang sim_BuildROMs.c -o /dev/null -D__ANDROID_API__=$(ANDROID_API) 2>&1))
OS_CCDEFS += -D__ANDROID_API__=$(ANDROID_API)
endif
endif
ifneq (lib,$(findstring lib,$(UNSUPPORTED_BUILD)))
ifeq (Android,$(shell uname -o))
ifneq (,$(shell if ${TEST} -d ${PREFIX}/lib; then echo prefixlib; fi))
LIBPATH += ${PREFIX}/lib
endif
ifneq (,$(shell if ${TEST} -d /system/lib; then echo systemlib; fi))
LIBPATH += /system/lib
endif
LIBPATH += $(LD_LIBRARY_PATH)
endif
ifeq (ldconfig,$(shell if ${TEST} -e /sbin/ldconfig; then echo ldconfig; fi))
LIBPATH := $(sort $(foreach lib,$(shell /sbin/ldconfig -p | grep ' => /' | sed 's/^.* => //'),$(dir $(lib))))
endif
endif
LIBSOEXT = so
LIBEXT = $(LIBSOEXT) a
else
ifeq (SunOS,$(OSTYPE))
OSNAME = Solaris
ifneq (lib,$(findstring lib,$(UNSUPPORTED_BUILD)))
LIBPATH := $(shell LANG=C; crle | grep 'Default Library Path' | awk '{ print $$5 }' | sed 's/:/ /g')
endif
LIBEXT = so
OS_LDFLAGS += -lsocket -lnsl
ifeq (incsfw,$(shell if ${TEST} -d /opt/sfw/include; then echo incsfw; fi))
INCPATH += /opt/sfw/include
OS_CCDEFS += -I/opt/sfw/include
endif
ifeq (libsfw,$(shell if ${TEST} -d /opt/sfw/lib; then echo libsfw; fi))
LIBPATH += /opt/sfw/lib
OS_LDFLAGS += -L/opt/sfw/lib -R/opt/sfw/lib
endif
OS_CCDEFS += -D_LARGEFILE_SOURCE
else
ifeq (cygwin,$(OSTYPE))
# use 0readme_ethernet.txt documented Windows pcap build components
INCPATH += ../windows-build/winpcap/WpdPack/Include
LIBPATH += ../windows-build/winpcap/WpdPack/Lib
PCAPLIB = wpcap
LIBEXT = a
else
ifneq (,$(findstring AIX,$(OSTYPE)))
OS_LDFLAGS += -lm -lrt
ifeq (incopt,$(shell if ${TEST} -d /opt/freeware/include; then echo incopt; fi))
INCPATH += /opt/freeware/include
OS_CCDEFS += -I/opt/freeware/include
endif
ifeq (libopt,$(shell if ${TEST} -d /opt/freeware/lib; then echo libopt; fi))
LIBPATH += /opt/freeware/lib
OS_LDFLAGS += -L/opt/freeware/lib
endif
else
ifneq (,$(findstring Haiku,$(OSTYPE)))
HAIKU_ARCH=$(shell getarch)
ifeq ($(HAIKU_ARCH),)
$(error Missing getarch command, your Haiku release is probably too old)
endif
ifeq ($(HAIKU_ARCH),x86_gcc2)
$(error Unsupported arch x86_gcc2. Run setarch x86 and retry)
endif
INCPATH := $(shell findpaths -e -a $(HAIKU_ARCH) B_FIND_PATH_HEADERS_DIRECTORY)
INCPATH += $(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY posix)
LIBPATH := $(shell findpaths -e -a $(HAIKU_ARCH) B_FIND_PATH_DEVELOP_LIB_DIRECTORY)
OS_LDFLAGS += -lnetwork
else
ifeq (,$(findstring NetBSD,$(OSTYPE)))
ifneq (no ldconfig,$(findstring no ldconfig,$(shell which ldconfig 2>&1)))
LDSEARCH :=$(shell LANG=C; ldconfig -r | grep 'search directories' | awk '{print $$3}' | sed 's/:/ /g')
endif
ifneq (,$(LDSEARCH))
LIBPATH := $(LDSEARCH)
else
ifeq (,$(strip $(LPATH)))
$(info *** Warning ***)
$(info *** Warning *** The library search path on your $(OSTYPE) platform can not be)
$(info *** Warning *** determined. This should be resolved before you can expect)
$(info *** Warning *** to have fully working simulators.)
$(info *** Warning ***)
$(info *** Warning *** You can specify your library paths via the LPATH environment)
$(info *** Warning *** variable.)
$(info *** Warning ***)
else
LIBPATH = $(subst :, ,$(LPATH))
endif
endif
OS_LDFLAGS += $(patsubst %,-L%,${LIBPATH})
endif
endif
endif
ifeq (usrpkglib,$(shell if ${TEST} -d /usr/pkg/lib; then echo usrpkglib; fi))
LIBPATH += /usr/pkg/lib
INCPATH += /usr/pkg/include
OS_LDFLAGS += -L/usr/pkg/lib -R/usr/pkg/lib
OS_CCDEFS += -I/usr/pkg/include
endif
ifeq (/usr/local/lib,$(findstring /usr/local/lib,${LIBPATH}))
INCPATH += /usr/local/include
OS_CCDEFS += -I/usr/local/include
endif
ifneq (,$(findstring NetBSD,$(OSTYPE))$(findstring FreeBSD,$(OSTYPE))$(findstring AIX,$(OSTYPE)))
LIBEXT = so
else
ifeq (HP-UX,$(OSTYPE))
ifeq (ia64,$(shell uname -m))
LIBEXT = so
else
LIBEXT = sl
endif
OS_CCDEFS += -D_HPUX_SOURCE -D_LARGEFILE64_SOURCE
OS_LDFLAGS += -Wl,+b:
override LTO =
else
LIBEXT = a
endif
endif
endif
endif
endif
endif
ifeq (,$(LIBSOEXT))
LIBSOEXT = $(LIBEXT)
endif
ifeq (,$(filter /lib/,$(LIBPATH)))
ifeq (existlib,$(shell if $(TEST) -d /lib/; then echo existlib; fi))
LIBPATH += /lib/
endif
endif
ifeq (,$(filter /usr/lib/,$(LIBPATH)))
ifeq (existusrlib,$(shell if $(TEST) -d /usr/lib/; then echo existusrlib; fi))
LIBPATH += /usr/lib/
endif
endif
export CPATH = $(subst $() $(),:,$(INCPATH))
export LIBRARY_PATH = $(subst $() $(),:,$(LIBPATH))
endif
$(info lib paths are: ${LIBPATH})
$(info include paths are: ${INCPATH})
need_search = $(strip $(shell ld -l$(1) /dev/null 2>&1 | grep $(1) | sed s/$(1)//))
LD_SEARCH_NEEDED := $(call need_search,ZzzzzzzZ)
ifneq (,$(call find_lib,m))
OS_LDFLAGS += -lm
$(info using libm: $(call find_lib,m))
endif
ifneq (,$(call find_lib,rt))
OS_LDFLAGS += -lrt
$(info using librt: $(call find_lib,rt))
endif
ifneq (,$(call find_include,pthread))
ifneq (,$(call find_lib,pthread))
PTHREAD_CCDEFS += -DSIM_ASYNCH_IO
PTHREAD_LDFLAGS += -lpthread
$(info using libpthread: $(call find_lib,pthread) $(call find_include,pthread))
else
LIBEXTSAVE := ${LIBEXT}
LIBEXT = a
ifneq (,$(call find_lib,pthread))
PTHREAD_CCDEFS += -DSIM_ASYNCH_IO
PTHREAD_LDFLAGS += -lpthread
$(info using libpthread: $(call find_lib,pthread) $(call find_include,pthread))
else
ifneq (,$(findstring Haiku,$(OSTYPE)))
PTHREAD_CCDEFS += -DUSE_READER_THREAD -DSIM_ASYNCH_IO
$(info using libpthread: $(call find_include,pthread))
else
ifeq (Darwin,$(OSTYPE))
PTHREAD_CCDEFS += -DUSE_READER_THREAD -DSIM_ASYNCH_IO
PTHREAD_LDFLAGS += -lpthread
$(info using macOS libpthread: $(call find_include,pthread))
endif
endif
endif
LIBEXT = $(LIBEXTSAVE)
endif
endif
# Find PCRE RegEx library.
ifneq (,$(call find_include,pcre))
ifneq (,$(call find_lib,pcre))
$(info using libpcre: $(call find_lib,pcre) $(call find_include,pcre))
ifneq (,$(ALL_DEPENDENCIES))
OS_CCDEFS += -DHAVE_PCRE_H
OS_LDFLAGS += -lpcre
ifeq ($(LD_SEARCH_NEEDED),$(call need_search,pcre))
OS_LDFLAGS += -L$(dir $(call find_lib,pcre))
endif
endif
else
NEEDED_PKGS += DPKG_PCRE
endif
else
NEEDED_PKGS += DPKG_PCRE
endif
# Find libedit BSD licensed library for readline support.
ifneq (,$(call find_lib,edit))
ifneq (,$(call find_include,editline/readline))
$(info using libedit: $(call find_lib,edit) $(call find_include,editline/readline))
ifneq (,$(ALL_DEPENDENCIES))
OS_CCDEFS += -DHAVE_LIBEDIT
OS_LDFLAGS += -ledit
ifneq (,$(call find_lib,termcap))
OS_LDFLAGS += -ltermcap
endif
ifeq ($(LD_SEARCH_NEEDED),$(call need_search,edit))
OS_LDFLAGS += -L$(dir $(call find_lib,edit))
endif
endif
else
NEEDED_PKGS += DPKG_EDITLINE
endif
else
NEEDED_PKGS += DPKG_EDITLINE
endif
# The recursive logic needs a GNU make at least v4 when building with
# separate compiles
ifneq (,$(call find_exe,gmake))
override MAKE = $(call find_exe,gmake)
endif
ifneq (,$(and $(findstring 3.,$(GNUMakeVERSION)),$(BUILD_SEPARATE)))
NEEDED_PKGS += DPKG_GMAKE
endif
# Find available ncurses library.
ifneq (,$(call find_include,ncurses))
ifneq (,$(call find_lib,ncurses))
OS_CURSES_DEFS += -DHAVE_NCURSES -lncurses
endif
endif
ifneq (,$(call find_include,semaphore))
ifneq (, $(shell grep sem_timedwait $(call find_include,semaphore)))
OS_CCDEFS += -DHAVE_SEMAPHORE
$(info using semaphore: $(call find_include,semaphore))
endif
endif
ifneq (,$(call find_include,sys/ioctl))
OS_CCDEFS += -DHAVE_SYS_IOCTL
endif
ifneq (,$(call find_include,linux/cdrom))
OS_CCDEFS += -DHAVE_LINUX_CDROM
endif
ifneq (,$(call find_include,dlfcn))
ifneq (,$(call find_lib,dl))
OS_CCDEFS += -DSIM_HAVE_DLOPEN=$(LIBSOEXT)
OS_LDFLAGS += -ldl
$(info using libdl: $(call find_lib,dl) $(call find_include,dlfcn))
else
ifneq (,$(findstring BSD,$(OSTYPE))$(findstring AIX,$(OSTYPE))$(findstring Haiku,$(OSTYPE)))
OS_CCDEFS += -DSIM_HAVE_DLOPEN=so
$(info using libdl: $(call find_include,dlfcn))
else
ifneq (,$(call find_lib,dld))
OS_CCDEFS += -DSIM_HAVE_DLOPEN=$(LIBSOEXT)
OS_LDFLAGS += -ldld
$(info using libdld: $(call find_lib,dld) $(call find_include,dlfcn))
else
ifeq (Darwin,$(OSTYPE))
OS_CCDEFS += -DSIM_HAVE_DLOPEN=dylib
$(info using macOS dlopen with .dylib)
endif
endif
endif
endif
endif
ifneq (,$(call find_include,utime))
OS_CCDEFS += -DHAVE_UTIME
endif
ifneq (,$(call find_include,png))
ifneq (,$(call find_lib,png))
$(info using libpng: $(call find_lib,png) $(call find_include,png))
PNG_CCDEFS += -DHAVE_LIBPNG
ifneq (,$(ALL_DEPENDENCIES))
PNG_LDFLAGS += -lpng
endif
ifneq (,$(call find_include,zlib))
ifneq (,$(call find_lib,z))
$(info using zlib: $(call find_lib,z) $(call find_include,zlib))
PNG_CCDEFS += -DHAVE_ZLIB
ifneq (,$(ALL_DEPENDENCIES))
PNG_LDFLAGS += -lz
endif
else
NEEDED_PKGS += DPKG_ZLIB
endif
else
NEEDED_PKGS += DPKG_ZLIB
endif
else
# some systems may name the png library libpng16
ifneq (,$(call find_lib,png16))
PNG_CCDEFS += -DHAVE_LIBPNG
PNG_LDFLAGS += -lpng16
$(info using libpng: $(call find_lib,png16) $(call find_include,png))
ifneq (,$(call find_include,zlib))
ifneq (,$(call find_lib,z))
PNG_CCDEFS += -DHAVE_ZLIB
PNG_LDFLAGS += -lz
$(info using zlib: $(call find_lib,z) $(call find_include,zlib))
else
NEEDED_PKGS += DPKG_ZLIB
endif
endif
else
NEEDED_PKGS += DPKG_PNG
endif
endif
else
NEEDED_PKGS += DPKG_PNG
endif
ifneq (,$(call find_include,glob))
OS_CCDEFS += -DHAVE_GLOB
else
ifneq (,$(call find_include,fnmatch))
OS_CCDEFS += -DHAVE_FNMATCH
endif
endif
ifneq (,$(call find_include,sys/mman))
ifneq (,$(shell grep shm_open $(call find_include,sys/mman)))
# some Linux installs have been known to have the include, but are
# missing librt (where the shm_ APIs are implemented on Linux)
# other OSes seem have these APIs implemented elsewhere
ifneq (,$(if $(findstring Linux,$(OSTYPE)),$(call find_lib,rt),OK))
OS_CCDEFS += -DHAVE_SHM_OPEN
$(info using mman: $(call find_include,sys/mman))
endif
endif
endif
ifneq (,$(VIDEO_USEFUL))
ifeq (cygwin,$(OSTYPE))
LIBEXTSAVE := ${LIBEXT}
LIBEXT = dll.a
endif
ifneq (,$(call find_include,SDL2/SDL))
ifneq (,$(call find_lib,SDL2))
ifneq (,$(call find_exe,sdl2-config))
SDLX_CONFIG = sdl2-config
endif
ifneq (,$(SDLX_CONFIG))
VIDEO_CCDEFS += -DHAVE_LIBSDL `$(SDLX_CONFIG) --cflags` $(PNG_CCDEFS)
VIDEO_LDFLAGS += `$(SDLX_CONFIG) --libs` $(PNG_LDFLAGS)
VIDEO_FEATURES = - video capabilities provided by libSDL2 (Simple Directmedia Layer)
DISPLAYL = ${DISPLAYD}/display.c $(DISPLAYD)/sim_ws.c
DISPLAYVT = ${DISPLAYD}/vt11.c
DISPLAY340 = ${DISPLAYD}/type340.c
DISPLAYNG = ${DISPLAYD}/ng.c
DISPLAYIII = ${DISPLAYD}/iii.c
DISPLAY_OPT += -DUSE_DISPLAY $(VIDEO_CCDEFS) -DUSE_SIM_VIDEO
$(info using libSDL2: $(call find_include,SDL2/SDL))
endif
else
NEEDED_PKGS += DPKG_SDL
endif
else
NEEDED_PKGS += DPKG_SDL
endif
ifneq (,$(BESM6_BUILD))
ifneq (,$(and $(findstring sdl2,${VIDEO_LDFLAGS}),$(call find_include,SDL2/SDL_ttf),$(call find_lib,SDL2_ttf)))
$(info using libSDL2_ttf: $(call find_lib,SDL2_ttf) $(call find_include,SDL2/SDL_ttf))
$(info ***)
VIDEO_TTF_OPT = $(VIDEO_CCDEFS) -DHAVE_LIBSDL_TTF
VIDEO_TTF_LDFLAGS += -lSDL2_ttf
VIDEO_FEATURES += with TrueType font support
# Retain support for explicitly supplying a preferred fontfile
ifneq (,$(FONTFILE))
VIDEO_TTF_OPT += -DFONTFILE=${FONTFILE}
endif
else
NEEDED_PKGS += DPKG_SDL_TTF
endif
ifneq (,$(and $(VIDEO_CCDEFS),$(PTHREAD_CCDEFS)))
VIDEO_CCDEFS += $(PTHREAD_CCDEFS)
VIDEO_LDFLAGS += $(PTHREAD_LDFLAGS)
endif
endif
endif
ifneq (,$(NETWORK_USEFUL))
ifneq (,$(call find_include,pcap))
ifneq (,$(shell grep 'pcap/pcap.h' $(call find_include,pcap) | grep include))
PCAP_H_PATH = $(dir $(call find_include,pcap))pcap/pcap.h
else
PCAP_H_PATH = $(call find_include,pcap)
endif
ifneq (,$(shell grep pcap_compile $(PCAP_H_PATH) | grep const))
BPF_CONST_STRING = -DBPF_CONST_STRING
endif
NETWORK_CCDEFS += -DHAVE_PCAP_NETWORK -I$(dir $(call find_include,pcap)) $(BPF_CONST_STRING)
NETWORK_LAN_FEATURES += PCAP
ifneq (,$(call find_lib,$(PCAPLIB)))
ifneq ($(USE_NETWORK),) # Network support specified on the GNU make command line
NETWORK_CCDEFS += -DUSE_NETWORK
ifeq (,$(findstring Linux,$(OSTYPE))$(findstring Darwin,$(OSTYPE)))
$(info *** Warning ***)
$(info *** Warning *** Directly linking against libpcap is provides no measurable)
$(info *** Warning *** benefits over dynamically linking libpcap.)
$(info *** Warning ***)
$(info *** Warning *** Support for linking this way is currently deprecated and may be removed)
$(info *** Warning *** in the future.)
$(info *** Warning ***)
else
$(info *** Error ***)
$(info *** Error *** Directly linking against libpcap is provides no measurable)
$(info *** Error *** benefits over dynamically linking libpcap.)
$(info *** Error ***)
$(info *** Error *** Support for linking directly has been removed on the $(OSTYPE))
$(info *** Error *** platform.)
$(info *** Error ***)
$(error Retry your build without specifying USE_NETWORK=1)
endif
ifeq (cygwin,$(OSTYPE))
# cygwin has no ldconfig so explicitly specify pcap object library
NETWORK_LDFLAGS = -L$(dir $(call find_lib,$(PCAPLIB))) -Wl,-R,$(dir $(call find_lib,$(PCAPLIB))) -l$(PCAPLIB)
else
NETWORK_LDFLAGS = -l$(PCAPLIB)
endif
$(info using libpcap: $(call find_lib,$(PCAPLIB)) $(call find_include,pcap))
NETWORK_FEATURES = - static networking support using $(OSNAME) provided libpcap components
else # default build uses dynamic libpcap
NETWORK_CCDEFS += -DUSE_SHARED
$(info using libpcap: $(call find_include,pcap))
NETWORK_FEATURES = - dynamic networking support using $(OSNAME) provided libpcap components
endif
else
LIBEXTSAVE := ${LIBEXT}
LIBEXT = a
ifneq (,$(call find_lib,$(PCAPLIB)))
NETWORK_CCDEFS += -DUSE_NETWORK
NETWORK_LDFLAGS := -L$(dir $(call find_lib,$(PCAPLIB))) -l$(PCAPLIB)
NETWORK_FEATURES = - static networking support using $(OSNAME) provided libpcap components
$(info using libpcap: $(call find_lib,$(PCAPLIB)) $(call find_include,pcap))
endif
LIBEXT = $(LIBEXTSAVE)
ifeq (Darwin,$(OSTYPE)$(findstring USE_,$(NETWORK_CCDEFS)))
NETWORK_CCDEFS += -DUSE_SHARED
NETWORK_FEATURES = - dynamic networking support using $(OSNAME) provided libpcap components
$(info using macOS dynamic libpcap: $(call find_include,pcap))
endif
endif
else # pcap desired but pcap.h not found
NEEDED_PKGS += DPKG_PCAP
# On non-Linux platforms, we'll still try to provide deprecated support for libpcap in /usr/local
INCPATHSAVE := ${INCPATH}
ifeq (,$(findstring Linux,$(OSTYPE)))
# Look for package built from tcpdump.org sources with default install target (or cygwin winpcap)
INCPATH += /usr/local/include
PCAP_H_FOUND = $(call find_include,pcap)
endif
ifneq (,$(strip $(PCAP_H_FOUND)))
ifneq (,$(shell grep 'pcap/pcap.h' $(call find_include,pcap) | grep include))