`

Java Makefile【转】

阅读更多

Java Makefile
A simple replacement for Ant

Version 4.4, January 2011
Geotechnical Software Services
Copyright © 1999 - 2011

 

This document is available at http://geosoft.no/development/javamake.html


Abstract: A cross-platform (MS-Windows, Linux, UNIX) makefile for a wide range of programming languages and tools (Java, C, C++, Fortran, Rmi, Javadoc, Makedepend etc.). Suitable for single file projects and scalable to multi million file projects. The Makefile is written once and for all; no further editing required. The file is well-organized and suitable as an example for learning GnuMake.


Introduction

The last few years integrated development environments (IDE) have become popular for software development. IDE's provides the developer with all the tools required for the development task such as file manager, version control system, modeling tools, editor, compiler, debugger, user interface builder, execution environment, profiler and performance analyzing tools. In particular the user interface builder part of IDE's has proved useful, and is the backbone of IDE's like VisualBasic, Delphi, VisualC++, VisualCafé to name a few.

In many cases however, it is far more efficient to do code development in a pure terminal oriented environment. This is done to avoid the vast overhead of the IDE itself, to achieve better control of the development process and to be able to choose development tools like editors and debuggers on an individual basis. For these reasons it is not uncommon to divide projects into UI modules and non-UI modules, and use IDE's only on the former.

Doing development in a pure environment requires a powerful make setup to be efficient. The makefile setup provided here is powerful yet simple. It was created to support large scale multi-platform development, but is equally well suited for the single source file project. Currently it supports Java, C, C++, Fortran but can easily be extended to any language or domain.

The makefiles in this document uses GnuMake syntax. GnuMake is the default make system on the Linux platform, it is available on all UNIX platforms, and a Microsoft Windows version can be downloaded from here. (Look for the file UnxUtils.zip. Download and unpack it, and make sure the wbin/ directory becomes part of your path.) The actual make command in GnuMake is sometimes called gnumake and sometime just make (as is the case on Linux). In this document the latter is used consistently.


Organizing the Development

Some directory is chosen to be the development root directory (denoted DEV_ROOT below), and underneath it should the following subdirectories be created:

 

  $DEV_ROOT/src
           /obj
           /lib
           /docs
           /make
	   /bin

The src/ directory holds source files (.java, .c++, .gif etc.) organized in units called packages. The directory structure should follow the Java convention of reversed domain name which ensures universally unique file identifiers. This is useful also for C/C++/Fortran based projects. For instance:

 

  $DEV_ROOT/src/com/adobe/...

 

The content of one directory constitutes one package. A typical package setup might be:

 

  $DEV_ROOT/src/com/adobe/illustrator/ui/window/
                         /illustrator/ui/dialogs/
                         /illustrator/ui/print/
                         /illustrator/ui/print/postscipt/
                         /illustrator/ui/print/pdf/
                         /acroread/editor/.../...
                         /acroread/editor/.../...
                         /...

For Java source, the package statement must always reflect the the name indicated by the directory of each source file.

The obj/ directory contains target files produced by the source files, and the directory structure will be identical to the one int the src tree. The sub structure will be automatically produced by make, but the obj directory itself must be created in advance.

The lib/ directory contains all libraries in use. This includes 3rd-party libraries (copied here manually), as well as libraries produced by make. For the latter, there will be one library per package (i.e. directory) within the source tree. Java source produce .jar libraries while C/C++/Fortran source produce .so libraries. The library is named according to the package location, so Java code in $DEV_ROOT/src/com/adobe/utils are put in $DEV_ROOT/lib/comadobeutil.jar and C code in $DEV_ROOT/src/no/geosoft/math/calculus are put in $DEV_ROOT/lib/nogeosoftmathcalculus.so and so on.

The docs/ directory will hold all output from automatic documentation tools like Javadoc or Doxygen. The entry point for the documentation depends on the tool, but for Javadoc it is the file $DEV_ROOT/docs/index.html.

The make/ directory will hold the main Makefile (shown below) and a script for producing package makefiles. It can optionally be used for holding make logs etc.

The bin/ directory is where make will put non-Java executables.


Prerequisites

The following three environment variables has to be set prior to the use of the make system given below:

  • DEV_ROOT - Pointing to the development root directory as described above. Use "/" as directory separator also on MS-Windows.

  • IS_UNIX - Should be set to true if the development platform is UNIX and left unset (default) if it is not. This variable is needed for the sole purpose of getting the file separator token used by the Java tools correct. (It is ; on MS-Windows and : on UNIX.)

  • JAVA_HOME - For Java development. Points to the Java distribution that is being used, for instance /usr/local/jdk1.3. All Java tools used by the make system is referred to through this pointer, thus changing to a different Java version is as simple as resetting this variable. Use "/" as directory separator also on MS-Windows.


The Makefiles

There are three different makefiles involved. The first two defines the project at hand and will differ for each project, while the third is generic and can be used as is:

  • Package Makefile - One for each package, located within the package directory, and containing the list of source files that constitute the package. These files are very simple, and can potentially be auto created.

  • Project Makefile - Located at $DEV_ROOT, listing all packages constitute the project, the executable class as well as documentation details.

  • Main Makefile - Located in the $DEV_ROOT/make directory and containing all the fine details about how to produce targets from source. This is the heart and the brain of the make system.

 

Package Makefile

The package makefiles should be called Makefile and should be located within the src tree, one per package. An example package makefile is shown below:

 

  Source = \
          ByteSwapper.java \
          Ebcdic.java \
          Formatter.java \
          IntMap.java \
          javacup.gif \
          properties.txt \

  RmiSource =

  Main      = ByteSwapper

  include $(DEV_ROOT)/Makefile

The Source entry lists all the source files. .java files will be passed to the Java compiler, .c files to the C-compiler and so on. Other files (like the .gif and .txt above) will be copied unprocessed to the obj tree.

The RmiSource entry lists all Java source files that are to be processed by the rmi compiler. Note that these files must also be listed under the Source entry as they are also processed by javac.

The Main entry is optional and indicates which class contains the main() method. Leave open if none of them do. For a Java program there is only one main entry point, but it is common to include main() in other classes in order to test that specific class. The setup above makes it possible to run these test applications by issuing "make run" from the package level. See below.

Project Makefile

The project makefile should be called Makefile and should be located at $DEV_ROOT. The project makefile lists all packages and jar archives that constitutes the project.

An example makefile for a typical Java project is shown below:

 

  JavaPackages = \
          no/geosoft/directory \
	  no/geosoft/user \
	  no/geosoft/database \

  JavaLibraries = \
  	  mysql-connector.jar \

  JavaMainClass = \
          no.geosoft.database.Main

  RunParameters =
  
  # Javadoc
  JavadocWindowTitle = 'Geotechnical Software Services - API Specification'
  JavadocDocTitle    = 'GeoSoft API'
  JavadocHeader      = 'GeoSoft API'
  JavadocFooter      = '<font size="-1">Copyright &copy; 2004 - Geotechnical Software Services <a href="http://geosoft.no">geosoft.no<a></font>'

  include $(DEV_ROOT)/make/Makefile


A similar example for a typical C++ project:

  Packages = \
          no/geosoft/directory \
	  no/geosoft/user \
	  no/geosoft/util \

  IncludeDirs = \
	  /usr/include \
          /usr/include/g++-2 \
          /usr/X11R6/include \

  LibraryDirs = \
          /usr/lib \
          /usr/X11R6/lib \

  Libraries = \
          mysql \


  include $(DEV_ROOT)/make/Makefile

The JavaPackages entry lists all Java packages governed by this makefile. The Packages entry list all other packages.

The IncludeDirs list include directories referenced in C/C++/Fortran code. LibraryDirs and Libraries identifies .so libraries for C/C++/Fortran based linking, while JavaLibraries lists 3-rd party jars located in the $DEV_ROOT/lib directory.

The JavaMainClass and RunParameters are used for executing Java applications.

The Javadoc entries are optional and used for decoration of the produced Javadoc documentation.

Main Makefile

The Main makefile is the heart and brain of the make setup, and should be located in the $DEV_ROOT/make directory and be called Makefile. It is not executed directly, but rather included by the project makefile. This makefile contains everything needed to build the project described in the project makefile and it is rather complex. However, it it is written once and for all, and can to a large extent be left alone as is. Remember; This is the only Makefile you will ever need.

The Main Makefile is shown below. Copy-paste it from the browser and use it for your own projects:

  #---------------------------------------------------------------------------
  #  (C) 1999 - 2011 GeoSoft - Geotechnical Software Services
  #  info@geosoft.no - http://geosoft.no
  #
  #  This program is free software; you can redistribute it and/or
  #  modify it under the terms of the GNU General Public License
  #  as published by the Free Software Foundation; either version 2
  #  of the License, or (at your option) any later version.
  #
  #  This program is distributed in the hope that it will be useful,
  #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  #  GNU General Public License for more details.
  #
  #  You should have received a copy of the GNU General Public License
  #  along with this program; if not, write to the Free Software
  #  Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  #  MA  02111-1307, USA.
  #---------------------------------------------------------------------------
  #---------------------------------------------------------------------------
  #
  #  GnuMake crash course:
  #
  #  target : depends
  #    rule
  #
  #  target  - the parameter given to make. I.e. what to build
  #  depends - file or other targets target depends on
  #  rule    - how to create target (note that rule is preceeded by a TAB char)
  #  $(VAR)  - environment variable or variable defined above
  #  $@      - Current target
  #  $*      - Current target without extension
  #  $<      - Current dependency
  #
  #---------------------------------------------------------------------------
  #---------------------------------------------------------------------------
  #
  #  Directories
  #
  #---------------------------------------------------------------------------
  
  SourceDir        = $(DEV_ROOT)/src
  TargetDir        = $(DEV_ROOT)/obj
  LibDir           = $(DEV_ROOT)/lib
  MakeDir          = $(DEV_ROOT)/make
  BinDir           = $(DEV_ROOT)/bin
  DocsDir          = $(DEV_ROOT)/docs
  CurrentDir       = $(CURDIR)

  ifdef Source
    Package          = $(subst $(SourceDir)/,,$(CurrentDir))
    PackageList      = $(Package)
    PackageSourceDir = $(SourceDir)/$(Package)
    PackageTargetDir = $(TargetDir)/$(Package)
    JavaMainClass    = $(subst /,.,$(Package)).$(Main)
  else
    PackageList      = $(Packages) $(JavaPackages)
  endif

  PackageListLoop  = $(patsubst %,$(SourceDir)/%/.loop,$(PackageList))

  JRE              = $(JAVA_HOME)/jre/lib/rt.jar

  ifdef IS_UNIX
    X = :
  else
    X = \;
  endif

  
  #---------------------------------------------------------------------------
  #
  #  Classification of files
  #
  #---------------------------------------------------------------------------

  # Source
  JavaFiles              = $(filter %.java,  $(Source))
  CppFiles               = $(filter %.cc,    $(Source))
  CFiles                 = $(filter %.c,     $(Source))
  FortranFiles           = $(filter %.f,     $(Source))
  CorbaFiles             = $(filter %.idl,   $(Source))
  OtherSourceFiles       = $(filter-out $(JavaFiles) $(CppFiles) $(CFiles) \
  		                      $(FortranFiles) $(CorbaFiles), \
  	                              $(Source))
  ManifestFile           = $(PackageSourceDir)/Manifest
  SourceFiles            = $(JavaFiles:%.java=  $(PackageSourceDir)/%.java)\
                           $(CppFiles:%.cc=     $(PackageSourceDir)/%.cc)\
                           $(CFiles:%.c=        $(PackageSourceDir)/%.c)\
                           $(FortranFiles:%.f=  $(PackageSourceDir)/%.f)

  
  # Target
  JavaClassFiles         = $(JavaFiles:%.java=  $(PackageTargetDir)/%.class)
  JavaClassFilesRel      = $(JavaFiles:%.java=  $(Package)/%.class)
  RmiStubFiles           = $(RmiSource:%.java=  $(PackageTargetDir)/%_Stub.class)
  RmiSkeletonFiles       = $(RmiSource:%.java=  $(PackageTargetDir)/%_Skel.class)
  JniClassFiles          = $(JniSource:%.java=  $(PackageTargetDir)/%.class)
  JniHeaders             = $(JniSource:%.java=  $(PackageSourceDir)/%.h)
  ObjectFiles            = $(CFiles:%.c=        $(PackageTargetDir)/%.o)\
  		         $(CppFiles:%.cc=     $(PackageTargetDir)/%.o)\
  		         $(FortranFiles:%.f=  $(PackageTargetDir)/%.o)
  OtherTargetFiles       = $(OtherSourceFiles:%=$(PackageTargetDir)/%)

  ThirdPartyJarsTmp = $(patsubst %,$(LibDir)/%,$(JavaLibraries))
  ThirdPartyJars    = $(subst $(Space),$(X),$(ThirdPartyJarsTmp))

  ifneq "$(words $(JavaFiles))" "0"
    JavaPackageName   = $(subst /,.,$(Package))
    JarFile           = $(LibDir)/$(subst /,,$(Package)).jar
  endif
  ifneq  "$(words $(ObjectFiles))" "0"
    DependencyFile    = $(PackageSourceDir)/Makedepend
    SharedLibrary     = $(LibDir)/lib$(subst /,,$(Package)).so
    StaticLibrary     = $(LibDir)/lib$(subst /,,$(Package)).a
    ifneq "$(Main)" ""
      Executable        = $(BinDir)/$(Main)
    endif
  endif
  
  #
  # Misc
  #
  ClassPath        = $(JRE)$(X)$(TargetDir)$(X)$(ThirdPartyJars)
  JavaPackageNames = $(subst /,.,$(JavaPackages))
  IncludePath      = -I$(SourceDir) $(IncludeDirs:%=-I%)
  LibDirs          = -L$(LibDir)    $(LibraryDirs:%=-L%)
  LocalLibs        = $(subst /,,$(Packages))
  LibList          = $(LocalLibs:%=-l%) $(Libraries:%=-l%)


  
  #---------------------------------------------------------------------------
  #
  #  Tools & Options
  #
  #---------------------------------------------------------------------------
  Print                  = @echo
  Copy                   = cp
  CCompiler              = gcc
  CppCompiler            = gcc
  Linker                 = gcc
  MakeDepend             = makedepend
  MakeDir                = mkdir -p
  Delete                 = rm -fr
  StaticArchiver         = ar
  DynamicArchiver        = gcc
  FortranCompiler        = f77
  JavaCompiler           = $(JAVA_HOME)/bin/javac
  JavaArchiver           = $(JAVA_HOME)/bin/jar
  JarSigner              = $(JAVA_HOME)/bin/jarsigner
  JavadocGenerator       = $(JAVA_HOME)/bin/javadoc
  JniCompiler            = $(JAVA_HOME)/bin/javah
  RmiCompiler            = $(JAVA_HOME)/bin/rmic
  JavaExecute            = $(JAVA_HOME)/bin/java
  Purify                 = purify
  WordCount              = wc
  List                   = cat

  MakeOptions            = -k -s
  MakeDependOptions      =
  StaticArchiverOptions  = rc
  DynamicArchiverOptions = -shared
  JavaArchiverOptions    =
  JniOptions             =
  RmiOptions             = -d $(TargetDir) -classpath $(ClassPath) \
  			 -sourcepath $(SourceDir)
  FortranOptions         =
  JavaCompilerOptions    = -d $(TargetDir) -classpath $(ClassPath) \
  			 -sourcepath $(SourceDir) -deprecation
  JavaRunOptions         = -classpath $(ClassPath)
  PurifyOptions          =
  JavadocOptions         = -d $(DocsDir) \
  			 -sourcepath $(SourceDir) \
  			 -classpath $(ClassPath) \
  			 -author \
  			 -package \
  			 -use \
  			 -splitIndex \
  			 -version \
  			 -link file:$(JAVA_HOME)/docs/api \
  			 -windowtitle $(JavadocWindowTitle) \
  			 -doctitle $(JavadocDocTitle) \
  			 -header $(JavadocHeader) \
  			 -bottom $(JavadocFooter)
  WordCountOptions       = --lines

  Empty                  =
  Space                  = $(Empty) $(Empty)


  
  #---------------------------------------------------------------------------
  #
  # Rules
  #
  #---------------------------------------------------------------------------
  
  default : build

  %.loop :
  	@$(MAKE) $(MakeOptions) -C $(subst .loop,,$@) _$(MAKECMDGOALS)all

  # Create target directory
  $(PackageTargetDir) :
  	$(MakeDir) $@

  # .c -> .o
  $(PackageTargetDir)/%.o : $(PackageTargetDir) $(PackageSourceDir)/%.c
  	$(Print) $@
  	@$(CCompiler) $(COptions) -c $(IncludePath) $< -o $@

  %.o : $(PackageSourceDir)/%.c
  	$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@

  # .cc -> .o
  $(PackageTargetDir)/%.o : $(PackageSourceDir)/%.cc
  	$(Print) $@
  	$(CppCompiler) $(CppOptions) -c $(IncludePath) $< -o $@

  %.o : $(PackageSourceDir)/%.cc
  	$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@

  # .f -> .o
  $(PackageTargetDir)/%.o : $(PackageSourceDir)/%.f
  	$(Print) $@
  	@$(FortranCompiler) $(FortranOptions) -c $< -o $@

  %.o : $(PackageSourceDir)/%.f
  	$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@

  # .java -> .class
  $(PackageTargetDir)/%.class : $(PackageSourceDir)/%.java
  	$(Print) $@
  	@$(JavaCompiler) $(JavaCompilerOptions) $<

  %.class : $(PackageSourceDir)/%.java
  	@$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@

  # .class -> .h
  $(PackageSourceDir)/%.h : $(PackageTargetDir)/%.class
  	$(Print) $@
  	$(JniCompiler) $(JniOptions) $(JavaPackageName).$*

  %.h : %.class
  	$(MAKE) $(MakeOptions) $(PackageSourceDir)/$@

  # .o -> .a
  $(LibDir)/%.a : $(ObjectFiles)
  	$(Print) $@
  	@$(StaticArchiver) $(StaticArchiverOptions) $@ $(ObjectFiles)

  %.a : $(ObjectFiles)
  	$(MAKE) $(MakeOptions) $(LibDir)/$@

  # .o -> .so
  $(LibDir)/%.so : $(ObjectFiles)
  	$(Print) $@
  	$(DynamicArchiver) $(ObjectFiles) $(DynamicArchiverOptions) -o $@

  %.so : $(ObjectFiles)
  	$(MAKE) $(MakeOptions) $(LibDir)/$@

  # .class -> .jar
  $(LibDir)/%.jar : $(JavaClassFiles) $(OtherTargetFiles)
  	$(Print) $@
  	@cd $(TargetDir); $(JavaArchiver) -cf $@ \
  	$(JavaClassFilesRel) $(OtherTargetFiles)

  %.jar : $(JavaClassFiles) $(OtherTargetFiles)
  	$(MAKE) $(MakeOptions) $(LibDir)/$@

  # .class -> JavaDoc
  javadoc :
  	$(Print) $(JavaPackageNames) > $(DEV_ROOT)/packages.tmp
  	$(JavadocGenerator) $(JavadocOptions) @$(DEV_ROOT)/packages.tmp
  	$(Delete) $(DEV_ROOT)/packages.tmp
  	$(Print) Done JavaDoc.

  # .class -> _Stub.class 
  $(PackageTargetDir)/%_Stub.class : $(PackageTargetDir)/%.class
  	$(Print) $@
  	$(RmiCompiler) $(RmiOptions) $(JavaPackageName).$*

  %_Stub.class : %.class
  	$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@

  # .class -> _Skel.class
  $(PackageTargetDir)/%_Skel.class : $(PackageTargetDir)/%.class
  	$(Print) $@
  	$(RmiCompiler) $(RmiOptions) $(JavaPackageName).$*

  %_Skel.class : %.class
  	$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@

  # Executable
  $(Executable) : $(ObjectFiles)
  	$(Print) $@
  	$(Linker) $(LinkOptions) $(LibDirs) $(LibList) $(ObjectFiles) -o $@

  # Anything else is just copied from source to target
  $(PackageTargetDir)/% : $(PackageSourceDir)/%
  	$(Print) $@
  	$(Copy) $< $@

  # make (or make build)
  build : $(PackageListLoop)
  	$(Print) Done build.

  _all : _buildall

  _buildall : \
  	$(DependencyFile) \
  	$(PackageTargetDir) \
  	$(ObjectFiles) \
  	$(JavaClassFiles) \
  	$(RmiStubFiles) \
  	$(RmiSkeletonFiles) \
  	$(OtherTargetFiles) \
  	$(SharedLibrary) \
  	$(StaticLibrary) \
  	$(JarFile) \
  	$(Executable)


  # make clean
  clean : $(PackageListLoop)
  	$(Print) Done clean.

  _cleanall :
  	$(Delete) $(PackageTargetDir)/* \
  		  $(JarFile) \
  	          $(SharedLibrary) \
  	          $(StaticLibrary) \
  	          $(Executable) \
  	          $(DependencyFile)


  # make depend
  depend : $(PackageListLoop)
  	$(Print) Done dependencies.

  _dependall : $(DependencyFile)

  $(DependencyFile) :
  	$(Print) $@
  	@cd $(PackageSourceDir); \
  	$(MakeDepend) $(MakeDependOptions) -f- -p$(PackageTargetDir)/ \
  	$(IncludePath) $(Source) > $(DependencyFile)

  # make lib
  lib    : $(PackageListLoop)
  	$(Print) Libraries built.

  _liball : $(JarFile) $(SharedLibrary) $(StaticLibrary)

  jar : $(JarFile)

  jarsign : $(JarFile)
  	$(JarSigner) -keystore GeoSoftKeystore $(JarFile) myself

  # make statistics
  _statisticsall :
  	@$(Print) $(SourceFiles) >> $(DEV_ROOT)/files.tmp

  statistics : $(PackageListLoop)
  	@$(List) $(DEV_ROOT)/files.tmp | xargs $(WordCount) $(WordCountOptions)
  	@$(Delete) $(DEV_ROOT)/files.tmp
  	$(Print) Done statistics.

  # make pure
  $(Executable).pure :
  	$(Purify) $(PurifyOptions) $(CppCompiler) $(LinkOptions) $(LibDirs) \
  	$(LibList) $(ObjectFiles) -o $@

  pure : $(Executable).pure

  # Execute
  _runexe :
  	$(Executable) $(RunParameters)

  _runjava :
  	$(JavaExecute) $(JavaRunOptions) $(JavaMainClass) $(RunParameters)

  run : _runjava


  ifdef $(DependencyFile)
  -include $(DependencyFile)
  endif

 


Running Make

Using the make system is quite simple. You will run it from either the package level or from the project level ($DEV_ROOT).

The following commands can be applied from the package level (i.e when standing in a given package directory within the src tree):

   make - Process all source files in the package

   make clean - Remove all target files of the package

   make SomeTarget - Produce a specific file like Math.class or math.o. etc.

   make run - Execute the Java class identified by Main in the package Makefile.

The following commands can be applied from the project level (i.e while standing in the $DEV_ROOT directory):

   make - Process all source files in all packages

   make clean - Remove all produced files in all packages

   make lib - Create all libraries

   make javadoc - Create documentation for entire project

   make run - Run application

   make depend - Create dependency information (non-Java)

   make statistics - Produce LOC statistics for the entire project


A Package Makefile Generator

A package makefile is nothing but a list of the files in the package directory. It can easily be generated automatically and the following script do just that. The script should be run while standing in the package directory.

 

  #!/bin/csh -f
  
  #***************************************************************************
  #
  # Makefile generator script
  #
  # (C) 2011 GeoSoft - Geotechnical Software Services
  # info@geosoft.no - http://geosoft.no
  #
  # This program is free software; you can redistribute it and/or
  # modify it under the terms of the GNU General Public License
  # as published by the Free Software Foundation; either version 2
  # of the License, or (at your option) any later version.
  #
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  #
  #***************************************************************************
  
  set file = Makefile

  rm -f $file
  touch $file

  printf "Source    = \\\n" >> $file

  foreach SourceFile (ls *.c *.cc *.java *.f *.gif *.jpg`)
      printf "\t%s \\\n" ${SourceFile} >> $file
  end
  printf "\n" >> $file

  printf "RmiSource =\n\n" >> $file
  printf "Main      =\n\n" >> $file
  printf "include %s" '$(DEV_ROOT)/Makefile >> $file

