]> git.codecow.com Git - Monocypher.git/commitdiff
Add installation target to the makefile
authorLoup Vaillant <loup@loup-vaillant.fr>
Fri, 22 Sep 2017 07:34:54 +0000 (09:34 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Fri, 22 Sep 2017 07:34:54 +0000 (09:34 +0200)
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

index 7d9b6d60ea59d7d242b508874c0aea736b2be038..6e12fb7acdde2b325c4f8a9eaf62aff85884b6e0 100644 (file)
--- 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