Skip to content

Commit befb81a

Browse files
committed
Improve Makefile to support build shared library and update the documentation
1 parent 7f3c052 commit befb81a

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

Makefile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ vpath %.o obj
22

33
# compile macro
44
CC = gcc
5-
CCFLAGS = -W -O3
5+
CCFLAGS = -W -O3 -fPIC
66
LDFLAGS = -O3 -lm
77
INCLUDES = -I.
88

99
src:=$(sort $(wildcard *.c))
10-
objects:=$(src:.c=.o)
10+
mainsrc:=main.c
11+
libsrc:=$(filter-out $(mainsrc),$(src))
12+
libobjects:=$(libsrc:.c=.o)
13+
mainobject:=$(mainsrc:.c=.o)
1114
exec:=polyop
15+
libname:=libpolyboolean.so
1216
bprefix:=bin/
1317
oprefix:=obj/
1418
bdir:=bin
@@ -20,14 +24,21 @@ cp:=cp -f
2024
cd:=cp -r -f
2125

2226
vpath $(exec) bin
27+
vpath $(libname) bin
2328

2429
# dependence
2530
%.o: %.c|$(odir)
2631
${CC} ${CCFLAGS} ${INCLUDES} -c $< -o $(addprefix $(oprefix),$@)
27-
$(exec):$(objects)|$(bdir)
28-
$(CC) $(addprefix $(oprefix),$(objects)) $(LDFLAGS) -o $(addprefix $(bprefix),$(exec))
32+
33+
$(exec): $(mainobject) $(libname)|$(bdir)
34+
$(CC) $(addprefix $(oprefix),$(mainobject)) -L$(bdir) -lpolyboolean -Wl,-rpath,'$$ORIGIN' $(LDFLAGS) -o $(addprefix $(bprefix),$(exec))
35+
36+
$(libname): $(libobjects)|$(bdir)
37+
$(CC) -shared $(addprefix $(oprefix),$(libobjects)) $(LDFLAGS) -o $(addprefix $(bprefix),$(libname))
38+
2939
$(odir):
3040
-$(md) $(odir)
41+
3142
$(bdir):
3243
-$(md) $(bdir)
3344

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The C codes in this repository are extracted and extended from one Computer Aide
55

66
Data structure
77

8-
The data structure for polygons is just array in double precision floating number which represents ordered points set in 3D space. The order of points set in the first (poly1) and second (poly2) polygon should be identical (both clockwise or both counterclockwise). Obviously the polygons should be planar (or approximately planar based on geometric tolerance) for valid Boolean operations. The reason why the polygons are 3D is the application scenarios in CAE is always three dimensional and some approximate cases should be treated. Because the focus of functions in the codes is on Boolean operations of two polygons, no extra tree-like data structure is introduced to improve the efficiency of geometric calculation, which is commonly used in Boolean operations of polygons (graphs) in large amount. The application in CAE shows the codes are efficient if the number of points and Boolean operations are not larger than 1M.
8+
The data structure for polygons is just array in double precision floating number which represents ordered points set in 3D space. The order of points set in the first (poly1) and second (poly2) polygon should be identical (both clockwise or both counterclockwise if viewing along a certain direction). Obviously the polygons should be planar (or approximately planar based on geometric tolerance) for valid Boolean operations. The reason why the polygons are 3D is that the application scenarios in CAE is always three dimensional and some approximate cases should be treated. Because the focus of functions in the codes is on Boolean operations of two polygons, no extra tree-like data structure is introduced to improve the efficiency of geometric calculation, which is commonly used in Boolean operations of polygons (graphs) in large amount. The application in CAE shows the codes are efficient if the number of points and Boolean operations are not larger than 1M.
99

1010
Algorithm
1111

0 commit comments

Comments
 (0)