Skip to content

Commit

Permalink
refactor: split header files into a separate folder
Browse files Browse the repository at this point in the history
This allows users to build and link without a release installation by
preserving the header files relative path and `-I<cmt-root-dir>/include`
when building.
  • Loading branch information
mpolitzer committed May 27, 2024
1 parent 38fb1f1 commit 4fe102d
Show file tree
Hide file tree
Showing 24 changed files with 31 additions and 30 deletions.
9 changes: 5 additions & 4 deletions sys-utils/libcmt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TARGET_PREFIX ?= $(PREFIX)
TOOLCHAIN_PREFIX ?= riscv64-linux-gnu-
TARGET_CC := $(TOOLCHAIN_PREFIX)gcc
TARGET_AR := $(TOOLCHAIN_PREFIX)ar
COMMON_CFLAGS := -Wvla -O2 -g -Wall -pedantic -Wextra -Isrc \
COMMON_CFLAGS := -Wvla -O2 -g -Wall -pedantic -Wextra -Iinclude \
-fno-strict-aliasing -fno-strict-overflow -fPIC
TARGET_CFLAGS := $(COMMON_CFLAGS) -ftrivial-auto-var-init=zero -Wstrict-aliasing=3
CFLAGS := $(COMMON_CFLAGS)
Expand Down Expand Up @@ -85,7 +85,7 @@ install: $(libcmt_LIB) $(libcmt_SO) build/ffi.h
mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib
cp -f $(libcmt_LIB) $(libcmt_SO) $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib
mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/
cp -f src/*.h $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/
cp -f include/libcmt/*.h $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/
cp -f build/ffi.h $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/
mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig
sed -e 's|@ARG_PREFIX@|$(TARGET_PREFIX)|g' src/libcmt.pc > $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig/libcmt.pc
Expand Down Expand Up @@ -126,7 +126,7 @@ install-mock: $(mock_LIB) $(mock_SO) build/ffi.h
mkdir -p $(DESTDIR)$(PREFIX)/lib
cp -f $(mock_LIB) $(mock_SO) $(DESTDIR)$(PREFIX)/lib
mkdir -p $(DESTDIR)$(PREFIX)/include/libcmt/
cp -f src/*.h $(DESTDIR)$(PREFIX)/include/libcmt/
cp -f include/libcmt/*.h $(DESTDIR)$(PREFIX)/include/libcmt/
cp -f build/ffi.h $(DESTDIR)$(PREFIX)/include/libcmt/
mkdir -p $(DESTDIR)$(PREFIX)/lib/pkgconfig
sed -e 's|@ARG_PREFIX@|$(PREFIX)|g' src/libcmt_mock.pc > $(DESTDIR)$(PREFIX)/lib/pkgconfig/libcmt.pc
Expand Down Expand Up @@ -183,7 +183,8 @@ $(tools_OBJDIR)/funsel: tools/funsel.c $(mock_LIB)

tools: $(tools_BINS)

build/ffi.h: src/buf.h src/abi.h src/keccak.h src/merkle.h src/io.h src/rollup.h
HDRS := $(patsubst %,include/libcmt/%, buf.h abi.h keccak.h merkle.h io.h rollup.h)
build/ffi.h: $(HDRS)
cat $^ | sh tools/prepare-ffi.sh > $@
#-------------------------------------------------------------------------------
LINTER_IGNORE_SOURCES=src/io.c
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion sys-utils/libcmt/src/abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "abi.h"
#include "libcmt/abi.h"

#include <errno.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion sys-utils/libcmt/src/buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "buf.h"
#include "libcmt/buf.h"

#include <errno.h>
#include <stdbool.h>
Expand Down
4 changes: 2 additions & 2 deletions sys-utils/libcmt/src/io-mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "io.h"
#include "util.h"
#include "libcmt/io.h"
#include "libcmt/util.h"

#include <errno.h>
#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions sys-utils/libcmt/src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "io.h"
#include "util.h"
#include "libcmt/io.h"
#include "libcmt/util.h"

#include <stdbool.h>
#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions sys-utils/libcmt/src/keccak.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "keccak.h"
#include "abi.h"
#include "libcmt/keccak.h"
#include "libcmt/abi.h"

#include <string.h>

Expand Down
4 changes: 2 additions & 2 deletions sys-utils/libcmt/src/merkle.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "merkle.h"
#include "util.h"
#include "libcmt/merkle.h"
#include "libcmt/util.h"

#include <errno.h>
#include <stdbool.h>
Expand Down
8 changes: 4 additions & 4 deletions sys-utils/libcmt/src/rollup.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "rollup.h"
#include "abi.h"
#include "merkle.h"
#include "util.h"
#include "libcmt/rollup.h"
#include "libcmt/abi.h"
#include "libcmt/merkle.h"
#include "libcmt/util.h"

#include <errno.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion sys-utils/libcmt/tests/abi-multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "abi.h"
#include "libcmt/abi.h"

#include <assert.h>
#include <stdint.h>
Expand Down
2 changes: 1 addition & 1 deletion sys-utils/libcmt/tests/abi-single.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "abi.h"
#include "libcmt/abi.h"

#include <assert.h>
#include <errno.h>
Expand Down
2 changes: 1 addition & 1 deletion sys-utils/libcmt/tests/buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "buf.h"
#include "libcmt/buf.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions sys-utils/libcmt/tests/gio.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "data.h"
#include "rollup.h"
#include "util.h"
#include "libcmt/rollup.h"
#include "libcmt/util.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions sys-utils/libcmt/tests/keccak.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "keccak.h"
#include "abi.h"
#include "libcmt/keccak.h"
#include "libcmt/abi.h"

#include <assert.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion sys-utils/libcmt/tests/merkle.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "merkle.h"
#include "libcmt/merkle.h"

#include <assert.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion sys-utils/libcmt/tests/progress.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "rollup.h"
#include "libcmt/rollup.h"
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions sys-utils/libcmt/tests/rollup.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "rollup.h"
#include "libcmt/rollup.h"
#include "libcmt/util.h"
#include "data.h"
#include "util.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion sys-utils/libcmt/tools/funsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "keccak.h"
#include "libcmt/keccak.h"

#include <stdio.h>
#include <stdlib.h>
Expand Down

0 comments on commit 4fe102d

Please sign in to comment.