Skip to content

Commit

Permalink
coap.h: Remove need for different coap.h files for different OS
Browse files Browse the repository at this point in the history
./autogen.sh and ./configure no longer need to be run prior to running
make for Contiki, LwIP or RIOT from the appropriate examples sub-directory.

scripts/fix_version.sh now handles updating coap.h for the different
LIBCOAP_ and PACKAGE_ definitions.
  • Loading branch information
mrdeep1 committed Aug 23, 2024
1 parent 8899063 commit e220c37
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 211 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,6 @@ jobs:
- name: install macOS software
run: |
brew install make automake libtool
- name: setup
run: |
./autogen.sh
- name: configure
run: |
./configure --disable-doxygen --disable-manpages --disable-dtls --without-epoll --disable-examples --disable-examples-source --disable-tcp --disable-oscore --disable-q-block
- name: compile
run: |
gmake -C examples/contiki
Expand All @@ -172,10 +166,6 @@ jobs:
- name: setup
run: |
sudo apt-get update && sudo apt-get install -y libc6-dev-i386
./autogen.sh
- name: configure
run: |
$GITHUB_WORKSPACE/configure --disable-documentation --disable-examples --disable-tests --disable-dtls
- name: compile
run: |
make -C examples/${{matrix.OS}} EXTRA_CFLAGS=-Werror
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ examples/*.exe
examples/riot/pkg_libcoap/patches

# the include/ folder
include/coap3/coap.h
include/coap3/coap_defines.h

# the tests/ folder
Expand Down
6 changes: 0 additions & 6 deletions BUILDING
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ prior to running 'make'.
RIOT
====

./autogen.sh
./configure --disable-tests --disable-documentation --disable-examples --disable-dtls
cd examples/riot
make

Expand All @@ -130,8 +128,6 @@ See examples/riot/README for further information.
LwIP
====

./autogen.sh
./configure --disable-tests --disable-documentation --disable-examples --disable-dtls
cd examples/lwip
make

Expand All @@ -140,8 +136,6 @@ Executable is ./server. See examples/lwip/README for further information.
Contiki-NG
==========

./autogen.sh
./configure --disable-tests --disable-documentation --disable-examples --disable-dtls
cd examples/contiki
make

Expand Down
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,6 @@ else(ENABLE_TCP)
endif(ENABLE_TCP)

# creates config header file in build directory
configure_file(${CMAKE_CURRENT_LIST_DIR}/include/coap${LIBCOAP_API_VERSION}/coap.h.in
${CMAKE_CURRENT_BINARY_DIR}/include/coap${LIBCOAP_API_VERSION}/coap.h)

configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake_coap_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/coap_config.h)

Expand Down Expand Up @@ -994,8 +991,6 @@ install(
COMPONENT dev
FILES_MATCHING
PATTERN "*.h"
PATTERN "coap.h" EXCLUDE
PATTERN "coap_riot.h" EXCLUDE
PATTERN "*_internal.h" EXCLUDE
PATTERN "oscore*" EXCLUDE)
install(
Expand Down
5 changes: 1 addition & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ EXTRA_DIST = \
include/coap$(LIBCOAP_API_VERSION)/coap_uthash_internal.h \
include/coap$(LIBCOAP_API_VERSION)/coap_utlist_internal.h \
include/coap$(LIBCOAP_API_VERSION)/coap_ws_internal.h \
include/coap$(LIBCOAP_API_VERSION)/coap.h.in \
include/coap$(LIBCOAP_API_VERSION)/coap.h.riot \
include/coap$(LIBCOAP_API_VERSION)/coap.h.windows \
include/oscore/oscore_cbor.h \
include/oscore/oscore_context.h \
include/oscore/oscore_cose.h \
Expand Down Expand Up @@ -242,7 +239,7 @@ libcoap_includedir = $(includedir)/coap$(LIBCOAP_API_VERSION)/
# $(top_srcdir)/include/coap-$(LIBCOAP_API_VERSION)/*

libcoap_include_HEADERS = \
$(top_builddir)/include/coap$(LIBCOAP_API_VERSION)/coap.h \
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap.h \
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/libcoap.h \
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_address.h \
$(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_async.h \
Expand Down
1 change: 0 additions & 1 deletion autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ depcomp
doc/Doxyfile doc/doxyfile.stamp doc/doxygen_sqlite3.db doc/Makefile doc/Makefile.in
examples/*.o examples/coap-client examples/coap-server examples/coap-rd
examples/Makefile examples/Makefile.in
include/coap3/coap.h
install-sh
libcoap-*.pc libtool ltmain.sh
man/coap*.[357] man/coap*.txt man/Makefile man/Makefile.in
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,6 @@ AC_CONFIG_FILES([
Makefile
doc/Makefile
examples/Makefile
include/coap$LIBCOAP_API_VERSION/coap.h
man/coap.txt
man/coap_address.txt
man/coap_async.txt
Expand Down Expand Up @@ -1552,6 +1551,7 @@ else
AC_MSG_RESULT([ build static library : "no"])
fi

mkdir -p include/coap$LIBCOAP_API_VERSION
LT_TEMP=`grep -B2 " COAP_" coap_config.h > include/coap$LIBCOAP_API_VERSION/coap_defines.h`
if test "x$LT_TEMP" != "x" ; then
AC_MSG_ERROR([Unable to build coap_defines.h])
Expand Down
11 changes: 2 additions & 9 deletions examples/lwip/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ LDLIBS := $(shell if [ -f $(libcoap_dir)/config.log ] ; then \
all: lwip \
check-version \
check-tinydtls \
$(coap_include_dir)/coap.h \
lib-server \
server \
lib-client \
Expand Down Expand Up @@ -204,21 +203,15 @@ SN_OBJS = ${SN_APP_OBJ} ${SN_LWIP_OBJ} ${SN_COAP_OBJ}
CD_OBJS = ${CD_APP_OBJ} ${CD_LWIP_OBJ} ${CD_COAP_OBJ} ${CD_DTLS_OBJ}
SD_OBJS = ${SD_APP_OBJ} ${SD_LWIP_OBJ} ${SD_COAP_OBJ} ${SD_DTLS_OBJ}

$(coap_include_dir)/coap.h:
@(if [ ! -f $(coap_include_dir)/coap.h ] ; then \
(cd $(libcoap_dir) ; ./autogen.sh ; ./configure --disable-dtls --disable-man) ; \
${MAKE}; \
fi)

${SN_OBJS} ${SD_OBJS}: $(coap_include_dir)/coap.h server-coap.h
${SN_OBJS} ${SD_OBJS}: server-coap.h

server: ${SN_OBJS}
$(CC) $(CFLAGS) ${SN_OBJS} -o server ${LDLIBS}

server-dtls: ${SD_OBJS}
$(CC) $(CFLAGS) ${SD_OBJS} -o server-dtls ${LDLIBS}

${CN_OBJS} ${CD_OBJS}: $(coap_include_dir)/coap.h client-coap.h
${CN_OBJS} ${CD_OBJS}: client-coap.h

client: ${CN_OBJS}
$(CC) $(CFLAGS) ${CN_OBJS} -o client ${LDLIBS}
Expand Down
1 change: 0 additions & 1 deletion examples/riot/pkg_libcoap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ endif

libcoap:
$(QQ)@cp $(LIBCOAP_SOURCE_DIR)/coap_config.h.riot $(LIBCOAP_SOURCE_DIR)/coap_config.h
$(QQ)@cp $(LIBCOAP_INCLUDE_DIR)/coap.h.riot $(LIBCOAP_INCLUDE_DIR)/coap.h
$(QQ)"$(MAKE)" -C $(LIBCOAP_SOURCE_DIR)/src -f $(CURDIR)/Makefile.libcoap

libcoap_oscore:
Expand Down
4 changes: 2 additions & 2 deletions include/coap3/coap.h.windows → include/coap3/coap.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* coap.h -- main header file for CoAP stack of libcoap (Windows)
* coap.h -- main header file for CoAP stack of libcoap
*
* Copyright (C) 2010-2012,2015-2024 Olaf Bergmann <[email protected]>
* 2015 Carsten Schoenert <[email protected]>
Expand Down Expand Up @@ -34,7 +34,7 @@
#define LIBCOAP_PACKAGE_VERSION "4.3.5rc3"

/* Define the numeric version identifier for libcoap */
#define LIBCOAP_VERSION (4003004U)
#define LIBCOAP_VERSION (4003004ULL)

