Merge branch 'master' of https://github.com/vanrein/asn2quickder
[asn2quickder] / Makefile
1 # This is asn2quickder, an ASN.1 compiler with Quick DER backend
2 #
3 # Quick DER is a small and efficient library for DER parsing, possible
4 # entirely without memory allocation in the routines.  This makes it
5 # perfect for many embedded uses, and the occasional quick actions on ASN.1
6 # encoded in DER, such as plucking fields out of a certificate or ticket.
7 #
8 # This basically is a Python script that invokes a few library routines.
9 # These install into $(DESTDIR)$(PREFIX)/lib/asn2quickder/asn1ate
10 # where the reason for the asn2quickder prefix is to avoid naming conflicts
11 # with any "real" asn1ate intallation; asn2quickder is a branch off asn1ate.
12 #
13 # References:
14 # https://github.com/vanrein/asn2quickder
15 # https://github.com/kimgr/asn1ate
16 # https://github.com/vanrein/quick-der
17 #
18 # From: Rick van Rein <rick@openfortress.nl>
19
20
21 DESTDIR ?=
22 PREFIX ?= /usr/local
23
24 SUBDIR=asn1ate
25
26 BINS=asn2quickder
27 LIBS=__init__ parser sema support/pygen
28
29 all: asn2quickder.destdir asn2quickder $(foreach lib,$(LIBS),$(SUBDIR)/$(lib).pyc)
30
31 asn2quickder.destdir:
32         ( echo '#!/bin/sh' ; echo 'PYTHONPATH='"'"'$(DESTDIR)/$(PREFIX)/lib/asn2quickder:$$PYTHONPATH'"'"' python '"'"'$(DESTDIR)/$(PREFIX)/lib/asn2quickder/asn1ate/asn2quickder.py'"'"' "$$@"' ) > "$@"
33         chmod ugo+x "$@"
34
35 asn2quickder:
36         ( echo '#!/bin/sh' ; echo 'HERE=$$(dirname "$$0")' ; echo 'PYTHONPATH="$$HERE:$$PYTHONPATH" python "$$HERE/asn1ate/asn2quickder.py" "$$@"' ) > "$@"
37         chmod ugo+x "$@"
38
39 %.pyc: %.py
40         PYTHONPATH=$(SUBDIR)/..:$(PYTHONPATH) python -c 'import asn1ate.$(basename $(subst /,.,$(subst $(SUBDIR)/,,$<)))'
41
42 %.pyo: %.pyc
43         PYTHONPATH=$(SUBDIR)/..:$(PYTHONPATH) python -O $<
44
45 clean:
46         rm -f $(foreach lib,$(LIBS),$(SUBDIR)/$(lib).pyc)
47         rm -f $(foreach lib,$(LIBS),$(SUBDIR)/$(lib).pyo)
48         rm -f asn2quickder.destdir asn2quickder
49
50 install: all
51         mkdir -p '$(DESTDIR)/$(PREFIX)/lib/asn2quickder/asn1ate/support'
52         $(foreach file,$(LIBS),install $(SUBDIR)/$(file).py  '$(DESTDIR)$(PREFIX)/lib/asn2quickder/asn1ate/$(file).py'  &&) echo 'Python library files installed'
53         $(foreach file,$(LIBS),install $(SUBDIR)/$(file).pyc '$(DESTDIR)$(PREFIX)/lib/asn2quickder/asn1ate/$(file).pyc' &&) echo 'Python optimised library files installed'
54         $(foreach file,$(BINS),install $(SUBDIR)/$(file).py  '$(DESTDIR)$(PREFIX)/lib/asn2quickder/asn1ate/$(file).py'  &&) echo 'Python binary files installed'
55         install asn2quickder.destdir '$(DESTDIR)$(PREFIX)/bin/asn2quickder'
56
57 uninstall:
58         rm -f '$(DESTDIR)$(PREFIX)/bin/asn2quickder'
59         rm -rf '$(DESTDIR)$(PREFIX)/lib/asn2quickder'
60
61