From 21949c7ef6c689782160399138d1e9984eb3f0a0 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 1 Aug 2013 02:12:50 +0200 Subject: improve makefile and add install and uninstall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5193ce1..0aaa0ce 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,102 @@ +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + +PREFIX = /usr +DATA = /share +LIB = /lib +BIN = /bin +ENV = /usr$(BIN)/env +BASHSHEBANG = $(ENV) bash +PY3SHEBANG = $(ENV) python3 +PKGNAME = argparser +LICENSES = $(PREFIX)$(DATA) +PY3VERSION = 3.3 +LIBPY3 = $(PREFIX)$(LIB)/python$(PY3VERSION) +LIBBASH = $(PREFIX)$(LIB) +LIBJAVA = $(PREFIX)$(LIB) +VERSION = 1.0 + + C_OPTIMISE = -O6 JAVA_OPTIMISE = -O -all: +JAVAC = javac + + + +all: python bash java c + +python: bin/argparser.py +bin/argparser.py: src/argparser.py + cp "$<" "$@" + sed -i 's:^#!/usr/bin/env python3$$:#!$(PY3SHEBANG)":' "$@" + +bash: bin/argparser.bash +bin/argparser.bash: src/argparser.bash + cp "$<" "$@" + sed -i 's:^#!/bin/bash$$:#!$(BASHSHEBANG)":' "$@" + +java: bin/ArgParser.jar +bin/ArgParser.jar: src/argparser/ArgParser.java + @mkdir -p bin + $(JAVAC) $(JAVA_OPTIMISE) -cp src -s src -d bin src/argparser/ArgParser.java + $(JAVAC) $(JAVA_OPTIMISE) -cp src -s src -d bin src/Test.java + cd bin ; jar cf ArgParser.jar argparser/ArgParser*.class + +c: bin/argparser.so +bin/argparser.so: src/argparser.c src/argparser.h @mkdir -p bin $(CC) $(C_OPTIMISE) -std=gnu99 -Wall -Wextra -pedantic -fPIC -c src/argparser.c -o bin/argparser.o $(CC) $(C_OPTIMISE) -std=gnu99 -Wall -Wextra -pedantic -shared bin/argparser.o -o bin/argparser.so $(CC) $(C_OPTIMISE) -std=gnu99 -Wall -Wextra -pedantic src/test.c bin/argparser.o -o bin/test - javac $(JAVA_OPTIMISE) -cp src -s src -d bin src/argparser/ArgParser.java - javac $(JAVA_OPTIMISE) -cp src -s src -d bin src/Test.java - cd bin ; jar cf ArgParser.jar argparser/ArgParser*.class + + + +install: install-python install-bash install-java install-c install-license + +install-python: bin/argparser.py + install -Dm644 bin/argparser.py "$(DESTDIR)$(LIBPY3)/argparser.py" + +install-bash: bin/argparser.bash + install -Dm644 bin/argparser.bash "$(DESTDIR)$(LIBBASH)/argparser.bash" + +install-java: bin/ArgParser.jar + install -Dm644 bin/ArgParser.jar "$(DESTDIR)$(LIBJAVA)/ArgParser.jar" + +install-c: bin/argparser.so + install -Dm644 bin/argparser.so "$(DESTDIR)$(LIB)/ArgParser.so.$(VERSION)" + ln -s "argparser.so.$(VERSION)" "$(DESTDIR)$(LIB)/argparser.so" + +install-license: + install -d "$(DESTDIR)$(LICENSES)/$(PKGNAME)" + install -m644 COPYING LICENSE "$(DESTDIR)$(LICENSES)/$(PKGNAME)" + + + +uninstall: uninstall-python uninstall-bash uninstall-java uninstall-c uninstall-license + +uninstall-python: + rm -- "$(DESTDIR)$(LIBPY3)/argparser.py" + +uninstall-bash: + rm -- "$(DESTDIR)$(LIBBASH)/argparser.bash" + +uninstall-java: + rm -- "$(DESTDIR)$(LIBJAVA)/ArgParser.jar" + +uninstall-c: + rm -- "$(DESTDIR)$(LIB)/argparser.so" + rm -- "$(DESTDIR)$(LIB)/argparser.so.1.0" + +uninstall-license: + rm -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)/LICENSE" + rm -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)/COPYING" + -rmdir -- "$(DESTDIR)$(LICENSES)/$(PKGNAME)" + + clean: -rm -r -- bin + -- cgit v1.2.3-70-g09d2