-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
1745 lines (1535 loc) · 58.9 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
#!/usr/bin/env make
#
# mkiocccentry and related tools - how to form an IOCCC submission
#
# For the mkiocccentry utility:
#
# Copyright (c) 2021-2025 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, http://www.isthe.com/chongo/index.html) /\oo/\
#
# Share and enjoy! :-)
####
####
# See also, the following files for additional Copyright information:
#
# iocccsize.c iocccsize.h soup/rule_count.c dbg/* dyn_alloc/*
####
#############
# utilities #
#############
# suggestion: List utility filenames, not paths.
# Do not list shell builtin (echo, cd, ...) tools.
# Keep the list in alphabetical order.
#
AWK= awk
CC= cc
CMP= cmp
CTAGS= ctags
DIFF= diff
GIT= git
GREP= grep
INDEPEND= independ
INSTALL= install
IS_AVAILABLE= soup/is_available.sh
MV= mv
PICKY= picky
RM= rm
RMDIR= rmdir
RSYNC= rsync
SED= sed
SEQCEXIT= seqcexit
SHELL= bash
SHELLCHECK= shellcheck
SLEEP= sleep
SORT= sort
TEE= tee
TR= tr
####################
# Makefile control #
####################
# The name of this directory
#
# This value is used to print the generic name of this directory
# so that various echo statements below can use this name
# to help distinguish themselves from echo statements used
# by Makefiles in other directories.
#
OUR_NAME= mkiocccentry
# echo-only action commands
# V= @: do not echo debug statements (quiet mode)
# V= @ echo debug statements (debug / verbose mode)
#
V= @:
#V= @
# S= @: do not echo start or end of a make rule (quiet mode)
# S= @ echo start or end of a make rule (debug / verbose mode)
#
#S= @:
S= @
# action commands that are NOT echo
# Q= @ do not echo internal Makefile actions (quiet mode)
# Q= echo internal Makefile actions (debug / verbose mode)
#
#Q=
Q= @
# E= @ do not echo calling make in another directory (quiet mode)
# E= echo calling make in another directory (debug / verbose mode)
#
E=
#E= @
# I= @ do not echo install commands (quiet mode)
# I= echo install commands (debug / verbose mode
#
I=
#I= @
# other Makefile control related actions
# Q= implies -v 0
# else -v 1
#
ifeq ($(strip ${Q}),@)
Q_V_OPTION="0"
else
Q_V_OPTION="1"
endif
# installing variables
#
# INSTALL_V= install w/o -v flag (quiet mode)
# INSTALL_V= -v install with -v (debug / verbose mode
#
#INSTALL_V=
INSTALL_V=
# where to install
#
# Default PREFIX is /usr/local so binaries would be installed in /usr/local/bin,
# libraries in /usr/local/lib etc. If one wishes to override this, say
# installing to /usr, they can do so like:
#
# make PREFIX=/usr install
#
PREFIX= /usr/local
# uninstalling variables
#
# RM_V= rm w/o -v flag (quiet mode)
# RM_V= -v rm with -v (debug / verbose mode)
#
#RM_V= -v
RM_V=
# Additional controls
#
# MAKE_CD_Q= --no-print-directory silence make cd messages (quiet mode)
# MAKE_CD_Q= silence make cd messages (quiet mode)
#
MAKE_CD_Q= --no-print-directory
#MAKE_CD_Q=
# Disable parallel Makefile execution
#
# We do not support parallel make. We have found most
# parallel make systems do not get the rule dependency order
# correct, resulting in a failed attempt to compile.
#
.NOTPARALLEL:
##################
# How to compile #
##################
# C source standards being used
#
# This repo supports c17 and later.
#
# NOTE: at one point we used -std=gnu11 because there were a few older systems
# in late 2021 that did not have compilers that (yet) supported gnu17.
# While there may be even more out of date systems that do not support
# gnu11, we have to draw the line somewhere. Besides, one of those systems
# reaches its EOL on 30 June 2024 and that's three days away at this
# point.
#
# --------------------------------------------------
#
# ^^ the line is above :-)
#
#C_STD= -std=gnu11
C_STD= -std=gnu17
# optimization and debug level
#
C_OPT= -O3 -g3
#C_OPT= -O0 -g
# Compiler warnings
#
WARN_FLAGS= -Wall -Wextra -Wno-char-subscripts
#WARN_FLAGS= -Wall -Wextra -Werror
# special compiler flags
#
C_SPECIAL= -DINTERNAL_INCLUDE
# linker options
#
LDFLAGS=
# where to find libdbg.a and libdyn_array.a
#
# LD_DIR - locations of libdbg.a and libdyn_array.a for the next sub-directory down
# LD_DIR2 - locations of libdbg.a and libdyn_array.a for 2 sub-directories down
#
LD_DIR= -L../dbg -L../dyn_array
LD_DIR2= -L../../dbg -L../../dyn_array
# how to compile
#
# We test by forcing warnings to be errors so you don't have to (allegedly :-) )
#
CFLAGS= ${C_STD} ${C_OPT} -pedantic ${WARN_FLAGS} ${C_SPECIAL} ${LDFLAGS}
###############
# source code #
###############
# source files that are permanent (not made, nor removed)
#
C_SRC= mkiocccentry.c iocccsize.c txzchk.c chkentry.c
H_SRC= chkentry.h mkiocccentry.h txzchk.h
# source files that do not conform to strict picky standards
#
LESS_PICKY_CSRC=
LESS_PICKY_HSRC=
# all shell scripts
#
SH_FILES= bug_report.sh
# all man pages that NOT built and NOT removed by make clobber
#
MAN1_PAGES=
MAN3_PAGES=
MAN8_PAGES=
ALL_MAN_PAGES= ${MAN1_PAGES} ${MAN3_PAGES} ${MAN8_PAGES}
######################
# intermediate files #
######################
# tags for just the files in this directory
#
LOCAL_DIR_TAGS= .local.dir.tags
# NOTE: intermediate files to make and removed by make clean
#
BUILT_C_SRC=
BUILT_H_SRC=
ALL_BUILT_SRC= ${BUILT_C_SRC} ${BUILT_H_SRC}
# NOTE: ${LIB_OBJS} are objects to put into a library and removed by make clean
#
LIB_OBJS=
# NOTE: ${OTHER_OBJS} are objects NOT put into a library and ARE removed by make clean
#
OTHER_OBJS= mkiocccentry.o iocccsize.o txzchk.o chkentry.o
# all intermediate files which are also removed by make clean
#
ALL_OBJS= ${LIB_OBJS} ${OTHER_OBJS}
# all source files
#
ALL_CSRC= ${C_SRC} ${LESS_PICKY_CSRC} ${BUILT_C_SRC}
ALL_HSRC= ${H_SRC} ${LESS_PICKY_HSRC} ${BUILT_H_SRC}
ALL_SRC= ${ALL_CSRC} ${ALL_HSRC} ${SH_FILES}
# all man pages that built and removed by make clobber
#
MAN1_BUILT=
MAN3_BUILT=
MAN8_BUILT=
ALL_MAN_BUILT= ${MAN1_BUILT} ${MAN3_BUILT} ${MAN8_BUILT}
#######################
# install information #
#######################
# where to install
#
MAN1_DIR= ${PREFIX}/share/man/man1
MAN3_DIR= ${PREFIX}/share/man/man3
MAN8_DIR= ${PREFIX}/share/man/man8
DEST_INCLUDE= ${PREFIX}/include
DEST_LIB= ${PREFIX}/lib
DEST_DIR= ${PREFIX}/bin
#################################
# external Makefile information #
#################################
# may be used outside of this directory
#
EXTERN_H=
EXTERN_O=
EXTERN_MAN=
EXTERN_LIBA=
EXTERN_PROG= bug_report.sh chkentry iocccsize mkiocccentry txzchk
# NOTE: ${EXTERN_CLOBBER} used outside of this directory and removed by make clobber
#
EXTERN_CLOBBER= ${EXTERN_O} ${EXTERN_LIBA} ${EXTERN_PROG}
######################
# target information #
######################
# man pages
#
MAN1_TARGETS= ${MAN1_PAGES} ${MAN1_BUILT}
MAN3_TARGETS= ${MAN3_PAGES} ${MAN3_BUILT}
MAN8_TARGETS= ${MAN8_PAGES} ${MAN8_BUILT}
ALL_MAN_TARGETS= ${MAN1_TARGETS} ${MAN3_TARGETS} ${MAN8_TARGETS}
# shell targets to make by all and removed by clobber
#
SH_TARGETS=
# program targets to make by all, installed by install, and removed by clobber
#
PROG_TARGETS= mkiocccentry iocccsize txzchk chkentry
# directories sometimes build under macOS and removed by clobber
#
DSYMDIRS= mkiocccentry.dSYM iocccsize.dSYM txzchk.dSYM chkentry.dSYM
# logs for testing
#
TMP_BUILD_LOG= ".build.log.$$$$"
BUILD_LOG= build.log
ALL_SUBDIRS= all_dbg all_dyn_array all_jparse all_jparse_test all_man all_soup all_test_ioccc
# what to make by all but NOT to removed by clobber
#
ALL_OTHER_TARGETS= ${SH_TARGETS} ${ALL_SUBDIRS} ${ALL_MAN_PAGES} build_man
# what to make by all, what to install, and removed by clobber (and thus not ${ALL_OTHER_TARGETS})
#
TARGETS= ${PROG_TARGETS} ${ALL_MAN_BUILT}
############################################################
# User specific configurations - override Makefile values #
############################################################
# The directive below retrieves any user specific configurations from Makefile.local.
#
# The - before include means it's not an error if the file does not exist.
#
# We put this directive just before the first all rule so that you may override
# or modify any of the above Makefile variables. To override a value, use := symbols.
# For example:
#
# CC:= gcc
#
-include Makefile.local
######################################
# all - default rule - must be first #
######################################
all: fast_hostchk just_all
@:
# The original make all that bypasses running hostchk.sh
#
just_all: ${ALL_SUBDIRS} ${TARGETS} build_man
# fast build environment sanity check
#
fast_hostchk: test_ioccc/hostchk.sh
-${Q} ./test_ioccc/hostchk.sh -f -v 0 -Z .; \
EXIT_CODE="$$?"; \
if [ "$$EXIT_CODE" -ne 0 ]; then \
${MAKE} hostchk_warning C_SPECIAL="${C_SPECIAL}"; \
fi
bug_report: bug_report.sh
-${Q} ./bug_report.sh -v 1
bug_report-tx: bug_report.sh
${S} echo "${OUR_NAME}: make $@: starting test of bug_report.sh -t -x"
${S} echo
${Q} ./bug_report.sh -t -x
${S} echo
${S} echo "${OUR_NAME}: ending test of bug_report.sh -t -x"
bug_report-txl: bug_report.sh
${S} echo "${OUR_NAME}: make $@: starting test of bug_report.sh -t -x -l"
${Q} ./bug_report.sh -t -x -l
${S} echo "${OUR_NAME}: ending test of bug_report.sh -t -x -l"
# slower more verbose build environment sanity check
#
hostchk: test_ioccc/hostchk.sh
-${Q} ./test_ioccc/hostchk.sh -v 1 -Z .; \
EXIT_CODE="$$?"; \
if [ "$$EXIT_CODE" -ne 0 ]; then \
${MAKE} hostchk_warning C_SPECIAL="${C_SPECIAL}"; \
fi
# get the users attention when hostchk.sh finds a problem
#
hostchk_warning:
@echo 1>&2
@echo '=-= WARNING WARNING WARNING =-=' 1>&2
@echo '=-= hostchk exited non-zero =-=' 1>&2
@echo 1>&2
@echo '=-= WARNING WARNING WARNING =-=' 1>&2
@echo '=-= your build environment may not be able to compile =-=' 1>&2
@echo '=-= mkiocccentry and friends =-=' 1>&2
@echo 1>&2
@echo '=-= WARNING WARNING WARNING =-=' 1>&2
@echo '=-= For hints as to what might be wrong try running:' 1>&2
@echo 1>&2
@echo ' ./test_ioccc/hostchk.sh -v 1' 1>&2
@echo 1>&2
@echo '=-= WARNING WARNING WARNING =-=' 1>&2
@echo '=-= If you think this is a bug, consider filing a bug report via:' 1>&2
@echo 1>&2
@echo ' ./bug_report.sh' 1>&2
@echo 1>&2
@echo '=-= about to sleep 10 seconds =-=' 1>&2
@echo 1>&2
${SLEEP} 10
@echo '=-= Letting the compile continue in hopes it might be OK, =-=' 1>&2
@echo '=-= even though we doubt it will be OK. =-=' 1>&2
@echo 1>&2
#################################################
# .PHONY list of rules that do not create files #
#################################################
.PHONY: all just_all fast_hostchk hostchk hostchk_warning all_sem_ref all_sem_ref_ptch bug_report build \
check_man clean clean_generated_obj clean_mkchk_sem clobber configure depend hostchk \
install uninstall test_ioccc legacy_clobber mkchk_sem parser parser-o picky prep soup \
pull release seqcexit shellcheck tags local_dir_tags all_tags test test-chkentry use_json_ref \
eat eating eat eating_soup kitchen soup_kitchen bug_report-txl \
build release pull reset_min_timestamp load_json_ref build_man bug_report-tx \
all_dbg all_dyn_array all_jparse all_jparse_test all_man all_soup all_test_ioccc depend
####################################
# things to make in this directory #
####################################
mkiocccentry.o: mkiocccentry.c
${CC} ${CFLAGS} mkiocccentry.c -c
mkiocccentry: mkiocccentry.o soup/soup.a jparse/libjparse.a dyn_array/libdyn_array.a dbg/libdbg.a
${CC} ${CFLAGS} $^ -lm -o $@
iocccsize.o: iocccsize.c
${CC} ${CFLAGS} -DMKIOCCCENTRY_USE iocccsize.c -c
iocccsize: iocccsize.o soup/soup.a dbg/libdbg.a
${CC} ${CFLAGS} $^ -o $@
txzchk.o: txzchk.c
${CC} ${CFLAGS} txzchk.c -c
txzchk: txzchk.o soup/soup.a jparse/libjparse.a dyn_array/libdyn_array.a dbg/libdbg.a
${CC} ${CFLAGS} $^ -o $@
chkentry.o: chkentry.c
${CC} ${CFLAGS} chkentry.c -c
chkentry: chkentry.o soup/soup.a jparse/libjparse.a dyn_array/libdyn_array.a dbg/libdbg.a
${CC} ${CFLAGS} $^ -lm -o $@
#########################################################
# rules that invoke Makefile rules in other directories #
#########################################################
all_dbg: dbg/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C dbg all C_SPECIAL="${C_SPECIAL}"
all_dyn_array: dyn_array/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C dyn_array all C_SPECIAL="${C_SPECIAL}"
all_jparse: jparse/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C jparse all C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
all_jparse_test: jparse/test_jparse/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C jparse/test_jparse all C_SPECIAL="${C_SPECIAL}" \
LD_DIR2="${LD_DIR2}"
soup: soup/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C soup soup C_SPECIAL="${C_SPECIAL}"
all_soup: soup/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C soup all C_SPECIAL="${C_SPECIAL}"
eat eating eat_soup eating_soup: soup/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C soup eat C_SPECIAL="${C_SPECIAL}"
kitchen soup_kitchen: soup/kitchen.sh
-${Q} ${MAKE} ${MAKE_CD_Q} -C soup kitchen C_SPECIAL="${C_SPECIAL}"
all_test_ioccc: test_ioccc/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C test_ioccc all C_SPECIAL="${C_SPECIAL}"
dbg/dbg.h: dbg/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C dbg extern_include C_SPECIAL="${C_SPECIAL}"
dbg/libdbg.a: dbg/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C dbg extern_liba C_SPECIAL="${C_SPECIAL}"
dbg/dbg_test: dbg/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C dbg dbg_test C_SPECIAL="${C_SPECIAL}"
dyn_array/dyn_array.h: dyn_array/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C dyn_array extern_include C_SPECIAL="${C_SPECIAL}"
dyn_array/libdyn_array.a: dyn_array/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C dyn_array extern_liba C_SPECIAL="${C_SPECIAL}"
jparse/jparse.h: jparse/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C jparse extern_include C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
jparse/libjparse.a: jparse/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C jparse extern_liba C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
jparse/jparse: jparse/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C jparse extern_prog C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
jparse/jsemtblgen: jparse/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C jparse extern_prog C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
jparse/jsemcgen.sh: jparse/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C jparse extern_prog C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
soup/soup.a: soup/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C soup extern_liba C_SPECIAL="${C_SPECIAL}"
soup/chk_sem_info.h: soup/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C soup extern_include C_SPECIAL="${C_SPECIAL}"
soup/chk_sem_auth.h: soup/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C soup extern_include C_SPECIAL="${C_SPECIAL}"
soup/soup.h: soup/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C soup extern_include C_SPECIAL="${C_SPECIAL}"
soup/limit_ioccc.sh: soup/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C soup extern_prog C_SPECIAL="${C_SPECIAL}"
reset_min_timestamp: soup/Makefile
${Q} ${MAKE} ${MAKE_CD_Q} -C soup reset_min_timestamp C_SPECIAL="${C_SPECIAL}"
####################################
# rules for use by other Makefiles #
####################################
###########################################################
# repo tools - rules for those who maintain the this repo #
###########################################################
# make prep
#
# Things to do before a release, forming a pull request and/or updating the
# GitHub repo.
#
# This runs through all of the prep steps. If some step failed along the way,
# exit non-zero at the end.
#
# NOTE: This rule is useful if for example you're not working on the parser and
# you're on a system without the proper versions of flex and/or bison but you
# still want to work on the repo. Another example use is if you don't have
# shellcheck and/or picky and you want to work on the repo.
#
# The point is: if you're working on this repo and make build fails, try this
# rule instead.
#
prep: test_ioccc/prep.sh
${S} echo "${OUR_NAME}: make $@ starting"
${Q} ${RM} -f ${TMP_BUILD_LOG}
${Q} ./test_ioccc/prep.sh -m${MAKE} -l "${TMP_BUILD_LOG}"; \
EXIT_CODE="$$?"; \
${MV} -f ${TMP_BUILD_LOG} ${BUILD_LOG}; \
if [[ $$EXIT_CODE -ne 0 ]]; then \
echo; \
echo "make $@: ERROR: ./test_ioccc/prep.sh exit code: $$EXIT_CODE"; \
fi; \
echo; \
echo "make $@: see ${BUILD_LOG} for details"; \
if [[ $$EXIT_CODE -ne 0 ]]; then \
exit "$$EXIT_CODE"; \
else \
echo "All Done!!! All Done!!! -- Jessica Noll, Age 2"; \
fi
${S} echo "${OUR_NAME}: make $@ ending"; \
# a slower version of prep that does not write to a log file so one can see the
# full details.
#
slow_prep: test_ioccc/prep.sh
${S} echo "${OUR_NAME}: make $@ starting"
${Q} ${RM} -f ${TMP_BUILD_LOG}
${Q} ./test_ioccc/prep.sh -m${MAKE}; \
EXIT_CODE="$$?"; \
if [[ $$EXIT_CODE -ne 0 ]]; then \
echo; \
echo "make $@: ERROR: ./test_ioccc/prep.sh exit code: $$EXIT_CODE"; \
fi; \
echo; \
echo "make $@: see ${BUILD_LOG} for details"; \
if [[ $$EXIT_CODE -ne 0 ]]; then \
exit "$$EXIT_CODE"; \
else \
echo "All Done!!! All Done!!! -- Jessica Noll, Age 2"; \
fi
${S} echo "${OUR_NAME}: make $@ ending"; \
# make build release pull
#
# Things to do before a release, forming a pull request and/or updating the
# GitHub repo.
#
# This runs through all of the prep steps, exiting on the first failure.
#
# NOTE: The reference copies of the JSON parser C code will NOT be used
# so if bison and/or flex is not found or too old THIS RULE WILL FAIL!
#
# NOTE: Please try this rule BEFORE make prep.
#
build: release
pull: release
release: test_ioccc/prep.sh
${S} echo "${OUR_NAME}: make $@ starting"
${Q} ${RM} -f ${TMP_BUILD_LOG}
${Q} ./test_ioccc/prep.sh -m${MAKE} -e -o -l "${TMP_BUILD_LOG}"; \
EXIT_CODE="$$?"; \
${MV} -f ${TMP_BUILD_LOG} ${BUILD_LOG}; \
if [[ $$EXIT_CODE -ne 0 ]]; then \
echo; \
echo "make $@: ERROR: ./test_ioccc/prep.sh exit code: $$EXIT_CODE"; \
fi; \
echo; \
echo "make $@: see ${BUILD_LOG} for details"; \
if [[ $$EXIT_CODE -ne 0 ]]; then \
exit "$$EXIT_CODE"; \
else \
echo "All Done!!! All Done!!! -- Jessica Noll, Age 2"; \
fi
${S} echo "${OUR_NAME}: make $@ ending"; \
# a slower version of release that does not write to a log file so one can see the
# full details.
#
slow_release: test_ioccc/prep.sh
${S} echo "${OUR_NAME}: make $@ starting"
${Q} ${RM} -f ${TMP_BUILD_LOG}
${Q} ./test_ioccc/prep.sh -m${MAKE} -e -o; \
EXIT_CODE="$$?"; \
if [[ $$EXIT_CODE -ne 0 ]]; then \
echo; \
echo "make $@: ERROR: ./test_ioccc/prep.sh exit code: $$EXIT_CODE"; \
fi; \
echo; \
echo "make $@: see ${BUILD_LOG} for details"; \
if [[ $$EXIT_CODE -ne 0 ]]; then \
exit "$$EXIT_CODE"; \
else \
echo "All Done!!! All Done!!! -- Jessica Noll, Age 2"; \
fi
${S} echo "${OUR_NAME}: make $@ ending"; \
# force test_ioccc/txzchk_test.sh results into test suite *.err files
#
# If test_ioccc/txzchk_test.sh reports some *.err files under ./test_ioccc/test_txzchk
# does not match the "expected" test result, force the *.err files to become what
# is generated.
#
# IMPORTANT: Only run this rule of you KNOW that the *.err files are simply
# out of date and that the difference between what is in the *.err
# files and what is being generated is correct.
#
rebuild_txzchk_test_errors force_expectations_for_txzchk_test:
@./test_ioccc/txzchk_test.sh -B || exit 1
# make parser
#
# Force the rebuild of the JSON parser and then form the reference copies of
# JSON parser C code (if recent enough version of flex and bison are found).
#
parser: jparse/Makefile
${E} ${MAKE} ${MAKE_CD_Q} -C jparse $@ C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
#
# make parser-o: Force the rebuild of the JSON parser.
#
# NOTE: This does NOT use the reference copies of JSON parser C code.
#
parser-o: jparse/Makefile
${E} ${MAKE} ${MAKE_CD_Q} -C jparse $@ C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
# load bison/flex reference code from the previous successful make parser
#
load_json_ref: jparse/Makefile
${E} ${MAKE} ${MAKE_CD_Q} -C jparse $@ C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
# restore bison/flex reference code that was produced by previous successful make parser
#
# This rule forces the use of reference copies of JSON parser C code.
#
use_json_ref: jparse/Makefile
${E} ${MAKE} ${MAKE_CD_Q} -C jparse $@ C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
# Form unpatched semantic tables, without headers and trailers, from the reference info and auth JSON files
#
# rule used by ../test_ioccc/prep.sh
#
all_sem_ref: soup/Makefile
${E} ${MAKE} ${MAKE_CD_Q} -C soup $@ C_SPECIAL="${C_SPECIAL}"
# form chk.????.ptch.{c,h} files
#
# Given a correct set of chk_sem_????.{c,h} files, we form chk.????.ptch.{c,h}
# diff patch relative to the ref/*.reference.json.{c,h} files.
#
# rule should never be invoked by ../test_ioccc/prep.sh
#
# This rule is run by the repo maintainers only AFTER chk_sem_????.{c,h} files
# are updated by hand.
#
all_sem_ref_ptch: soup/Makefile
${E} ${MAKE} ${MAKE_CD_Q} -C soup $@ C_SPECIAL="${C_SPECIAL}"
# sequence exit codes
#
seqcexit: ${ALL_CSRC} dbg/Makefile dyn_array/Makefile jparse/Makefile \
soup/Makefile test_ioccc/Makefile
${S} echo
${S} echo "${OUR_NAME}: make $@ starting"
${S} echo
${E} ${MAKE} ${MAKE_CD_Q} -C dbg $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C dyn_array $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C jparse $@ C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
${E} ${MAKE} ${MAKE_CD_Q} -C soup $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C test_ioccc $@ C_SPECIAL="${C_SPECIAL}"
${Q} if ! ${IS_AVAILABLE} ${SEQCEXIT} >/dev/null 2>&1; then \
echo 'The ${SEQCEXIT} tool could not be found or is unreliable in your system.' 1>&2; \
echo 'The ${SEQCEXIT} tool is required for the $@ rule.'; 1>&2; \
echo ''; 1>&2; \
echo 'See the following GitHub repo for ${SEQCEXIT}:'; 1>&2; \
echo ''; 1>&2; \
echo ' https://github.com/lcn2/seqcexit'; 1>&2; \
echo ''; 1>&2; \
exit 1; \
else \
echo "${SEQCEXIT} -D werr_sem_val -D werrp_sem_val -- ${ALL_CSRC}"; \
${SEQCEXIT} -D werr_sem_val -D werrp_sem_val -- ${ALL_CSRC}; \
fi
${S} echo
${S} echo "${OUR_NAME}: make $@ ending"
picky: ${ALL_SRC} dbg/Makefile dyn_array/Makefile jparse/Makefile \
soup/Makefile test_ioccc/Makefile
${S} echo
${S} echo "${OUR_NAME}: make $@ starting"
${S} echo
${E} ${MAKE} ${MAKE_CD_Q} -C dbg $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C dyn_array $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C jparse $@ C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
${E} ${MAKE} ${MAKE_CD_Q} -C soup $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C test_ioccc $@ C_SPECIAL="${C_SPECIAL}"
${Q} if ! ${IS_AVAILABLE} ${PICKY} >/dev/null 2>&1; then \
echo 'The ${PICKY} tool could not be found or is unreliable in your system.' 1>&2; \
echo 'The ${PICKY} tool is required for the $@ rule.' 1>&2; \
echo 1>&2; \
echo 'See the following GitHub repo for ${PICKY}:'; 1>&2; \
echo 1>&2; \
echo ' https://github.com/lcn2/picky' 1>&2; \
echo 1>&2; \
exit 1; \
else \
echo "${PICKY} -w132 -u -s -t8 -v -e -- ${C_SRC} ${H_SRC}"; \
${PICKY} -w132 -u -s -t8 -v -e -- ${C_SRC} ${H_SRC}; \
EXIT_CODE="$$?"; \
if [[ $$EXIT_CODE -ne 0 ]]; then \
echo "make $@: ERROR: CODE[1]: $$EXIT_CODE" 1>&2; \
exit 1; \
fi; \
echo "${PICKY} -w -u -s -t8 -v -e -8 -- ${SH_FILES}"; \
${PICKY} -w -u -s -t8 -v -e -8 -- ${SH_FILES}; \
EXIT_CODE="$$?"; \
if [[ $$EXIT_CODE -ne 0 ]]; then \
echo "make $@: ERROR: CODE[2]: $$EXIT_CODE" 1>&2; \
exit 2; \
fi; \
fi
${S} echo
${S} echo "${OUR_NAME}: make $@ ending"
# inspect and verify shell scripts
#
shellcheck: ${SH_FILES} .shellcheckrc dbg/Makefile dyn_array/Makefile jparse/Makefile \
soup/Makefile test_ioccc/Makefile
${S} echo
${S} echo "${OUR_NAME}: make $@ starting"
${S} echo
${E} ${MAKE} ${MAKE_CD_Q} -C dbg $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C dyn_array $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C jparse $@ C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
${E} ${MAKE} ${MAKE_CD_Q} -C soup $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C test_ioccc $@ C_SPECIAL="${C_SPECIAL}"
${Q} if ! ${IS_AVAILABLE} ${SHELLCHECK} >/dev/null 2>&1; then \
echo 'The ${SHELLCHECK} command could not be found or is unreliable in your system.' 1>&2; \
echo 'The ${SHELLCHECK} command is required to run the $@ rule.'; 1>&2; \
echo ''; 1>&2; \
echo 'See the following GitHub repo for ${SHELLCHECK}:'; 1>&2; \
echo ''; 1>&2; \
echo ' https://github.com/koalaman/shellcheck.net'; 1>&2; \
echo ''; 1>&2; \
echo 'Or use the package manager in your OS to install it.' 1>&2; \
exit 1; \
else \
echo "${SHELLCHECK} -f gcc -- ${SH_FILES}"; \
${SHELLCHECK} -f gcc -- ${SH_FILES}; \
EXIT_CODE="$$?"; \
if [[ $$EXIT_CODE -ne 0 ]]; then \
echo "make $@: ERROR: CODE[1]: $$EXIT_CODE" 1>&2; \
exit 1; \
fi; \
fi
${S} echo
${S} echo "${OUR_NAME}: make $@ ending"
# inspect and verify man pages
#
check_man: dbg/Makefile dyn_array/Makefile jparse/Makefile \
soup/Makefile test_ioccc/Makefile
${S} echo
${S} echo "${OUR_NAME}: make $@ starting"
${S} echo
${E} ${MAKE} ${MAKE_CD_Q} -C dbg $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C dyn_array $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C jparse $@ C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
${E} ${MAKE} ${MAKE_CD_Q} -C soup $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C test_ioccc $@ C_SPECIAL="${C_SPECIAL}"
${S} echo
${S} echo "${OUR_NAME}: make $@ ending"
# build a user convenience man directory
#
build_man: dbg/Makefile dyn_array/Makefile jparse/Makefile \
soup/Makefile test_ioccc/Makefile
${V} echo
${V} echo "${OUR_NAME}: make $@ starting"
${V} echo
${Q} ${MAKE} ${MAKE_CD_Q} -C dbg install_man \
MAN1_DIR=../man/man1 MAN3_DIR=../man/man3 MAN8_DIR=../man/man8 I=@ \
INSTALL_V= C_SPECIAL="${C_SPECIAL}"
${Q} ${MAKE} ${MAKE_CD_Q} -C dyn_array install_man \
MAN1_DIR=../man/man1 MAN3_DIR=../man/man3 MAN8_DIR=../man/man8 I=@ \
INSTALL_V= C_SPECIAL="${C_SPECIAL}"
${Q} ${MAKE} ${MAKE_CD_Q} -C jparse install_man \
MAN1_DIR=../man/man1 MAN3_DIR=../man/man3 MAN8_DIR=../man/man8 I=@ \
INSTALL_V= C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
${Q} ${MAKE} ${MAKE_CD_Q} -C soup install_man \
MAN1_DIR=../man/man1 MAN3_DIR=../man/man3 MAN8_DIR=../man/man8 I=@ \
INSTALL_V= C_SPECIAL="${C_SPECIAL}"
${Q} ${MAKE} ${MAKE_CD_Q} -C test_ioccc install_man \
MAN1_DIR=../man/man1 MAN3_DIR=../man/man3 MAN8_DIR=../man/man8 I=@ \
INSTALL_V= C_SPECIAL="${C_SPECIAL}"
${V} echo
${V} echo "${OUR_NAME}: make $@ ending"
# vi/vim tags
#
tags: ${ALL_CSRC} ${ALL_HSRC} dbg/Makefile dyn_array/Makefile jparse/Makefile \
soup/Makefile test_ioccc/Makefile
${S} echo
${S} echo "${OUR_NAME}: make $@ starting"
${S} echo
${Q} if ! ${IS_AVAILABLE} ${CTAGS} >/dev/null 2>&1; then \
echo 'The ${CTAGS} command could not be found.' 1>&2; \
echo 'The ${CTAGS} command is required to run the $@ rule.'; 1>&2; \
echo ''; 1>&2; \
echo 'Use the package manager from your OS to install the ${CTAGS} package.' 1>&2; \
echo 'The following GitHub repo may be a useful ${CTAGS} alternative:'; 1>&2; \
echo ''; 1>&2; \
echo ' https://github.com/universal-ctags/ctags'; 1>&2; \
echo ''; 1>&2; \
exit 1; \
fi
${E} ${MAKE} ${MAKE_CD_Q} -C dbg local_dir_tags C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C dyn_array local_dir_tags C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C jparse local_dir_tags C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
${E} ${MAKE} ${MAKE_CD_Q} -C soup local_dir_tags C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C test_ioccc local_dir_tags C_SPECIAL="${C_SPECIAL}"
${Q} echo
${E} ${MAKE} local_dir_tags
${Q} echo
${E} ${MAKE} all_tags
${S} echo
${S} echo "${OUR_NAME}: make $@ ending"
# use the ${CTAGS} tool to form ${LOCAL_DIR_TAGS} of the source in this directory
#
local_dir_tags: ${ALL_CSRC} ${ALL_HSRC}
${S} echo
${S} echo "${OUR_NAME}: make $@ starting"
${S} echo
${Q} if ! ${IS_AVAILABLE} ${CTAGS} >/dev/null 2>&1; then \
echo 'The ${CTAGS} command could not be found.' 1>&2; \
echo 'The ${CTAGS} command is required to run the $@ rule.'; 1>&2; \
echo ''; 1>&2; \
echo 'Use the package manager from your OS to install the ${CTAGS} package.' 1>&2; \
echo 'The following GitHub repo may be a useful ${CTAGS} alternative:'; 1>&2; \
echo ''; 1>&2; \
echo ' https://github.com/universal-ctags/ctags'; 1>&2; \
echo ''; 1>&2; \
exit 1; \
fi
${Q} ${RM} -f ${LOCAL_DIR_TAGS}
-${E} ${CTAGS} -w -f ${LOCAL_DIR_TAGS} ${ALL_CSRC} ${ALL_HSRC}
${S} echo
${S} echo "${OUR_NAME}: make $@ ending"
# for a tags file from all ${LOCAL_DIR_TAGS} in all of the other directories
#
all_tags:
${S} echo
${S} echo "${OUR_NAME}: make $@ starting"
${S} echo
${E} ${MAKE} ${MAKE_CD_Q} -C dbg $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C dyn_array $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C jparse $@ C_SPECIAL="${C_SPECIAL}" \
LD_DIR="${LD_DIR}" LD_DIR2="${LD_DIR2}"
${E} ${MAKE} ${MAKE_CD_Q} -C soup $@ C_SPECIAL="${C_SPECIAL}"
${E} ${MAKE} ${MAKE_CD_Q} -C test_ioccc $@ C_SPECIAL="${C_SPECIAL}"
${Q} echo
${Q} ${RM} -f tags
${Q} for dir in . dbg dyn_array jparse jparse/test_jparse soup test_ioccc; do \
if [[ -s $$dir/${LOCAL_DIR_TAGS} ]]; then \
echo "${SED} -e 's;\t;\t'$${dir}'/;' $${dir}/${LOCAL_DIR_TAGS} >> tags"; \
${SED} -e 's;\t;\t'$${dir}'/;' "$${dir}/${LOCAL_DIR_TAGS}" >> tags; \
elif [[ -e $$dir/${LOCAL_DIR_TAGS} ]]; then \
echo "make $@ Warning: found empty local tags file: $$dir/${LOCAL_DIR_TAGS}" 1>&2 ; \
else \
echo "make $@ Warning: missing local tags file: $$dir/${LOCAL_DIR_TAGS}" 1>&2 ; \
fi; \
done
${E} ${SORT} tags -o tags
${S} echo
${S} echo "${OUR_NAME}: make $@ ending"
# perform all of the mkiocccentry repo required tests