Skip to content

Commit eec57b6

Browse files
committed
Mac is supported now
1 parent 1b5c5a3 commit eec57b6

File tree

7 files changed

+143
-1
lines changed

7 files changed

+143
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
release.properties
55
target
66
combined/dependency-reduced-pom.xml
7+
.DS_Store

combined/pom.xml

+24
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,25 @@ See crc64.h for a separate Copyright and license notice.
105105
</dependency>
106106
</dependencies>
107107
</profile>
108+
<profile>
109+
<id>mac-x86_64</id>
110+
<activation>
111+
<os>
112+
<family>mac</family>
113+
</os>
114+
<property>
115+
<name>sun.arch.data.model</name>
116+
<value>64</value>
117+
</property>
118+
</activation>
119+
<dependencies>
120+
<dependency>
121+
<groupId>biz.karms.crc64java</groupId>
122+
<artifactId>crc64java-mac-x86_64</artifactId>
123+
<version>${project.version}</version>
124+
</dependency>
125+
</dependencies>
126+
</profile>
108127
<profile>
109128
<id>release</id>
110129
<activation>
@@ -134,6 +153,11 @@ See crc64.h for a separate Copyright and license notice.
134153
<artifactId>crc64java-linux-x86_64</artifactId>
135154
<version>${project.version}</version>
136155
</dependency>
156+
<dependency>
157+
<groupId>biz.karms.crc64java</groupId>
158+
<artifactId>crc64java-mac-x86_64</artifactId>
159+
<version>${project.version}</version>
160+
</dependency>
137161
</dependencies>
138162
</profile>
139163
</profiles>

java/pom.xml

+21
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,27 @@ See crc64.h for a separate Copyright and license notice.
108108
</dependencies>
109109
</profile>
110110

111+
<profile>
112+
<id>mac-x86_64</id>
113+
<activation>
114+
<os>
115+
<family>mac</family>
116+
</os>
117+
<property>
118+
<name>sun.arch.data.model</name>
119+
<value>64</value>
120+
</property>
121+
</activation>
122+
<dependencies>
123+
<dependency>
124+
<groupId>biz.karms.crc64java</groupId>
125+
<artifactId>crc64java-mac-x86_64</artifactId>
126+
<version>${project.version}</version>
127+
<scope>test</scope>
128+
</dependency>
129+
</dependencies>
130+
</profile>
131+
111132
<profile>
112133
<id>release</id>
113134
<activation>

java/src/main/java/biz/karms/crc64java/CRC64.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static void init() {
6565
Class sslClass = libCl.loadClass(CRC64Imp.class.getName());
6666
instance = (CRC64) sslClass.newInstance();
6767
} catch (Exception e1) {
68+
e1.printStackTrace();
6869
throw new RuntimeException(e1);
6970
}
7071
}
@@ -95,8 +96,10 @@ protected String findLibrary(String libname) {
9596
os = "linux";
9697
} else if (sysOs.startsWith("WINDOWS")) {
9798
os = "win";
99+
} else if (sysOs.startsWith("MAC")) {
100+
os = "mac";
98101
} else {
99-
throw new UnsupportedOperationException("Only Linux and Windows is supported.");
102+
throw new UnsupportedOperationException("Only Linux, Windows and Mac is supported.");
100103
}
101104
final String sysArch = System.getProperty("os.arch").toUpperCase(Locale.US);
102105
String arch;

mac-x86_64/Makefile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CC = cc
2+
SRC = crc64.c
3+
OBJ = $(patsubst %.c, target/%.o, $(SRC))
4+
5+
default: target/classes/mac-x86_64/libcrc64.dylib
6+
7+
clean:
8+
rm -rf target
9+
10+
target/classes/mac-x86_64:
11+
mkdir -p target/classes/mac-x86_64
12+
13+
target/%.o : ../libcrc64/src/%.c target/classes/mac-x86_64
14+
$(CC) $(CFLAGS) -Wall -std=c99 -fPIC -g -c $< -o $@ -I../libcrc64/include -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
15+
# $(CC) $(CFLAGS) -Werror -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wpointer-arith -std=c99 -Wdeclaration-after-statement -Wformat -Wformat-security -Wunused -Wno-unknown-pragmas -fPIC -c $< -o $@ -I../libcrc64/include -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
16+
17+
target/classes/mac-x86_64/libcrc64.dylib: $(OBJ)
18+
$(CC) $(CFLAGS) -shared $(OBJ) -o $@ $(LDFLAGS)

mac-x86_64/pom.xml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!--
2+
This file is part of CRC64Java.
3+
4+
CRC64Java is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
CRC64Java is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with Foobar. If not, see <http://www.gnu.org/licenses />.
16+
17+
See crc64.h for a separate Copyright and license notice.
18+
-->
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
22+
<parent>
23+
<groupId>biz.karms.crc64java</groupId>
24+
<artifactId>crc64java-parent</artifactId>
25+
<version>1.0.8-SNAPSHOT</version>
26+
<relativePath>../</relativePath>
27+
</parent>
28+
29+
<artifactId>crc64java-mac-x86_64</artifactId>
30+
<version>1.0.8-SNAPSHOT</version>
31+
32+
<packaging>jar</packaging>
33+
34+
<build>
35+
<plugins>
36+
<plugin>
37+
<groupId>org.apache.maven.plugins</groupId>
38+
<artifactId>maven-deploy-plugin</artifactId>
39+
<configuration>
40+
<skip>false</skip>
41+
</configuration>
42+
</plugin>
43+
<plugin>
44+
<groupId>org.codehaus.mojo</groupId>
45+
<artifactId>exec-maven-plugin</artifactId>
46+
<executions>
47+
<execution>
48+
<goals>
49+
<goal>exec</goal>
50+
</goals>
51+
<phase>generate-resources</phase>
52+
</execution>
53+
</executions>
54+
<configuration>
55+
<executable>gmake</executable>
56+
</configuration>
57+
</plugin>
58+
</plugins>
59+
</build>
60+
</project>

pom.xml

+15
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,20 @@ See crc64.h for a separate Copyright and license notice.
147147
<module>windows-x86_64</module>
148148
</modules>
149149
</profile>
150+
<profile>
151+
<id>mac-x86_64</id>
152+
<activation>
153+
<os>
154+
<family>mac</family>
155+
</os>
156+
<property>
157+
<name>sun.arch.data.model</name>
158+
<value>64</value>
159+
</property>
160+
</activation>
161+
<modules>
162+
<module>mac-x86_64</module>
163+
</modules>
164+
</profile>
150165
</profiles>
151166
</project>

0 commit comments

Comments
 (0)