#ifdef __cplusplus
extern "C" {
Expand Down
74 changes: 0 additions & 74 deletions include/coap3/coap.h.in

This file was deleted.

74 changes: 0 additions & 74 deletions include/coap3/coap.h.riot

This file was deleted.

10 changes: 6 additions & 4 deletions scripts/fix_version.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
FILES="coap_config.h.contiki \
coap_config.h.riot \
coap_config.h.windows \
include/coap@LIBCOAP_API_VERSION@/coap.h.riot \
include/coap@LIBCOAP_API_VERSION@/coap.h.windows \
examples/lwip/config/coap_config.h"
examples/lwip/config/coap_config.h \
include/coap@LIBCOAP_API_VERSION@/coap.h"

for file in $FILES ; do
sed -i $file -e 's/#define PACKAGE_NAME ".*"/#define PACKAGE_NAME "@PACKAGE_NAME@"/g'
sed -i $file -e 's/#define PACKAGE_STRING ".*"/#define PACKAGE_STRING "@PACKAGE_STRING@"/g'
sed -i $file -e 's/#define PACKAGE_VERSION ".*"/#define PACKAGE_VERSION "@PACKAGE_VERSION@"/g'
sed -i $file -e 's/#define PACKAGE_TARNAME ".*"/#define PACKAGE_TARNAME "@PACKAGE_TARNAME@"/g'
sed -i $file -e 's/#define LIBCOAP_VERSION (.*)/#define LIBCOAP_VERSION (@LIBCOAP_VERSION@U)/g'

sed -i $file -e 's/#define LIBCOAP_PACKAGE_BUGREPORT (.*)/#define LIBCOAP_PACKAGE_BUGREPORT (@PACKAGE_BUGREPORT@)/g'
sed -i $file -e 's/#define LIBCOAP_PACKAGE_STRING ".*"/#define LIBCOAP_PACKAGE_STRING "@PACKAGE_STRING@"/g'
sed -i $file -e 's^#define LIBCOAP_PACKAGE_URL ".*"^#define LIBCOAP_PACKAGE_URL "@PACKAGE_URL@"^g'
sed -i $file -e 's/#define LIBCOAP_PACKAGE_VERSION ".*"/#define LIBCOAP_PACKAGE_VERSION "@PACKAGE_VERSION@"/g'
sed -i $file -e 's/#define LIBCOAP_VERSION (.*)/#define LIBCOAP_VERSION (@LIBCOAP_VERSION@ULL)/g'
done

for file in CMakeLists.txt ; do
Expand Down
35 changes: 25 additions & 10 deletions scripts/github_dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,36 @@ err=$?
echo $ARCHIVE
if test $err = 0 -a "x$ARCHIVE" != "x"; then
DIR=`pwd`/`tar taf $ARCHIVE |cut -d/ -f1|head -1`
tar xaf $ARCHIVE && cd $DIR && \
$DIR/configure $PREFIX --enable-tests --enable-silent-rules --enable-documentation --enable-examples --disable-dtls && \
make EXTRA_CFLAGS=-Werror && make install EXTRA_CFLAGS=-Werror
err=$?
tar xaf $ARCHIVE && cd $DIR
err=$terr

# LwIP
make -C $DIR/examples/lwip EXTRA_CFLAGS=-Werror
terr=$?
if [ $err = 0 ] ; then
err=$terr
fi

# Contiki
make -C $DIR/examples/contiki
terr=$?
if [ $err = 0 ] ; then
make -C $DIR/examples/lwip EXTRA_CFLAGS=-Werror
err=$?
err=$terr
fi

# RIOT
make -C $DIR/examples/riot
terr=$?
if [ $err = 0 ] ; then
make -C $DIR/examples/contiki
err=$?
err=$terr
fi

# Standard build
$DIR/configure $PREFIX --enable-tests --enable-silent-rules --enable-documentation --enable-examples --disable-dtls && \
make EXTRA_CFLAGS=-Werror && make install EXTRA_CFLAGS=-Werror
terr=$?
if [ $err = 0 ] ; then
make -C $DIR/examples/riot
err=$?
err=$terr
fi
fi

Expand Down
Loading

0 comments on commit e220c37

Please sign in to comment.