forked from freeciv/freeciv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
3852 lines (3609 loc) · 103 KB
/
meson.build
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
project('freeciv', ['c', 'cpp'], meson_version: '>= 0.57.0')
c_compiler = meson.get_compiler('c')
cxx_compiler = meson.get_compiler('cpp')
if c_compiler.has_argument('-Wno-nonnull-compare')
add_global_arguments('-Wno-nonnull-compare', language : 'c')
endif
add_global_arguments('-fPIC', language : 'cpp')
host_system = host_machine.system()
meta_url = 'https://meta.freeciv.org/metaserver.php'
mp_list_url = ''
storage_dir = ''
default_port = ''
proj_def = get_option('project-definition')
if proj_def != ''
fs = import('fs')
if fs.is_file(proj_def)
proj = fs.read(proj_def).strip().split('\n')
foreach item : proj
if item.startswith('META_URL')
meta_url = item.substring(9)
elif item.startswith('MODPACK_LIST_URL')
mp_list_url = item.substring(17)
elif item.startswith('FREECIV_STORAGE_DIR')
storage_dir = item.substring(20)
elif item.startswith('FREECIV_DEFAULT_PORT')
default_port = item.substring(21)
elif not item.startswith('#') and item != ''
error('Unknown parameter ' + item + ' in project definition')
endif
endforeach
else
error('Project definition file ' + proj_def + ' not found!')
endif
endif
priv_conf_data = configuration_data()
pub_conf_data = configuration_data()
liblua_conf_data = configuration_data()
pub_conf_data.set('FREECIV_META_URL', '"' + meta_url + '"')
if mp_list_url != ''
pub_conf_data.set('MODPACK_LIST_URL', '"' + mp_list_url + '"')
endif
if default_port == ''
default_port = 5556
endif
priv_conf_data.set('DEFAULT_SOCK_PORT', default_port)
pub_conf_data.set('FREECIV_AI_MOD_LAST', 3)
priv_conf_data.set('BINDIR',
join_paths(get_option('prefix'), get_option('bindir')))
priv_conf_data.set('DATADIR',
join_paths(get_option('prefix'), get_option('datadir')))
priv_conf_data.set('SYSCONFDIR',
join_paths(get_option('prefix'), get_option('sysconfdir')))
# Release cycle phases
# See fc_version about proper values for these.
priv_conf_data.set('DATASUBDIR', 'dev')
priv_conf_data.set('IS_DEVEL_VERSION', 1)
priv_conf_data.set('IS_FREEZE_VERSION', 0)
priv_conf_data.set('IS_BETA_VERSION', 0)
priv_conf_data.set('FREECIV_RELEASE_MONTH', 0)
priv_conf_data.set('NEXT_STABLE_VERSION', '"3.3.0"')
if host_machine.endian() == 'big'
priv_conf_data.set('WORDS_BIGENDIAN', 1)
endif
if get_option('debug')
priv_conf_data.set('FREECIV_DEBUG', 1)
pub_conf_data.set('FREECIV_DEBUG', 1)
add_global_arguments(
'-Werror',
language: ['c', 'cpp'])
add_global_arguments('-Wshadow', language: ['c'])
if host_system == 'windows'
# Qt headers have problems with dllimport attributes
add_global_arguments('-Wno-error=attributes', language : 'cpp')
else
add_global_arguments('-Wshadow', language: ['cpp'])
endif
else
add_global_arguments('-DQT_NO_DEBUG', language : 'cpp')
endif
if host_system == 'windows'
def_storage_dir = '~\\\\.freeciv'
else
if host_system == 'haiku'
def_storage_dir = '~/config/settings/freeciv'
else
def_storage_dir = '~/.freeciv'
endif
endif
if storage_dir == ''
storage_dir = def_storage_dir
endif
# pub conf defines a macro for FREECIV_STORAGE_DIR
# priv conf does substitution in data path macros
# They need this in different formats.
pub_conf_data.set('FREECIV_STORAGE_DIR', '"' + storage_dir + '"')
priv_conf_data.set('FREECIV_STORAGE_DIR', storage_dir)
if host_system == 'windows'
priv_conf_data.set('LOCALEDIR',
join_paths('.', get_option('datadir'), 'locale'))
priv_conf_data.set('DEFAULT_DATA_PATH',
'".;data;@FREECIV_STORAGE_DIR@/@DATASUBDIR@;@DATADIR@/freeciv"')
priv_conf_data.set('DEFAULT_SAVE_PATH',
'".;@FREECIV_STORAGE_DIR@/saves"')
priv_conf_data.set('DEFAULT_SCENARIO_PATH',
'".;data/scenarios;@FREECIV_STORAGE_DIR@/@DATASUBDIR@/scenarios;@FREECIV_STORAGE_DIR@/scenarios;@DATADIR@/freeciv/scenarios"')
else
priv_conf_data.set('LOCALEDIR',
join_paths(get_option('prefix'),
get_option('datadir'), 'locale'))
priv_conf_data.set('DEFAULT_DATA_PATH',
'".:data:@FREECIV_STORAGE_DIR@/@DATASUBDIR@:@DATADIR@/freeciv"')
priv_conf_data.set('DEFAULT_SAVE_PATH',
'".:@FREECIV_STORAGE_DIR@/saves"')
priv_conf_data.set('DEFAULT_SCENARIO_PATH',
'".:data/scenarios:@FREECIV_STORAGE_DIR@/@DATASUBDIR@/scenarios:@FREECIV_STORAGE_DIR@/scenarios:@DATADIR@/freeciv/scenarios"')
endif
if get_option('freeciv-web')
pub_conf_data.set('FREECIV_WEB', 1)
server_binary_name = 'freeciv-web'
else
pub_conf_data.set('FREECIV_DELTA_PROTOCOL', 1)
server_binary_name = 'freeciv-server'
endif
if meson.is_cross_build()
cross_inc_str = meson.get_cross_property('cross_inc_path')
cross_inc_path = [cross_inc_str]
cross_lib_path = [meson.get_cross_property('cross_lib_path')]
crosser = meson.get_cross_property('crosser')
# emscripten build is always cross-build, so check it only here
if c_compiler.compiles(
'''#ifndef __EMSCRIPTEN__
error fail
#endif''')
emscripten = true
else
emscripten = false
endif
else
cross_inc_str = ''
cross_inc_path = []
cross_lib_path = []
crosser = false
emscripten = false
endif
qtver = get_option('qtver')
# From this, at least the _WIN32_WINNT must be set before
# trying to find the functions.
if host_system == 'windows'
pub_conf_data.set('FREECIV_MSWINDOWS', 1)
pub_conf_data.set('FREECIV_HAVE_TINYCTHR', 1)
pub_conf_data.set('FREECIV_HAVE_WINSOCK', 1)
pub_conf_data.set('FREECIV_SOCKET_ZERO_NOT_STDIN', 1)
priv_conf_data.set('ALWAYS_ROOT', 1)
min_win_ver = get_option('min-win-ver')
if min_win_ver != ''
add_global_arguments('-D_WIN32_WINNT=' + min_win_ver, language: ['c', 'cpp'])
endif
if get_option('ruledit') or \
get_option('clients').contains('qt') or \
get_option('fcmp').contains('qt')
if get_option('debug')
# Qt flags have malformed macro definition triggering this error
# Also C compiler affected as the macro is on its commandline too
if c_compiler.has_argument('-Wno-c99-extensions')
add_global_arguments('-Wno-c99-extensions', language : 'c')
endif
if cxx_compiler.has_argument('-Wno-c99-extensions')
add_global_arguments('-Wno-c99-extensions', language : 'cpp')
endif
endif
if min_win_ver == ''
if qtver == 'qt6' or qtver == 'qt6x'
add_global_arguments('-D_WIN32_WINNT=0x0A00', language : ['c', 'cpp'])
else
add_global_arguments('-D_WIN32_WINNT=0x0603', language : ['c', 'cpp'])
endif
endif
elif min_win_ver == ''
add_global_arguments('-D_WIN32_WINNT=0x0603', language : ['c', 'cpp'])
endif
net_dep = c_compiler.find_library('ws2_32')
else
if get_option('min-win-ver') != ''
error('Option min-win-ver supported on Windows only!')
endif
# Assume that vsnprintf() is a working one, if it's found
# (that's checked separately)
priv_conf_data.set('HAVE_WORKING_VSNPRINTF', 1)
if host_system == 'haiku'
net_dep = c_compiler.find_library('network')
pub_conf_data.set('FREECIV_HAVE_PTHREAD', 1)
priv_conf_data.set('ALWAYS_ROOT', 1)
else
pub_conf_data.set('FREECIV_HAVE_PTHREAD', 1)
net_dep = []
endif
endif
pub_headers = [
'locale.h',
'inttypes.h',
'stdint.h',
'sys/types.h',
'unistd.h',
'sys/time.h',
'sys/socket.h',
'sys/select.h',
'netinet/in.h',
'dirent.h',
'stdbool.h',
'winsock2.h'
]
priv_headers = [
'arpa/inet.h',
'bzlib.h',
'direct.h',
'dlfcn.h',
'execinfo.h',
'fcntl.h',
'time.h',
'libgen.h',
'zstd.h',
'memory.h',
'netdb.h',
'pwd.h',
'signal.h',
'stdlib.h',
'strings.h',
'string.h',
'sys/file.h',
'sys/ioctl.h',
'sys/random.h',
'sys/signal.h',
'sys/stat.h',
'sys/termio.h',
'sys/uio.h',
'sys/utsname.h',
'sys/wait.h',
'termios.h',
'vfork.h'
]
if cross_inc_str == ''
header_arg = []
else
header_arg = '-I' + cross_inc_str
endif
foreach hdr : pub_headers
if c_compiler.has_header(hdr, args: header_arg)
pub_conf_data.set('FREECIV_HAVE_' + hdr.underscorify().to_upper(), 1)
priv_conf_data.set('HAVE_' + hdr.underscorify().to_upper(), 1)
endif
endforeach
foreach hdr : priv_headers
if c_compiler.has_header(hdr, args: header_arg)
priv_conf_data.set('HAVE_' + hdr.underscorify().to_upper(), 1)
endif
endforeach
if host_system == 'windows'
# We don't want Cygwin to find these, so checking only under "real" Windows layer
win_priv_headers= [
'bcrypt.h'
]
if c_compiler.has_header('ws2tcpip.h', args: header_arg)
net_incl = '''#include <ws2tcpip.h>'''
pub_conf_data.set('FREECIV_HAVE_WS2TCPIP_H', 1)
priv_conf_data.set('HAVE_WS2TCPIP_H', 1)
else
net_incl = ''
endif
foreach hdr : win_priv_headers
if c_compiler.has_header(hdr, args: header_arg)
priv_conf_data.set('HAVE_' + hdr.underscorify().to_upper(), 1)
endif
endforeach
else
net_incl = ''
endif
priv_functions = [
'fork',
'vfork',
'backtrace',
'bind',
'clock_gettime',
'connect',
'fdopen',
'fopen_s',
'fileno',
'flock',
'getentropy',
'gettimeofday',
'ftime',
'gethostbyname',
'getline',
'getnameinfo',
'getpwuid',
'inet_aton',
'inet_ntop',
'inet_pton',
'opendir',
'putenv',
'getcwd',
'select',
'setenv',
'snooze',
'strcasecoll',
'strcasestr',
'strcoll',
'strerror',
'stricoll',
'strstr',
'uname',
'nanosleep',
'usleep',
'vprintf',
'vsnprintf',
'_mkdir',
'_strcoll',
'_stricoll',
'fcntl',
'ioctl',
'vsnprintf',
'va_copy',
'localtime_r'
]
foreach func : priv_functions
if c_compiler.has_function(func,
dependencies: net_dep)
priv_conf_data.set('HAVE_' + func.underscorify().to_upper(), 1)
endif
endforeach
liblua_functions = [
'mkstemp',
'popen',
'pclose',
'_longjmp',
'_setjmp',
'gmtime_r',
'localtime_r',
'fseeko'
]
foreach func : liblua_functions
if c_compiler.has_function(func,
dependencies: net_dep)
liblua_conf_data.set('HAVE_' + func.underscorify().to_upper(), 1)
endif
endforeach
if c_compiler.has_header('unistd.h')
liblua_conf_data.set('FREECIV_HAVE_UNISTD_H', 1)
endif
if c_compiler.has_function('BCryptGenRandom', args: '-lbcrypt')
bcrypt_lib_dep = c_compiler.find_library('bcrypt')
priv_conf_data.set('HAVE_BCRYPTGENRANDOM', 1)
else
bcrypt_lib_dep = []
endif
if c_compiler.has_function('getaddrinfo', dependencies: net_dep)
priv_conf_data.set('HAVE_GETADDRINFO', 1)
pub_conf_data.set('FREECIV_IPV6_SUPPORT', 1)
else
# Maybe it exist as a macro instead?
if c_compiler.compiles(net_incl + '''
int main(void) { getaddrinfo(NULL, NULL, NULL, NULL); }''',
include_directories: include_directories(cross_inc_path))
priv_conf_data.set('HAVE_GETADDRINFO', 1)
pub_conf_data.set('FREECIV_IPV6_SUPPORT', 1)
else
warning('IPv6 support not enabled')
endif
endif
if c_compiler.has_header('libcharset.h', args: header_arg)
if c_compiler.has_function('locale_charset')
priv_conf_data.set('HAVE_LIBCHARSET', 1)
charset_dep = []
else
charset_dep = c_compiler.find_library('charset', dirs: cross_lib_path,
required: false)
if charset_dep.found() and c_compiler.has_function('locale_charset', dependencies: charset_dep)
priv_conf_data.set('HAVE_LIBCHARSET', 1)
else
charset_dep = []
endif
endif
else
charset_dep = []
endif
rl_req = get_option('readline')
if rl_req != 'false'
readline_dep = c_compiler.find_library('readline', dirs: cross_lib_path,
required:false)
if readline_dep.found() and c_compiler.has_function('rl_completion_suppress_append',
dependencies: readline_dep)
pub_conf_data.set('FREECIV_HAVE_LIBREADLINE', 1)
elif rl_req == 'true'
error('Readline support requested but not found.')
endif
else
readline_dep = []
endif
if c_compiler.has_header('lzma.h', args: header_arg)
priv_conf_data.set('HAVE_LZMA_H', 1)
lzma_dep = c_compiler.find_library('lzma', dirs: cross_lib_path,
required:false)
if lzma_dep.found()
pub_conf_data.set('FREECIV_HAVE_LIBLZMA', 1)
endif
else
lzma_dep = []
endif
zstd_dep = c_compiler.find_library('zstd', dirs: cross_lib_path,
required:false)
if zstd_dep.found()
pub_conf_data.set('FREECIV_HAVE_LIBZSTD', 1)
endif
mw_req = get_option('mwand')
if mw_req != 'false'
mw_dep = dependency('MagickWand', version : '>= 7.0', required : false)
if mw_dep.found()
pub_conf_data.set('FREECIV_MWAND7', '1')
else
mw_dep = dependency('MagickWand', version : '>= 6.0', required : false)
endif
if mw_dep.found()
priv_conf_data.set('HAVE_MAPIMG_MAGICKWAND', '1')
elif mw_req == 'true'
error('MagickWand support requested but not found.')
endif
else
mw_dep = []
endif
if c_compiler.compiles('''
#include <stddef>
int main(void) { int *var = nullptr; return 0; }''',
include_directories: include_directories(cross_inc_path))
pub_conf_data.set('FREECIV_HAVE_C23_NULLPTR', 1)
endif
if cxx_compiler.compiles('''
#include <cstddef>
int main(void) { int *var = nullptr; return 0; }''',
include_directories: include_directories(cross_inc_path))
pub_conf_data.set('FREECIV_HAVE_CXX_NULLPTR', 1)
endif
if emscripten
icu_dep = []
syslua = 'false'
emscripten_use_args = [
'-s', 'USE_ICU=1',
'-s', 'USE_ZLIB=1',
'-s', 'USE_PTHREADS=1'
]
add_global_arguments(
emscripten_use_args,
language : [ 'c', 'cpp'])
add_global_link_arguments(
emscripten_use_args,
'-s', 'TOTAL_MEMORY=64MB',
language : [ 'c', 'cpp'])
else
priv_conf_data.set('HAVE_FCDB', 1)
priv_conf_data.set('HAVE_FCDB_SQLITE3', 1)
icu_dep = dependency('icu-uc')
syslua = get_option('syslua')
lua_dep_tmp = dependency('lua-5.4', required:false)
endif
if syslua != 'false' and lua_dep_tmp.found()
lua_inc_path = []
lua_sources = []
lua_dep = lua_dep_tmp
elif syslua == 'true'
error('Syslua requested but not found.')
else
lua_inc_path = 'dependencies/lua-5.4/src'
lua_sources = [
'dependencies/lua-5.4/src/lapi.c',
'dependencies/lua-5.4/src/lauxlib.c',
'dependencies/lua-5.4/src/lbaselib.c',
'dependencies/lua-5.4/src/lcode.c',
'dependencies/lua-5.4/src/lcorolib.c',
'dependencies/lua-5.4/src/lctype.c',
'dependencies/lua-5.4/src/ldblib.c',
'dependencies/lua-5.4/src/ldebug.c',
'dependencies/lua-5.4/src/ldo.c',
'dependencies/lua-5.4/src/ldump.c',
'dependencies/lua-5.4/src/lfunc.c',
'dependencies/lua-5.4/src/lgc.c',
'dependencies/lua-5.4/src/linit.c',
'dependencies/lua-5.4/src/liolib.c',
'dependencies/lua-5.4/src/llex.c',
'dependencies/lua-5.4/src/lmathlib.c',
'dependencies/lua-5.4/src/lmem.c',
'dependencies/lua-5.4/src/loadlib.c',
'dependencies/lua-5.4/src/lobject.c',
'dependencies/lua-5.4/src/lopcodes.c',
'dependencies/lua-5.4/src/loslib.c',
'dependencies/lua-5.4/src/lparser.c',
'dependencies/lua-5.4/src/lstate.c',
'dependencies/lua-5.4/src/lstring.c',
'dependencies/lua-5.4/src/lstrlib.c',
'dependencies/lua-5.4/src/ltable.c',
'dependencies/lua-5.4/src/ltablib.c',
'dependencies/lua-5.4/src/ltm.c',
'dependencies/lua-5.4/src/lundump.c',
'dependencies/lua-5.4/src/lutf8lib.c',
'dependencies/lua-5.4/src/lvm.c',
'dependencies/lua-5.4/src/lzio.c',
]
lua_dep = dependency('', required:false)
endif
if c_compiler.compiles('''#include <netinet/in.h>
int main(void) { struct ip_mreqn req; req.imr_ifindex = 0; return 0; }''',
include_directories: include_directories(cross_inc_path))
priv_conf_data.set('HAVE_IP_MREQN', 1)
endif
if c_compiler.has_function('iconv', args: header_arg)
priv_conf_data.set('HAVE_ICONV', 1)
iconv_lib_dep = []
elif c_compiler.has_header_symbol('iconv.h', 'iconv', args: header_arg)
iconv_lib_dep = c_compiler.find_library('iconv', dirs: cross_lib_path,
required: false)
if iconv_lib_dep.found()
priv_conf_data.set('HAVE_ICONV', 1)
endif
else
iconv_lib_dep = []
endif
if c_compiler.compiles('''#include <stddef.h>
#include <iconv.h>
int main(void) { iconv_t cd; const char **c; iconv(cd, c, NULL, NULL); return 0; }''',
include_directories: include_directories(cross_inc_path))
priv_conf_data.set('ICONV_CONST', 'const')
else
priv_conf_data.set('ICONV_CONST', '')
endif
if get_option('cacert-path') != ''
priv_conf_data.set('CUSTOM_CACERT_PATH',
'"' + get_option('cacert-path') + '"')
endif
potential_size_t_formats = [ '%zu', '%ld', '%lld', '%I64d', '%I32d' ]
foreach format : potential_size_t_formats
if c_compiler.compiles('''#include <stdio.h>
#if defined(__GNUC__)
void fr(const char *form, ...)
__attribute__((__format__(__printf__, 1, 2)));
#else
#define fr(_a_,_b_) printf(_a_,_b_)
#endif
int main(void) { size_t var = 0; fr("''' + format + '''", var); return 0; }''',
include_directories: include_directories(cross_inc_path),
args: ['-Werror', '-Wall'])
priv_conf_data.set('SIZE_T_PRINTF', '"' + format + '"')
break
endif
endforeach
if get_option('audio') or get_option('clients').contains('sdl2')
if host_system == 'windows'
sdl2main_dep = [c_compiler.find_library('mingw32', dirs: cross_lib_path),
c_compiler.find_library('SDL2main', dirs: cross_lib_path),
c_compiler.find_library('SDL2', dirs: cross_lib_path)]
else
if emscripten
emscripten_sdl2_args = [
'-s', 'USE_SDL=2'
]
if get_option('audio')
emscripten_sdl2_args += [ '-s', 'USE_SDL_MIXER=2' ]
endif
if get_option('clients').contains('sdl2')
emscripten_sdl2_args += [
'-s', 'USE_SDL_IMAGE=2',
'-s', 'USE_SDL_TTF=2',
'-s', 'USE_SDL_GFX=2'
]
endif
add_global_arguments(emscripten_sdl2_args, language: ['c', 'cpp'])
add_global_link_arguments(emscripten_sdl2_args, language: ['c', 'cpp'])
sdl2main_dep = []
else
sdl2main_dep = [c_compiler.find_library('SDL2', dirs: cross_lib_path)]
endif
endif
endif
if qtver == 'qt5'
add_global_arguments('-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00', language : 'cpp')
priv_conf_data.set('FC_QT5_MODE', 1)
qt_opts = []
elif qtver == 'qt6x'
add_global_arguments('-DQT_DISABLE_DEPRECATED_BEFORE=0x060300', language : 'cpp')
qt_opts = 'cpp_std=c++17'
else
add_global_arguments('-DQT_DISABLE_DEPRECATED_BEFORE=0x060000', language : 'cpp')
qt_opts = 'cpp_std=c++17'
endif
if get_option('audio')
priv_conf_data.set('AUDIO_SDL', 1)
if emscripten
audio_dep = []
else
audio_sdl2_dep = c_compiler.find_library('SDL2_mixer',
dirs: cross_lib_path)
audio_dep = [sdl2main_dep, audio_sdl2_dep]
endif
audio_sdl_src = 'client/audio_sdl.c'
else
audio_dep = []
audio_sdl_src = []
endif
if get_option('json-protocol')
if not c_compiler.has_header('jansson.h')
error('json-protocol requires jansson.h header, but it is not found')
endif
pub_conf_data.set('FREECIV_JSON_CONNECTION', 1)
jansson_dep = c_compiler.find_library('jansson')
else
jansson_dep = []
endif
nls_req = get_option('nls')
if c_compiler.has_header('libintl.h', args: header_arg)
pub_conf_data.set('FREECIV_HAVE_LIBINTL_H', 1)
priv_conf_data.set('HAVE_LIBINTL_H', 1)
elif nls_req
error('nls support requested, but libintl.h header not found')
endif
if nls_req
pub_conf_data.set('FREECIV_ENABLE_NLS', 1)
priv_conf_data.set('ENABLE_NLS', 1)
gettext_dep = c_compiler.find_library('intl', dirs: cross_lib_path,
required: false)
else
gettext_dep = []
endif
if emscripten
sqlite3_dep = []
sqlite3_src = []
curl_dep = []
m_dep = []
else
sqlite3_dep = c_compiler.find_library('sqlite3', dirs: cross_lib_path)
sqlite3_src = [
'dependencies/luasql/src/luasql.c',
'dependencies/luasql/src/ls_sqlite3.c',
]
curl_dep = c_compiler.find_library('curl', dirs: cross_lib_path)
m_dep = c_compiler.find_library('m', dirs: cross_lib_path)
endif
if not emscripten
if c_compiler.compiles(net_incl + '''
#include <stddef.h>
#include <curl/curl.h>
int main(void) { curl_mime *mime = curl_mime_init(NULL); }''',
include_directories: include_directories(cross_inc_path)
)
priv_conf_data.set('HAVE_CURL_MIME_API', 1)
else
error('Too old libcurl version - does not support mime API')
endif
endif
if get_option('gitrev')
priv_conf_data.set('GITREV', 1)
endif
if crosser
pub_conf_data.set('FREECIV_CROSSER', 1)
endif
if cxx_compiler.compiles('''
class me {
void top(); };
void me::top() { [=, this]() {}; };
''',
name: 'C++20 capture this',
args: ['-Werror', '-Wall'])
pub_conf_data.set('FREECIV_HAVE_CXX20_CAPTURE_THIS', 1)
endif
configure_file(input : 'gen_headers/meson_fc_config.h.in',
output : 'fc_config.h',
configuration: priv_conf_data)
configure_file(input : 'gen_headers/meson_freeciv_config.h.in',
output : 'freeciv_config.h',
configuration: pub_conf_data)
configure_file(input : 'gen_headers/meson_liblua_config.h.in',
output : 'liblua_config.h',
configuration: liblua_conf_data)
add_global_arguments('-DHAVE_CONFIG_H',
language: ['c', 'cpp'])
if get_option('nls')
subdir('translations/core')
subdir('translations/nations')
subdir('translations/ruledit')
endif
gen_packets_args = get_option('gen-packets-args')
python_exe = find_program('python3')
sh_exe = find_program('sh')
common_inc = include_directories(cross_inc_path,
lua_inc_path, 'dependencies/luasql/src', 'dependencies/tinycthread',
'dependencies/tolua-5.2/include', 'dependencies/cvercmp',
'utility', 'common', 'common/networking', 'common/scriptcore',
'common/aicore')
server_inc = [common_inc, include_directories('server', 'server/advisors',
'server/scripting', 'server/generator', 'server/savegame',
'ai', 'ai/classic')]
client_inc = [common_inc, include_directories('client', 'client/include',
'client/luascript', 'client/agents')]
tool_inc = [server_inc, include_directories('tools/ruleutil', 'tools/shared')]
runwrap = custom_target('runwrap', output: 'run.sh',
command: [sh_exe, files('bootstrap/generate_meson_run.sh'), '@OUTPUT@'],
depend_files: files('bootstrap/generate_meson_run.sh'),
build_by_default: true)
verhdr = custom_target('verhdr', output: 'version_gen.h',
command: [sh_exe, files('gen_headers/generate_version_header.sh'), '@OUTPUT@'],
depend_files: files('fc_version'))
ls_core = custom_target('langstat_core', output: 'langstat_core.txt',
command: [sh_exe, files('bootstrap/generate_langstat.sh'), 'core',
meson.project_source_root(), meson.project_build_root()])
ls_nations = custom_target('langstat_nations', output: 'langstat_nations.txt',
command: [sh_exe, files('bootstrap/generate_langstat.sh'), 'nations',
meson.project_source_root(), meson.project_build_root()])
ls_ruledit = custom_target('langstat_ruledit', output: 'langstat_ruledit.txt',
command: [sh_exe, files('bootstrap/generate_langstat.sh'), 'ruledit',
meson.project_source_root(), meson.project_build_root()])
specenum = custom_target('specenum_gen.h', output: 'specenum_gen.h',
command: [python_exe, files('utility/generate_specenum.py'),
'@OUTPUT@'])
pack_common = custom_target('packets_common',
input: files('common/networking/packets.def'),
output: ['packets_gen.h', 'packets_gen.c'],
command: [python_exe, files('common/generate_packets.py'),
'@INPUT@',
'--common-h', '@OUTPUT0@',
'--common-c', '@OUTPUT1@'] + gen_packets_args,
depend_files: files('common/generate_packets.py'))
pack_server = custom_target('packets_server',
input: files('common/networking/packets.def'),
output: ['hand_gen.h', 'hand_gen.c'],
command: [python_exe, files('common/generate_packets.py'),
'@INPUT@',
'--server-h', '@OUTPUT0@',
'--server-c', '@OUTPUT1@'] + gen_packets_args,
depend_files: files('common/generate_packets.py'))
pack_client = custom_target('packets_client',
input: files('common/networking/packets.def'),
output: ['packhand_gen.h', 'packhand_gen.c'],
command: [python_exe, files('common/generate_packets.py'),
'@INPUT@',
'--client-h', '@OUTPUT0@',
'--client-c', '@OUTPUT1@'] + gen_packets_args,
depend_files: files('common/generate_packets.py'))
gitrev = custom_target('gitrev', output: 'fc_gitrev_gen.h',
command: [sh_exe, files('bootstrap/generate_gitrev.sh'),
meson.project_source_root(), '@OUTPUT@'],
build_by_default: get_option('gitrev'))
if host_system == 'windows'
tinycthr_files = files('dependencies/tinycthread/fc_tinycthread.c')
else
tinycthr_files = files()
endif
fc_deps = static_library('fc_dependencies',
'dependencies/cvercmp/cvercmp.c',
lua_sources,
'dependencies/tolua-5.2/src/lib/tolua_event.c',
'dependencies/tolua-5.2/src/lib/tolua_is.c',
'dependencies/tolua-5.2/src/lib/tolua_map.c',
'dependencies/tolua-5.2/src/lib/tolua_push.c',
'dependencies/tolua-5.2/src/lib/tolua_to.c',
sqlite3_src, tinycthr_files,
sources: [verhdr],
include_directories : common_inc,
dependencies: lua_dep
)
if meson.is_cross_build() or get_option('sys-tolua-cmd')
tolua_cmd = find_program('tolua')
else
tolua_cmd = executable('tolua',
'dependencies/tolua-5.2/src/bin/tolua.c',
'dependencies/tolua-5.2/src/bin/toluabind.c',
include_directories : ['dependencies/lua-5.4/src',
'dependencies/tolua-5.2/include'],
link_with: fc_deps,
dependencies: m_dep
)
endif
tolua = generator(tolua_cmd,
arguments: ['-n', '@BASENAME@',
'-o', '@BUILD_DIR@/@BASENAME@_gen.c',
'-H', '@BUILD_DIR@/@BASENAME@_gen.h',
'@INPUT@'],
output: [ '@BASENAME@_gen.c', '@BASENAME@_gen.h'])
tolua_com_a = custom_target('tolua_custom_a',
output: ['tolua_common_a_gen.c',
'tolua_common_a_gen.h'],
command: [tolua_cmd, '-n', 'common_a',
'-o', '@OUTPUT0@',
'-H', '@OUTPUT1@',
files('common/scriptcore/tolua_common_a.pkg')])
tolua_com_z = custom_target('tolua_custom_z',
output: ['tolua_common_z_gen.c',
'tolua_common_z_gen.h'],
command: [tolua_cmd, '-n', 'common_z',
'-o', '@OUTPUT0@',
'-H', '@OUTPUT1@',
files('common/scriptcore/tolua_common_z.pkg')])
tolua_game = custom_target('tolua_game',
output: ['tolua_game_gen.c',
'tolua_game_gen.h'],
command: [tolua_cmd, '-n', 'game',
'-o', '@OUTPUT0@',
'-H', '@OUTPUT1@',
files('common/scriptcore/tolua_game.pkg')])
tolua_signal = custom_target('tolua_signal',
output: ['tolua_signal_gen.c',
'tolua_signal_gen.h'],
command: [tolua_cmd, '-n', 'signal',
'-o', '@OUTPUT0@',
'-H', '@OUTPUT1@',
files('common/scriptcore/tolua_signal.pkg')])
if host_system == 'windows'
windres_cmd = find_program('x86_64-w64-mingw32-windres', 'windres')
windres = generator(windres_cmd,
arguments: ['-I', '@SRC_DIR@/windows',
'-i', '@INPUT@',
'-o', '@OUTPUT@'],
output: '@[email protected]')
clienticon = windres.process('windows/clienticon.rc')
mpicon = windres.process('windows/mpicon.rc')
rulediticon = windres.process('windows/rulediticon.rc')
servericon = windres.process('windows/servericon.rc')
else
clienticon = []
mpicon = []
rulediticon = []
servericon = []
endif
common_lib = library('freeciv',
'utility/astring.c',
'utility/bitvector.c',
'utility/bugs.c',
'utility/capability.c',
'utility/deprecations.c',
'utility/distribute.c',
'utility/fcbacktrace.c',
'utility/fc_cmdhelp.c',
'utility/fc_cmdline.c',
'utility/fc_dirent.c',
'utility/fciconv.c',
'utility/fcintl.c',
'utility/fcthread.c',
'utility/fc_utf8.c',
'utility/genhash.c',
'utility/genlist.c',
'utility/inputfile.c',
'utility/ioz.c',
'utility/iterator.c',
'utility/log.c',
'utility/md5.c',
'utility/mem.c',
'utility/netfile.c',
'utility/netintf.c',
'utility/rand.c',
'utility/randseed.c',
'utility/registry.c',
'utility/registry_ini.c',
'utility/registry_xml.c',
'utility/section_file.c',
'utility/shared.c',
'utility/string_vector.c',
'utility/support.c',
'utility/timing.c',
'common/aicore/aiactions.c',
'common/aicore/aisupport.c',
'common/aicore/caravan.c',
'common/aicore/citymap.c',
'common/aicore/cm.c',
'common/aicore/path_finding.c',
'common/aicore/pf_tools.c',
'common/networking/connection.c',
'common/networking/dataio_json.c',
'common/networking/dataio_raw.c',
'common/networking/packets.c',
'common/networking/packets_json.c',
'common/scriptcore/api_common_intl.c',
'common/scriptcore/api_common_utilities.c',
'common/scriptcore/api_game_effects.c',
'common/scriptcore/api_game_find.c',
'common/scriptcore/api_game_methods.c',
'common/scriptcore/api_game_specenum.c',
'common/scriptcore/api_signal_base.c',
'common/scriptcore/api_specenum.c',
'common/scriptcore/luascript.c',
'common/scriptcore/luascript_func.c',
'common/scriptcore/luascript_signal.c',