Skip to content

Commit

Permalink
Make it easier to build only the freestanding code
Browse files Browse the repository at this point in the history
Freestanding C, as opposed to hosted C (see the macro), is restricted to
a few C headers and usually lacks a libc. In our case, that means we
cannot assume <stdio.h> and FILE* is present, but we do require
<string.h> (memcpy, memcmp).

This commit simply makes it easier for me to test that TinyCBOR still
compiles in freestanding mode. Eventually I need to test with an actual
Zephyr build (issue intel#40).

Signed-off-by: Thiago Macieira <[email protected]>
  • Loading branch information
thiagomacieira committed Jan 30, 2018
1 parent 5515a99 commit 15c4021
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ SED = sed

# Our sources
TINYCBOR_HEADERS = src/cbor.h src/cborjson.h
TINYCBOR_SOURCES = \
TINYCBOR_FREESTANDING_SOURCES = \
src/cborerrorstrings.c \
src/cborencoder.c \
src/cborencoder_close_container_checked.c \
src/cborparser.c \
src/cborparser_dup_string.c \
src/cborpretty.c \
#
TINYCBOR_SOURCES = \
$(TINYCBOR_FREESTANDING_SOURCES) \
src/cborparser_dup_string.c \
src/cborpretty_stdio.c \
src/cbortojson.c \
src/cborvalidation.c \
Expand Down Expand Up @@ -128,6 +131,10 @@ configure: .config
.config: Makefile.configure
$(MAKE) -f $(SRCDIR)Makefile.configure OUT='>&9' configure 9> $@

lib/libtinycbor-freestanding.a: $(TINYCBOR_FREESTANDING_SOURCES:.c=.o)
@$(MKDIR) -p lib
$(AR) cqs $@ $^

lib/libtinycbor.a: $(TINYCBOR_SOURCES:.c=.o)
@$(MKDIR) -p lib
$(AR) cqs $@ $^
Expand Down Expand Up @@ -190,6 +197,7 @@ clean: mostlyclean
$(RM) bin/cbordump
$(RM) bin/json2cbor
$(RM) lib/libtinycbor.a
$(RM) lib/libtinycbor-freestanding.a
$(RM) tinycbor.pc
$(RM) lib/libtinycbor.so*
test -e tests/Makefile && $(MAKE) -C tests clean || :
Expand Down

0 comments on commit 15c4021

Please sign in to comment.