Skip to content

Commit

Permalink
Link and C flags are also specified in dune-accessible files.
Browse files Browse the repository at this point in the history
For mirage/mirage#969
Instead of pkg-config, one can use the following files to get the
compilation flags:

ocaml-freestanding/libs
ocaml-freestanding/cflags
  • Loading branch information
TheLortex committed Feb 14, 2019
1 parent 513c094 commit c5bf86c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ FREESTANDING_LIBS=build/openlibm/libopenlibm.a \
build/nolibc/libnolibc.a
endif

all: $(FREESTANDING_LIBS) ocaml-freestanding.pc
all: $(FREESTANDING_LIBS) ocaml-freestanding.pc flags/libs flags/cflags

Makeconf:
./configure.sh
Expand Down Expand Up @@ -100,6 +100,24 @@ ocaml-freestanding.pc: ocaml-freestanding.pc.in Makeconf
-e 's!@@PKG_CONFIG_EXTRA_LIBS@@!$(PKG_CONFIG_EXTRA_LIBS)!' \
ocaml-freestanding.pc.in > $@

flags/libs: flags/libs.tmp Makeconf
sed -e 's!@@PKG_CONFIG_EXTRA_LIBS@@!$(PKG_CONFIG_EXTRA_LIBS)!' \
flags/libs.tmp > flags/libs.tmp2
for PKG in $(PKG_CONFIG_DEPS); do \
echo " " >> flags/libs.tmp2;\
env PKG_CONFIG_PATH=$(shell opam config var prefix)/lib/pkgconfig pkg-config $$PKG --libs >> flags/libs.tmp2;\
done
echo "("`cat flags/libs.tmp2`")" > flags/libs

flags/cflags: flags/cflags.tmp Makeconf
for PKG in $(PKG_CONFIG_DEPS); do \
echo " " >> flags/cflags.tmp;\
env PKG_CONFIG_PATH=$(shell opam config var prefix)/lib/pkgconfig pkg-config $$PKG --cflags >> flags/cflags.tmp;\
done
echo "("`cat flags/cflags.tmp`")" > flags/cflags



install: all
./install.sh

Expand Down
1 change: 1 addition & 0 deletions flags/cflags.tmp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-I%{prefix}%/include/ocaml-freestanding
1 change: 1 addition & 0 deletions flags/libs.tmp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-L%{ocaml-freestanding:lib}% -lasmrun -lnolibc -lopenlibm @@PKG_CONFIG_EXTRA_LIBS@@
2 changes: 2 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ touch ${DESTLIB}/META
# pkg-config
mkdir -p ${prefix}/lib/pkgconfig
cp ocaml-freestanding.pc ${prefix}/lib/pkgconfig/ocaml-freestanding.pc
cp flags/cflags ${DESTLIB}
cp flags/libs ${DESTLIB}
4 changes: 4 additions & 0 deletions opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ depends: [
("solo5-bindings-hvt" | "solo5-bindings-virtio" | "solo5-bindings-muen" | "solo5-bindings-genode")
"ocaml" {>= "4.04.2" & < "4.08.0"}
]
substs: [
"flags/cflags.tmp"
"flags/libs.tmp"
]
conflicts: [
"sexplib" {= "v0.9.0"}
"solo5-kernel-ukvm"
Expand Down

0 comments on commit c5bf86c

Please sign in to comment.