mbedtls: Update to mbedtls-2.4.0
[contrib/iotivity.git] / Makefile
1 #!/usr/bin/make -f
2 name?=iotivity
3
4 default/%:
5         @echo "# $@ ignored"
6
7
8 default: all
9
10 # Overide variables
11 host_arch?=$(shell arch || echo "default")
12 OSTYPE?=$(shell echo "$${OSTYPE}")
13 uname?=$(shell echo `uname -s` || echo "")
14
15 TARGET_OS?=${uname}
16 ifeq ("",${TARGET_OS})
17 TARGET_OS=${OSTYPE}
18 endif
19
20 ifeq ("linux-gnu","${TARGET_OS}")
21 TARGET_OS=linux
22 endif
23 ifeq ("Linux","${TARGET_OS}")
24 TARGET_OS=linux
25 endif
26 ifeq ("",${TARGET_OS})
27 TARGET_OS=default
28 endif
29
30 ifeq ("i386","${host_arch}")
31 TARGET_ARCH?=x86
32 else
33 ifeq ("i486","${host_arch}")
34 TARGET_ARCH?=x86
35 else
36 ifeq ("i586","${host_arch}")
37 TARGET_ARCH?=x86
38 else
39 ifeq ("i686","${host_arch}")
40 TARGET_ARCH?=x86
41 else
42 ifeq ("armel","${host_arch}")
43 TARGET_ARCH?=arm
44 else
45 ifeq ("armhf","${host_arch}")
46 TARGET_ARCH?=arm
47 endif
48 ifeq ("aarch64","${host_arch}")
49 TARGET_ARCH?=arm64
50 endif
51 ifeq ("armv7l","${host_arch}")
52 TARGET_ARCH?=arm
53 endif
54 endif
55 endif
56 endif
57 endif
58 endif
59
60 # Default variables to overide before
61 LOGGING?=0
62 RELEASE?=1
63 SECURED?=0
64 TARGET_ARCH?=${host_arch}
65 TARGET_OS?=${uname}
66 TARGET_TRANSPORT?=IP
67 _includedir?=/usr/include
68 _libdir?=/usr/lib
69 _sbindir?=/usr/sbin
70 buildroot?=${DESTDIR}
71
72 ifeq (1,${RELEASE})
73 build_dir?=release
74 else
75 build_dir?=debug
76 endif
77
78 all: SConstruct
79         scons \
80   LOGGING=${LOGGING} \
81   RELEASE=${RELEASE} \
82   SECURED=${SECURED} \
83   TARGET_ARCH=${TARGET_ARCH} \
84   TARGET_OS=${TARGET_OS} \
85   TARGET_TRANSPORT=${TARGET_TRANSPORT} \
86   V=1 \
87   VERBOSE=1 \
88   #eol
89
90
91 check: auto_build.sh
92         ${<D}/${<F} unit_tests \
93  && "log: $@: succeeded" \
94  || echo "warning: $@: failed and ignored, TODO: fix $@ (and don't ignore $@ failures)"
95
96
97 install: rule/fix rule/install_headers rule/install_examples
98         install -d ${buildroot}${_libdir}
99         find . -iname "lib*.a" -exec install "{}" ${buildroot}${_libdir}/ \;
100         find . -iname "lib*.so" -exec install "{}" ${buildroot}${_libdir}/ \;
101         -rm -fv ${buildroot}${_libdir}/lib*.a
102         install -d ${buildroot}${_libdir}/pkgconfig
103         install -d ${DESTDIR}/usr/share/pkgconfig
104         install ${name}.pc ${buildroot}${_libdir}/pkgconfig/
105         ln -fs ../../../${_libdir}/pkgconfig/${name}.pc ${DESTDIR}/usr/share/pkgconfig
106
107         @echo "TODO: workaround headers namespaces"
108         ln -fs iotivity/resource ${buildroot}${_includedir}/
109         ln -fs iotivity/service ${buildroot}${_includedir}/
110         ln -fs iotivity/resource/c_common ${buildroot}${_includedir}/
111
112
113 clean:
114         rm -f *~
115
116 rule/fix: ${name}.pc
117         sed -e 's|^prefix=.*|prefix=/usr|g' -i ${<}
118
119
120 rule/install_headers: resource service
121         find $< \
122   -iname "include" -o -iname 'inc' -a -type d\
123  | grep -v example | grep -v csdk \
124  | while read dir ; do \
125   dirname=$$(dirname -- "$${dir}") ; \
126   install -d ${buildroot}${_includedir}/${name}/$${dirname} ; \
127   install $${dir}/*.* ${buildroot}${_includedir}/${name}/$${dirname}/ ; \
128  done
129         cd resource/csdk && \
130  find . -iname "include" -o -iname 'inc' -a -type d\
131  | while read dir ; do \
132   dirname=$$(dirname -- "$${dir}") ; \
133   install -d ${buildroot}${_includedir}/${name}/resource/$${dirname} ; \
134   install $${dir}/*.* ${buildroot}${_includedir}/${name}/resource/$${dirname}/ ; \
135  done
136         install -d ${buildroot}${_includedir}/${name}/resource/oc_logger/targets/
137
138         install ./resource/oc_logger/include/targets/*.* \
139  ${buildroot}${_includedir}/${name}/resource/oc_logger/targets/
140
141         install -d ${buildroot}${_includedir}/${name}/resource/c_common
142
143         install ./resource/c_common/*.h \
144  ${buildroot}${_includedir}/${name}/resource/c_common/
145
146         install -d ${buildroot}${_libdir}/${name}/examples/
147
148
149 rule/install_examples:
150 #       install out/${TARGET_OS}/${TARGET_ARCH}/${build_dir}/resource/examples/*client ${buildroot}${_libdir}/${name}/examples/
151 #       install out/${TARGET_OS}/${TARGET_ARCH}/${build_dir}/resource/examples/*server ${buildroot}${_libdir}/${name}/examples/
152 #       install out/${TARGET_OS}/${TARGET_ARCH}/${build_dir}/*/*/*/*client ${buildroot}${_libdir}/${name}/examples/
153 #       install out/${TARGET_OS}/${TARGET_ARCH}/${build_dir}/*/*/*/*server ${buildroot}${_libdir}/${name}/examples/
154 #       install out/${TARGET_OS}/${TARGET_ARCH}/${build_dir}/*lient ${buildroot}${_libdir}/${name}/examples/
155 #       install out/${TARGET_OS}/${TARGET_ARCH}/${build_dir}/*erver ${buildroot}${_libdir}/${name}/examples/
156
157 rule/help:
158         @echo "OSTYPE=${OSTYPE}"
159         @echo "TARGET_OS=${TARGET_OS}"
160         @echo "host_arch=${host_arch}"
161         @echo "uname=${uname}"
162
163 docs_file?=${name}-docs.zip
164
165 rule/docs: resource/docs/javadocGen.sh
166         rm -rf ${docs_file}
167         mkdir -p ${<D}/html
168         touch ${<D}/html/footer.html
169         cd ${<D} && ./${<F}
170         cd ${CURDIR} && zip -r9 ${docs_file} ./${<D}
171         find . \
172  -iname 'DoxyFile' -printf "%h\n" \
173  -o -iname 'extlibs' -prune -a -iname 'out' -prune \
174  | while read file ; do \
175   cd "${CURDIR}/$${file}" && doxygen ; \
176   cd ${CURDIR} ; \
177   zip -r9 ${docs_file} $${file} ; \
178 done