/* ** udpates: ** 08/22/00 - changes to .PKGDIRS. to allow "." on RHS of :JAR: and ** :JAVAPKG: (ie 'xxx.jar :JAR: .') ** 10/18/00 - .JAVAPKG introduced so new .java files are seen when ** rebuilding. */ PKGPRFX = com.lucent.stc PKGPATHPRFX = com/lucent/stc PKGREPOSITORY = $(VROOT)/class /* ** Orbix IDL compiler flags */ JIDL = idlj JIDLFLAGS = -N -jP $(PKGPRFX) -jO ./ /* ** JAVA IDL Rule ** NAME: :JIDL: ** WHAT: Operator to generate Java code form .idl file. .idl files ** specified on the RHS are converted to Java code under a subdirectory ** corresponding to the java package. The necessary directories are ** created by JIDL if they do not exist. ** LHS: ** RHS: .idl file(s) **/ ":JIDL:" : .MAKE .OPERATOR local I for I $(*) $(I:B) : $(I) (IDL) (JIDL) (JIDLFLAGS) (CCFLAGS) .VIRTUAL $(IGNORE) $(JIDL) -v $(JIDL) $(JIDLFLAGS) $(CCFLAGS:N=-[ID]*:N!=-[ID]-*) $(*) end .MAIN .INSTALL : $(*:B) /* ** Used by .VJARFILES. and :JAVAPKG: ** Usage: $(.PKGDIRS. [] ** ex: $(.PKGDIRS. com/lucent/stc *.class|*.jpg ** ** NOTE: this is used by both :JAR: and :JAVAPKG:. If you have the :JAR: ** rules from newsletter issue 05 you may already have .PKGDIRS. defined. ** If they are not identical then use this newer one. ** ** Given a directory .PKGDIRS. will recursively list directories underneath ** that contain one or more .java or .class files. We assume the only files ** that would be in these directories are passed in as the second argument ** (ie. JARTYPES), plus .mk or Makefile. If a second argument is not ** specified then *.class and *.java are assumed. Anything else might be ** intrepreted as a directory. */ .PKGDIRS. :FUNCTION: local L PD D A1 A2 PD = A1 = $(%:O=1) A2 := $(%:O=2:Y??*.java|*.class?o) .SOURCE.pkgdirs : .CLEAR $(A1) L := $(*.SOURCE.pkgdirs:L:N!=*.tmpjar) PD += $(L:N=$(A2):D=$(A1):O=1:Y??$(A1:N=.)?o) for D $(L:N!=$(A2)|*.m[kosl]|Makefile:H<=U) PD += $(.PKGDIRS. $(A1)/$(D) $(A2)) end return $(PD:H<=U) /* ** NAME: :JAVAPKG: ** WHAT: Operator to compile a package of .java code into a package of ** .class files. ** LHS: root directory for the target .class package ** RHS: root of java source package directory ** ** Limitations: only one :JAVAPKG: assertion per makefile ** ** Example: ** $(VROOT)/class :JAVAPKG: com/lucent/stc ** ** Compile a java package by setting up several :JAVA: assertions. ** The directory specified on the RHS is searched recursively for ** .java files. Each subdirectory containing .java files is built ** in one shot by setting up a :JAVA: assertion with the .java files ** for that subdirectory on the RHS of :JAVA:. This allows us to break ** the compilation of the package into sub-packages (and sub-sub-packages). ** ** Furthermore, a given directory is broken up into chunks of MAX .java ** files, if that directory contains more than MAX files. This works ** around the issue of building the ems/Data directory (over 1400) files ** at once, which is too much for the compiler to handle. MAX is defined ** below in :JAVAPKG:. MAX=200 seems to work fine. ** ** The order the sub-packages are built cannot be guarenteed. If ** finer control over the order is required (ie. for dependency reasons) ** then you may specify the actual sub-packages on the RHS in the order ** you want them built. ** ** The LHS specifies the root destination directory, or where you ** package the .class files. This directory is passed to javac with ** the -d flag. It can be overridden by setting JAVACFLAGS+=-d . ** ** This rule was originally written to handle the java code generated ** by :JIDL:, but in theory it should be usable for any collection of ** java code. */ ":JAVAPKG:" : .OPERATOR .MAKE .JAVAPKGLIST. := $(*) .JAVAPKGDIR. := $(<) .MAKEINIT : .JAVAPKG /* ** The meat of the JVAPKG action is in the following rule so we can execute ** it each time the makefile is processed. We need to do this in order to ** pick up any new .java files. If the action is part of the .OPERATOR ** then it only gets executed when the makefile is compiled and new .java ** files created after the initial nmake run will be ignored. */ .JAVAPKG : .MAKE .VIRTUAL .AFTER .FORCE local D1 D2 J C MAX L MAX = 200 JAVACFLAGS += $(JAVACFLAGS:N=-d:Y??-d $(.JAVAPKGDIR.)?) for D1 $(.JAVAPKGLIST.) for D2 $(.PKGDIRS. $(D1):H<=U) L := $(D2:L=*.java:D=$(D2):B:S:H) while "$(L:O=$(MAX))" J := $(L:O<=$(MAX)) C := $(J:D=$(.JAVAPKGDIR.)/$(D2):B:S=.class) $(C) :JAVA: $(J) .MAIN : $(C) L := $(L:O>$(MAX)) end C := $(L:D=$(.JAVAPKGDIR.)/$(D2):B:S=.class) $(C) :JAVA: $(L) .MAIN : $(C) end end /* JAVA Compiler Rules ------------------------------------------------- */ JAVA = $(JAVA_HOME)/bin/java JAVAC = $(JAVA_HOME)/bin/javac JAR = $(JAVA_HOME)/bin/jar RMIC = $(JAVA_HOME)/bin/rmic JARFLAGS = cvf JAVACFLAGS = -g /* ** Directories to search for class files. These will be constructed ** into the CLASSPATH for the javac compiler. Releative directories ** will be searched through the viewpath automatically. */ .SOURCE.class : $(VROOT)/class .SOURCE.class : /opt/Iona/OrbixWeb3.2c/classes /* ** Add $CLASSPATH from the shell environment to our classpath */ .SOURCE.class : $(CLASSPATH:C/:/ /g) /* ** NAME: :JAVA: ** WHAT: Operator to compile specified .java files into .class files. ** LHS: target .class files (including path if not current dir) ** RHS: source .java files ** ** Example: (see gui/util/Makefile) ** ** Usage: file1.class ... filen.class :JAVA: file1.java ... filen.java ** ** The R loop: for any RMI*.class files, also generate RMI*_Skel.class ** and RMI*_Stub.class using .DO.RMIC. The crazy looking ** edit operators are to insure nmake knows what files ** are being generated, including their directory path. ** ** This operator calls .DO.JAVA for actual javac processing. */ ":JAVA:" : .MAKE .OPERATOR for R $(<:N=*RMI*.class) $(R:D:B=$(R:B:C/$(R:B)/$(R:B)_Stub):S=.class) \ $(R:D:B=$(R:B:C/$(R:B)/$(R:B)_Skel):S=.class) \ : $(R) .DO.RMIC .ALL : $(R:D:B=$(R:B:C/$(R:B)/$(R:B)_Stub):S=.class) end $(<) :JOINT: $(*) .DO.JAVA /* ** .DO.JAVA - called from the :JAVA: operator. ** Compile all file prerequisites using JAVAC. This passes ALL the files ** to the java compiler in a single call. This is faster than doing ** one at a time, and eliminates some dependency problems. ** ** If -d is NOT in JAVACFLAGS then default to "-d $(PKGREPOSITORY)". ** To write class files to another location use "JAVACFLAGS += -d ". */ .DO.JAVA : .USE (JAVAC) (JAVACFLAGS) $(JAVAC) $(JAVACFLAGS:N=-d:Y??-d $(PKGREPOSITORY)?) $(JAVACFLAGS) -classpath $(*.SOURCE.class:C/ /:/g) $(*) /* ** Generate RMI*_Skel.class and RMI*_Stub.class from RMI*.class. ** Called from :JAVA: */ .DO.RMIC :JOINT: .USE (RMI) $(RMIC) -d $(PKGREPOSITORY) -classpath $(*.SOURCE.class:C/ /:/g) \ $(*:D:B:C|^.*$(PKGPATHPRFX)|$(PKGPRFX)|:C|/|.|G)