From 487699ed794edf16070916624a340ea625c326a5 Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Fri, 22 Sep 2017 09:34:54 +0200 Subject: [PATCH] Add installation target to the makefile Fixes #24 Defines and uses the $DESTDIR and $PREFIX variables. They can be overriden from the command line. By default, they are set to "" and "usr/local" respectively. Defines and uses a $PKGCONFIG variable to set the location of the pkgconfig configuration file (monocypher.pc). That variable depends on $PREFIX. Copies libmonocypher.a, libmonocypher.so and monocypher.h to their respective destinations, and creates the pkgconfig configuration file. --- makefile | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/makefile b/makefile index 7d9b6d6..6e12fb7 100644 --- a/makefile +++ b/makefile @@ -18,20 +18,42 @@ CC=gcc -std=gnu99 # speed tests don't work with -std=cxx, they need the POSIX ex #CC = clang -std=c99 -fsanitize=undefined #CC = clang -std=c99 -fprofile-instr-generate -fcoverage-mapping -#TODO maybe just use the environment variable? CFLAGS= -pedantic -Wall -Wextra -O3 -march=native +DESTDIR= +PREFIX=usr/local +PKGCONFIG=$(DESTDIR)usr/local/lib/pkgconfig -.PHONY: all clean install test speed +.PHONY: all library static-library dynamic-library clean install test speed + +all : library +install: library src/monocypher.h + mkdir -p $(DESTDIR)/$(PREFIX)/lib + cp lib/libmonocypher.a lib/libmonocypher.so $(DESTDIR)/$(PREFIX)/lib + cp src/monocypher.h $(DESTDIR)/$(PREFIX)/include + @echo "Create /$(PKGCONFIG)/monocypher.pc" + @echo "prefix=/$(PREFIX)" > /$(PKGCONFIG)/monocypher.pc + @echo 'exec_prefix=$${prefix}' >> /$(PKGCONFIG)/monocypher.pc + @echo 'libdir=$${exec_prefix}/lib' >> /$(PKGCONFIG)/monocypher.pc + @echo 'includedir=$${prefix}/include' >> /$(PKGCONFIG)/monocypher.pc + @echo '' >> /$(PKGCONFIG)/monocypher.pc + @echo 'Name: monocypher' >> /$(PKGCONFIG)/monocypher.pc + @echo 'Version: 1.1.0' >> /$(PKGCONFIG)/monocypher.pc + @echo 'Description: Easy to use, easy to deploy crypto library' \ + >> /$(PKGCONFIG)/monocypher.pc + @echo '' >> /$(PKGCONFIG)/monocypher.pc + @echo 'Libs: -L$${libdir} -lmonocypher' >> /$(PKGCONFIG)/monocypher.pc + @echo 'Cflags: -I$${includedir}' >> /$(PKGCONFIG)/monocypher.pc + + +library: static-library dynamic-library +static-library : lib/libmonocypher.a +dynamic-library: lib/libmonocypher.so -all: lib/libmonocypher.a lib/libmonocypher.so clean: rm -rf lib/ rm -f *.out -# TODO -# install: - test: test.out ./test.out -- 2.47.3