summaryrefslogtreecommitdiff
path: root/support/make/jar.mk
blob: 7fadaaa3ef676be5a5f61773af5a00b160a9c63c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
############################################################-*-Makefile-*-####
# JAR - Build Java Archive
##############################################################################
# $Id$

##############################################################################
# Usage
#
#   make jc [target=<target>] {<VARIABLE>=<value>}
#
##############################################################################
# Variables
#
# JAR			 = archive command
# JAR_FLAGS		+= archive flags
# JAR_ARCHIVE		 = archive file
# JAR_MANIFEST		 = manifest file
# JAR_INPUTDIR		 = directory containing the files to archive
# JAR_FILES		+= paths (relative to INPUTDIR) of the files to archive
#
# All variables may have target specific values which override the
# normal value. Those values are specified by variables whose name is
# prefixed with the target name. For example, to override the value of
# the variable JAR_ARCHIVE with target PROJECT, one may define the
# variable PROJECT_JAR_ARCHIVE
#
##############################################################################
# Examples
#
# Build the PROJECT java archive
#
#   make jar target=PROJECT
#
#
# Build a java archive containing all files in ./classes
#
#   make jar JAR_ARCHIVE=test.jar JAR_INPUTDIR=./classes JAR_FILES=.
#
##############################################################################

##############################################################################
# Defaults

JAR			?= jar

##############################################################################
# Values

jar			 = $(call JAR_LOOKUP,JAR)
jar_FLAGS		 = $(call JAR_LOOKUP,JAR_FLAGS)
jar_ARCHIVE		 = $(call JAR_LOOKUP,JAR_ARCHIVE)
jar_MANIFEST		 = $(call JAR_LOOKUP,JAR_MANIFEST)
jar_INPUTDIR		 = $(call JAR_LOOKUP,JAR_INPUTDIR)
jar_FILES		 = $(call JAR_LOOKUP,JAR_FILES)

##############################################################################
# Command

jar			+= c$(jar_FLAGS)f$(jar_MANIFEST:%=m)
jar			+= $(jar_ARCHIVE)
jar			+= $(jar_MANIFEST)
jar			+= $(jar_INPUTDIR:%=-C %)
jar			+= $(jar_FILES)

##############################################################################
# Functions

JAR_LOOKUP		 = $(if $($(target)_$(1)),$($(target)_$(1)),$($(1)))

##############################################################################
# Rules

jar:
	$(strip $(jar))

.PHONY		: jar

##############################################################################