-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.mk
177 lines (149 loc) · 4.32 KB
/
common.mk
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
174
175
176
177
CC = gcc
CPP = g++
LFLAGS_LIB =
LFLAGS_APP = -L${SEABREEZE}/lib
CFLAGS_BASE = -I${SEABREEZE}/include \
-c \
-Wall \
-Wunused \
-Wmissing-include-dirs \
-Werror \
-g \
-O0 \
-fpic \
-fno-stack-protector \
-shared
export UNAME = $(shell uname)
# MacOS X configuration
ifeq ($(UNAME), Darwin)
LIBBASENAME = libseabreeze
SUFFIX = dylib
LFLAGS_APP += -L/usr/lib \
-lstdc++
LFLAGS_LIB += -dynamic \
-dynamiclib \
-framework Carbon \
-framework CoreFoundation \
-framework IOKit
CFLAGS_BASE = -I${SEABREEZE}/include \
-c \
-Wall \
-Wunused \
-Wmissing-include-dirs \
-Werror \
-g \
-O0 \
-fpic \
-fno-stack-protector
# Cygwin-32 configuration
else ifeq ($(findstring CYGWIN, $(UNAME)), CYGWIN)
# caller can override this, but this is the current Ocean Optics default
VISUALSTUDIO_PROJ ?= VisualStudio2015bbbbbbb
LIBBASENAME = SeaBreeze
SUFFIX = dll
CFLAGS_BASE = -I${SEABREEZE}/include \
-c \
-Wall \
-Wunused \
-Werror \
-ggdb3 \
-shared
# MinGW-32 configuration
else ifeq ($(findstring MINGW, $(UNAME)), MINGW)
SUFFIX = dll
LIBBASENAME = libseabreeze
LFLAGS_APP += -L/local/lib \
-lusb0 \
-lstdc++ \
-lm
LFLAGS_LIB += -L/local/lib \
-lusb0 \
-shared
# Linux configuration
else
SUFFIX = so
LIBBASENAME = libseabreeze
LFLAGS_APP += -L/usr/lib \
-lstdc++ \
-lusb-1.0 \
-lm
LFLAGS_LIB += -L/usr/lib \
-shared \
-lusb-1.0
endif
# enable Logger
ifndef logger
logger = 1
endif
ifeq ($(logger),1)
CFLAGS_BASE += -DOOI_DEBUG
endif
# osx install name
ifdef install_name
LFLAGS_LIB += -install_name $(install_name)
endif
# these are for the .o files making up libseabreeze
CPPFLAGS = $(CFLAGS_BASE)
CFLAGS = $(CFLAGS_BASE) -std=gnu99
# allow for a 32 bit build
ifdef wordwidth
ifeq ($(wordwidth),32)
CPPFLAGS += -arch i386
CFLAGS += -arch i386
LFLAGS_APP += -arch i386
LFLAGS_LIB += -arch i386
endif
ifeq ($(wordwidth),fat)
CPPFLAGS += -arch i386 -arch x86_64
CFLAGS += -arch i386 -arch x86_64
LFLAGS_APP += -arch i386 -arch x86_64
LFLAGS_LIB += -arch i386 -arch x86_64
endif
endif
export LIBNAME=$(LIBBASENAME).$(SUFFIX)
SUFFIXES = .c .cpp .o .d
SRCS_CPP := $(wildcard *.cpp)
DEPS_CPP := $(patsubst %.cpp,%.d,$(SRCS_CPP))
OBJS_CPP := $(patsubst %.cpp,%.o,$(SRCS_CPP))
SRCS_C := $(wildcard *.c)
DEPS_C := $(patsubst %.c,%.d,$(SRCS_C))
OBJS_C := $(patsubst %.c,%.o,$(SRCS_C))
VISUALSTUDIO_PROJECTS = VisualStudio2005 \
VisualStudio2010 \
VisualStudio2012 \
VisualStudio2013 \
VisualStudio2015
ifneq ($(MAKECMDGOALS),clean)
-include $(DEPFILES)
endif
deps: ${DEPS_CPP} ${DEPS_C}
%.d: %.cpp
@echo caching $@
@${CPP} ${CFLAGS_BASE} -MM $< | sed "s/$*.o/& $@/g" > $@
%.d: %.c
@echo caching $@
@${CC} ${CFLAGS_BASE} -MM $< | sed "s/$*.o/& $@/g" > $@
%.o: %.cpp
@echo building $@
@${CPP} ${CPPFLAGS} $< -o $@
%.o: %.c
@echo building $@
@${CC} ${CFLAGS} $< -o $@
objs: subdirs ${OBJS_CPP} ${OBJS_C}
@/bin/cp *.o ${SEABREEZE}/lib 1>/dev/null 2>&1 || true
subdirs:
@if [ "$(SUBDIRS)" ] ; then for d in $(SUBDIRS) ; do $(MAKE) -C $$d || exit ; done ; else true ; fi
clean:
@echo cleaning $$PWD
@for d in $(SUBDIRS); do $(MAKE) -C $$d $@ || exit; done
@$(RM) -f *.d *.o *.obj *.exe *.stackdump lib/* $(APPS)
@for VS in $(VISUALSTUDIO_PROJECTS) ; \
do \
if [ -d os-support/windows/$$VS ] ; \
then \
echo cleaning os-support/windows/$$VS ; \
( cd os-support/windows/$$VS && $(MAKE) clean ) || exit ; \
fi ; \
done
@if [ -d doc ] ; then ( cd doc && $(RM) -rf man rtf html *.err ) ; fi
new: clean all