1# $NetBSD: Makefile,v 1.5 2024/06/24 18:01:03 riastradh Exp $
2
3NOLINT=
4NOMAN=
5.include <bsd.own.mk>
6
7DIST = ${.CURDIR}/../dist
8
9.PATH: ${DIST}/src ${DIST}/src/cbor ${DIST}/src/cbor/internal
10
11CPPFLAGS+= -I${DIST}/src -DHAVE_ENDIAN_H -I. -DEIGHT_BYTE_SIZE_T
12
13.if ${MACHINE} == "vax"
14# vax does not have NaN (no ieee754, so this code will not work anyway)
15CPPFLAGS+=-DNAN=INFINITY
16.endif
17
18LIB=    cbor
19
20SRCS+=   cbor.c
21
22# For ldexp
23LIBDPLIBS = m ${NETBSDSRCDIR}/lib/libm
24
25VERS_FILE=${DIST}/CMakeLists.txt
26
27.for i in MAJOR MINOR PATCH
28CBOR_VERSION_${i} != \
29    ${TOOL_SED} -ne '/CBOR_VERSION_${i}/s/.*"\([0-9]*\)")$$/\1/p' ${VERS_FILE}
30.endfor
31
32CBOR_VERSION = ${CBOR_VERSION_MAJOR}.${CBOR_VERSION_MINOR}.${CBOR_VERSION_PATCH}
33
34# cbor/
35SRCS+= \
36arrays.c \
37bytestrings.c \
38callbacks.c \
39common.c \
40encoding.c \
41floats_ctrls.c \
42ints.c \
43maps.c \
44serialization.c \
45streaming.c \
46strings.c \
47tags.c
48
49# cbor/internal
50SRCS+= \
51builder_callbacks.c \
52encoders.c \
53loaders.c \
54memory_utils.c \
55stack.c \
56unicode.c
57
58INCS+= \
59cbor.h \
60cbor/arrays.h \
61cbor/bytestrings.h \
62cbor/callbacks.h \
63cbor/common.h \
64cbor/configuration.h \
65cbor/data.h \
66cbor/encoding.h \
67cbor/floats_ctrls.h \
68cbor/ints.h \
69cbor/maps.h \
70cbor/serialization.h \
71cbor/streaming.h \
72cbor/strings.h \
73cbor/tags.h
74
75INCSDIR=/usr/include
76
77PKGCONFIG=libcbor
78
79.SUFFIXES: .in
80
81.in:
82	${TOOL_SED} \
83	    -e s@CMAKE_INSTALL_PREFIX@/usr@ \
84	    -e s@CMAKE_INSTALL_LIBDIR@/lib@ \
85	    -e s@PROJECT_NAME@libcbor@ \
86	    -e s@CBOR_VERSION@${CBOR_VERSION}@ ${.ALLSRC} > ${.TARGET}
87
88libcbor.pc: libcbor.pc.in
89
90SHLIB_MAJOR=    0
91SHLIB_MINOR=    5
92
93cbor/configuration.h: ${VERS_FILE}
94	${_MKTARGET_CREATE}
95	mkdir -p cbor && ( \
96	echo	'#define CBOR_MAJOR_VERSION ${CBOR_VERSION_MAJOR}' && \
97	echo	'#define CBOR_MINOR_VERSION ${CBOR_VERSION_MINOR}' && \
98	echo	'#define CBOR_PATCH_VERSION ${CBOR_VERSION_PATCH}' && \
99	echo	'#define CBOR_CUSTOM_ALLOC 0' && \
100	echo	'#define CBOR_BUFFER_GROWTH 2' && \
101	echo	'#define CBOR_PRETTY_PRINTER 1' && \
102	echo	'#define CBOR_RESTRICT_SPECIFIER restrict' && \
103	echo	'#define CBOR_INLINE_SPECIFIER ') > ${.TARGET}.tmp && \
104	${MV} ${.TARGET}.tmp ${.TARGET}
105
106CLEANFILES+= cbor/configuration.h
107CLEANFILES+= cbor/configuration.h.tmp
108
109.include <bsd.lib.mk>
110