-
Notifications
You must be signed in to change notification settings - Fork 2
/
not-autoversion.m4
1369 lines (1314 loc) · 49.6 KB
/
not-autoversion.m4
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
dnl **************************************************************************
dnl _ _ _ ___ _ _ _
dnl | \ | | | | / _ \ | | | | | |
dnl | \| | ___ | |_ / /_\ \_ _| |_ ___ | |_ ___ ___ | |___
dnl | . ` |/ _ \| __| | _ | | | | __/ _ \| __/ _ \ / _ \| / __|
dnl | |\ | (_) | |_ | | | | |_| | || (_) | || (_) | (_) | \__ \
dnl \_| \_/\___/ \__| \_| |_/\__,_|\__\___/ \__\___/ \___/|_|___/
dnl
dnl A collection of useful m4 macros for GNU Autotools
dnl
dnl -- Released under GNU GPL3 --
dnl
dnl https://github.com/madmurphy/not-autotools
dnl **************************************************************************
dnl **************************************************************************
dnl A U T O V E R S I O N I N G M A C R O S
dnl **************************************************************************
dnl NR_RECORD_HISTORY([root], event1[, event2[, ... last-event]])
dnl **************************************************************************
dnl
dnl Automatically assigns version numbers to all the releases of an
dnl unversioned history declared in a ChangeLog-like style
dnl
dnl Would you like to stop worrying about the meanings of the changes that
dnl your release carries, and how these must be translated into different
dnl versioning schemes (such as semantic versioning, libtool's version info,
dnl distributions-specific conventions, etc., etc.)?
dnl
dnl If yes, then you are in the right place.
dnl
dnl This framework offers a simple way to automatize the versioning process,
dnl by relying only on a ChangeLog-like list of _unversioned events_, whose
dnl version is computed automatically and in a reproducible way that depends
dnl on the nature of the changes.
dnl
dnl The `n4_has()` macro from `not-m4sugar.m4` is required, so before getting
dnl started you will need to copy and paste it in your `configure.ac`.
dnl Furthermore, all the macros from this document will need to be to be
dnl included too.
dnl
dnl With this framework, a list of unversioned events is passed to
dnl `NR_RECORD_HISTORY()` early in `configure.ac` -- possibly before
dnl `AC_INIT()`.
dnl
dnl Storing the complete release history will look more or less like the
dnl following example -- the version numbers in the comments are only for the
dnl purpose of clarity, as the macro does not require any version numbers for
dnl its input (it rather _generates_ them):
dnl
dnl NR_RECORD_HISTORY([[1]],
dnl
dnl dnl *************** 1.1.0 (0:0:0) #1 ***************
dnl [[2018-10-21],
dnl [HEADERS],
dnl [MILESTONE]],
dnl
dnl dnl *************** 1.1.1 (0:0:0) #1 ***************
dnl [[2018-10-29],
dnl [MISCELLANEA]],
dnl
dnl dnl *************** 1.1.2 (0:1:0) #1 ***************
dnl [[2018-11-12],
dnl [IMPLEMENTATION],
dnl [MISCELLANEA]],
dnl
dnl dnl *************** 1.2.0 (0:2:0) #2 ***************
dnl [[2018-12-03],
dnl [IMPLEMENTATION],
dnl [HEADERS]],
dnl
dnl dnl *************** 1.3.0 (1:0:1) #0 ***************
dnl [[2019-02-14],
dnl [INTERFACE],
dnl [IMPLEMENTATION],
dnl [MISCELLANEA]],
dnl
dnl dnl *************** 1.4.0 (2:0:2) #0 ***************
dnl [[2019-03-22],
dnl [INTERFACE]],
dnl
dnl dnl *************** 1.5.0 (3:0:3) #0 ***************
dnl [[2019-05-07],
dnl [INTERFACE],
dnl [IMPLEMENTATION],
dnl [MISCELLANEA]],
dnl
dnl dnl *************** 1.6.0 (3:1:3) #0 ***************
dnl [[2019-06-10],
dnl [IMPLEMENTATION],
dnl [MILESTONE]],
dnl
dnl dnl *************** 1.7.0 (3:2:3) #1 ***************
dnl [[CURRENT],
dnl [IMPLEMENTATION],
dnl [HEADERS],
dnl [MISCELLANEA]])
dnl
dnl In the simplest scenario, a `configure.ac` script will look like the
dnl following example:
dnl
dnl NR_RECORD_HISTORY(...)
dnl
dnl AC_INIT([Foo Bar],
dnl NR_PROJECT_VERSION,
dnl [the.author@example.com],
dnl [foobar],
dnl [https://www.example.com])
dnl
dnl ...
dnl
dnl And that's it.
dnl
dnl Before further reading, you can see the example above in action at
dnl `examples/not-autoversion/simple-example/`.
dnl
dnl The arguments passed to `NR_RECORD_HISTORY()` are the `root` version
dnl (simply `[[1]]` in the example above) -- this parameter will be described
dnl later in this manual -- and a series of events.
dnl
dnl If you prefer to write the events in reverse chronological order, please
dnl see `NR_RECORD_HISTORY_RCO()`.
dnl
dnl An `event` is itself a list, composed of a unique custom name followed by
dnl one or more changes.
dnl
dnl A `change` is a registered descriptive token that illustrates the type of
dnl change that a release carries. A typical `event` looks like the following
dnl list,
dnl
dnl [[36ab69c],
dnl [IMPLEMENTATION],
dnl [HEADERS],
dnl [MISCELLANEA]]
dnl
dnl where `36ab69c` is the event's name (in this case it is a git commit, but
dnl the field may contain any custom unique string) and `IMPLEMENTATION`,
dnl `HEADERS` and `MISCELLANEA` are the tokens that best describe the changes
dnl that have occurred during that release event.
dnl
dnl Possible tokens for the `change` keywords are:
dnl
dnl DEPARTURE If this is a library, the new changes break binary
dnl compatibility with the programs that have depended
dnl on it so far (if this is the case, you **must**
dnl pick this token). If this is a program, this token
dnl describes a major reshape or a change of paradigm.
dnl
dnl INTERFACE If this is a library, the way in which the
dnl compiled binary interfaces with other programs has
dnl changed; if this is a program, the way in which it
dnl interfaces with humans has changed. You should not
dnl worry about binary compatibility here; if this
dnl description meets in some ways the reality of what
dnl happened, you should pick this token.
dnl
dnl HEADERS This keyword describes source-only additions to
dnl a library's public headers (if any) _that did not
dnl alter in any way the compiled binary_ (e.g., C
dnl macros, typedefs, adding deprecated features
dnl etc.). If these exist, pick this token too. If
dnl these co-exist with changes in the interface, you
dnl may use both tokens.
dnl
dnl MILESTONE This keyword describes changes _of any kind_ (in
dnl the implementation, the package data, the program
dnl functionalities, the documentation, etc.),
dnl important enough to be highlighted as milestones.
dnl
dnl IMPLEMENTATION This keyword describes internal changes in the
dnl compiled binary that did not alter at all the way
dnl this interfaces with the rest of the world. If
dnl these are present, pick this token.
dnl
dnl MISCELLANEA This keyword describes generic changes that did
dnl not affect the source code _in any way_ (e.g.,
dnl documentation, build system, package data, etc.).
dnl
dnl LAUNCH This keyword indicates that the development stage
dnl (0.X.X) has ended and the project has entered a
dnl mature stage (1.0.0). If we are already in a
dnl mature stage, this keyword is no-op.
dnl
dnl FORK This keyword indicates that the project has begun
dnl a new path as a fork from the previous events. The
dnl version state will be reset to [[0]] or [[1]],
dnl depending on whether the `LAUNCH` keyword is
dnl present as well or not.
dnl
dnl Each event can contain all possible assortments of the tokens above.
dnl Unregistered keywords, if found, will be simply ignored.
dnl
dnl # `Hello world!` and `GUITAR` will be ignored
dnl [[a94d2aa],
dnl [IMPLEMENTATION],
dnl [Hello world!],
dnl [MILESTONE],
dnl [GUITAR]]
dnl
dnl The advantage of this approach is that you won't have to worry about
dnl weird algorithms, such as "increase that number, reset that other", and so
dnl on; you simply look at the bouquet of available keywords, and if one or
dnl more keywords describe your changes adequately you just pick them,
dnl without second thoughts; the framework will do all the calculations for
dnl you, and these will always be reproducible. As an additional benefit, your
dnl package will now possess a human-readable (although generic)
dnl ChangeLog-like release history that can be read by machines too.
dnl
dnl You will notice during a development stage (0.X.X) that some of the tokens
dnl behave differently. This is so by design. The only way to exit from a
dnl development stage is by assigning the `LAUNCH` keyword to one of the
dnl events in the history, or by starting the history with a `root` argument
dnl greater than zero.
dnl
dnl Once you have written down the history, several literals will be exported
dnl to your `configure.ac` script. The ones that refer to the current version
dnl (i.e. the latest event in the history) are:
dnl
dnl * `NR_PROJECT_MAJVER`
dnl * `NR_PROJECT_MINVER`
dnl * `NR_PROJECT_MICVER`
dnl * `NR_BINARY_MAJVER`
dnl * `NR_BINARY_MINVER`
dnl * `NR_BINARY_MICVER`
dnl * `NR_INTERFACE_NUM`
dnl * `NR_INTERFACES_SUPPORTED`
dnl * `NR_IMPLEMENTATION_NUM`
dnl * `NR_SOURCE_AGE`
dnl * `NR_PROJECT_VERSION`
dnl * `NR_BINARY_VERSION`
dnl * `NR_LIBTOOL_VERSION_INFO`
dnl * `NR_HISTORY_CURRENT_EVENT_NAME`
dnl * `NR_HISTORY_CURRENT_VSTATE`
dnl * `NR_HISTORY_ROOT_VSTATE`
dnl
dnl The documentation will not be versioned by this framework (hence why the
dnl generic `MISCELLANEA` token must be used for referring to it), as there
dnl are no known mechanical rules for versioning a documentation.
dnl
dnl The first ten macros expand to positive integers. In particular,
dnl
dnl * `NR_PROJECT_MAJVER`, `NR_PROJECT_MINVER` and `NR_PROJECT_MICVER`
dnl cumulatively apply semantic versioning to the entire project (these
dnl numbers construct your main version string `NR_PROJECT_VERSION`)
dnl * `NR_BINARY_MAJVER`, `NR_BINARY_MINVER`, `NR_BINARY_MICVER`, apply
dnl something similar to semantic versioning to the compiled binary only
dnl (detached from the package), whith the difference that during a
dnl development stage (0.X.X) these will remain always zero (which is why a
dnl binary version starting with zero does not indicate a development stage)
dnl -- these build your binary version string `NR_BINARY_VERSION`)
dnl * `NR_INTERFACE_NUM`, `NR_INTERFACES_SUPPORTED` and
dnl `NR_IMPLEMENTATION_NUM`, correspond to libtool version info's `current`,
dnl `age` and `revision` respectively (see `NR_LIBTOOL_VERSION_INFO` for the
dnl entire string) -- during a development stage (0.X.X) these will remain
dnl always zero
dnl * `NR_SOURCE_AGE` counts the header-only changes since the last interface
dnl was released
dnl
dnl Moreover, the `NR_HISTORY_CURRENT_EVENT_NAME` macro expands to the name of
dnl the latest release event (typically `CURRENT`), while
dnl `NR_HISTORY_CURRENT_VSTATE` and `NR_HISTORY_ROOT_VSTATE`
dnl contain the earliest and the latest version states available.
dnl
dnl NOTE: If your package installs different independent libraries, using the
dnl `NR_LIBTOOL_VERSION_INFO` literal might become problematic. You
dnl will have to choose whether using the same version info for all
dnl your libraries (in this case you can use `NR_LIBTOOL_VERSION_INFO`
dnl for it), or versioning each module differently by hand (and in this
dnl case you will have to either ignore `NR_LIBTOOL_VERSION_INFO`, or
dnl use it only for a module that you consider to be the main module of
dnl the package). The `NR_BINARY_VERSION` literal instead will never be
dnl affected by the presence of independent modules, as this literal
dnl always refers collectively to all the binaries shipped by your
dnl package (i.e. it is never the version of one single module, but of
dnl the entire set of binaries that your package generates altogether).
dnl The changes that you write in your history must in any case refer
dnl to the entire package as a whole.
dnl
dnl If used in conjunction with `NC_CONFIG_SHADOW_DIR()` (see
dnl `m4/not-extended-config.m4`), this framework literally makes it possible
dnl continuously to publish releases _without ever having to write a single
dnl version number by hand_, not even once; `NC_CONFIG_SHADOW_DIR()` and
dnl `NR_RECORD_HISTORY()` can do that for you and apply the changes to the
dnl entire package tree. You can see a minimal example if this symbiosis in
dnl action under `examples/not-autoversion/extended-example/`.
dnl
dnl Since `NR_RECORD_HISTORY()` is normally invoked before `AC_INIT()`, no
dnl `configure` substitutions are automatically generated. It is possible
dnl however to export all the literals above as `configure` substitutions by
dnl calling the `NC_AUTOVERSION_SUBSTITUTIONS` macro **after** `AC_INIT()` has
dnl finally been invoked:
dnl
dnl NR_RECORD_HISTORY(...)
dnl AC_INIT(...)
dnl ...
dnl NC_AUTOVERSION_SUBSTITUTIONS
dnl ...
dnl AC_OUTPUT
dnl
dnl The substitutions will have names identical to their m4 counterparts, but
dnl will not have the `NR_` prefix -- more or less like the `AC_PACKAGE_NAME`
dnl literal produces a `PACKAGE_NAME` `configure` substitution, without the
dnl `AC_` prefix. For example, `NR_PROJECT_MAJVER`'s substitution will be
dnl named `PROJECT_MAJVER`.
dnl
dnl If you don't need the whole group of literals, you can manually pick up
dnl only the literals that you need instead of invoking
dnl `NC_AUTOVERSION_SUBSTITUTIONS`, and create a smaller set of targeted
dnl substitutions:
dnl
dnl
dnl NR_RECORD_HISTORY(...)
dnl AC_INIT(...)
dnl ...
dnl AC_SUBST([PROJECT_MAJVER], NR_PROJECT_MAJVER)
dnl AC_SUBST([PROJECT_MINVER], NR_PROJECT_MINVER)
dnl AC_SUBST([PROJECT_MICVER], NR_PROJECT_MICVER)
dnl ...
dnl # etc.
dnl ...
dnl AC_OUTPUT
dnl
dnl To bootstrap the history from an initial state different than 0.1.0
dnl (0:0:0) #0 ("SEMVER (LIBTOOL) #SOURCE_AGE") you can pass a comma-separated
dnl list of (up to) seven positive numbers as the `root` argument. The
dnl expected fields are: project-major[, project-minor[, project-micro[,
dnl current[, revision[, age[, source-age]]]]].
dnl
dnl For instance, to use `1` as the initial major version and `6` as the
dnl initial minor version, use
dnl
dnl NR_RECORD_HISTORY([[1], [6]],
dnl [[2018-10-21],
dnl [HEADERS],
dnl [MILESTONE]],
dnl [...])
dnl
dnl If you want to start the development version from 0.0.0 instead of the
dnl default 0.1.0, use `NR_RECORD_HISTORY([[0], [0]], event1, ..., eventN)`.
dnl
dnl To obtain the version state of a past event knowing its name the
dnl `NR_HISTORY_GET_EVENT_VSTATE()` macro is made available. This macro
dnl becomes useful when the history has grown too big and you want to archive
dnl a part of it out of your `configure.ac` -- although, unless this has grown
dnl really gigantic, consider always keeping the history whole and simply
dnl using a separate file for it, included in `configure.ac` via
dnl `m4_include()`.
dnl
dnl For example, imagine you want to archive the history up until an event
dnl named `ccb21a3`; you would simply add to your `configure.ac`, temporarily,
dnl
dnl AC_MSG_NOTICE([NR_HISTORY_GET_EVENT_VSTATE([ccb21a3])])
dnl
dnl which would print something like,
dnl
dnl configure: 1, 13, 0, 3, 1, 3, 0
dnl
dnl then you would remove the history until `ccb21a3` (included) and use the
dnl seven numbers above as the root argument for the new shorter history. The
dnl removed part can be preserved as a separate inert file.
dnl
dnl NR_RECORD_HISTORY([[1], [13], [0], [3], [1], [3], [0]],
dnl [[f82ca90],
dnl [INTERFACE],
dnl [...]])
dnl
dnl Finally, to deal with pre-releases, you simply add your pre-release suffix
dnl to `AC_INIT()` by hand. This is the best way to deal with something that
dnl is never going to become part of the history:
dnl
dnl AC_INIT([Foo Bar],
dnl NR_PROJECT_VERSION[.alpha],
dnl [the.author@example.com],
dnl [foobar],
dnl [https://www.example.com])
dnl
dnl This macro may -- and should -- be invoked before `AC_INIT()`.
dnl
dnl NOTE: Since this framework deals only with upstream changes, it runs
dnl entirely at `autoreconf` time (not at `configure` time); there will
dnl be no traces of it in the `configure` script generated, except for
dnl the literals computed. It goes without saying that you cannot use
dnl shell expansions here, you must use only literals.
dnl
dnl Expansion type: literal (void)
dnl Requires: `NR_BUMP_VSTATE()`, `NR_GET_EVENT_VSTATE()`
dnl Version: 1.0.1
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([NR_RECORD_HISTORY], [dnl
dnl
dnl
dnl NR_HISTORY_ROOT_VSTATE([event-name])
dnl **************************************************************************
dnl The initial version state expanded from the `root` argument passed to
dnl `NR_RECORD_HISTORY()`
m4_define([NR_HISTORY_ROOT_VSTATE],
m4_dquote(m4_default_nblank_quoted(m4_argn([1], $1), [0]),
m4_default_nblank(m4_quote(m4_argn([2], $1)),
[m4_if(m4_eval(m4_argn([1], $1)[ + 0 > 0]), [1],
[0],
[1])]),
m4_default_nblank_quoted(m4_argn([3], $1), [0]),
m4_default_nblank_quoted(m4_argn([4], $1), [0]),
m4_default_nblank_quoted(m4_argn([5], $1), [0]),
m4_default_nblank_quoted(m4_argn([6], $1), [0]),
m4_default_nblank_quoted(m4_argn([7], $1), [0])))dnl
dnl
dnl
dnl NR_HISTORY_EVENTS()
dnl **************************************************************************
dnl The entire history in chronological order, without information about the
dnl root version
m4_define([NR_HISTORY_EVENTS],
[m4_shift($@)])dnl
dnl
dnl
dnl NR_HISTORY_GET_EVENT_VSTATE([event-name])
dnl **************************************************************************
dnl
dnl Get the version of a particular event in the release history by using its
dnl name -- defaults to `NR_HISTORY_CURRENT_VSTATE` when no event is
dnl found
dnl
dnl The returned text is a comma-separated list of numbers, representing
dnl respecively major, minor, micro, current, revision, age, source-age.
dnl
dnl To extract a particular value from it, you can pass the returned list as
dnl arguments to any of the following macros:
dnl
dnl * `NR_VSTATE_GET_PROJECT_VERSION()`
dnl * `NR_VSTATE_GET_PROJECT_MAJVER()`
dnl * `NR_VSTATE_GET_PROJECT_MINVER()`
dnl * `NR_VSTATE_GET_PROJECT_MICVER()`
dnl * `NR_VSTATE_GET_BINARY_VERSION()`
dnl * `NR_VSTATE_GET_BINARY_MAJVER()`
dnl * `NR_VSTATE_GET_BINARY_MINVER()`
dnl * `NR_VSTATE_GET_BINARY_MICVER()`
dnl * `NR_VSTATE_GET_LIBTOOL_VERSION_INFO()`
dnl * `NR_VSTATE_GET_INTERFACE_NUM()`
dnl * `NR_VSTATE_GET_INTERFACES_SUPPORTED()`
dnl * `NR_VSTATE_GET_IMPLEMENTATION_NUM()`
dnl * `NR_VSTATE_GET_SOURCE_AGE()`
dnl
dnl **************************************************************************
m4_define([NR_HISTORY_GET_EVENT_VSTATE],
[NR_GET_EVENT_VSTATE(]m4_dquote([$][1])[,
m4_dquote(NR_HISTORY_ROOT_VSTATE),
NR_HISTORY_EVENTS)])dnl
dnl
dnl
dnl NR_HISTORY_CURRENT_EVENT_NAME()
dnl **************************************************************************
dnl The name assigned to the latest history event (typically `CURRENT`)
m4_define([NR_HISTORY_CURRENT_EVENT_NAME],
m4_quote(m4_argn([1], m4_unquote(m4_argn([$#], $@)))))dnl
dnl
dnl
dnl NR_HISTORY_CURRENT_VSTATE()
dnl **************************************************************************
dnl The current version state
m4_define([NR_HISTORY_CURRENT_VSTATE],
m4_quote(NR_HISTORY_GET_EVENT_VSTATE))dnl
dnl
dnl
dnl NR_PROJECT_MAJVER()
dnl **************************************************************************
dnl The project's major version number -- equal to `NR_BINARY_MAJVER` + 1
m4_define([NR_PROJECT_MAJVER],
m4_quote(m4_argn([1], NR_HISTORY_CURRENT_VSTATE)))dnl
dnl
dnl
dnl NR_PROJECT_MINVER()
dnl **************************************************************************
dnl The project's minor version number
m4_define([NR_PROJECT_MINVER],
m4_quote(m4_argn([2], NR_HISTORY_CURRENT_VSTATE)))dnl
dnl
dnl
dnl NR_PROJECT_MICVER()
dnl **************************************************************************
dnl The project's micro version number
m4_define([NR_PROJECT_MICVER],
m4_quote(m4_argn([3], NR_HISTORY_CURRENT_VSTATE)))dnl
dnl
dnl
dnl NR_PROJECT_VERSION()
dnl **************************************************************************
dnl The project's version string
m4_define([NR_PROJECT_VERSION],
m4_quote(NR_PROJECT_MAJVER.NR_PROJECT_MINVER.NR_PROJECT_MICVER))dnl
dnl
dnl
dnl NR_BINARY_MAJVER()
dnl **************************************************************************
dnl The binary's major version number -- equal to `NR_PROJECT_MAJVER` - 1
m4_define([NR_BINARY_MAJVER],
m4_if(m4_eval(NR_PROJECT_MAJVER[ > 0]), [1],
[m4_quote(m4_decr(NR_PROJECT_MAJVER))], [[0]]))dnl
dnl
dnl
dnl NR_BINARY_MINVER()
dnl **************************************************************************
dnl The binary's minor version number -- synonym of `NR_INTERFACES_SUPPORTED`
m4_define([NR_BINARY_MINVER],
m4_quote(m4_argn([6], NR_HISTORY_CURRENT_VSTATE)))dnl
dnl
dnl
dnl NR_BINARY_MICVER()
dnl **************************************************************************
dnl The binary's micro version number -- synonym of `NR_IMPLEMENTATION_NUM`
m4_define([NR_BINARY_MICVER],
m4_quote(m4_argn([5], NR_HISTORY_CURRENT_VSTATE)))dnl
dnl
dnl
dnl NR_BINARY_VERSION()
dnl **************************************************************************
dnl The binary's version string
m4_define([NR_BINARY_VERSION],
m4_quote(NR_BINARY_MAJVER.NR_BINARY_MINVER.NR_BINARY_MICVER))dnl
dnl
dnl
dnl NR_INTERFACE_NUM()
dnl **************************************************************************
dnl libtool version info's `current` field
m4_define([NR_INTERFACE_NUM],
m4_quote(m4_argn([4], NR_HISTORY_CURRENT_VSTATE)))dnl
dnl
dnl
dnl NR_INTERFACES_SUPPORTED()
dnl **************************************************************************
dnl libtool version info's `age` field -- synonym of `NR_BINARY_MINVER`
m4_define([NR_INTERFACES_SUPPORTED],
m4_quote(NR_BINARY_MINVER))dnl
dnl
dnl
dnl NR_IMPLEMENTATION_NUM()
dnl **************************************************************************
dnl libtool version info's `revision` field -- synonym of `NR_BINARY_MICVER`
m4_define([NR_IMPLEMENTATION_NUM],
m4_quote(NR_BINARY_MICVER))dnl
dnl
dnl
dnl NR_LIBTOOL_VERSION_INFO()
dnl **************************************************************************
dnl GNU libtool version info
m4_define([NR_LIBTOOL_VERSION_INFO],
m4_quote(NR_INTERFACE_NUM:NR_IMPLEMENTATION_NUM:NR_INTERFACES_SUPPORTED))dnl
dnl
dnl
dnl NR_SOURCE_AGE()
dnl **************************************************************************
dnl The number of source-only changes since the last interface change
m4_define([NR_SOURCE_AGE],
m4_quote(m4_argn([7], NR_HISTORY_CURRENT_VSTATE)))dnl
dnl
])
dnl NR_RECORD_HISTORY_RCO([root], last-event1[, last-event2[, ...
dnl first-event]])
dnl **************************************************************************
dnl
dnl Identical to `NR_RECORD_HISTORY()`, but events must be listed in reverse
dnl chronological order (most recent first)
dnl
dnl For example:
dnl
dnl NR_RECORD_HISTORY_RCO([[1]],
dnl
dnl dnl *************** 1.7.0 (3:2:3) #1 ***************
dnl [[2019-08-02],
dnl [IMPLEMENTATION],
dnl [HEADERS],
dnl [MISCELLANEA]],
dnl
dnl dnl *************** 1.6.0 (3:1:3) #0 ***************
dnl [[2019-06-10],
dnl [IMPLEMENTATION],
dnl [MILESTONE]],
dnl
dnl dnl *************** 1.5.0 (3:0:3) #0 ***************
dnl [[2019-05-07],
dnl [INTERFACE],
dnl [IMPLEMENTATION],
dnl [MISCELLANEA]],
dnl
dnl dnl *************** 1.4.0 (2:0:2) #0 ***************
dnl [[2019-03-22],
dnl [INTERFACE]],
dnl
dnl dnl *************** 1.3.0 (1:0:1) #0 ***************
dnl [[2019-02-14],
dnl [INTERFACE],
dnl [IMPLEMENTATION],
dnl [MISCELLANEA]],
dnl
dnl dnl *************** 1.2.0 (0:2:0) #2 ***************
dnl [[2018-12-03],
dnl [IMPLEMENTATION],
dnl [HEADERS]],
dnl
dnl dnl *************** 1.1.2 (0:1:0) #1 ***************
dnl [[2018-11-12],
dnl [IMPLEMENTATION],
dnl [MISCELLANEA]],
dnl
dnl dnl *************** 1.1.1 (0:0:0) #1 ***************
dnl [[2018-10-29],
dnl [MISCELLANEA]],
dnl
dnl dnl *************** 1.1.0 (0:0:0) #1 ***************
dnl [[2018-10-21],
dnl [HEADERS],
dnl [MILESTONE]])
dnl
dnl Expansion type: literal
dnl Requires: `NR_RECORD_HISTORY()`
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([NR_RECORD_HISTORY_RCO],
[NR_RECORD_HISTORY([$1], m4_reverse(m4_shift($@)))])
dnl NR_BUMP_VSTATE(project-major, project-minor, project-micro, current,
dnl revision, age, source-age, change-list)
dnl **************************************************************************
dnl
dnl Applies one or more changes to a version state
dnl
dnl This macro is mainly intended to be used internally by
dnl `NR_RECORD_HISTORY()`; you will hardly ever need it. For the definition of
dnl a `change`, please refer to `NR_RECORD_HISTORY()`.
dnl
dnl The `change-list` argument corresponds to an `event` without its first
dnl member (i.e. without the event's name).
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: `n4_has()` from `not-m4sugar.m4`
dnl Version: 1.0.1
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([NR_BUMP_VSTATE],
[n4_has([$8],
[FORK],
[n4_has([$8],
[LAUNCH],
[1, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0])],
[m4_if(m4_eval([$1 > 0]), [1],
[n4_has([$8],
[DEPARTURE],
[m4_incr([$1]), 0, 0, m4_incr([$4]), 0, 0, 0],
[INTERFACE],
[[$1], m4_incr([$2]), 0, m4_incr([$4]), 0, m4_incr([$6]), 0],
[IMPLEMENTATION],
[n4_has([$8],
[HEADERS],
[[$1], m4_incr([$2]), 0, [$4], m4_incr([$5]), [$6], m4_incr([$7])],
[MILESTONE],
[[$1], m4_incr([$2]), 0, [$4], m4_incr([$5]), [$6], [$7]],
[[$1], [$2], m4_incr([$3]), [$4], m4_incr([$5]), [$6], [$7]])],
[HEADERS],
[[$1], m4_incr([$2]), 0, [$4], [$5], [$6], m4_incr([$7])],
[MILESTONE],
[[$1], m4_incr([$2]), 0, [$4], [$5], [$6], [$7]],
[MISCELLANEA],
[[$1], [$2], m4_incr([$3]), [$4], [$5], [$6], [$7]],
[[$1], [$2], [$3], [$4], [$5], [$6], [$7]])],
[n4_has([$8],
[LAUNCH],
[1, 0, 0, 0, 0, 0, 0],
[DEPARTURE],
[0, m4_incr([$2]), 0, 0, 0, 0, 0],
[INTERFACE],
[0, m4_incr([$2]), 0, 0, 0, 0, 0],
[HEADERS],
[0, m4_incr([$2]), 0, 0, 0, 0, 0],
[MILESTONE],
[0, m4_incr([$2]), 0, 0, 0, 0, 0],
[IMPLEMENTATION],
[0, [$2], m4_incr([$3]), 0, 0, 0, 0],
[MISCELLANEA],
[0, [$2], m4_incr([$3]), 0, 0, 0, 0],
[0, [$2], [$3], 0, 0, 0, 0])])])])
dnl NR_GET_EVENT_VSTATE(event-name, root-vstate, event1[, event2[, ...
dnl eventN]])
dnl **************************************************************************
dnl
dnl Similar to `NR_HISTORY_GET_EVENT_VSTATE()`, but not bound to any
dnl particular history (the desired history must be passed explicitly, in
dnl chronological order)
dnl
dnl This macro is mainly intended to be used internally by
dnl `NR_RECORD_HISTORY()`; you will hardly ever need it.
dnl
dnl For example, the following code
dnl
dnl NR_GET_EVENT_VSTATE([1989-04-28],
dnl
dnl [[0], [0], [0], [0], [0], [0], [0]],
dnl
dnl [[1987-11-02],
dnl [MISCELLANEA]],
dnl [[1989-04-28],
dnl [IMPLEMENTATION]],
dnl [[1991-08-13],
dnl [INTERFACE],
dnl [IMPLEMENTATION],
dnl [MISCELLANEA]])
dnl
dnl expands to
dnl
dnl 0, 0, 2, 0, 1, 0, 0
dnl
dnl The difference between `root-vstate` and `NR_RECORD_HISTORY()`'s `root`
dnl argument is that the former must always contain exactly seven integers.
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: `NR_BUMP_VSTATE()`
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([NR_GET_EVENT_VSTATE],
[m4_if([$#], [1], [], [$#], [2], [$2], [$#], [3],
[NR_BUMP_VSTATE($2, m4_dquote(m4_shift($3)))],
[m4_if([$1], m4_argn([1], $3),
[NR_BUMP_VSTATE($2, m4_dquote(m4_shift($3)))],
[NR_GET_EVENT_VSTATE([$1],
m4_dquote(NR_BUMP_VSTATE($2,
m4_dquote(m4_shift($3)))),
m4_shift3($@))])])])
dnl NR_GET_EVENT_VSTATE_RCO(event-name, root-vstate, last-event1[,
dnl last-event2[, ... first-event]])
dnl **************************************************************************
dnl
dnl Identical to `NR_GET_EVENT_VSTATE()`, but events must be listed in reverse
dnl chronological order (most recent first)
dnl
dnl For example:
dnl
dnl NR_GET_EVENT_VSTATE([1989-04-28],
dnl
dnl [[0], [0], [0], [0], [0], [0], [0]],
dnl
dnl m4_reverse([[1991-08-13],
dnl [INTERFACE],
dnl [IMPLEMENTATION],
dnl [MISCELLANEA]],
dnl [[1989-04-28],
dnl [IMPLEMENTATION]],
dnl [[1987-11-02],
dnl [MISCELLANEA]]))
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: `NR_BUMP_VSTATE()`
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([NR_GET_EVENT_VSTATE_RCO],
[NR_GET_EVENT_VSTATE([$1], [$2], m4_reverse(m4_shift2($@)))])
dnl NR_FOR_EACH_EVENT(macro-name, root-vstate, event1[, event2[, ... eventN]])
dnl **************************************************************************
dnl
dnl Similar to `NR_HISTORY_FOR_EACH_EVENT()`, but not bound to any particular
dnl history (the desired history must be passed explicitly, in chronological
dnl order)
dnl
dnl This macro is mainly intended to be used internally by
dnl `NR_HISTORY_FOR_EACH_EVENT()`; you will hardly ever need it.
dnl
dnl For example, the following code
dnl
dnl # Requires: `n4_let()` from `not-m4sugar.m4`
dnl AC_DEFUN([PRINT_RELEASE], [
dnl [##] NR_VSTATE_GET_PROJECT_VERSION($1) ($2)
dnl
dnl - n4_let([DEPARTURE],
dnl [**Major version bump** - this release is binary-incompatible with previous[]m4_newline() releases!],
dnl [INTERFACE],
dnl [The interface has changed],
dnl [HEADERS],
dnl [The public headers have changed],
dnl [MILESTONE],
dnl [One or more milestones have been reached],
dnl [IMPLEMENTATION],
dnl [The implementation has been improved],
dnl [MISCELLANEA],
dnl [Minor changes in the package],
dnl
dnl [m4_join(m4_newline()[- ], m4_unquote(m4_shift2($@)))])
dnl ])
dnl
dnl cat << 'END_HEREDOC'
dnl NR_FOR_EACH_EVENT([PRINT_RELEASE],
dnl
dnl [[1], [0], [0], [0], [0], [0], [0]],
dnl
dnl [[2018-10-21], [HEADERS], [MILESTONE]],
dnl [[2018-10-29], [MISCELLANEA]],
dnl [[2018-11-12], [IMPLEMENTATION], [MISCELLANEA]],
dnl [[2018-12-03], [IMPLEMENTATION], [HEADERS]],
dnl [[2019-02-14], [INTERFACE], [IMPLEMENTATION], [MISCELLANEA]],
dnl [[2019-03-22], [INTERFACE]],
dnl [[2019-05-07], [INTERFACE], [IMPLEMENTATION], [MISCELLANEA]],
dnl [[2019-06-10], [IMPLEMENTATION], [MILESTONE]],
dnl [[2020-01-11], [DEPARTURE]])
dnl END_HEREDOC
dnl
dnl will print
dnl
dnl ## 1.1.0 (2018-10-21)
dnl
dnl - The public headers have changed
dnl - One or more milestones have been reached
dnl
dnl ## 1.1.1 (2018-10-29)
dnl
dnl - Minor changes in the package
dnl
dnl ## 1.1.2 (2018-11-12)
dnl
dnl - The implementation has been improved
dnl - Minor changes in the package
dnl
dnl ## 1.2.0 (2018-12-03)
dnl
dnl - The implementation has been improved
dnl - The public headers have changed
dnl
dnl ## 1.3.0 (2019-02-14)
dnl
dnl - The interface has changed
dnl - The implementation has been improved
dnl - Minor changes in the package
dnl
dnl ## 1.4.0 (2019-03-22)
dnl
dnl - The interface has changed
dnl
dnl ## 1.5.0 (2019-05-07)
dnl
dnl - The interface has changed
dnl - The implementation has been improved
dnl - Minor changes in the package
dnl
dnl ## 1.6.0 (2019-06-10)
dnl
dnl - The implementation has been improved
dnl - One or more milestones have been reached
dnl
dnl ## 2.0.0 (2020-01-11)
dnl
dnl - **Major version bump** - this release is binary-incompatible with previous
dnl releases!
dnl
dnl The difference between `root-vstate` and `NR_RECORD_HISTORY()`'s `root`
dnl argument is that the former must always contain exactly seven integers.
dnl
dnl The custom macro `macro-name` is invoked with the release version as first
dnl argument, the release name as second argument, and a variable number of
dnl change tokens as variadic arguments.
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: `NR_BUMP_VSTATE()`
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
AC_DEFUN([NR_FOR_EACH_EVENT],
[m4_if([$#], [1], [], [$#], [2], [$2],
[$1(m4_dquote(NR_BUMP_VSTATE($2, m4_dquote(m4_shift($3)))), $3)[]m4_if([$#], [3], [],
[NR_FOR_EACH_EVENT([$1],
m4_dquote(NR_BUMP_VSTATE($2,
m4_dquote(m4_shift($3)))),
m4_shift3($@))])])])
dnl NR_FOR_EACH_EVENT_RCO(macro-name, root-vstate, last-event1[, last-event2[,
dnl ... first-event]])
dnl **************************************************************************
dnl
dnl Identical to `NR_FOR_EACH_EVENT()`, but events must be listed in reverse
dnl chronological order (most recent first)
dnl
dnl Despite the events are passed in reverse chronological order, the macro
dnl always iterates through them in chronological order.
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: `NR_BUMP_VSTATE()`
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([NR_FOR_EACH_EVENT_RCO],
[NR_FOR_EACH_EVENT([$1], [$2], m4_reverse(m4_shift2($@)))])
dnl NR_HISTORY_FOR_EACH_EVENT(macro-name)
dnl **************************************************************************
dnl
dnl Calls a custom macro for each event in the history, computing its version
dnl
dnl For example, the following code
dnl
dnl NR_RECORD_HISTORY([[1]],
dnl [[2018-10-21], [HEADERS], [MILESTONE]],
dnl [[2018-10-29], [MISCELLANEA]],
dnl [[2018-11-12], [IMPLEMENTATION], [MISCELLANEA]],
dnl [[2018-12-03], [IMPLEMENTATION], [HEADERS]],
dnl [[2019-02-14], [INTERFACE], [IMPLEMENTATION], [MISCELLANEA]],
dnl [[2019-03-22], [INTERFACE]],
dnl [[2019-05-07], [INTERFACE], [IMPLEMENTATION], [MISCELLANEA]],
dnl [[2019-06-10], [IMPLEMENTATION], [MILESTONE]],
dnl [[2020-01-11], [DEPARTURE]])
dnl
dnl # Requires: `n4_let()` from `not-m4sugar.m4`
dnl AC_DEFUN([PRINT_RELEASE], [
dnl [##] NR_VSTATE_GET_PROJECT_VERSION($1) ($2)
dnl
dnl - n4_let([DEPARTURE],
dnl [**Major version bump** - this release is binary-incompatible with previous[]m4_newline() releases!],
dnl [INTERFACE],
dnl [The interface has changed],
dnl [HEADERS],
dnl [The public headers have changed],
dnl [MILESTONE],
dnl [One or more milestones have been reached],
dnl [IMPLEMENTATION],
dnl [The implementation has been improved],
dnl [MISCELLANEA],
dnl [Minor changes in the package],
dnl
dnl [m4_join(m4_newline()[- ], m4_unquote(m4_shift2($@)))])
dnl ])
dnl
dnl cat << 'END_HEREDOC'
dnl NR_HISTORY_FOR_EACH_EVENT([PRINT_RELEASE])
dnl END_HEREDOC
dnl
dnl will print
dnl
dnl ## 1.1.0 (2018-10-21)
dnl
dnl - The public headers have changed
dnl - One or more milestones have been reached
dnl
dnl ## 1.1.1 (2018-10-29)
dnl
dnl - Minor changes in the package
dnl
dnl ## 1.1.2 (2018-11-12)
dnl
dnl - The implementation has been improved
dnl - Minor changes in the package
dnl
dnl ## 1.2.0 (2018-12-03)
dnl
dnl - The implementation has been improved
dnl - The public headers have changed
dnl
dnl ## 1.3.0 (2019-02-14)
dnl
dnl - The interface has changed
dnl - The implementation has been improved
dnl - Minor changes in the package
dnl
dnl ## 1.4.0 (2019-03-22)
dnl
dnl - The interface has changed
dnl
dnl ## 1.5.0 (2019-05-07)
dnl