corba/make/common/Rules.gmk
changeset 3871 3d528461f61d
parent 3291 805a72a26925
child 3874 02fe9a813203
equal deleted inserted replaced
3665:c5d39b6be65c 3871:3d528461f61d
    25 
    25 
    26 #
    26 #
    27 #
    27 #
    28 # Rules shared by all Java makefiles.
    28 # Rules shared by all Java makefiles.
    29 #
    29 #
    30 # Used to apply to source file $<, checks code conventions, issues warnings.
    30 
    31 define check-conventions
    31 # Used with wildcard to look into a java package for files (assumes max 5 deep)
    32   if [ "$(CONVENTION_WATCH)" = "true" ] ; then \
    32 _WC_DIRS  = * */* */*/* */*/*/* */*/*/*/*
    33     if [ "`$(CAT) -n -v -t $< | $(EGREP) -v '\@\(\#\)' | $(EGREP) '\^[MLI]'`" != "" ] ; then \
       
    34       $(ECHO) "WARNING: File contains tabs, ^M, or ^L characters: $<"; \
       
    35       if [ "$(CONVENTION_DETAILS)" = "true" ] ; then \
       
    36         $(CAT) -n -v -t $< | $(EGREP) -v '\@\(\#\)' | $(EGREP) '\^[MLI]' ; \
       
    37       fi; \
       
    38     fi; \
       
    39   fi
       
    40 endef
       
    41 
    33 
    42 # Make sure the default rule is all
    34 # Make sure the default rule is all
    43 rules_default_rule: all
    35 rules_default_rule: all
    44 
    36 
    45 #
    37 #
    55 
    47 
    56 #
    48 #
    57 # If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files
    49 # If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files
    58 #
    50 #
    59 ifdef AUTO_FILES_PROPERTIES_DIRS
    51 ifdef AUTO_FILES_PROPERTIES_DIRS
    60   AUTO_FILES_PROPERTIES_FILTERS1  = $(SCM_DIRs) 'X-*' '*-X-*' ',*'
    52   # Wildcard all possible properties files
    61   AUTO_FILES_PROPERTIES_FILTERS1 += $(AUTO_PROPERTIES_PRUNE)
    53   _WC_PROP_FILES = $(patsubst %, %/*.properties, $(_WC_DIRS))
    62   FILES_properties_find_filters1 = $(AUTO_FILES_PROPERTIES_FILTERS1:%=-name % -prune -o)
    54   # Wildcard package directories for this Makefile
    63   FILES_properties_auto1 := \
    55   _AUTO_WC_PROP_FILES = $(foreach dir, $(AUTO_FILES_PROPERTIES_DIRS), \
    64      $(shell \
    56           $(patsubst %, $(dir)/%, $(_WC_PROP_FILES)) )
    65         for dir in $(ALL_CLASSES_SRC) ; do \
    57   # Wildcard all source directories
    66           if [ -d $$dir ] ; then \
    58   _AUTO_WC_ALL_PROP_FILES1 = $(foreach dir, $(ALL_CLASSES_SRC), \
    67             ( $(CD) $$dir; \
    59           $(patsubst %, $(dir)/%,  $(_AUTO_WC_PROP_FILES)) )
    68               for sdir in $(AUTO_FILES_PROPERTIES_DIRS); do \
    60   # Find all files meeting this pattern
    69                 if [ -d $$sdir ] ; then \
    61   FILES_properties_auto1 := $(wildcard $(_AUTO_WC_ALL_PROP_FILES1))
    70                   $(FIND) $$sdir $(FILES_properties_find_filters1) \
       
    71                                  -name '*.properties' -print ; \
       
    72                 fi ; \
       
    73               done \
       
    74             ); \
       
    75           fi; \
       
    76         done \
       
    77       )
       
    78 else
    62 else
    79   FILES_properties_auto1 =
    63   FILES_properties_auto1 =
    80 endif # AUTO_FILES_PROPERTIES_DIRS
    64 endif # AUTO_FILES_PROPERTIES_DIRS
    81 
    65 
    82 # Add any automatically found properties files to the properties file list
    66 # Add any automatically found properties files to the properties file list
   102 #    and since they could be generated late, we need to be careful that
    86 #    and since they could be generated late, we need to be careful that
   103 #    we look for these sources late and not use the ':=' assignment which
    87 #    we look for these sources late and not use the ':=' assignment which
   104 #    might miss their generation.
    88 #    might miss their generation.
   105 
    89 
   106 ifdef AUTO_FILES_JAVA_DIRS
    90 ifdef AUTO_FILES_JAVA_DIRS
   107   # Filter out these files or directories
    91   # Wildcard all possible java files
   108   AUTO_FILES_JAVA_SOURCE_FILTERS1  = $(SCM_DIRs) 'X-*' '*-X-*' '*-template.java' ',*'
    92   _WC_JAVA_FILES = $(patsubst %, %/*.java, $(_WC_DIRS))
   109   AUTO_FILES_JAVA_SOURCE_FILTERS2  = 
    93   # Wildcard package directories for this Makefile
   110   AUTO_FILES_JAVA_SOURCE_FILTERS1 += $(AUTO_JAVA_PRUNE)
    94   _AUTO_WC_JAVA_FILES = $(foreach dir, $(AUTO_FILES_JAVA_DIRS), \
   111   AUTO_FILES_JAVA_SOURCE_FILTERS2 += $(AUTO_JAVA_PRUNE)
    95           $(patsubst %, $(dir)/%, $(_WC_JAVA_FILES)) )
   112 
    96   # Wildcard all source directories
   113   # First list is the normal sources that should always be there,
    97   _AUTO_WC_ALL_JAVA_FILES1 = $(foreach dir, $(ALL_CLASSES_SRC), \
   114   #   by using the ':=', which means we do this processing once.
    98           $(patsubst %, $(dir)/%,  $(_AUTO_WC_JAVA_FILES)) )
   115   FILES_java_find_filters1 = $(AUTO_FILES_JAVA_SOURCE_FILTERS1:%=-name % -prune -o)
    99   # Find all files meeting this pattern
   116   FILES_java_auto1 := \
   100   FILES_java_auto1 := $(wildcard $(_AUTO_WC_ALL_JAVA_FILES1))
   117      $(shell \
   101 
   118         for dir in $(ALL_CLASSES_SRC) ; do \
       
   119           if [ -d $$dir ] ; then \
       
   120             ( $(CD) $$dir; \
       
   121               for sdir in $(AUTO_FILES_JAVA_DIRS); do \
       
   122                 if [ -d $$sdir ] ; then \
       
   123                   $(FIND) $$sdir $(FILES_java_find_filters1) \
       
   124                                  -name '*.java' -print ; \
       
   125                 fi ; \
       
   126               done \
       
   127             ); \
       
   128           fi; \
       
   129         done \
       
   130       )
       
   131   # Second list is the generated sources that should be rare, but will likely
   102   # Second list is the generated sources that should be rare, but will likely
   132   #   show up late and we need to look for them at the last minute, so we
   103   #   show up late and we need to look for them at the last minute, so we
   133   #   cannot use the ':=' assigment here. But if this gets expanded multiple
   104   #   cannot use the ':=' assigment here. But if this gets expanded multiple
   134   #   times, the if tests should make them relatively cheap.
   105   #   times, the if tests should make them relatively cheap.
   135   FILES_java_find_filters2 = $(AUTO_FILES_JAVA_SOURCE_FILTERS2:%=-name % -prune -o)
   106   # Wildcard the generated source directories
   136   FILES_java_auto2 = \
   107   _AUTO_WC_ALL_JAVA_FILES2 = $(patsubst %, $(GENSRCDIR)/%, $(_AUTO_WC_JAVA_FILES))
   137      $(shell \
   108   # Find all files meeting this pattern
   138         for dir in $(GENSRCDIR); do \
   109   FILES_java_auto2 = $(wildcard $(_AUTO_WC_ALL_JAVA_FILES2))
   139           if [ -d $$dir ] ; then \
       
   140             ( $(CD) $$dir; \
       
   141               for sdir in $(AUTO_FILES_JAVA_DIRS); do \
       
   142                 if [ -d $$sdir ] ; then \
       
   143                   $(FIND) $$sdir $(FILES_java_find_filters2) \
       
   144                                  -name '*.java' -print ; \
       
   145                 fi ; \
       
   146               done \
       
   147             ); \
       
   148           fi; \
       
   149         done \
       
   150       )
       
   151 else
   110 else
   152   FILES_java_auto1 =
   111   FILES_java_auto1 =
   153   FILES_java_auto2 =
   112   FILES_java_auto2 =
   154 endif
   113 endif
   155 
   114 
   160 JAVA_SOURCE_LIST=$(TEMPDIR)/.classes.list
   119 JAVA_SOURCE_LIST=$(TEMPDIR)/.classes.list
   161 
   120 
   162 # Add a java source to the list
   121 # Add a java source to the list
   163 define add-java-file
   122 define add-java-file
   164 $(ECHO) "$?" >> $(JAVA_SOURCE_LIST)
   123 $(ECHO) "$?" >> $(JAVA_SOURCE_LIST)
   165 $(check-conventions)
       
   166 endef
   124 endef
   167 
   125 
   168 $(CLASSDESTDIR)/%.class: $(GENSRCDIR)/%.java
   126 $(CLASSDESTDIR)/%.class: $(GENSRCDIR)/%.java
   169 	@$(add-java-file)
   127 	@$(add-java-file)
   170 $(CLASSDESTDIR)/%.class: $(PLATFORM_SRC)/classes/%.java
   128 $(CLASSDESTDIR)/%.class: $(PLATFORM_SRC)/classes/%.java
   195 #   rather than any bootclasspath classes.
   153 #   rather than any bootclasspath classes.
   196 JAVAC_PREFER_SOURCE = -Xprefer:source
   154 JAVAC_PREFER_SOURCE = -Xprefer:source
   197 
   155 
   198 .compile.classlist : $(JAVA_SOURCE_LIST)
   156 .compile.classlist : $(JAVA_SOURCE_LIST)
   199 	@$(MKDIR) -p $(CLASSDESTDIR)
   157 	@$(MKDIR) -p $(CLASSDESTDIR)
   200 	@if [ `$(CAT) $(JAVA_SOURCE_LIST) | $(WC) -l` -ge 1 ] ; then \
   158 	if [ -s $(JAVA_SOURCE_LIST) ] ; then \
   201 	  $(ECHO) "# Java sources to be compiled: (listed in file $(JAVA_SOURCE_LIST))"; \
       
   202 	  $(CAT) $(JAVA_SOURCE_LIST); \
       
   203 	  $(ECHO) "# Running javac:"; \
       
   204 	  $(ECHO) $(JAVAC_CMD) $(JAVAC_PREFER_SOURCE) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \
       
   205 	  $(JAVAC_CMD) $(JAVAC_PREFER_SOURCE) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \
   159 	  $(JAVAC_CMD) $(JAVAC_PREFER_SOURCE) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \
   206 	fi
   160 	fi
   207 	@$(java-vm-cleanup)
   161 	@$(java-vm-cleanup)
   208 
   162 
   209 clobber clean::
   163 clobber clean::
   218 endif
   172 endif
   219 
   173 
   220 packages.clean:
   174 packages.clean:
   221 ifeq ($(DONT_CLOBBER_CLASSES),false)
   175 ifeq ($(DONT_CLOBBER_CLASSES),false)
   222   ifdef AUTO_FILES_JAVA_DIRS
   176   ifdef AUTO_FILES_JAVA_DIRS
   223 	@for sdir in $(AUTO_FILES_JAVA_DIRS); do \
   177 	$(RM) -r $(patsubst %, $(CLASSDESTDIR)/%, $(AUTO_FILES_JAVA_DIRS))
   224 	  $(ECHO) "$(RM) -r $(CLASSDESTDIR)/$$sdir"; \
       
   225 	  $(RM) -r $(CLASSDESTDIR)/$$sdir; \
       
   226         done
       
   227   else
   178   else
   228 	$(RM) -r $(CLASSDESTDIR)/$(PKGDIR)
   179 	$(RM) -r $(CLASSDESTDIR)/$(PKGDIR)
   229   endif
   180   endif
   230 endif
   181 endif
   231 
   182 
   257 
   208 
   258 classheaders: classes $(CLASSHDR_DOTFILE)
   209 classheaders: classes $(CLASSHDR_DOTFILE)
   259 
   210 
   260 $(CLASSHDR_DOTFILE): $(CLASSES_export)
   211 $(CLASSHDR_DOTFILE): $(CLASSES_export)
   261 	$(prep-target)
   212 	$(prep-target)
   262 	@$(ECHO) "# Running javah:"
       
   263 	$(JAVAH_CMD) -d $(CLASSHDRDIR)/ \
   213 	$(JAVAH_CMD) -d $(CLASSHDRDIR)/ \
   264 		$(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner))
   214 		$(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner))
   265 	@$(java-vm-cleanup)
   215 	@$(java-vm-cleanup)
   266 	@$(TOUCH) $@
   216 	@$(TOUCH) $@
   267 
   217 
   268 classheaders.clean:
   218 classheaders.clean:
   269 	$(RM) $(CLASSHDR_DOTFILE)
   219 	$(RM) -r $(CLASSHDRDIR) $(CLASSHDR_DOTFILE)
   270 	$(RM) -r $(CLASSHDRDIR)
       
   271 
   220 
   272 else # FILES_export
   221 else # FILES_export
   273 
   222 
   274 classheaders: classes
   223 classheaders: classes
   275 
   224