Created a Makefile with all / install / clean / uninstall targets
[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: $(foreach lib,$(LIBS),$(SUBDIR)/$(lib).pyc)
30
31 %.pyc: %.py
32         PYTHONPATH=$(SUBDIR)/.. python -c 'import asn1ate.$(basename $(subst /,.,$(subst $(SUBDIR)/,,$<)))'
33
34 %.pyo: %.pyc
35         PYTHONPATH=$(SUBDIR)/.. python -O $<
36
37 clean:
38         rm -f $(foreach lib,$(LIBS),$(SUBDIR)/$(lib).pyc)
39         rm -f $(foreach lib,$(LIBS),$(SUBDIR)/$(lib).pyo)
40
41 install: all
42         mkdir -p '$(DESTDIR)$(PREFIX)/lib/asn2quickder/asn1ate/support'
43         $(foreach file,$(LIBS),install $(SUBDIR)/$(file).py  '$(DESTDIR)$(PREFIX)/lib/asn2quickder/asn1ate/$(file).py'  &&) echo 'Python library files installed'
44         $(foreach file,$(LIBS),install $(SUBDIR)/$(file).pyc '$(DESTDIR)$(PREFIX)/lib/asn2quickder/asn1ate/$(file).pyc' &&) echo 'Python optimised library files installed'
45         $(foreach file,$(BINS),install $(SUBDIR)/$(file).py  '$(DESTDIR)$(PREFIX)/lib/asn2quickder/asn1ate/$(file).py'  &&) echo 'Python binary files installed'
46         ( echo '#!/bin/sh' ; echo 'PYTHONPATH='"'"'$(PREFIX)/lib/asn2quickder'"'"' python '"'"'$(PREFIX)/lib/asn2quickder/asn1ate/asn2quickder.py'"'"' "$$@"' ) > '$(DESTDIR)$(PREFIX)/bin/asn2quickder'
47         chmod ugo+x '$(DESTDIR)$(PREFIX)/bin/asn2quickder'
48
49 uninstall:
50         rm -f '$(DESTDIR)$(PREFIX)/bin/asn2quickder'
51         rm -rf '$(DESTDIR)$(PREFIX)/lib/asn2quickder'
52
53