From c52d731e5ef47a43f549d497883d39fccb2992a6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 11 Mar 2025 21:53:43 -0700 Subject: [PATCH] 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 --- Makefile | 8 ++++++-- Makefile.nmake | 8 ++++++-- src/cbor.h | 5 +---- src/tinycbor-export.h.in | 3 +++ 4 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 src/tinycbor-export.h.in diff --git a/Makefile b/Makefile index 6df1655..a9fdc66 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/Makefile.nmake b/Makefile.nmake index 6afe517..fa79fa2 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -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) diff --git a/src/cbor.h b/src/cbor.h index 7a08be2..765a0ce 100644 --- a/src/cbor.h +++ b/src/cbor.h @@ -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) diff --git a/src/tinycbor-export.h.in b/src/tinycbor-export.h.in new file mode 100644 index 0000000..778100b --- /dev/null +++ b/src/tinycbor-export.h.in @@ -0,0 +1,3 @@ +#ifndef CBOR_API +#define CBOR_API +#endif \ No newline at end of file