Note that the RmiSource and the Main tags cannot be set automatically and, if required, these should be added after the script has been run.     

0
0
分享到:
评论
2 楼 joshuasabrina 2013-06-10  
w156445045 写道
干啥的,咋全是英文。

和ANT,MAVEN类似。跨平台的构建工具。
1 楼 w156445045 2013-05-31  
干啥的,咋全是英文。

相关推荐

    java写的makefile解析器

    java写的makefile解析器,共大家分析makefile语法用

    makefile实用教程汇编

    ### makefile实用教程知识点汇编 #### 一、Makefile概览 - **定义**:Makefile是一种用于自动化编译过程的脚本文件,通过它能够管理复杂的项目编译流程,尤其是在Unix/Linux环境下广泛使用。 - **作用**: - 自动...

    MakefileJava:用于编译java项目的通用makefile

    生成文件Java 用于编译 java 项目的通用 makefile。 目前,makefile 可以使用 java 包编译 java 项目。 体系结构:所有源文件都需要位于名为“src”(小写)的文件夹中。 这是一个社区项目。 我希望你能通过报告你的...

    该组件现在在Camel2.19.0中可用_Java_Makefile_下载.zip

    3. **Java和Makefile**:在Java项目中使用Makefile可能意味着项目使用Maven或Gradle等构建工具,但为了某些特定需求,如自定义构建脚本或跨平台构建一致性,选择了Makefile。通常,Makefile会调用这些现代构建工具的...

    Makefile万能通用版(C++和C混合编译也适用)

    * 软件开发:Makefile可以用于编译各种语言的源代码,例如C、C++、Java等。 * 嵌入式系统:Makefile可以用于编译嵌入式系统的固件。 * 数据分析:Makefile可以用于编译数据分析工具和算法。 Makefile是一种功能强大...

    javamake:用于生成和部署Eclipse Java项目的小makefile模板

    概括这个小Makefile是出于Eclipse停止运行而Swift构建Eclipse项目的冲动,这是由于Apple在其升级软件包之一期间打破了可视Java应用程序的无限智慧。 该文件是自描述文件:我假设您有一个Java Eclipse项目,并安装了...

    Makefile学习教程

    9. 包含其他Makefile:可以使用include语句在Makefile中包含其他Makefile文件,使得项目中的多个Makefile能够共享变量和规则。 10. 高级特性:包括静态模式规则、后缀规则、make的参数等,这些是提高Makefile编写...

    j4make:Java Makefile图形解析器

    java Makefile图形解析器 汇编 make 在dist/j4make.jar创建一个可执行jar 用法 -f,--format &lt;FORMAT&gt; output format one of [XML, DOT, GEXF, RDF] -h,--help Print Help and exit -v,--version Print version ...

    我读过的最好的makefile教程

    Makefile 教程 ...* 编译和链接 Java 项目 * 编译和链接 Python 项目 Makefile 是一种非常重要的编译和链接工具,广泛应用于 Unix 和 Linux 平台。它可以帮助开发者自动化编译和链接过程,提高软件开发的效率。

    Makefile-Templates-master.7z

    在"Makefile-Templates-master"文件夹中,你可能会找到各种类型的Makefile模板,例如针对C/C++项目的模板,Python项目的模板,甚至包括Java或Node.js项目的模板。每个模板都会展示如何定义规则来处理源代码、编译、...

    aix makefile linking

    7. 使用JNI(Java Native Interface)将Java程序与本地C/C++库链接,这对于需要在Java程序中嵌入本地代码的应用非常重要。 8. 和线程库以及Fortran库链接的相关知识,这涉及到多语言和库的互操作性。 9. 通过网络...

    makefile.rar

    在实际项目中,Makefile可以用于编译C/C++程序、Python脚本、Java项目等。通过设置规则,可以定制清理临时文件、编译特定模块、执行测试等多种任务。 七、高级特性 1.隐含规则:Makefile内置了一些常见的编译和...

    NDK MakeFile

    在Java层,你可以使用`System.loadLibrary()`来加载本地库,并通过JNI(Java Native Interface)来调用C/C++函数。 在实际开发中,了解和掌握NDK MakeFile的编写是必要的,因为这能够帮助你有效地管理原生代码的...

    intellij-makefile:支持基于IntelliJ的IDE的Makefile

    【标题】:“intellij-makefile:支持基于IntelliJ的IDE的Makefile”是指一个插件,它专门针对IntelliJ IDEA这个流行的Java开发IDE,提供了对Makefile项目的良好支持。这个插件允许开发者在IntelliJ IDEA环境中编写...

    gcc make makefile cmake cmakelist 区别

    GCC是一个跨平台的编译器,支持众多的编程语言,包括但不限于C、C++、Objective-C、Fortran和Java。GCC的主要功能是将源代码编译成可执行文件或库文件。对于小型项目,单一源文件可以直接使用gcc命令进行编译。但是...

    java2c工具(修复)

    - Makefile或其他构建文件:用于编译和运行示例或工具的配置文件。 总的来说,Java2C工具是一个强大的工具,它消除了Java和C之间的数据转换障碍,使得两种语言的混合编程变得更加容易。通过理解和熟练使用Java2C,...

    vcproj2make:将 Visual Studio 解决方案转换为 makefile

    Visual Studio 项目到 Makefile 该项目旨在成为一种将项目构建信息从 Visual Studio 项目文件格式自动转录为 makefile 的方法。 一般架构 大体架构是先将所有VS文件解析成反映VS项目文件打包信息的数据结构。 然后...

    makefile编写方法.docx

    1. 软件开发:Makefile 广泛应用于软件开发中,例如,编译 C、C++、Java 等语言的程序。 2. 工程管理:Makefile 可以对工程进行管理,例如,管理源文件、头文件、目标文件等。 3. 自动化编译:Makefile 带来了...

Global site tag (gtag.js) - Google Analytics