aboutsummaryrefslogtreecommitdiff
path: root/zinclib.d/Makefile
blob: 3a9d9d92128c81eb7bfedd309dcbfeecf53ceb5b (plain)
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
########################################
#      Makefile for zinclib            #
########################################

# default
all: zinclib





######################################################################
#           IntuiKit common Makefile                                 #
#                                                                    #
#     This software is the property of IntuiLab SA, France.          #
#                                                                    #
#     Contributors:                                                  #
#         Benoit Peccatte <peccatte@intuilab.com>                    #
#                                                                    #
######################################################################

## remove when no more in development
DEBUG :=1

##################################
# Default GNU compilation options
##################################
CXX      := g++
GCC      := g++
LIBEXT   := .so
EXE      :=
DELFILES :=

PROFILE     =
MACRO       =
LIBDIR      = ./lib
INCLUDE     = -isystem ./include
LDFLAGS     = $(PROFILE) -L$(LIBDIR)
CXXFLAGS    = -Wall -fpermissive $(MACRO) $(PROFILE) $(INCLUDE)
INCLUDES    = -fno-rtti
LIBLDFLAGS  = -shared $(LDFLAGS) -Wl,-export-dynamic
LIBCXXFLAGS = -fPIC $(CXXFLAGS)


###################################
# Automatic architecture detection
###################################
ifndef ARCH
ARCH := $(shell uname -s)
endif

# linux
ifeq ($(ARCH),Linux)
LIBEXT  := .so
MACRO   += -DLINUX
LDFLAGS += -ldl
endif

# MacOSX
ifeq ($(ARCH),Darwin)
LIBEXT  := .dylib
MACRO   += -DMACOSX_BSD
LDFLAGS += -ldl
LIBLDFLAGS  = -Wl,-single_module -dynamiclib $(LDFLAGS)
endif

# Windows cross compile
ifeq ($(ARCH),win32)
CXX     := i386-mingw32msvc-g++
GCC     := i386-mingw32msvc-gcc
LIBEXT  := .dll
EXE     := .exe
MACRO   += -DWIN32
LDFLAGS += -L$(EXPAT_HOME)
endif

# native windows 2K, XP
ifeq ($(ARCH),MINGW32_NT-5.1)
LIBEXT  := .dll
EXE     := .exe
MACRO   += -DWIN32
endif



###################
# Options handling
###################

##### DEBUG options
ifdef DEBUG
CXXFLAGS += -g
endif

##### Profiling options
ifdef PROF
PROFILE    = -pg -fprofile-arcs -ftest-coverage
DELFILES  += *.gcov *.bb *.bbg *.da gmon.out
endif

##### Purify coverage options
ifdef COV
GCC := purecov $(GCC)
DELFILES  += *.pcv
endif

##### Purify options
ifdef PURIFY
GCC := purify -view-file=pure.pv $(GCC)
DELFILES  += .pure* *_pure_* pure.pv
endif

##### Options to display more warnings
ifdef VERBOSE
CXXFLAGS += -Wctor-dtor-privacy -Wnon-virtual-dtor
CXXFLAGS += -Wold-style-cast -Woverloaded-virtual
CXXFLAGS += -Wsign-promo -Wsynth -Wsynth -pedantic -Wchar-subscripts
CXXFLAGS += -Wcomment -Wimplicit -Wmissing-braces -Wparentheses
CXXFLAGS += -Wreturn-type -Wswitch -Wtrigraphs -Wunused
CXXFLAGS += -Wreorder -Wunknown-pragmas -W -Wsign-compare
CXXFLAGS += -Wfloat-equal -Wundef -Wlarger-than-1000
CXXFLAGS += -Wpointer-arith -Wcast-qual -Wcast-align
CXXFLAGS += -Wstrict-prototypes -Wmissing-prototypes
CXXFLAGS += -Wmissing-noreturn -Wmissing-format-attribute -Wpacked
CXXFLAGS += -Wredundant-decls -Wunreachable-code -Winline
CXXFLAGS += -Wdisabled-optimization -Wconversion -Wshadow 
CXXFLAGS += -O0
ifeq ($(VERBOSE),2)
CXXFLAGS += -Wpadded -Wabi -Weffc++ -Waggregate-return -Wwrite-strings
endif
endif

##### Optimization options
ifdef OPTIMIZE
CXXFLAGS += -O$(OPTIMIZE) -Wuninitialized
endif

#########################################################
#     END  OF IntuiKit Common                           #
#########################################################

# specific options
LDFLAGS += -ltcl8.4 -ltk8.4 -lTkZinc

# easy target
zinclib: tmp/zinclib.o

tmp/zinclib.o: tmp/ZincObjects.o tmp/ZincPath.o tmp/Zinc.o
	ld -r -o $@ $^

# generic target
tmp/%.o: src/%.cpp
	@mkdir -p tmp
	$(CXX) $(LIBCXXFLAGS) -o $@ -c $<

clean:
	rm -f tmp/*.o $(PROFFILES)

# documentation
doc:
	cd src; doxygen ../doxyConfig
	mkdir -p doc
	rm -rf doc/html
	mv src/docs/* doc
	rmdir src/docs

# tests
test:
	cd test; $(MAKE)
	cd test; ./runtests.sh

.PHONY: test doc