1 #
   2 # Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 PREFIXES=-pkgPrefix CORBA org.omg \
  27     -pkgPrefix CosNaming org.omg \
  28     -pkgPrefix CosTransactions org.omg \
  29     -pkgPrefix CosTSInteroperation org.omg \
  30     -pkgPrefix DynamicAny org.omg \
  31     -pkgPrefix Dynamic org.omg \
  32     -pkgPrefix IOP org.omg \
  33     -pkgPrefix Messaging org.omg \
  34     -pkgPrefix PortableInterceptor org.omg \
  35     -pkgPrefix PortableServer org.omg \
  36     -pkgPrefix activation com.sun.corba.se.spi \
  37     -pkgPrefix GIOP com.sun.corba.se \
  38     -pkgPrefix PortableActivationIDL com.sun.corba.se \
  39     -pkgPrefix messages com.sun.corba.se
  40 
  41 define add_idl_package
  42   # param 1 = MYPACKAGE
  43   # param 2 = src root
  44   # param 3 = gensrc root
  45   # param 4 = source idl to compile
  46   # param 5 = target idl package
  47   # param 6 = delete these files that were output from the idlj
  48   # param 7 = idls that match these patterns should be compiled with -oldImplBase
  49   # param 8 = the idlj command
  50   # Save the generated java files to a temporary directory so
  51   # that we can find them and create proper dependencies.
  52   # After that, we move them to the real gensrc target dir.
  53   $4_TMPDIR:=tmp___$(subst /,_,$(patsubst $2/%,%,$4))___
  54   ifneq ($$(filter $7,$4),)
  55     $4_OLDIMPLBASE:=-oldImplBase
  56     $4_OLDIMPLBASE_MSG:=with -oldImplBase
  57   endif
  58   $5 : $4
  59         $$(call LogInfo, Compiling IDL $(patsubst $2/%,%,$4))
  60         $$(call MakeDir, $$(@D))
  61         $(RM) -rf $3/$$($4_TMPDIR)
  62         $8 -td $3/$$($4_TMPDIR) \
  63             -i $2/org/omg/CORBA \
  64             -i $2/org/omg/PortableInterceptor \
  65             -i $2/org/omg/PortableServer \
  66             -D CORBA3 -corba 3.0 \
  67             -fall \
  68             $$($4_OLDIMPLBASE) \
  69             $(PREFIXES) \
  70             $4
  71         $(RM) -f $$(addprefix $3/$$($4_TMPDIR)/,$6)
  72         $(CP) -r $3/$$($4_TMPDIR)/* $3
  73         ($(CD) $3/$$($4_TMPDIR) && $(FIND) . -type f | $(SED) 's!\./!$3/!g' | $(NAWK) '{ print $$$$1 ": $4" }' > $5)
  74         $(RM) -rf $3/$$($4_TMPDIR)
  75 endef
  76 
  77 # Setup make rules for creating an IDL compilation.
  78 #
  79 # Parameter 1 is the name of the rule. This name is used as variable prefix,
  80 # and the targets generated are listed in a variable by that name.
  81 #
  82 # Remaining parameters are named arguments. These include:
  83 #   IDLJ
  84 #   SRC
  85 #   BIN
  86 #   INCLUDES
  87 #   EXCLUDES
  88 #   OLDIMPLBASES
  89 #   DELETES
  90 SetupIdlCompilation = $(NamedParamsMacroTemplate)
  91 define SetupIdlCompilationBody
  92 
  93   # Find all existing java files and existing class files.
  94   $$(call MakeDir,$$($1_BIN))
  95   $1_SRCS := $$(shell find $$($1_SRC) -name "*.idl")
  96   $1_BINS := $$(shell find $$($1_BIN) -name "*.java")
  97   # Prepend the source/bin path to the filter expressions.
  98   $1_SRC_INCLUDES := $$(addprefix $$($1_SRC)/,$$($1_INCLUDES))
  99   $1_SRC_EXCLUDES := $$(addprefix $$($1_SRC)/,$$($1_EXCLUDES))
 100   $1_BIN_INCLUDES := $$(addprefix $$($1_BIN)/,$$($1_INCLUDES))
 101   $1_BIN_EXCLUDES := $$(addprefix $$($1_BIN)/,$$($1_EXCLUDES))
 102   $1_OLDIMPLBASES := $$(addprefix $$($1_SRC)/,$$($1_OLDIMPLBASES))
 103   # Now remove unwanted java/class files.
 104   $1_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS))
 105   $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
 106   $1_BINS := $$(filter $$($1_BIN_INCLUDES),$$($1_BINS))
 107   $1_BINS := $$(filter-out $$($1_BIN_EXCLUDES),$$($1_BINS))
 108   $1 := $$(sort $$(patsubst $$($1_SRC)/%.idl,$$($1_BIN)/%.idl.d,$$($1_SRCS)))
 109   # Now create the dependencies for each idl target.
 110   $$(foreach p,$$($1),$$(eval $$(call add_idl_package,$1,$$($1_SRC),$$($1_BIN),$$(patsubst $$($1_BIN)/%.idl.d,$$($1_SRC)/%.idl,$$p),$$p,$$($1_DELETES),$$($1_OLDIMPLBASES),$$($1_IDLJ))))
 111 endef
 112 
 113 .SUFFIXES: .java .class .package