Modifications of the Makefile

Problems with the old Makefile

  1. Current Makefile does not correctly handle dependencies. See Rewriting makefiles.
  2. The current Makefile source is very complicated.

Solution of the Dependencies

The dependencies with our Makefile are resolved correctly using the Jikes compiler. You can to see the results obtained with Java and Jikes and check the differences here. We have followed the previous reference (Rewriting makefiles).

  1. Jikes Installation (if it is not installed)
    $ sudo apt-get -install jikes
    
  2. Update-Alternatives Javac Configuration
    1. Check if Jikes is installed
      $ sudo update-alternatives --list javac
      
      /usr/lib/jvm/java-6-openjdk/bin/javac
      /usr/bin/jikes-kaffe
      
    2. Change alternatives
      $ sudo update-alternatives --config javac
      
      There are 2 alternatives which provide «javac».
      
        Selection     Alternative
      -----------------------------------------------
      *+        1    /usr/lib/jvm/java-6-openjdk/bin/javac
                2    /usr/bin/jikes-kaffe
      
    3. We select the alternative 2 and check the change
      $ sudo update-alternatives --config javac
      
      There are 2 alternatives which provide «javac».
      
        Selection     Alternative
      -----------------------------------------------
       +        1    /usr/lib/jvm/java-6-openjdk/bin/javac
      *         2    /usr/bin/jikes-kaffe
      
    4. We check the new javac reference
      $ javac -version
      
      Jikes Compiler - Version 1.22 - 3 October 2004
      Copyright (C) IBM Corporation 1997-2003, 2004.
      - Licensed Materials - Program Property of IBM - All Rights Reserved.
      Originally written by Philippe Charles and David Shields of IBM Research,
      Jikes is now maintained and refined by the Jikes Project at:
      <http://ibm.com/developerworks/opensource/jikes>
      Please consult this URL for more information and for reporting problems.
      
  3. Now, we can to use the "make compile" command and it will resolve the dependencies.

Simplify the Makefile

  1. Specific variables for each package. In old Makefile had:
    1. Generic variables and functions:
      findInnerClasses = $(subst $$,\$$, $(subst $(CLASS_DIR)/,, $(foreach pattern, $(1), $(wildcard $(CLASS_DIR)/$(pattern)\$$*.class))))
      
      # Complete the targets classes names
      completeClassName = $(addprefix $(CLASS_DIR)/, $(addsuffix .class, $(1)))
      
      # Complete the targets java names
      completeJavaName = $(addprefix $(SRC_DIR)/, $(addsuffix .java, $(1)))
      
    2. Specifics variables (for example, the Analyzer case):
      SOLBCN_ANALYZER_PACKAGE = \
      	solBCN/analyzer/Analyzer \
      	solBCN/analyzer/BruteForceTreeDecompositor \
      	solBCN/analyzer/DegreeTreeDecompositor \
      	solBCN/analyzer/ConnectivityTreeDecompositor \
      	solBCN/analyzer/PlanarFacesTreeDecompositor \
      	solBCN/analyzer/ConstructionPlanFactory \
      	solBCN/analyzer/Filter \
      	solBCN/analyzer/TDInternalNode \
      	solBCN/analyzer/TDLeafNode \
      	solBCN/analyzer/TDNode \
      	solBCN/analyzer/TreeDecompositionEvent \
      	solBCN/analyzer/TreeDecompositionException \
      	solBCN/analyzer/TreeDecompositionFactory \
      	solBCN/analyzer/TreeDecomposition \
      	solBCN/analyzer/TreeDecompositionDebugger \
      	solBCN/analyzer/TreeDecompositionListener \
      	solBCN/analyzer/TreeDecompositor \
      	solBCN/analyzer/TripletTreeDecompositor \
      	solBCN/analyzer/TripletIterator
      
      SOLBCN_ANALYZER_JAR_PACKAGE = $(addsuffix .class, $(SOLBCN_ANALYZER_PACKAGE)) \
      			      $(call findInnerClasses, $(SOLBCN_ANALYZER_PACKAGE))
      SOLBCN_ANALYZER_CLASSES = $(call completeClassName, $(SOLBCN_ANALYZER_PACKAGE))
      SOLBCN_ANALYZER_JAVA = $(call completeJavaName, $(SOLBCN_ANALYZER_PACKAGE))
      SOLBCN_ANALYZER_JAR = $(SOLBCN_LIB_DIR)/solBCN_analyzer.jar
      
    3. Specific objective (for example, the Analyzer case):
      analyzer $(SOLBCN_ANALYZER_JAR): $(SOLBCN_ANALYZER_CLASSES)
      	cd $(CLASS_DIR); $(JAR) cf ../$(SOLBCN_ANALYZER_JAR) $(SOLBCN_ANALYZER_JAR_PACKAGE)
      
  2. In new Make file we use a generic case for the creation of any jar (less constructor and test packages that have specific cases):
    1. Generic variable:
      SHELL_INST_BIN_FILES = $(subst $$,\$$, $(shell cd src; find solBCN/$* -name '.svn' -exec true \; -prune -o \( -type f -not \( -name "*.java" -o -name "*.u" -o -name "*.html" \) -printf '-C src %p\n' \)))
      
    2. Generic objective:
      solBCN_%.jar: compile
      	$(shell $(JAR) cf $(LIB_DIR)/$@ $(SHELL_INST_BIN_FILES))
      	@echo $@" packaging OK."
      
  3. The new Makefile include installation instructions to the Debian package installation:
    ################################################################################
    # Installation   				                               #
    ################################################################################
    
    # Create directories for copying files
    install_dirs:	
    	mkdir -p $(DESTDIR)/opt/solBCN
    	mkdir -p $(DESTDIR)/opt/solBCN/lib
    	mkdir -p $(DESTDIR)/usr/share/applications
    	mkdir -p $(DESTDIR)/usr/share/pixmaps
    	mkdir -p $(DESTDIR)/usr/share/man/man1
    	mkdir -p $(DESTDIR)/usr/bin	
    
    install: install_dirs
    	install -m 755 solbcn $(DESTDIR)/opt/solBCN/
    	install -m 755 solbcn $(DESTDIR)/usr/bin/
    	install -m 644 debian/GEARS.png $(DESTDIR)/usr/share/pixmaps/GEARS.png
    	install -m 644 debian/solbcn.desktop $(DESTDIR)/usr/share/applications/solbcn.desktop
    	install -m 755 debian/solbcn.1 $(DESTDIR)/usr/share/man/man1/solbcn.1
    	install -m 755 lib/*.jar $(DESTDIR)/opt/solBCN/lib
    

Attachments