-
Notifications
You must be signed in to change notification settings - Fork 96
/
Makefile.common
282 lines (241 loc) · 13.7 KB
/
Makefile.common
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
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Comment in if using Cygwin:
#SHELL:=/bin/bash
TARGET:=target
SRC:=src/main/java
SRC_NATIVE:=src/main/native
ifndef VERSION
$(error Set VERSION environment variable)
endif
ifndef JAVA_HOME
$(error Set JAVA_HOME environment variable)
endif
JAVA := "$(JAVA_HOME)/bin/java"
JAVAC := "$(JAVA_HOME)/bin/javac"
JAVAH := "$(JAVA_HOME)/bin/javah"
OSINFO_CLASS := org.apache.commons.crypto.OsInfo
OSINFO_PROG := $(TARGET)/classes/org/apache/commons/crypto/OsInfo.class
OS_NAME := $(shell $(JAVA) -cp $(TARGET)/classes $(OSINFO_CLASS) --os)
OS_ARCH := $(shell $(JAVA) -cp $(TARGET)/classes $(OSINFO_CLASS) --arch)
LIB_FOLDER := $(shell $(JAVA) -cp $(TARGET)/classes $(OSINFO_CLASS))
commons-crypto := commons-crypto-$(VERSION)
jni_md := $(shell find -L "$(JAVA_HOME)" -name jni_md.h | head -1)
ifneq ($(jni_md),)
jni_include := $(shell dirname "$(jni_md)")
endif
# os=Default is meant to be generic Unix/Linux
# The following list must include all OS entries below (apart from Default)
# Also there should be a target in the makefile for each of the combinations
# For example, 'Linux-x86' is invoked by the target 'linux32'
known_os_archs := Linux-x86 Linux-x86_64 Linux-aarch64 Linux-riscv64 Linux-arm Linux-armhf Linux-ppc Linux-ppc64 \
Mac-x86 Mac-x86_64 Mac-arm64 Mac-aarch64 \
FreeBSD-x86_64 \
Windows-x86 Windows-x86_64 \
SunOS-x86 SunOS-sparc SunOS-x86_64 \
AIX-ppc64
os_arch := $(OS_NAME)-$(OS_ARCH)
ifeq (,$(findstring $(strip $(os_arch)),$(known_os_archs)))
os_arch := Default
endif
os_folder := $(shell echo $(OS_NAME) | tr A-Z a-z)
# cross-compilation toolchain prefix (e.g. "arm-linux-gnueabi-")
CROSS_PREFIX :=
Default_CC := $(CROSS_PREFIX)gcc
Default_CXX := $(CROSS_PREFIX)g++
Default_STRIP := $(CROSS_PREFIX)strip
Default_CFLAGS := -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden
Default_CXXFLAGS := -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden
Default_LINKFLAGS := -shared -static
Default_LIBNAME := libcommons-crypto.so
Default_COMMONS_CRYPTO_FLAGS :=
Linux-x86_CC := $(CROSS_PREFIX)gcc
Linux-x86_CXX := $(CROSS_PREFIX)g++
Linux-x86_STRIP := $(CROSS_PREFIX)strip
Linux-x86_CXXFLAGS := -I"$(JAVA_HOME)/include" -O2 -fPIC -fvisibility=hidden -m32
Linux-x86_CFLAGS := -I"$(JAVA_HOME)/include" -O2 -fPIC -fvisibility=hidden -m32
Linux-x86_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-x86_LIBNAME := libcommons-crypto.so
Linux-x86_COMMONS_CRYPTO_FLAGS:=
Linux-x86_64_CC := $(CROSS_PREFIX)gcc
Linux-x86_64_CXX := $(CROSS_PREFIX)g++
Linux-x86_64_STRIP := $(CROSS_PREFIX)strip
Linux-x86_64_CXXFLAGS := -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64 -Wall -Werror
Linux-x86_64_CFLAGS := -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64 -Wall -Werror
Linux-x86_64_LINKFLAGS := -shared -static-libgcc
Linux-x86_64_LIBNAME := libcommons-crypto.so
Linux-x86_64_COMMONS_CRYPTO_FLAGS :=
Linux-ppc_CC := gcc
Linux-ppc_CXX := g++
Linux-ppc_STRIP := strip
Linux-ppc_CXXFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m32
Linux-ppc_CFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m32
Linux-ppc_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-ppc_LIBNAME := libcommons-crypto.so
Linux-ppc_COMMONS_CRYPTO_FLAGS :=
Linux-ppc64_CC := gcc
Linux-ppc64_CXX := g++
Linux-ppc64_STRIP := strip
Linux-ppc64_CXXFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64
Linux-ppc64_CFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64
Linux-ppc64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-ppc64_LIBNAME := libcommons-crypto.so
Linux-ppc64_COMMONS_CRYPTO_FLAGS :=
AIX-ppc64_CC := gcc
AIX-ppc64_CXX := g++
AIX-ppc64_STRIP := strip -X64
AIX-ppc64_CXXFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64
AIX-ppc64_CFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64
AIX-ppc64_LINKFLAGS := -shared -static-libgcc -static-libstdc++ -lcrypt
AIX-ppc64_LIBNAME := libcommons-crypto.a
AIX-ppc64_COMMONS_CRYPTO_FLAGS :=
SunOS-x86_CC := gcc
SunOS-x86_CXX := g++
SunOS-x86_STRIP := strip
SunOS-x86_CFLAGS := -include lib/inc_linux/jni_md.h -I"$(JAVA_HOME)/include" -O2 -fPIC -fvisibility=hidden
SunOS-x86_CXXFLAGS := -include lib/inc_linux/jni_md.h -I"$(JAVA_HOME)/include" -O2 -fPIC -fvisibility=hidden
SunOS-x86_LINKFLAGS := -shared -static-libgcc -static-libstdc++
SunOS-x86_LIBNAME := libcommons-crypto.so
SunOS-x86_COMMONS_CRYPTO_FLAGS :=
SunOS-sparc_CC := gcc
SunOS-sparc_CXX := g++
SunOS-sparc_STRIP := strip
SunOS-sparc_CFLAGS := -include lib/inc_linux/jni_md.h -I"$(JAVA_HOME)/include" -O2 -fPIC -fvisibility=hidden
SunOS-sparc_CXXFLAGS := -include lib/inc_linux/jni_md.h -I"$(JAVA_HOME)/include" -O2 -fPIC -fvisibility=hidden
SunOS-sparc_LINKFLAGS := -shared -static-libgcc -static-libstdc++
SunOS-sparc_LIBNAME := libcommons-crypto.so
SunOS-sparc_COMMONS_CRYPTO_FLAGS :=
SunOS-x86_64_CC := gcc
SunOS-x86_64_CXX := g++
SunOS-x86_64_STRIP := strip
SunOS-x86_64_CFLAGS := -include lib/inc_linux/jni_md.h -I"$(JAVA_HOME)/include" -O2 -fPIC -fvisibility=hidden -m64
SunOS-x86_64_CXXFLAGS := -include lib/inc_linux/jni_md.h -I"$(JAVA_HOME)/include" -O2 -fPIC -fvisibility=hidden -m64
SunOS-x86_64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
SunOS-x86_64_LIBNAME := libcommons-crypto.so
SunOS-x86_64_COMMONS_CRYPTO_FLAGS :=
# '-include lib/inc_linux/jni_md.h' is used to force the use of our version,
# which defines JNIEXPORT differently; otherwise, since OpenJDK includes
# jni_md.h in same directory as jni.h, the include path is ignored when
# jni_md.h is included from jni.h
Linux-arm_CC := $(CROSS_PREFIX)gcc
Linux-arm_CXX := $(CROSS_PREFIX)g++
Linux-arm_STRIP := $(CROSS_PREFIX)strip
Linux-arm_CFLAGS := -Ilib/inc_linux -I"$(JAVA_HOME)/include" -O2 -fPIC -fvisibility=hidden -mfloat-abi=softfp
Linux-arm_CXXFLAGS := -Ilib/inc_linux -I"$(JAVA_HOME)/include" -O2 -fPIC -fvisibility=hidden -mfloat-abi=softfp
Linux-arm_LINKFLAGS := -shared -static-libgcc
Linux-arm_LIBNAME := libcommons-crypto.so
Linux-arm_COMMONS_CRYPTO_FLAGS:=
Linux-armhf_CC := $(CROSS_PREFIX)gcc
Linux-armhf_CXX := $(CROSS_PREFIX)g++
Linux-armhf_STRIP := $(CROSS_PREFIX)strip
Linux-armhf_CFLAGS := -Ilib/inc_linux -I"$(JAVA_HOME)/include" -O2 -fPIC -fvisibility=hidden -mfloat-abi=hard
Linux-armhf_CXXFLAGS := -Ilib/inc_linux -I"$(JAVA_HOME)/include" -O2 -fPIC -fvisibility=hidden -mfloat-abi=hard
Linux-armhf_LINKFLAGS := -shared -static-libgcc
Linux-armhf_LIBNAME := libcommons-crypto.so
Linux-armhf_COMMONS_CRYPTO_FLAGS:=
Linux-aarch64_CC := $(CROSS_PREFIX)gcc
Linux-aarch64_CXX := $(CROSS_PREFIX)g++
Linux-aarch64_STRIP := $(CROSS_PREFIX)strip
Linux-aarch64_CXXFLAGS := -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -Wall -Werror
Linux-aarch64_CFLAGS := -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -Wall -Werror
Linux-aarch64_LINKFLAGS := -shared -static-libgcc
Linux-aarch64_LIBNAME := libcommons-crypto.so
Linux-aarch64_COMMONS_CRYPTO_FLAGS :=
Linux-riscv64_CC := $(CROSS_PREFIX)gcc
Linux-riscv64_CXX := $(CROSS_PREFIX)g++
Linux-riscv64_STRIP := $(CROSS_PREFIX)strip
Linux-riscv64_CXXFLAGS := -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -Wall -Werror
Linux-riscv64_CFLAGS := -Ilib/inc_linux -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -Wall -Werror
Linux-riscv64_LINKFLAGS := -shared -static-libgcc
Linux-riscv64_LIBNAME := libcommons-crypto.so
Linux-riscv64_COMMONS_CRYPTO_FLAGS :=
# For GitHub on macos-14, this needs to be defined as /opt/homebrew/include
ifndef Mac_INC_OPENSSL
Mac_INC_OPENSSL := /usr/local/opt/openssl/include
endif
Mac-x86_CC := gcc -arch i386
Mac-x86_CXX := g++ -arch i386
Mac-x86_STRIP := strip -x
Mac-x86_CFLAGS := -Ilib/inc_mac -I"$(JAVA_HOME)/include" -O2 -fPIC -mmacosx-version-min=10.4 -fvisibility=hidden -I/usr/local/include -I$(Mac_INC_OPENSSL)
Mac-x86_CXXFLAGS := -Ilib/inc_mac -I"$(JAVA_HOME)/include" -O2 -fPIC -mmacosx-version-min=10.4 -fvisibility=hidden -I/usr/local/include -I$(Mac_INC_OPENSSL)
Mac-x86_LINKFLAGS := -dynamiclib -static-libgcc -L/usr/local/lib
Mac-x86_LIBNAME := libcommons-crypto.jnilib
Mac-x86_COMMONS_CRYPTO_FLAGS :=
Mac-x86_64_CC := gcc -arch $(OS_ARCH)
Mac-x86_64_CXX := gcc -arch $(OS_ARCH)
Mac-x86_64_STRIP := strip -x
Mac-x86_64_CFLAGS := -Ilib/inc_mac -I"$(JAVA_HOME)/include" -O2 -fPIC -mmacosx-version-min=10.7 -fvisibility=hidden -I/usr/local/include -I$(Mac_INC_OPENSSL)
Mac-x86_64_CXXFLAGS := -Ilib/inc_mac -I"$(JAVA_HOME)/include" -O2 -fPIC -mmacosx-version-min=10.7 -fvisibility=hidden -I/usr/local/include -I$(Mac_INC_OPENSSL)
Mac-x86_64_LINKFLAGS := -dynamiclib -L/usr/local/lib
Mac-x86_64_LIBNAME := libcommons-crypto.jnilib
Mac-x86_64_COMMONS_CRYPTO_FLAGS :=
Mac-arm64_CC := gcc -arch $(OS_ARCH)
Mac-arm64_CXX := gcc -arch $(OS_ARCH)
Mac-arm64_STRIP := strip -x
Mac-arm64_CFLAGS := -Ilib/inc_mac -I"$(JAVA_HOME)/include" -O2 -fPIC -mmacosx-version-min=11.0 -fvisibility=hidden -I/usr/local/include -I$(Mac_INC_OPENSSL)
Mac-arm64_CXXFLAGS := -Ilib/inc_mac -I"$(JAVA_HOME)/include" -O2 -fPIC -mmacosx-version-min=11.0 -fvisibility=hidden -I/usr/local/include -I$(Mac_INC_OPENSSL)
Mac-arm64_LINKFLAGS := -dynamiclib -L/usr/local/lib
Mac-arm64_LIBNAME := libcommons-crypto.jnilib
Mac-arm64_COMMONS_CRYPTO_FLAGS :=
Mac-aarch64_CC := gcc -arch arm64
Mac-aarch64_CXX := gcc -arch arm64
Mac-aarch64_STRIP := strip -x
Mac-aarch64_CFLAGS := -Ilib/inc_mac -I"$(JAVA_HOME)/include" -O2 -fPIC -mmacosx-version-min=11.0 -fvisibility=hidden -I/usr/local/include -I$(Mac_INC_OPENSSL)
Mac-aarch64_CXXFLAGS := -Ilib/inc_mac -I"$(JAVA_HOME)/include" -O2 -fPIC -mmacosx-version-min=11.0 -fvisibility=hidden -I/usr/local/include -I$(Mac_INC_OPENSSL)
Mac-aarch64_LINKFLAGS := -dynamiclib -L/usr/local/lib
Mac-aarch64_LIBNAME := libcommons-crypto.jnilib
Mac-aarch64_COMMONS_CRYPTO_FLAGS :=
FreeBSD-x86_64_CC := $(CROSS_PREFIX)gcc
FreeBSD-x86_64_CXX := $(CROSS_PREFIX)g++
FreeBSD-x86_64_STRIP := $(CROSS_PREFIX)strip
FreeBSD-x86_64_CFLAGS := -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden
FreeBSD-x86_64_CXXFLAGS := -I"$(JAVA_HOME)/include" -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden
FreeBSD-x86_64_LINKFLAGS := -shared -static-libgcc
FreeBSD-x86_64_LIBNAME := libcommons-crypto.so
FreeBSD-x86_64_COMMONS_CRYPTO_FLAGS :=
Windows-x86_CC := $(CROSS_PREFIX)gcc
Windows-x86_CXX := $(CROSS_PREFIX)g++
Windows-x86_STRIP := $(CROSS_PREFIX)strip
Windows-x86_CFLAGS := -I/usr/share/mingw-w64/include -I"$(JAVA_HOME)/include" -I"$(OPENSSL_HOME)/include" -Ilib/inc_win -O2 -fno-inline
Windows-x86_CXXFLAGS := -I/usr/share/mingw-w64/include -I"$(JAVA_HOME)/include" -I"$(OPENSSL_HOME)/include" -Ilib/inc_win -O2 -fno-inline
Windows-x86_LINKFLAGS := -Wl,--kill-at -shared -static
Windows-x86_LIBNAME := commons-crypto.dll
Windows-x86_COMMONS_CRYPTO_FLAGS :=
Windows-x86_64_CC := $(CROSS_PREFIX)gcc
Windows-x86_64_CXX := $(CROSS_PREFIX)g++
Windows-x86_64_STRIP := $(CROSS_PREFIX)strip
Windows-x86_64_CFLAGS := -I/usr/share/mingw-w64/include -I"$(JAVA_HOME)/include" -I"$(OPENSSL_HOME)/include" -Ilib/inc_win -O2 -fno-inline
Windows-x86_64_CXXFLAGS := -I/usr/share/mingw-w64/include -I"$(JAVA_HOME)/include" -I"$(OPENSSL_HOME)/include" -Ilib/inc_win -O2 -fno-inline
Windows-x86_64_LINKFLAGS := -Wl,--kill-at -shared -static
Windows-x86_64_LIBNAME := commons-crypto.dll
Windows-x86_64_COMMONS-CRYPTO_FLAGS :=
STRIP := $($(os_arch)_STRIP)
CC := $($(os_arch)_CC)
CXX := $($(os_arch)_CXX)
STRIP := $($(os_arch)_STRIP)
CFLAGS := $($(os_arch)_CFLAGS)
CXXFLAGS := $($(os_arch)_CXXFLAGS)
LINKFLAGS := $($(os_arch)_LINKFLAGS)
LIBNAME := $($(os_arch)_LIBNAME)
COMMONS-CRYPTO_FLAGS := $($(os_arch)_COMMONS-CRYPTO_FLAGS)
CFLAGS := $(CFLAGS) -Ilib/include -I/usr/include -I"$(SRC_NATIVE)/org/apache/commons/crypto/"
CXXFLAGS := $(CXXFLAGS) -Ilib/include -I/usr/include
ifneq ($(jni_include),)
CFLAGS := $(CFLAGS) -I"$(jni_include)" -I"$(TARGET)/jni-classes"
CXXFLAGS := $(CXXFLAGS) -I"$(jni_include)" -I"$(TARGET)/jni-classes"
endif