@@ -48,37 +48,30 @@ ci: fmt-check clippy test
4848
4949# Generate pkg-config file
5050pkgconfig : build-release
51+ @if [ -z " $$ INSTALL" ]; then \
52+ echo " Error: INSTALL environment variable is not set." ; \
53+ echo " Please set INSTALL to the installation directory, e.g.: export INSTALL=/usr/local" ; \
54+ exit 1; \
55+ fi
5156 @mkdir -p rust_accumulator/target/pkgconfig
5257 @VERSION=$$(grep '^version' rust_accumulator/Cargo.toml | head -1 | cut -d'"' -f2 ) ; \
53- echo " prefix=/usr/local" > rust_accumulator/target/pkgconfig/librust_accumulator.pc; \
54- echo " exec_prefix=\$ ${prefix} " >> rust_accumulator/target/pkgconfig/librust_accumulator.pc; \
55- echo " libdir=\$ ${exec_prefix} /lib" >> rust_accumulator/target/pkgconfig/librust_accumulator.pc; \
56- echo " includedir=\$ ${prefix} /include" >> rust_accumulator/target/pkgconfig/librust_accumulator.pc; \
57- echo " " >> rust_accumulator/target/pkgconfig/librust_accumulator.pc; \
58- echo " Name: librust_accumulator" >> rust_accumulator/target/pkgconfig/librust_accumulator.pc; \
59- echo " Description: A rust based lib for a PCS based accumulator" >> rust_accumulator/target/pkgconfig/librust_accumulator.pc; \
60- echo " Version: $$ VERSION" >> rust_accumulator/target/pkgconfig/librust_accumulator.pc; \
61- echo " " >> rust_accumulator/target/pkgconfig/librust_accumulator.pc; \
62- echo " Cflags: -I\$ ${includedir} " >> rust_accumulator/target/pkgconfig/librust_accumulator.pc; \
63- echo " Libs: -L\$ ${libdir} -lrust_accumulator" >> rust_accumulator/target/pkgconfig/librust_accumulator.pc
58+ sed -e " s|@PREFIX@|$$ INSTALL|g" -e " s|@VERSION@|$$ VERSION|g" \
59+ librust_accumulator.pc.in > rust_accumulator/target/pkgconfig/librust_accumulator.pc
6460 @echo " pkg-config file created at rust_accumulator/target/pkgconfig/librust_accumulator.pc"
6561
66- # Install library and pkg-config file (requires sudo for system-wide install)
62+ # Install library and pkg-config file
6763install : build-release pkgconfig
68- @echo " Installing to prefix: $$ {PREFIX:-/usr/local}"
69- install -d $$ {PREFIX:-/usr/local}/lib
70- @if [ -f rust_accumulator/target/release/librust_accumulator.so ]; then \
71- install -m 755 rust_accumulator/target/release/librust_accumulator.so $$ {PREFIX:-/usr/local}/lib/; \
72- elif [ -f rust_accumulator/target/release/librust_accumulator.dylib ]; then \
73- install -m 755 rust_accumulator/target/release/librust_accumulator.dylib $$ {PREFIX:-/usr/local}/lib/; \
74- elif [ -f rust_accumulator/target/release/librust_accumulator.dll ]; then \
75- install -m 755 rust_accumulator/target/release/librust_accumulator.dll $$ {PREFIX:-/usr/local}/lib/; \
76- else \
77- echo " Error: No library file found" ; exit 1; \
64+ @if [ -z " $$ INSTALL" ]; then \
65+ echo " Error: INSTALL environment variable is not set." ; \
66+ echo " Please set INSTALL to the installation directory, e.g.: export INSTALL=/usr/local" ; \
67+ exit 1; \
7868 fi
79- install -d $$ {PREFIX:-/usr/local}/lib/pkgconfig
80- install -m 644 rust_accumulator/target/pkgconfig/librust_accumulator.pc $$ {PREFIX:-/usr/local}/lib/pkgconfig/
81- @echo " Installation complete. Library installed to $$ {PREFIX:-/usr/local}/lib/"
69+ @echo " Installing to: $$ INSTALL"
70+ install -d $$ INSTALL/lib
71+ install -m 644 rust_accumulator/target/release/librust_accumulator.a $$ INSTALL/lib/
72+ install -d $$ INSTALL/lib/pkgconfig
73+ install -m 644 rust_accumulator/target/pkgconfig/librust_accumulator.pc $$ INSTALL/lib/pkgconfig/
74+ @echo " Installation complete. Library installed to $$ INSTALL/lib/"
8275
8376# Show help
8477help :
9588 @echo " doc - Build documentation"
9689 @echo " doc-open - Build and open documentation in browser"
9790 @echo " ci - Run all checks (format, clippy, test)"
98- @echo " pkgconfig - Generate pkg-config file"
99- @echo " install - Install library and pkg-config file (use PREFIX=/path to customize )"
91+ @echo " pkgconfig - Generate pkg-config file (requires INSTALL env var) "
92+ @echo " install - Install library and pkg-config file (requires INSTALL env var )"
10093 @echo " help - Show this help message"
0 commit comments