#********************************************************************* # # (C) 2003 - 2007 Yumetech, Inc # http://aviatrix3d.j3d.org/ # # Lowest level common makefile for both native and Java code # # Author: Justin Couch # Version: $Revision: 1.8 $ # #********************************************************************* # # Directories for standard stuff # include $(PROJECT_ROOT)/make/Makefile.inc SHADER_DEV_ROOT = $(SHADER_DIR) CLASS_DIR = classes JAR_DIR = jars JAR_MAKE_DIR = $(MAKE_DIR)/jar SHADER_SRC_DIR = src/glsl DESTINATION = classes JAR_TMP_DIR = .jar_tmp MANIFEST_DIR = $(MAKE_DIR)/manifest # # Built up tool information # ifdef SHADER_HOME JAR = $(JAVA_HOME)/bin/jar JAR_INSTALL_DIR = $(JAVA_HOME)/jre/lib/ext else JAR = jar endif EMPTY = SPACE = $(EMPTY) $(EMPTY) OS_NAME=$(shell uname) ifeq (, $(strip $(findstring CYGWIN, $(OS_NAME)))) PATH_SEP=':' else PATH_SEP=';' endif ifdef JARS LOCAL_JARTMP = $(patsubst %,$(JAR_DIR)/%,$(JARS)) LOCAL_JARLIST = $(subst $(SPACE),$(PATH_SEP),$(LOCAL_JARTMP)) endif ifdef JARS_3RDPARTY OTHER_JARTMP = $(patsubst %,$(LIB_DIR)/%,$(JARS_3RDPARTY)) OTHER_JARLIST = $(subst $(SPACE),$(PATH_SEP),$(OTHER_JARTMP)) endif CP = $(CLASS_DIR) ifdef LOCAL_JARLIST CP :="$(CP)$(PATH_SEP)$(LOCAL_JARLIST)" endif ifdef OTHER_JARLIST ifdef CLASSPATH CP1:="$(CP)$(PATH_SEP)$(OTHER_JARLIST)" else CP1 := "$(OTHER_JARLIST)" endif endif ifdef CP1 CLASSPATH="$(CP1)" else CLASSPATH="$(CP)" endif # # Build rules. # PACKAGE_LOC = $(subst .,/,$(PACKAGE)) PACKAGE_DIR = $(DESTINATION)/$(PACKAGE_LOC) SHADER_FILES = $(filter %.java,$(SOURCE)) NONSHADER_FILES = $(patsubst %.java,,$(SOURCE)) CLASS_FILES = $(SHADER_FILES:%.java=$(PACKAGE_DIR)/%.class) OTHER_FILES = $(EXTRA:%=$(PACKAGE_DIR)/%) JAR_CLASS_FILES = $(patsubst %, %/*.*, $(JAR_CONTENT)) #JAR_EXTRA_FILES = $(EXTRA_FILES:%=$(SHADER_SRC_DIR)/%) JAR_CONTENT_CMD = -C $(JAR_TMP_DIR) . $(patsubst %, -C $(SHADER_SRC_DIR) %, $(EXTRA_FILES)) LINK_FILES = $(patsubst %, -link %,$(LINK_URLS)) # Make a list of all packages involved ifdef PACKAGE PACKAGE_LIST = $(subst .,/,$(PACKAGE)) else PACKAGE_LIST = $(subst .,/,$(BUILD_ORDER)) endif PLIST_CLEAN = $(patsubst %,$(SHADER_SRC_DIR)/%/.clean,$(PACKAGE_LIST)) PLIST_BUILD = $(patsubst %,$(SHADER_SRC_DIR)/%/.build,$(PACKAGE_LIST)) # # Option listing for the various commands # ifdef MANIFEST JAR_OPTIONS = -cmf JAR_MANIFEST = $(MANIFEST_DIR)/$(MANIFEST) else JAR_OPTIONS = -cf endif # # General build rules # # Rule 0. Applied when make is called without targets. all: $(DESTINATION) $(OTHER_FILES) # Rule 1. If the destination dir is missing then create it $(DESTINATION) : $(PRINT) Creating $(DESTINATION) @ $(MAKEDIR) $(DESTINATION) # Rule 3. Change ".build" tag to "Makefile", thus call the package makefile # which in turn recalls this makefile with target all (rule 0). %.build : $(PRINT) Building directory $(subst .build,' ',$@) @ $(MAKE) -k -f $(subst .build,Makefile,$@) all # Rule 4. Call rule 3 for every package buildall : $(PLIST_BUILD) $(OTHER_FILES) $(PRINT) Done build. # # Specific dependency build rules # # Rule 5. Building a .class file from a .java file # Rule 9. Default behaviour within a package: Simply copy the object from src # to classes. Note that the location of this rule is important. It must be after # the package specifics. $(PACKAGE_DIR)/% : $(SHADER_SRC_DIR)/$(PACKAGE_LOC)/% $(MAKEDIR) $(PACKAGE_DIR) $(PRINT) Copying $* $(COPY) $< $@ $(CHMOD) u+rw $< # Rule 6. If the destination dir is missing then create it $(INCLUDE_DIR) : $(PRINT) Missing include dir. Creating $(INCLUDE_DIR) @ $(MAKEDIR) $(INCLUDE_DIR) # Rule 7. If the destination dir is missing then create it $(LIB_DIR) : $(PRINT) Missing library dir. Creating $(LIB_DIR) @ $(MAKEDIR) $(LIB_DIR) # # Cleanups # # Rule 10. Remove all produced files (except javadoc) cleanall : $(DELETE) $(PACKAGE_DIR)/*.class $(OTHER_FILES) $(JNI_HEADERS) # Rule 11. Change ".clean" tag to "Makefile", thus call the package makefile # which in turn recalls this makefile with target cleanall (rule 10). %.clean : $(MAKE) -k -f $(subst .clean,Makefile,$@) cleanall # Rule 12: Call rule 11 for every package directory clean : $(PLIST_CLEAN) $(PRINT) Done clean. # # JAR file related stuff # # Rule 13. Build a jar file. $* strips the last phony .JAR extension. # Copy all the required directories to a temp dir and then build the # JAR from that. The -C option on the jar command recurses all the # directories, which we don't want because we want to control the # packaging structure. %.JAR : @ $(MAKEDIR) $(JAR_DIR) $(JAR_TMP_DIR) $(PRINT) Deleting the old JAR file @ $(DELETE) $(JAR_DIR)/$* $(PRINT) Building the new JAR file $* @ $(RMDIR) $(JAR_TMP_DIR)/* if [ -n "$(JAR_CLASS_FILES)" ] ; then \ for X in $(JAR_CONTENT) ; do \ $(MAKEDIR) $(JAR_TMP_DIR)/"$$X" ; \ $(COPY) $(SHADER_SRC_DIR)/"$$X"/*.* $(JAR_TMP_DIR)/"$$X" ; \ done ; \ fi $(JAR) $(JAR_OPTIONS) $(JAR_MANIFEST) $(JAR_DIR)/$* $(JAR_CONTENT_CMD) # Rule 13. Create given jar file by invoking its Makefile which triggers # rule 12 %.jar : $(PRINT) Building JAR file $@ @ $(MAKE) -k -f $(patsubst %,$(JAR_MAKE_DIR)/Makefile.$*,$@) $(patsubst %,$*_$(JAR_VERSION).jar,$@).JAR $(PRINT) Cleaning up @ $(RMDIR) $(JAR_TMP_DIR) # Rule 14. Create all jar files by invoking rule 13 jar : $(JARS) $(PRINT) Done jars. # Rule 18. Install the JAR files after we have created them install: $(JAR_INSTALL_DIR) $(PRINT) Copying JAR files to $(JAR_INSTALL_DIR) $(COPY) $(JAR_DIR)/* $(JAR_INSTALL_DIR) # Rule 16. A combination of steps used for automatic building complete : clean buildall jar