-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.am
235 lines (179 loc) · 8.98 KB
/
Makefile.am
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
# Copyright 2008-2019 Douglas Wikstrom
#
# This file is part of Verificatum Elliptic Curve library (VEC).
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
.PHONY: clean cleandoc
ACLOCAL_AMFLAGS=-I m4
##################### Variables used by Automake ############################
# Installation directory of jar files.
jardir = $(datadir)/java
# Distribution file.
distfile = $(PACKAGE)-$(VERSION).tar.gz
########################## Custom variables #################################
CWD = $(shell pwd)
SRC = src
PKGPATH = $(SRC)/java
MFSRC = $(SRC)/mf
JHDROUT = native
BINDIR = bin
JARFILE = $(PACKAGE)-$(VERSION).jar
VECJ_JAR = $(jardir)/$(JARFILE)
CLASSESROOT = classes
CLASSPATH := $(CLASSESROOT)
SRC_BINDIR = $(SRC)/bin
NATLIBS = $(CWD)/native/.libs
# Code analysis
STATANA = tools/staticanalysis
CSDIR = $(STATANA)/checkstyle
FBDIR = $(STATANA)/findbugs
PMDDIR = $(STATANA)/pmd
# Coverage analysis.
COVERAGE = $(CWD)/tools/coverage
JCOVDIR = $(COVERAGE)/jcov
COBDIR = $(COVERAGE)/cobertura
# Variables pointing to external resources.
VEC_VERSION = $(shell vec-info version)
JCOVJARDIR = $(HOME)/jcov_2.0
COBHOME = $(HOME)/cobertura-2.1.1
COBCLASSPATH=$(shell find $(COBHOME) | grep "\.jar" | grep -E "cobertura.*/cobertura-[^-]*\.jar|asm-|slf4j-|logback-|oro-"| tr "\n" ":")
JDK_DOC = "http://docs.oracle.com/javase/8/docs/api"
# Java sources.
JAVA_FILES := $(PKGPATH)/com/verificatum/vecj/VEC.java \
$(PKGPATH)/com/verificatum/vecj/TestVEC.java \
$(PKGPATH)/com/verificatum/vecj/BenchVEC.java
########################### Compilation #####################################
all: headers.stamp
$(PKGPATH)/com/verificatum/vecj/VEC.java: $(PKGPATH)/com/verificatum/vecj/VEC.magic scriptmacros.m4
cat scriptmacros.m4 $(PKGPATH)/com/verificatum/vecj/VEC.magic | m4 > $(PKGPATH)/com/verificatum/vecj/VEC.java
# Create the destination directory.
classesroot.stamp:
mkdir -p $(CLASSESROOT)
@touch classesroot.stamp
# Jar manifest generated with current version.
$(CLASSESROOT)/MANIFEST.MF: $(MFSRC)/MANIFEST.MF.src
cat .macros.m4 $(MFSRC)/MANIFEST.MF.src | m4 > $(CLASSESROOT)/MANIFEST.MF
# Compile Java sources.
classes.stamp: classesroot.stamp $(JAVA_FILES)
$(JAVAC) -Xlint:unchecked $(AM_JAVACFLAGS) $(JAVACFLAGS) -d $(CLASSESROOT) $(JAVA_FILES)
@touch classes.stamp
# Build JAR file.
$(JARFILE): classes.stamp $(CLASSESROOT)/MANIFEST.MF
cd $(CLASSESROOT); $(JAR) cfm $@ MANIFEST.MF com; cp $@ ..
# Generate header files for native code.
headers.stamp: $(JARFILE)
$(JAVAC) -h $(JHDROUT) $(PKGPATH)/com/verificatum/vecj/VEC.java
@rm -f $(PKGPATH)/com/verificatum/vecj/VEC.class
@touch headers.stamp
scriptmacros.m4:
@printf "define(M4_VERSION, $(VERSION))dnl\n" > scriptmacros.m4
@printf "define(M4_VEC_VERSION, $(VEC_VERSION))dnl\n" >> scriptmacros.m4
@printf "define(M4_BINDIR, $(bindir))dnl\n" >> scriptmacros.m4
@printf "define(M4_LIBDIR, $(libdir))dnl\n" >> scriptmacros.m4
@printf "define(M4_VECJ_JAR, $(VECJ_JAR))dnl\n" >> scriptmacros.m4
$(BINDIR)/vecj-$(VERSION)-info: scriptmacros.m4 $(SRC_BINDIR)/vecj-info.src
mkdir -p $(BINDIR)
cat scriptmacros.m4 $(SRC_BINDIR)/vecj-info.src | m4 > $(BINDIR)/vecj-$(VERSION)-info
chmod +x $(BINDIR)/vecj-$(VERSION)-info
# Variables with special meaning in Autotools.
SUBDIRS = . native
# Variables that determines which files are part of the distribution
# and how they are installed.
jar_DATA = $(JARFILE)
dist_noinst_DATA = $(SRC) README.md LICENSE NEWS AUTHORS ChangeLog .version.m4 .macros.m4
dist_bin = $(BINDIR)/vecj-$(VERSION)-info
dist_bin_SCRIPTS = $(BINDIR)/vecj-$(VERSION)-info
########################## Static analysis ##################################
# Edit the wrappers in the subdirectories of $(STATANA) if needed.
# Do a Checkstyle analysis of the source and save the result in
# $(CSDIR)/checkstyle_report.txt.
checkstyle: $(CSDIR)/checkstyle_report.txt $(CSDIR)/checkstyle_filter.sh
$(CSDIR)/checkstyle_report.txt: headers.stamp
rm -f $(CSDIR)/checkstyle_report_tmp.txt
cd $(CSDIR); ./checkstyle_wrapper checkstyle_configure.xml checkstyle_raw_report.txt $(CWD)/$(PKGPATH); ./checkstyle_filter.sh checkstyle_raw_report.txt checkstyle_report.txt
# Do a Findbugs analysis of the jar and save the result in
# $(FBDIR)/findbugs_report.txt.
findbugs: $(FBDIR)/findbugs_report.txt
$(FBDIR)/findbugs_report.txt: headers.stamp
./$(FBDIR)/findbugs_wrapper -textui -exclude $(FBDIR)/findbugs_configure.xml $(JARFILE) > $(FBDIR)/findbugs_report.txt
# Do a PMD analysis of the source and save the result in
# $(PMDDIR)/pmd_report.txt. PMD does not provide any proper way of
# installation. The $(PMDDIR)/pmd_wrapper tries to find the directory
# named pmd-bin-?-?-? for the most recent version. If no such
# directory exists, then it tries the same in the home directory. Edit
# the wrapper if needed.
pmd: $(PMDDIR)/pmd_report.txt
$(PMDDIR)/pmd_report.txt: headers.stamp
./$(PMDDIR)/pmd_wrapper -rulesets $(PMDDIR)/pmd_ruleset.xml -d $(PKGPATH) | sed "s/.*verificatum\/\(com\/verificatum.*\)/\1/p" | uniq > $(PMDDIR)/pmd_raw_report.txt
cd $(PMDDIR); ./pmd_filter.sh pmd_raw_report.txt pmd_report.txt
# Execute all static analyzers.
analysis: checkstyle findbugs pmd $(STATANA)/generate_analysis.sh
cd $(STATANA); ./generate_analysis.sh
cat $(STATANA)/analysis_report.txt
########################## Coverage analysis ################################
# Set JCOVJARDIR above to use this.
jcov: headers.stamp
mkdir -p $(JCOVDIR)
cd $(JCOVDIR); rm -f filtered.xml
cp $(JARFILE) $(JCOVDIR)/
cd $(JCOVDIR); java -jar $(JCOVJARDIR)/jcov.jar Instr -t template.xml -e com.verificatum.vecj.TestVEC -e com.verificatum.vecj.BenchVEC -field on -native off $(JARFILE)
cd $(JCOVDIR); java -ea -Djava.library.path=$(NATLIBS):$(libdir) -classpath $(JCOVJARDIR)/jcov_file_saver.jar:$(JARFILE) com.verificatum.vecj.TestVEC "P-256"
cd $(JCOVDIR); java -jar $(JCOVJARDIR)/jcov.jar RepGen result.xml
# Set COBHOME above to use this. A recent version is required. After
# downloading Cobertura you need to convert the .sh files to Unix
# format with dos2unix and make them executable before running.
cobertura: headers.stamp
rm -rf $(COBDIR)
rm -f cobertura.ser
mkdir -p $(COBDIR)/classes
$(COBHOME)/cobertura-instrument.sh --ignore "java.lang.Error" --destination $(COBDIR)/classes $(CLASSESROOT)/com/verificatum/vecj/VEC.class $(CLASSESROOT)/com/verificatum/vecj/FpowmTab.class $(CLASSESROOT)/com/verificatum/vecj/MillerRabin.class
java -ea -Djava.library.path=$(NATLIBS):$(libdir) -classpath $(COBCLASSPATH):$(COBDIR)/classes:$(CLASSESROOT) com.verificatum.vecj.TestVEC "P-256"
$(COBHOME)/cobertura-report.sh --srcdir /home/dog/verificatum/vecj/src/java/ --destination $(COBDIR)/report --format html $(COBDIR)/classes
coverage: jcov cobertura
########################### Usage targets ###################################
check: headers.stamp
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(libdir) java -ea -Djava.library.path=$(NATLIBS):$(libdir) -classpath $(JARFILE):$(jardir)/$(JARFILE) com.verificatum.vecj.TestVEC
bench: headers.stamp
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(libdir) java -Djava.library.path=$(NATLIBS):$(libdir) -classpath $(JARFILE):$(jardir)/$(JARFILE) com.verificatum.vecj.BenchVEC
api: headers.stamp
rm -rf api
javadoc -d api -link $(JDK_DOC) $(JAVA_FILES)
########################## Cleaning targets #################################
# Autoconf variable for files to be cleaned.
CLEANFILES = *.stamp $(JARFILE) $(distfile) $(JHDROUT)/com_verificatum_vecj_VEC.h scriptmacros.m4 $(PKGPATH)/com/verificatum/vecj/VEC.java
cleanapi:
rm -rf api .libs
cleancheckstyle:
rm -rf $(CSDIR)/checkstyle_raw_report.txt $(CSDIR)/checkstyle_report.txt
cleanfindbugs:
rm -rf $(FBDIR)/findbugs_report.txt
cleanpmd:
rm -rf $(PMDDIR)/pmd_report.txt $(PMDDIR)/pmd_raw_report.txt
cleananalysis: cleancheckstyle cleanfindbugs cleanpmd
rm -rf $(STATANA)/analysis_report.txt
cleanjcov:
rm -rf $(JCOVDIR)
cleancobertura:
rm -rf $(COBDIR) cobertura.ser
cleancoverage: cleanjcov cleancobertura
clean-local: cleanapi cleananalysis cleancoverage
find . -name "*~" -delete
rm -rf report result.xml template.xml $(CLASSESROOT) compile $(BINDIR)/vecj-$(VERSION)-info