-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·52 lines (43 loc) · 1.02 KB
/
Makefile
File metadata and controls
executable file
·52 lines (43 loc) · 1.02 KB
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
vpath %.o obj
# compile macro
CC = gcc
CCFLAGS = -W -O3 -fPIC
LDFLAGS = -O3 -lm
INCLUDES = -I.
src:=$(sort $(wildcard *.c))
mainsrc:=main.c
libsrc:=$(filter-out $(mainsrc),$(src))
libobjects:=$(libsrc:.c=.o)
mainobject:=$(mainsrc:.c=.o)
exec:=polyop
libname:=libpolyboolean.so
bprefix:=bin/
oprefix:=obj/
bdir:=bin
odir:=obj
md:=mkdir -p
rd:=rm -r -f
del:=rm -f
cp:=cp -f
cd:=cp -r -f
vpath $(exec) bin
vpath $(libname) bin
# dependence
%.o: %.c|$(odir)
${CC} ${CCFLAGS} ${INCLUDES} -c $< -o $(addprefix $(oprefix),$@)
$(exec): $(mainobject) $(libname)|$(bdir)
$(CC) $(addprefix $(oprefix),$(mainobject)) -L$(bdir) -lpolyboolean -Wl,-rpath,'$$ORIGIN' $(LDFLAGS) -o $(addprefix $(bprefix),$(exec))
$(libname): $(libobjects)|$(bdir)
$(CC) -shared $(addprefix $(oprefix),$(libobjects)) $(LDFLAGS) -o $(addprefix $(bprefix),$(libname))
$(odir):
-$(md) $(odir)
$(bdir):
-$(md) $(bdir)
.PHONY:clean
clean:
-$(del) *.o $(exec)
-$(rd) $(odir) $(bdir)
.PHONY:debug
debug: CCFLAGS = -W -O0 -g -fPIC
debug: LDFLAGS = -O0 -g -lm
debug: $(exec)