File: CommonJavaMakefile

package info (click to toggle)
openni2 2.2.0.33%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 22,216 kB
  • sloc: cpp: 111,197; ansic: 35,511; sh: 10,542; python: 1,313; java: 952; makefile: 575; xml: 12
file content (76 lines) | stat: -rw-r--r-- 2,423 bytes parent folder | download | duplicates (4)
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
#############################################################################
# Primesense template makefile.
# This file should not be made, but only included from other makefiles.
# By default, this makefile compiles in release. To compile a debug version:
#    make CFG=Debug
#
# Project makefile should define the following BEFORE including this file:
# SRC_FILES - a list of all source files
# JAR_NAME - name of the package
# BIN_DIR - Bin directory (output dir)
# INC_DIRS - a list of additional include directories
# LIB_DIRS - a list of additional library directories
# USED_JARS - a list of libraries used
# MAIN_CLASS - [Optional] for executable jar
#############################################################################

# take this file's dir
COMMON_JAVA_MAKE_FILE_DIR = $(dir $(lastword $(MAKEFILE_LIST)))

include $(COMMON_JAVA_MAKE_FILE_DIR)CommonDefs.mak

nullstring :=
space := $(nullstring) # end of the line

USED_JARS_OPTION =
ifneq "$(USED_JARS)" ""
	USED_JARS_PATH = $(foreach jar, $(USED_JARS), $(OUT_DIR)/$(jar).jar)
	USED_JARS_OPTION = -cp $(subst $(space),:,$(strip $(USED_JARS_PATH)))
endif

OUTPUT_NAME = $(JAR_NAME).jar

# create manifest file if needed
JAR_MANIFEST_CREATE_COMMAND := 
MANIFEST_FILE := 
JAR_OPTIONS = -cf

ifneq (, $(if $(or $(MAIN_CLASS), $(USED_JARS)),1))
	JAR_OPTIONS = -cfm
	MANIFEST_FILE = $(INT_DIR)/Manifest.txt
	JAR_MANIFEST_CREATE_COMMAND = (
	ifneq (,$(MAIN_CLASS))
		JAR_MANIFEST_CREATE_COMMAND += echo "Main-Class: $(MAIN_CLASS)";
	endif
	ifneq (,$(USED_JARS))
		JAR_MANIFEST_CREATE_COMMAND += echo "Class-Path: $(foreach jar, $(USED_JARS), $(jar).jar)";
	endif
	JAR_MANIFEST_CREATE_COMMAND += ) > $(MANIFEST_FILE)
endif

CREATE_SHORTCUT = 
ifneq (, $(MAIN_CLASS))
	SHORTCUT = $(OUT_DIR)/$(JAR_NAME)
	CREATE_SHORTCUT = echo LD_LIBRARY_PATH=. java -jar $(OUTPUT_NAME) > $(SHORTCUT); chmod +x $(SHORTCUT)
endif

#############################################################################
# Targets
#############################################################################
include $(COMMON_JAVA_MAKE_FILE_DIR)CommonTargets.mak

.PHONY: clean-manifest clean-int

# Final output file
$(OUTPUT_FILE): $(SRC_FILES_LIST) | $(OUT_DIR) $(INT_DIR)
	javac $(USED_JARS_OPTION) -d $(INT_DIR) $(SRC_FILES)
	$(JAR_MANIFEST_CREATE_COMMAND)
	jar $(JAR_OPTIONS) $@ $(MANIFEST_FILE) -C $(INT_DIR) .
	$(CREATE_SHORTCUT)

clean-int:
	rm -rf $(INT_DIR)
	
clean: clean-int