File: HACKING

package info (click to toggle)
licenseutils 0.0.9-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 9,544 kB
  • sloc: ansic: 26,826; sh: 6,905; makefile: 710; cpp: 348; sed: 16
file content (152 lines) | stat: -rw-r--r-- 5,765 bytes parent folder | download | duplicates (4)
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
# Copyright (C) 2013, 2017 Ben Asselstine
# 
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.  This file is offered as-is,
# without any warranty.

SPECIAL NOTICE:

When you modify the program and want to test it, you have to make install
and remove your ~/.lu-shrc file if you've added a new command.

This is because the program runs itself, and it runs the version of itself
that is in the path.
To build this software from a git clone:
----

Install run-time dependencies:
libpng >= version 1.2.49
libcurl >= version 7.10.0
GNU coreutils (it needs the fmt command at runtime),
and GNU bash (the interactive licensing shell is based on bash)

Install build dependencies:
GNU autoconf, GNU automake, GNU libtool, GNU gettext, GNU Texinfo, 
GNU Help2man, GNU make, GNU gcc, GNU m4, GNU autopoint

$ ./bootstrap
$ ./configure
$ make


To add a new command to this program:

1. complete source files foo.c foo.h.  use project.c as an example.
2. add source files to src/Makefile.am.
3. in src/licensing.c: 
      include foo.h header in licensing.c.
      modify the enum such that FOO is added.
      modify lu_commands such that "[FOO] = &foo," is added.
4. add src/foo.c to po/POTFILES.in if it has any translations.
5. add src/foo.c and src/foo.h to PREBOOTSTRAPFILES in Makefile.am.

or alternatively if your new command is a script:
1. complete lush script foo (#!/usr/bin env lush).  
      use new-boilerplate.in as an example.
2. add shell script to pkglibexec_SCRIPTS in src/Makefile.am
3. in src/licensing.c:
      modify the enum such that FOO is added.
      modify lu_commands such that "[FOO] = &foo," is added.
      create struct lu_command_t foo.
4. add src/foo to PREBOOTSTRAPFILES in Makefile.am

The command name must start with a lowercase character.
The command must not have a space in it, or any other special character.

If the command is a script there will be difficulties in integrating it into the test suite because the licensing binary will expect it to live in the pkglibexecdir, but in make distcheck the installdir doesn't have the scripts (yet).   This also has the consequence of lush scripts not working the test suite.  Care needs to be taken to call the script as it exists in the builddir.  It won't even be executable yet, so you will have to explicitly call your script with the interpreter.



To add a new commenting style to this program:

1. add it to styles.ac
      add it here: enable_commenting_styles="c c++ fortran gettext groff haskell m4 pascal scheme shell texinfo /HERE/"
      and here:
       '/HERE/')support_/here/_style=1]AC_DEFINE([SUPPORT_/HERE/_STYLE],[1],
            [define to 1 if we want to support /here/ style comments])[;;
      and finally:
       AM_CONDITIONAL(SUPPORT_/HERE/_STYLE, test "x${support_/here/_style}" != "x")

2. fill out the /here/-style.c and /here/-style.h files.
   use src/c-style.[ch] as an example.

3. add it to src/styles.am
      like so:
      if SUPPORT_/HERE/_STYLE
        DEFS+=-DSUPPORT_/HERE/_STYLE
        liblicenseutils_la_SOURCES+=/here/-style.c /here/-style.h
      endif

4. add the new .c and .h to Makefile.am PREBOOTSTRAPFILES

5. add the new .c file to po/POTFILES.in

6. add the new commenting style to src/styles.c in 3 places.

      1. alphabetically at the top to include the .h file
      #ifdef SUPPORT_/HERE/_STYLE
      #include "/here/-style.h"
      #endif
      2. in order that you want the autodetection to take place in lu_styles[]
      #ifdef SUPPORT_/HERE/_STYLE
          &/here/_style,
      #endif
      3. alphabetically in the parsers array
      #ifdef SUPPORT_/HERE/_STYLE
          {&/here/_style_argp},
      #endif

----

lush is a bash shell with aliases.
the aliases are made with `licensing --generate-bashrc'
it also includes some command-line completion stuff.

if you run `licensing' without any commands it starts a lush shell.

----


the state for the program is kept in ~/.licenseutils

./selected-comment-style
the string that indicates which comment style the boilerplate should use.
the different comment style strings appear in comment.c.
no newline appears at the end of the line.
this file is used to create the prompt.
the command `choose c' or `choose shell' will change this file.

./selected-licenses
is the string that indicates which license we're using in the prompt.
the different license strings appear in the various lu_command_t structures instantiated in various license commands.
no newline appears at the end of the line.
this file is used to create the prompt.
the command `choose gplv3+' or `choose gpl' will change this file.

./top-line
is the string that begins the current working boilerplate.
this line is terminated with a new line.
the command `top foo bar' creates this file... with a line that looks like:
foo bar

./project-line
is the string that goes in between copyright holders and license notice text.
the line is terminated with a new line.
the command `project foo' creates this file... with a line that looks like:
This file is part of foo.

./license-notice
this file contains the license notices that we have chosen.
the command `choose gplv3+' or `choose gpl' will change this file.
typically this text comes from gnu.org, so it may take a moment to download.
this text is terminated with a newline.


the command new-boilerplate removes all of these files.

the preview command assembles the boilerplate from these files.

the test suite changes ${HOME} to point elsewhere so that make distcheck can complete successfully.

the licensing binary depends on the Coreutils `fmt' command being present on the system and in the user's path.