cbor.h: let tinycbor-export.h define CBOR_API

And make CBOR_PRIVATE_API fall back to it.

We also need to provide the file for the old Makefile build too.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Thiago Macieira
2025-03-12 16:49:17 -07:00
parent 582423c9d9
commit c52d731e5e
4 changed files with 16 additions and 8 deletions
+6 -2
View File
@@ -21,7 +21,7 @@ RMDIR = rmdir
SED = sed
# Our sources
TINYCBOR_HEADERS = src/cbor.h src/cborjson.h src/tinycbor-version.h
TINYCBOR_HEADERS = src/cbor.h src/cborjson.h src/tinycbor-version.h src/tinycbor-export.h
TINYCBOR_FREESTANDING_SOURCES = \
src/cborerrorstrings.c \
src/cborencoder.c \
@@ -143,6 +143,9 @@ bin/json2cbor: $(JSON2CBOR_SOURCES:.c=.o) $(BINLIBRARY)
@$(MKDIR) -p bin
$(CC) -o $@ $(LDFLAGS) $^ $(LDFLAGS_CJSON) $(LDLIBS)
src/tinycbor-export.h: src/tinycbor-export.h.in
cp $< $@
tinycbor.pc: tinycbor.pc.in
$(SED) > $@ < $< \
-e 's,@prefix@,$(prefix),' \
@@ -190,6 +193,7 @@ mostlyclean:
$(RM) $(TINYCBOR_SOURCES:.c=.o)
$(RM) $(TINYCBOR_SOURCES:.c=.pic.o)
$(RM) $(CBORDUMP_SOURCES:.c=.o)
$(RM) src/tinycbor-export.h
clean: mostlyclean
$(RM) bin/cbordump
@@ -232,7 +236,7 @@ cflags += \
-Werror=int-conversion
endif
%.o: %.c
%.o: %.c $(TINYCBOR_HEADERS)
@test -d $(@D) || $(MKDIR) $(@D)
$(CC) $(cflags) $($(basename $(notdir $@))_CCFLAGS) -c -o $@ $<
%.pic.o: %.c
+6 -2
View File
@@ -1,6 +1,6 @@
CFLAGS = -W3
TINYCBOR_HEADERS = src\cbor.h src\cborjson.h
TINYCBOR_HEADERS = src\cbor.h src\cborjson.h src\tinycbor-export.h
TINYCBOR_SOURCES = \
src\cborerrorstrings.c \
src\cborencoder.c \
@@ -24,7 +24,7 @@ TINYCBOR_OBJS = \
src\cborpretty_stdio.obj \
src\cborvalidation.obj
all: lib\tinycbor.lib
all: src/tinycbor-export.h lib\tinycbor.lib
check: tests\Makefile lib\tinycbor.lib
cd tests & $(MAKE) check
silentcheck:
@@ -32,12 +32,16 @@ silentcheck:
tests\Makefile: tests\tests.pro
qmake -o $@ $**
src\tinycbor-export.h: src\tinycbor-export.h.in
copy $** $@
lib\tinycbor.lib: $(TINYCBOR_OBJS)
-if not exist lib\NUL md lib
lib -nologo /out:$@ $**
mostlyclean:
-del $(TINYCBOR_OBJS)
-del src\tinycbor-export.h
clean: mostlyclean
-del lib\tinycbor.lib
if exist tests\Makefile (cd tests & $(MAKE) clean)
+1 -4
View File
@@ -60,11 +60,8 @@ extern "C" {
# define SIZE_MAX ((size_t)-1)
#endif
#ifndef CBOR_API
# define CBOR_API
#endif
#ifndef CBOR_PRIVATE_API
# define CBOR_PRIVATE_API
# define CBOR_PRIVATE_API CBOR_API
#endif
#ifndef CBOR_INLINE_API
# if defined(__cplusplus)
+3
View File
@@ -0,0 +1,3 @@
#ifndef CBOR_API
#define CBOR_API
#endif