File: Makefile_common.mk

package info (click to toggle)
octave-iso2mesh 1.9.8%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 11,128 kB
  • sloc: cpp: 11,982; ansic: 10,158; sh: 365; makefile: 59
file content (114 lines) | stat: -rwxr-xr-x 2,813 bytes parent folder | download
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
########################################################
#
#  Makefile for Compiling External Tools needed by Iso2Mesh
#  Copyright (C) 2018 Qianqian Fang <q.fang at neu.edu>
#
########################################################

########################################################
# Base Makefile for all example/tests and main program
#
# This file specifies the compiler options for compiling
# and linking
########################################################

ifndef ROOTDIR
ROOTDIR := .
endif

ifndef I2MDIR
I2MDIR := $(ROOTDIR)
endif

BXDSRC :=$(I2MDIR)/src

CXX        := g++
CC         := gcc
AR         := g++
BIN        := ../bin
BUILT      := built
BINDIR     := $(BIN)
OBJDIR 	   := $(BUILT)
CCFLAGS    := -c -Wall -O3  #-g
INCLUDEDIR := $(I2MDIR)/src
ARFLAGS    :=
AROUTPUT   := -o
MAKE       :=make
CMAKE      :=cmake

COPY	 := cp
ECHO	 := echo
MKDIR    := mkdir

OBJSUFFIX        := .o
BINSUFFIX        := 

OBJS      := $(addprefix $(OBJDIR)/, $(FILES))
OBJS      := $(subst $(OBJDIR)/$(BXDSRC)/,$(BXDSRC)/,$(OBJS))
OBJS      := $(addsuffix $(OBJSUFFIX), $(OBJS))

TARGETSUFFIX:=$(suffix $(BINARY))

ifeq ($(TARGETSUFFIX),.so)
	CCFLAGS+= -fPIC 
	ARFLAGS+= -shared -Wl,-soname,$(BINARY).1 
endif

ifeq ($(TARGETSUFFIX),.a)
        CCFLAGS+=
	AR         := ar
        ARFLAGS    := r
	AROUTPUT   :=
endif

all: $(SUBDIRS) makedirs copybin

$(SUBDIRS):
	if test -f $@/CMakeLists.txt; then cd $@ && $(CMAKE) . && cd ..; fi
	$(MAKE) -C $@ --no-print-directory

copybin:
	@$(COPY) cgalmesh/mesh_3D_image           ../bin/cgalmesh
	@$(COPY) cgalmesh/mesh_polyhedral_domain  ../bin/cgalpoly
	@$(COPY) cgalsurf/mesh_a_3d_gray_image    ../bin/cgalsurf
	@$(COPY) cgalsimp2/edge_collapse_enriched_polyhedron  ../bin/cgalsimp2
	@$(COPY) cork/bin/cork  ../bin/cork
	@$(COPY) meshfix/meshfix  ../bin/meshfix
	@$(COPY) meshfix/contrib/JMeshLib/test/jmeshlib  ../bin/jmeshlib
	@$(COPY) tetgen/tetgen  ../bin/tetgen1.5

makedirs:
	@if test ! -d $(BINDIR); then $(MKDIR) $(BINDIR); fi
#	@if test ! -d $(OBJDIR); then $(MKDIR) $(OBJDIR); fi

.SUFFIXES : $(OBJSUFFIX) .cpp

##  Compile .cpp files ##
$(OBJDIR)/%$(OBJSUFFIX): %.cpp
	@$(ECHO) Building $@
	$(CXX) $(CCFLAGS) $(USERCCFLAGS) -I$(INCLUDEDIR) -o $@  $<

##  Compile .cpp files ##
%$(OBJSUFFIX): %.cpp
	@$(ECHO) Building $@
	$(CXX) $(CCFLAGS) $(USERCCFLAGS) -I$(INCLUDEDIR) -o $@  $<

##  Compile .c files  ##
$(OBJDIR)/%$(OBJSUFFIX): %.c
	@$(ECHO) Building $@
	$(CC) $(CCFLAGS) $(USERCCFLAGS) -I$(INCLUDEDIR) -o $@  $<

##  Link  ##
$(BINDIR)/$(BINARY): $(OBJS)
	@$(ECHO) Building $@
	$(AR)  $(ARFLAGS) $(AROUTPUT) $@ $(OBJS) $(USERARFLAGS)

## Clean
clean:
	rm -rf $(OBJS) $(OBJDIR) #$(BINDIR)
ifdef SUBDIRS
	for i in $(SUBDIRS); do $(MAKE) --no-print-directory -C $$i clean; done
endif

.PHONY: regression clean arch makedirs dep $(SUBDIRS)