Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
1195 lines (1063 loc) · 35 KB
/
Copy pathMakefile
File metadata and controls
1195 lines (1063 loc) · 35 KB
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
#!/usr/bin/env make
#
# rogomatic - Rog-O-Matic XIV
#
# The following Copyright ONLY applies to this Makefile and README.md files.
#
# Copyright (c) 2025-2026 by Landon Curt Noll. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby granted,
# provided that the above copyright, this permission notice and text
# this comment, and the disclaimer below appear in all of the following:
#
# supporting documentation
# source copies
# source works derived from this source
# binaries derived from this source or from derived source
#
# LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
# EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
# chongo (Landon Curt Noll) /\oo/\
#
# http://www.isthe.com/chongo/index.html
# https://github.com/lcn2
#
# Share and enjoy! :-)
#############
# utilities #
#############
CAT= cat
CC= cc
CHGRP= chgrp
CHMOD= chmod
CLANG_FORMAT= clang-format
CMP= cmp
CODESIGN= codesign
COLCRT= colcrt
CP= cp
CTAGS= ctags
GREP= grep
GROFF= groff
ID= id
INSTALL= install
MAKEDEPEND= makedepend
MKDIR= mkdir
MV= mv
NROFF= nroff
RM= rm
RMDIR= rmdir
SED= sed
SHELL= bash
SORT= sort
TBL= tbl
TOUCH= touch
TRUE= true
#################
# configuration #
#################
PREFIX= /usr/local
BINDIR= ${PREFIX}/bin
SHAREDIR= ${PREFIX}/share
DESTDOC= ${SHAREDIR}/rogomatic
ORIG_DESTDOC= ${DESTDOC}/ORIG_DOC
MANDIR= ${PREFIX}/man
MAN6DIR= ${MANDIR}/man6
# RGMDIR - rogomatic directory
#
# NOTE: RGMDIR will contain logs of Rogomatic's
# scores, an error.log file, and the long term memory file.
# It must be writable by everyone, since score files must be
# created and destroyed by anyone running the program.
#
TMPDIR= /var/tmp
RGMDIR= ${TMPDIR}/rogomatic
# ROGUE - default location of the rogue game
#
# See: https://github.com/lcn2/rogue5.4
#
ROGUE= /usr/local/bin/rogue
# GOODGAME - level at which we always save the gamelog file
#
# NOTE: The -G goodlvl command line option may change the level value.
#
GOODGAME= 23
# USLEEP - Set the default sleep time between actions to USLEEP microseconds
#
# NOTE: The -U usec command line option may change the level value.
#
USLEEP= 14000
# PLUNGE_LVL - Starting level in which we plunge down immediately when we can
#
# NOTE: The plunge mode stops at level 26 because that is where the
# Amulet of Yendor is found. DO NOT set PLUNGE larger than 25!
#
# See the plunge() function in tactics.c.
#
# NOTE: Historically PLUNGE_LVL was 18 and was a constant in an if statement:
#
# if (Level > 17 && Level < 26 && godownstairs (NOTRUNNING)) {
#
# By using a lower value, we start to plunge earlier. We might nit
# obtain as much gold, but we increase the chance we survive to
# find the Amulet of Yendor.
#
PLUNGE_LVL= 13
#####################
# debug information #
#####################
# V=@: do not echo debug statements (quiet mode)
# V=@ echo debug statements (debug / verbose mode)
#
V=@:
#V=@
# Q=@ do not echo internal Makefile actions (quiet mode)
# Q= echo internal Makefile actions (debug / verbose mode)
#
#Q=
Q=@
# S= >/dev/null 2>&1 silence ${CC} output during hsrc file formation
# S= full ${CC} output during hsrc file formation
#
S= >/dev/null 2>&1
#S=
# H=@: do not report hsrc file formation progress
# H=@ echo hsrc file formation progress
#
#H=@:
H=@
############################
# how to build and install #
############################
CSTD= -std=gnu17
CCWARN=
target=$(shell uname -s 2>/dev/null)
ifeq ($(target),NetBSD)
# The NetBSD maintainers don't define permission bits S_IRUSR et al. in <sys/stat.h>, so NetBSD needs to:
# -D_XOPEN_SOURCE=800 enable permission bits S_IRUSR et al.
# While other systems enable strlcpy, strlcat via <string.h>, NetBSD doesn't, so NetBSD needs to:
# -D_NETBSD_SOURCE enable strlcpy, strlcat
CPPFLAGS= -D_XOPEN_SOURCE=800 -D_NETBSD_SOURCE
else
CPPFLAGS=
endif
COPT= -O3
DEBUG= -ggdb3
CFLAGS= ${CSTD} ${CCWARN} ${CPPFLAGS} ${COPT} ${DEBUG}
LDFLAGS= ${DEBUG}
LC_CTYPE= C
AT= @
# The NetBSD maintainers insist in using curses instead of ncurses.
# NetBSD uses their own curses: a hybrid of BSD curses and X/Open curses.
# There are known incompatibles between NetBSD curses and what the next of the
# world calls ncurses. See https://wiki.netbsd.org/curses_in_netbsd/
# where not only does the NetBSD maintainers admit to being one of the
# last operating systems (or even the last one?) not using ncurses, and
# where they indicate what is different with ncurses. One should also
# read: https://www.invisible-island.net/ncurses/ncurses-netbsd.html
# for more info. Well if you use NetBSD, we hope the NetBSD curses
# works for you.
#
# Alternatively NetBSD users can install the ncurses package for
# NetBSD: https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc/devel/ncurses/README.html
#
ifeq ($(target),NetBSD)
# Ncurses package installed or use old curses.h?
LIBS!=if test -f /usr/pkg/include/ncurses/ncurses.h; then echo '-lncurses'; else echo '-lcurses'; fi
ifeq ($(LIBS),-lncurses)
CPPFLAGS+=-I/usr/pkg/include -I/usr/pkg/include/ncurses
LDFLAGS+=-L/usr/pkg/lib
endif
else
LIBS= -lncurses
endif
OTHER_TARGES= titlepage
# targets and local files no longer supported
#
# These files were renamed, so the old name is now obsolete.
#
OBSOLETE_TARGETS= kill_player kill_player.sh run-rogo run-rogo.sh rerun-rogo rerun-rogo.sh
TARGETS= rogomatic player rgmplot histplot gene run_rogo rerun_rogo unstuck_player end_player mrerun_rogo mstop_rogo
################################
# source and destination files #
################################
# we build these .h files during the make
#
BUILD_H_SRC= modern_curses.h have_strlcpy.h have_strlcat.h
H_SRC= config.h getroguetoken.h globals.h install.h strl.h termtokens.h types.h
OBJS= arms.o command.o config.o database.o debug.o debuglog.o explore.o fork_exec.o \
getroguetoken.o io.o learn.o ltm.o main.o mess.o monsters.o pack.o \
rand.o replay.o rooms.o terminal.o scorefile.o search.o stats.o strategy.o strl.o \
survival.o tactics.o things.o timer.o titlepage.o utility.o worth.o
CFILES= arms.c command.c config.c database.c debug.c debuglog.c explore.c fork_exec.c \
getroguetoken.c io.c learn.c ltm.c main.c mess.c monsters.c pack.c \
rand.c replay.c rooms.c terminal.c scorefile.c search.c stats.c strategy.c strl.c \
survival.c tactics.c things.c timer.c titlepage.c utility.c worth.c
MISC_C= setup.c histplot.c rgmplot.c gene.c
C_SRC= ${CFILES} ${MISC_C}
SRC= ${C_SRC} ${H_SRC} ${BUILD_H_SRC}
SH_SRC= run_rogo.sh rerun_rogo.sh unstuck_player.sh end_player.sh mrerun_rogo.sh
SH_TOOL= run_rogo
MISC_OBJS= gene.o histplot.o rgmplot.o setup.o
OTHERS= rplot rgmhist rgmscatter
DOC_SRC= rogomatic.6.in rogomatic.cat.in
# These original documentation files install under the ${ORIG_DESTDOC} directory.
#
ORIG_DOC= ORIG_DOC/amulet.photo ORIG_DOC/Bugreport ORIG_DOC/copyright \
ORIG_DOC/knowledge ORIG_DOC/README.0 ORIG_DOC/rnotes ORIG_DOC/rogo.mss \
ORIG_DOC/rogomatic.man ORIG_DOC/rogtitle.mss ORIG_DOC/rogue.commands \
ORIG_DOC/strike.mss ORIG_DOC/terminfo.vt100 ORIG_DOC/title.ani \
ORIG_DOC/title.start ORIG_DOC/titlepage.ani
# These documentation files install under the ${DESTDOC} directory.
#
MISC_DOC= CODE_OF_CONDUCT.md CONTRIBUTING.md COPYING LICENSE README.md SECURITY.md
# File used by macOS to codesign for debugging
#
DEBUG_ENTITLEMENTS= debug.entitlements
MAKE_FILE= Makefile
###################################
# Common Address Sanitizer (ASAN) #
###################################
# Common Address Sanitizer (ASAN)
#
# For more info see: https://github.com/google/sanitizers/wiki/AddressSanitizer
# See also: https://developer.apple.com/documentation/xcode/diagnosing-memory-thread-and-crash-issues-early
# And also: https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
#
# The following Address Sanitizer (ASAN) are common to both RHEL 10.2 (Linux) and macOS 26.5.1.
#
# By default, the Address Sanitizer is NOT enabled.
#
FSANITIZE:= -Wno-invalid-command-line-argument
FSANITIZE+= -fno-common
FSANITIZE+= -fno-omit-frame-pointer
FSANITIZE+= -fsanitize=address
FSANITIZE+= -fsanitize=alignment
FSANITIZE+= -fsanitize=bool
FSANITIZE+= -fsanitize=bounds
FSANITIZE+= -fsanitize=enum
FSANITIZE+= -fsanitize=float-cast-overflow
FSANITIZE+= -fsanitize=float-divide-by-zero
FSANITIZE+= -fsanitize=integer-divide-by-zero
FSANITIZE+= -fsanitize=nonnull-attribute
FSANITIZE+= -fsanitize=null
FSANITIZE+= -fsanitize=object-size
FSANITIZE+= -fsanitize=returns-nonnull-attribute
FSANITIZE+= -fsanitize=shift
FSANITIZE+= -fsanitize=signed-integer-overflow
FSANITIZE+= -fsanitize=undefined
FSANITIZE+= -fsanitize=unreachable
FSANITIZE+= -fsanitize=vla-bound
FSANITIZE+= -fsanitize=vptr
# Address Sanitizer (ASAN) options for macOS
#
MACOS_FSANITIZE+= -fsanitize=nullability-arg
MACOS_FSANITIZE+= -fsanitize=nullability-assign
MACOS_FSANITIZE+= -fsanitize=nullability-return
MACOS_FSANITIZE+= -fstack-protector-all
# Address Sanitizer (ASAN) options for Linux
#
LINUX_FSANITIZE+= -fstack-protector-all
# Guess at Address Sanitizer (ASAN) options for non-macOS non-Linux
#
OTHER_FSANITIZE+= -fstack-protector-all
####
# macOS Address Sanitizer (ASAN)
#
# This comment block was tested under:
#
# macOS 27.0 with Apple clang version 21.0.0 (clang-2100.3.34.2)
#
# See: https://developer.apple.com/documentation/xcode/diagnosing-memory-thread-and-crash-issues-early
#
# To use the Address Sanitizer, uncomment this set set of lines and recompile (make clobber all):
#
# For more info see: https://github.com/google/sanitizers/wiki/AddressSanitizer
#
# And also: https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
#
# For Homebrew gcc version 16 only:
#
# CC:= gcc-16
# DEBUG:= -g2
#
# For Apple clang and Homebrew gcc:
#
# CCWARN+= -Wall
# CCWARN+= -pedantic
# CCWARN+= -Werror
# COPT:= -O0
#
# For Apple clang only:
#
# FSANITIZE+= -fsanitize=nullability-arg
# FSANITIZE+= -fsanitize=nullability-assign
# FSANITIZE+= -fsanitize=nullability-return
#
# CFLAGS+= ${FSANITIZE} -fstack-protector-all
# LDFLAGS+= ${FSANITIZE}
# DEBUG:= -ggdb3
####
####
# RHEL (Linux) Address Sanitizer (ASAN)
#
# This comment block was tested under:
#
# RHEL 10.2 with clang version 21.1.8 (Red Hat, Inc. 21.1.8-1.el10)
#
# with these RPMs installed:
#
# libasan-14.3.1-4.4.el10.x86_64
# libubsan-14.3.1-4.4.el10.x86_64
#
# To use the Address Sanitizer, uncomment this set set of lines and recompile (make clobber all):
#
# For more info see: https://github.com/google/sanitizers/wiki/AddressSanitizer
#
# And also: https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
#
# Be sure you have the following dnf packages installed:
#
# dnf install readline-devel ncurses-libs ncurses-devel libasan libubsan
#
# CCWARN+= -Wall
# CCWARN+= -pedantic
# CCWARN+= -Werror
# COPT:= -O0
#
# CFLAGS+= ${FSANITIZE} -fstack-protector-all
# LDFLAGS+= ${FSANITIZE}
# DEBUG:= -ggdb3
####
######################################
# all - default rule - must be first #
######################################
all: ${BUILD_H_SRC} ${TARGETS} rogomatic.6
#####################################
# object files with special defines #
#####################################
config.o: config.c
${CC} ${CFLAGS} -DUSLEEP=${USLEEP} -DGOODGAME=${GOODGAME} -DRGMDIR='"${RGMDIR}"' $< -c
setup.o: setup.c
${CC} ${CFLAGS} -DUSLEEP=${USLEEP} -DGOODGAME=${GOODGAME} -DROGUE='"${ROGUE}"' -DRGMDIR='"${RGMDIR}"' $< -c
strategy.o: strategy.c
${CC} ${CFLAGS} -DPLUNGE_LVL=${PLUNGE_LVL} $< -c
tactics.o: tactics.c
${CC} ${CFLAGS} -DPLUNGE_LVL=${PLUNGE_LVL} $< -c
terminal.o: terminal.c
${CC} ${CFLAGS} -DRGMDIR='"${RGMDIR}"' $< -c
utility.o: utility.c
${CC} ${CFLAGS} -DRGMDIR='"${RGMDIR}"' $< -c
########################
# default object files #
########################
.c.o:
${CC} ${CFLAGS} -c $*.c
##################
# tools to build #
##################
gene: gene.o rand.o learn.o stats.o timer.o utility.o config.o strl.o terminal.o
${CC} ${CFLAGS} ${LDFLAGS} gene.o rand.o learn.o stats.o timer.o utility.o config.o strl.o terminal.o -lm ${LIBS} -o $@
histplot: histplot.o timer.o utility.o strl.o config.o terminal.o
${CC} ${LDFLAGS} histplot.o timer.o utility.o strl.o config.o terminal.o ${LIBS} -o $@
player: ${OBJS}
${CC} ${LDFLAGS} ${OBJS} -lm ${LIBS} -o $@
ifeq ($(target),Darwin)
${CODESIGN} -s - -f --entitlements ${DEBUG_ENTITLEMENTS} $@
endif
rgmplot: rgmplot.o timer.o utility.o strl.o config.o terminal.o
${CC} ${LDFLAGS} rgmplot.o timer.o utility.o strl.o config.o terminal.o ${LIBS} -o $@
rogomatic: setup.o scorefile.o timer.o utility.o config.o strl.o terminal.o fork_exec.o
${CC} ${LDFLAGS} setup.o scorefile.o timer.o utility.o config.o strl.o terminal.o fork_exec.o ${LIBS} -o $@
ifeq ($(target),Darwin)
${CODESIGN} -s - -f --entitlements ${DEBUG_ENTITLEMENTS} $@
endif
run_rogo: run_rogo.sh
${CP} -f run_rogo.sh $@
${CHMOD} +x $@
rerun_rogo: rerun_rogo.sh
${CP} -f rerun_rogo.sh $@
${CHMOD} +x $@
mrerun_rogo: mrerun_rogo.sh
${CP} -f mrerun_rogo.sh $@
${CHMOD} +x $@
unstuck_player: unstuck_player.sh
${CP} -f unstuck_player.sh $@
${CHMOD} +x $@
end_player: end_player.sh
${CP} -f end_player.sh $@
${CHMOD} +x $@
mstop_rogo: mstop_rogo.sh
${CP} -f mstop_rogo.sh $@
${CHMOD} +x $@
##################################################
# other targets that are not automatically built #
##################################################
# NOTE: This rule is NOT part of the build of rogomatic documentation!
# We use this rule to form the rogomatic.cat.in file from the rogomatic.6.in file.
#
form_rogomatic_cat_in: rogomatic.6.in
${RM} -f rogomatic.cat.in
${GROFF} -Tascii -man rogomatic.6.in | LC_CTYPE=C ${SED} -e 's/.\x08//g' > rogomatic.cat.in
# reformat primary (non-built) source using clang-format
#
clang-format: .clang-format ${C_SRC} ${H_SRC}
${CLANG_FORMAT} -i --style=file:.clang-format ${C_SRC} ${H_SRC}
# try to compile all with gcc, full warnings, no optimizer, no ASAN
#
# NOTE: Consider doing a "make clobber" first, especially when switching from a previous "make all", "make clang", etc.
#
# NOTE: On some systems with clang installed (i.e., macOS / Darwin), the clang package installs a gcc executable that
# acts like a front end translating gcc args into clang args. In such cases, gcc is just clang,
# and so if we "make gcc" in that case, the final result is really just did "make clang": not what we want.
# If someone has called "make gcc", we presume that their intention is to use gcc, not clang.
# Where clang is primary, and gcc is just an arg front end to clang, it is possible to install gcc
# as a separate package. On such true dual compiler systems, where gcc has been explicitly installed
# as a separate compiler, a gcc-digits binary is also installed; "digits" is the major version of gcc.
#
# For macOS (Darwin) systems, if someone invokes "make gcc", we avoid the mistake of using the gcc
# front end to clang by mistake. Thus, on macOS, for "make gcc" to work properly and compile with
# the gcc compiler, we will require that the system have explicitly installed gcc, and to invoke it
# in the gcc-digits binary form. Nevertheless, we realize that this ties the "make gcc" rule for
# such systems to an explicit major version of gcc. And there are GOOD REASONS to do this:
#
# The sad state of the gcc debugger, gdb, is such that it has become, in our opinion,
# a second-rate debugger. We won't go into much detail here other than to say that it
# is "not fun" to try to debug with gdb, a binary that uses ncurses (or curses) to control the
# terminal (e.g., rogue), and it is "not fun" to debug with gdb, a binary that will "fork/exec"
# something (e.g., rogomatic).
#
# The gcc compiler release process is described by some as "mood swings", with significant
# and sometimes non-trivial changes to behaviour. Therefore, we tie the "make gcc" make rule
# to an explicit major version of gcc, and ONLY update the "make gcc" rule when we have
# fully tested the result under the next major version of gcc.
#
# Remember that the reason why we have "make gcc" (and "make clang") is to compile in such a way as to
# make debugging more effective. If you do not intend to compile for debugging purposes, just use "make all"
# and explicitly set the compiler you want:
#
# make all CC='/path/to/cc'
#
# What should you do if you don't like the way "make gcc" operates? We recommend just using "make all"
# with explicit make variable settings on the command line. For example, say you are on a macOS (Darwin)
# system where "make gcc" calls gcc-16 and you want to instead call gcc-17, then try:
#
# make all CC='gcc-17' CCWARN='-Wall -pedantic -Werror' COPT='-O0' DEBUG='-g2'
#
# Or say you are on some other system where both clang and gcc are installed, and that the gcc executable
# isn't a clang front end (be SURE this is the case, and that due to the order you installed clang and gcc,
# or due to your $PATH value that gcc isn't just an arg converting front end for clang!). Then try:
#
# make all CC='/path/to/gcc' CCWARN='-Wall -pedantic -Werror' COPT='-O0' DEBUG='-g2'
#
# So where does all these comments leave us?
#
# The "make gcc" rule is intended for debugging, and we do NOT recommend debugging code with gdb.
# So these may not be the compiler droids you are looking for. :-)
#
# The Darwin target value of CC in "make gcc" below is the current major version of gcc that
# we have attempted to support. You are on your own if you wish to use a different major version.
#
# See the above comments for make line workarounds if you need them.
#
gcc:
ifeq ($(target),Darwin)
${MAKE} -f ${MAKE_FILE} all CC='gcc-16' CCWARN='-Wall -pedantic -Werror' COPT='-O0' DEBUG='-g2'
else
${MAKE} -f ${MAKE_FILE} all CC='gcc' CCWARN='-Wall -pedantic -Werror' COPT='-O0' DEBUG='-ggdb3'
endif
# compile all with clang, full warnings, no optimizer, no ASAN
#
# NOTE: Consider doing a "make clobber" first, especially when switching from a previous "make all", "make gcc", etc.
#
clang:
${MAKE} -f ${MAKE_FILE} all CC='clang' CCWARN='-Wall -Wno-char-subscripts -pedantic -Werror' COPT='-O0' DEBUG='-ggdb3'
# compile all with Address Sanitizer (ASAN) enabled
#
# If macOS (Darwin), set Address Sanitizer (ASAN) values for compiling and linking.
# See the "macOS Address Sanitizer (ASAN)" section above for details.
#
# If Linux, set Address Sanitizer (ASAN) values for compiling and linking.
# See the "RHEL (Linux) Address Sanitizer (ASAN)" section above for details.
#
# On all non-macOS non-Linux environments, make a best guess on (ASAN) values for compiling and linking.
#
# NOTE: Consider doing a "make clobber" first, especially when switching from a previous "make all", "make clang", etc.
#
# Suggestion:
#
# make clobber asan
# rm -f asan.log.* ; ASAN_OPTIONS="log_path=asan.log" ./rogomatic ; reset ; cat asan.log.*
#
asan:
ifeq ($(target),Darwin)
${MAKE} -f ${MAKE_FILE} all CC='clang' CCWARN='-Wall -Wno-char-subscripts -pedantic -Werror' COPT='-O0' \
DEBUG='-ggdb3 ${FSANITIZE} ${MACOS_FSANITIZE}'
else
ifeq ($(target),Linux)
${MAKE} -f ${MAKE_FILE} all CC='gcc' CCWARN='-Wall -Wno-char-subscripts -pedantic -Werror' COPT='-O0' \
DEBUG='-ggdb3 ${FSANITIZE} ${LINUX_FSANITIZE}'
else
${MAKE} -f ${MAKE_FILE} all CC='gcc' CCWARN='-Wall -Wno-char-subscripts -pedantic -Werror' COPT='-O0' \
DEBUG='-ggdb3 ${FSANITIZE} ${OTHER_FSANITIZE}'
endif
endif
# titlepage - test the title page
#
titlepage: titlepage.c
${CC} titlepage.c -DTITLEPAGE_MAIN ${LIBS} -o titlepage
#####################
# constricted files #
#####################
hsrc: ${BUILD_H_SRC}
# NOTE: The modern_curses.h file doesn't need these make variables, we simply test them here as a convenience.
#
modern_curses.h: ${MAKE_FILE}
${Q} ${RM} -f modern_curses.o modern_curses $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@
${Q} echo ' */' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#if !defined(INCLUDE_MODERN_CURSES_H)' >> $@
${Q} echo '#define INCLUDE_MODERN_CURSES_H' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '/* do have modern new curses ? */' >> $@
-${Q} if echo '#include <ncurses.h>' | ${CC} -E ${CPPFLAGS} - ${S}; then \
echo '#include <ncurses.h> /* yes, using new curses */' >> $@; \
echo >> $@; \
echo '#define MODERN_CURSES NEW_CURSES' >> $@; \
elif echo '#include <curses.h>' | ${CC} -E ${CPPFLAGS} - ${S}; then \
echo '#include <curses.h> /* no, you have old curses, or what NetBSD calls curses */' >> $@; \
echo >> $@; \
echo '#define MODERN_CURSES OLD_CURSES' >> $@; \
else \
echo 'Neither <ncurses.h> nor <curses.h> found' 1>&2; \
echo 'Perhaps you need you install both ncurses and ncurses-devel ?' 1>&2; \
exit 1; \
fi
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#endif' >> $@
${H} echo '$@ formed'
-${Q}if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= start of $@ =-=-='; \
${CAT} $@; \
echo '=-=-= end of $@ =-=-='; \
echo ''; \
else \
${TRUE}; \
fi
have_strlcpy.h: have_strlcpy.c ${MAKE_FILE}
${Q} ${RM} -f unused_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@
${Q} echo ' */' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#if !defined(INCLUDE_STRLCPY_H)' >> $@
${Q} echo '#define INCLUDE_STRLCPY_H' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '/* do we have the strlcpy() function? */' >> $@
${Q} ${RM} -f have_strlcpy.o have_strlcpy
-${Q} ${CC} have_strlcpy.c -c ${S} \
|| ${TRUE}
-${Q} ${CC} have_strlcpy.o -o have_strlcpy ${S} \
|| ${TRUE}
-${Q} ./have_strlcpy > unused_tmp ${E} \
|| ${TRUE}
-${Q} if [ -s unused_tmp ]; then \
${CAT} unused_tmp >> $@; \
else \
echo '#undef INCLUDE_STRLCPY /* no - use code from strl.c */' \
>> $@; \
fi
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#endif' >> $@
${Q} ${RM} -f have_strlcpy have_strlcpy.o unused_tmp
${H} echo '$@ formed'
-${Q}if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= start of $@ =-=-='; \
${CAT} $@; \
echo '=-=-= end of $@ =-=-='; \
echo ''; \
else \
${TRUE}; \
fi
have_strlcat.h: have_strlcat.c ${MAKE_FILE}
${Q} ${RM} -f unused_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@
${Q} echo ' */' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#if !defined(INCLUDE_STRLCAT_H)' >> $@
${Q} echo '#define INCLUDE_STRLCAT_H' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '/* do we have the strlcat() function? */' >> $@
${Q} ${RM} -f have_strlcat.o have_strlcat
-${Q} ${CC} have_strlcat.c -c ${S} \
|| ${TRUE}
-${Q} ${CC} have_strlcat.o -o have_strlcat ${S} \
|| ${TRUE}
-${Q} ./have_strlcat > unused_tmp ${E} \
|| ${TRUE}
-${Q} if [ -s unused_tmp ]; then \
${CAT} unused_tmp >> $@; \
else \
echo '#undef INCLUDE_STRLCAT /* no - use code from strl.c */' \
>> $@; \
fi
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#endif' >> $@
${Q} ${RM} -f have_strlcat have_strlcat.o unused_tmp
${H} echo '$@ formed'
-${Q}if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= start of $@ =-=-='; \
${CAT} $@; \
echo '=-=-= end of $@ =-=-='; \
echo ''; \
else \
${TRUE}; \
fi
################################
# form rogomatic documentation #
################################
stddocs: rogomatic.6 rogomatic.cat
rogomatic.6: rogomatic.6.in
${RM} -f $@
LC_CTYPE=C ${SED} -e 's;${AT}RGMDIR${AT};${RGMDIR};' \
-e 's;${AT}BINDIR${AT};${BINDIR};' \
-e 's;${AT}GOODGAME${AT};${GOODGAME};' \
-e 's;${AT}USLEEP${AT};${USLEEP};' \
rogomatic.6.in > rogomatic.6
rogomatic.cat: rogomatic.6 rogomatic.cat.in
${RM} -f $@
@-if test "x${GROFF}" != "x" -a "x${SED}" != "x" ; then \
echo "${GROFF} -Tascii -man rogomatic.6 | LC_CTYPE=C ${SED} -e 's/.\x08//g' > $@" ; \
${GROFF} -Tascii -man rogomatic.6 | LC_CTYPE=C ${SED} -e 's/.\x08//g' > $@ ; \
elif test "x${NROFF}" != "x" -a "x${TBL}" != "x" -a "x${COLCRT}" != "x" ; then \
echo "${NROFF} -man rogomatic.6 | ${COLCRT} - > $@" ; \
${NROFF} -man rogomatic.6 | ${COLCRT} - > $@ ; \
else \
echo "LC_CTYPE=C ${SED} \
-e 's;${AT}RGMDIR${AT};${RGMDIR};' \
-e 's;${AT}BINDIR${AT};${BINDIR};' \
-e 's;${AT}GOODGAME${AT};${GOODGAME};' \
-e 's;${AT}USLEEP${AT};${USLEEP};' \
rogomatic.cat.in > $@" ; \
LC_CTYPE=C ${SED} \
-e 's;${AT}RGMDIR${AT};${RGMDIR};' \
-e 's;${AT}BINDIR${AT};${BINDIR};' \
-e 's;${AT}GOODGAME${AT};${GOODGAME};' \
-e 's;${AT}USLEEP${AT};${USLEEP};' \
rogomatic.cat.in > $@ ; \
fi
#################################################
# .PHONY list of rules that do not create files #
#################################################
.PHONY: all stddocs clean clobber install \
backup clashes dist fluff print titler words \
index depend
###################################
# standard Makefile utility rules #
###################################
legacy_clean:
${Q}${RM} -f datesub.o tf.o findscore.o
legacy_clobber:
${Q}${RM} -f datesub datesub.l tf
clean: legacy_clean
${RM} -f ${MISC_OBJS}
${RM} -f ${OBJS}
clobber: legacy_clobber clean
${RM} -f tags index rogomatic.6 rogomatic.cat
${RM} -f ${OTHER_TARGES}
${RM} -f ${TARGETS}
${RM} -f ${BUILD_H_SRC}
${RM} -rf *.dSYM
-@for i in ${OBSOLETE_TARGETS}; do \
if [[ -e $$i ]]; then \
echo "${RM} -f $$i" ; \
${RM} -f "$$i" ; \
fi; \
done
install: all ${MISC_DOC} ${ORIG_DOC} stddocs
${INSTALL} -d -m 0755 ${BINDIR}
${INSTALL} -m 0755 ${TARGETS} ${BINDIR}
ifeq ($(target),Darwin)
${CODESIGN} -s - -f --entitlements ${DEBUG_ENTITLEMENTS} ${BINDIR}/rogomatic ${BINDIR}/player
endif
${INSTALL} -d -m 1777 ${TMPDIR}
${INSTALL} -d -m 1777 ${RGMDIR}
${INSTALL} -d -m 0755 ${SHAREDIR}
${INSTALL} -d -m 0755 ${DESTDOC}
${INSTALL} -m 0444 ${MISC_DOC} ${DESTDOC}
${INSTALL} -d -m 0755 ${ORIG_DESTDOC}
${INSTALL} -m 0444 ${ORIG_DOC} ${ORIG_DESTDOC}
${INSTALL} -d -m 0755 ${MANDIR}
${INSTALL} -d -m 0755 ${MAN6DIR}
${INSTALL} -m 0444 rogomatic.6 ${MAN6DIR}
-@for i in ${OBSOLETE_TARGETS} run_rogo.sh; do \
if [[ -e ${BINDIR}/$$i ]]; then \
echo "removing obsolete: ${BINDIR}/$$i" ; \
${RM} -f -v "${BINDIR}/$$i" ; \
fi; \
done
uninstall:
-@for i in ${TARGETS}; do \
echo "${RM} -f -v ${BINDIR}/$$i"; \
${RM} -f -v ${BINDIR}/$$i; \
done
-@for i in ${MISC_DOC} ${ORIG_DOC}; do \
echo "${RM} -f -v ${DESTDOC}/$$i"; \
${RM} -f -v ${DESTDOC}/$$i; \
done
-${RM} -f -v ${MAN6DIR}/rogomatic.6
-@if [[ -d "${RGMDIR}" ]]; then \
echo "${RMDIR} ${RGMDIR} 2>/dev/null"; \
${RMDIR} ${RGMDIR} 2>/dev/null; \
fi
-@if [[ -d "${RGMDIR}" ]]; then \
echo "You may wish to: rm -rf ${RGMDIR}"; \
fi
-@if [[ -d "${ORIG_DESTDOC}" ]]; then \
echo "${RMDIR} ${ORIG_DESTDOC} 2>/dev/null"; \
${RMDIR} ${ORIG_DESTDOC} 2>/dev/null; \
fi
-@if [[ -d "${ORIG_DESTDOC}" ]]; then \
echo "You may wish to: rm -rf ${ORIG_DESTDOC}"; \
fi
-@if [[ -d "${DESTDOC}" ]]; then \
echo "${RMDIR} ${DESTDOC} 2>/dev/null"; \
${RMDIR} ${DESTDOC} 2>/dev/null; \
fi
-@if [[ -d "${DESTDOC}" ]]; then \
echo "You may wish to: rm -rf ${DESTDOC}"; \
fi
-@for i in ${OBSOLETE_TARGETS} run_rogo.sh; do \
if [[ -e ${BINDIR}/$$i ]]; then \
echo "removing obsolete: ${BINDIR}/$$i" ; \
${RM} -f -v "${BINDIR}/$$i" ; \
fi; \
done
index: ${CFILES}
${RM} -f index
${CTAGS} -x ${C_SRC} > index
tags: ${SRC}
${CTAGS} -w ${SRC}
###############################
# easy backward compatibility #
###############################
# These rules were referenced in the makefile of 2022 Nov 17
#
# We no longer support these rules.
#
# We provide these stub rules for backward compatibility.
backup:
@echo dist rule disabled, use the GitHub repo: https://github.com/lcn2/rogomatic
clashes:
@echo $@ disabled
dist:
@echo dist rule disabled, use the GitHub repo: https://github.com/lcn2/rogomatic
fluff:
@echo $@ disabled
print:
@echo $@ disabled
titler:
@echo $@ disabled
words:
@echo $@ disabled
####################
# dependency rules #
####################
###
#
# Home grown make dependency rules. Your system may not support
# or have the needed tools. You can ignore this section.
#
# We will form a skeleton tree of *.c files containing only #include "foo.h"
# lines and .h files containing the same lines surrounded by multiple include
# prevention lines. This allows us to build a static depend list that will
# satisfy all possible cpp symbol definition combinations.
#
###
depend: ${SRC}
${Q} if [ -f ${MAKE_FILE}.bak ]; then \
echo "${MAKE_FILE}.bak exists, remove or move it"; \
exit 1; \
else \
${TRUE}; \
fi
${Q} if type -f ${MAKEDEPEND}; then \
${TRUE}; \
else \
echo "make depend failed: cannot find makedepend command: ${MAKEDEPEND}" 1>&2; \
exit 1; \
fi
${Q} ${RM} -rf skel
${Q} ${MKDIR} -p skel
-${Q} for i in ${C_SRC}; do \
${SED} -n '/^#[ ]*include[ ]*"/p' "$$i" > "skel/$$i"; \
done
${Q} ${MKDIR} -p skel/custom
-${Q} for i in ${H_SRC} ${BUILD_H_SRC} /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
echo "#if !defined($$tag)" > "skel/$$i"; \
echo "#define $$tag" >> "skel/$$i"; \
${SED} -n '/^#[ ]*include[ ]*"/p' "$$i" | \
LANG=C ${SORT} -u >> "skel/$$i"; \
echo '#endif /* '"$$tag"' */' >> "skel/$$i"; \
fi; \
done
${Q} ${RM} -f skel/makedep.out
${Q} echo top level skel formed
${Q} echo forming dependency list
${Q} :> skel/makedep.out
${Q} cd skel; ${MAKEDEPEND} \
-w 1 -f makedep.out -- \
${CFLAGS} -- \
${SRC} 2>/dev/null
-${Q} for i in ${C_SRC} /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
echo "$$i" | ${SED} 's/^\(.*\)\.c/\1.o: \1.c/'; \
fi; \
done >> skel/makedep.out
${Q} LANG=C ${SORT} -u skel/makedep.out -o skel/makedep.out
${Q} echo dependency list formed
${Q} echo forming new ${MAKE_FILE}
${Q} ${RM} -f ${MAKE_FILE}.bak
${Q} ${MV} ${MAKE_FILE} ${MAKE_FILE}.bak
${Q} ${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' \
${MAKE_FILE}.bak > ${MAKE_FILE}
${Q} ${GREP} -E -v '^#' skel/makedep.out >> ${MAKE_FILE}
${Q} echo removing top level skel
${Q} ${RM} -rf skel
-${Q} if ${CMP} -s ${MAKE_FILE}.bak ${MAKE_FILE}; then \
echo 'top level ${MAKE_FILE} was already up to date'; \
echo 'restoring original ${MAKE_FILE}'; \
${MV} -f ${MAKE_FILE}.bak ${MAKE_FILE}; \
else \
echo 'old ${MAKE_FILE} is now ${MAKE_FILE}.bak'; \
echo 'new top level ${MAKE_FILE} formed'; \
echo 'try: diff -u ${MAKE_FILE}.bak ${MAKE_FILE}'; \
fi
###
#
# make depend stuff
#
###
# DO NOT DELETE THIS LINE -- make depend depends on it.
arms.o: arms.c