michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: ####################################################################### michael@0: # # michael@0: # Parameters to this makefile (set these in this file): # michael@0: # # michael@0: # a) # michael@0: # TARGETS -- the target to create # michael@0: # (defaults to $LIBRARY $PROGRAM) # michael@0: # b) # michael@0: # DIRS -- subdirectories for make to recurse on # michael@0: # (the 'all' rule builds $TARGETS $DIRS) # michael@0: # c) # michael@0: # CSRCS, CPPSRCS -- .c and .cpp files to compile # michael@0: # (used to define $OBJS) # michael@0: # d) # michael@0: # PROGRAM -- the target program name to create from $OBJS # michael@0: # ($OBJDIR automatically prepended to it) # michael@0: # e) # michael@0: # LIBRARY -- the target library name to create from $OBJS # michael@0: # ($OBJDIR automatically prepended to it) # michael@0: # f) # michael@0: # JSRCS -- java source files to compile into class files # michael@0: # (if you don't specify this it will default # michael@0: # to *.java) # michael@0: # g) # michael@0: # PACKAGE -- the package to put the .class files into # michael@0: # (e.g. netscape/applet) # michael@0: # (NOTE: the default definition for this may be # michael@0: # overridden if "jdk.mk" is included) # michael@0: # h) # michael@0: # JMC_EXPORT -- java files to be exported for use by JMC_GEN # michael@0: # (this is a list of Class names) # michael@0: # i) # michael@0: # JRI_GEN -- files to run through javah to generate headers # michael@0: # and stubs # michael@0: # (output goes into the _jri sub-dir) # michael@0: # j) # michael@0: # JMC_GEN -- files to run through jmc to generate headers # michael@0: # and stubs # michael@0: # (output goes into the _jmc sub-dir) # michael@0: # k) # michael@0: # JNI_GEN -- files to run through javah to generate headers # michael@0: # (output goes into the _jni sub-dir) # michael@0: # # michael@0: ####################################################################### michael@0: michael@0: # michael@0: # CPU_TAG is now defined in the $(TARGET).mk files michael@0: # michael@0: michael@0: ifndef COMPILER_TAG michael@0: ifneq ($(DEFAULT_COMPILER), $(notdir $(firstword $(CC)))) michael@0: # michael@0: # Temporary define for the Client; to be removed when binary release is used michael@0: # michael@0: ifdef MOZILLA_CLIENT michael@0: COMPILER_TAG = michael@0: else michael@0: COMPILER_TAG = _$(notdir $(firstword $(CC))) michael@0: endif michael@0: else michael@0: COMPILER_TAG = michael@0: endif michael@0: endif michael@0: michael@0: ifeq ($(MKPROG),) michael@0: MKPROG = $(CC) michael@0: endif michael@0: michael@0: # michael@0: # This makefile contains rules for building the following kinds of michael@0: # objects: michael@0: # - (1) LIBRARY: a static (archival) library michael@0: # - (2) SHARED_LIBRARY: a shared (dynamic link) library michael@0: # - (3) IMPORT_LIBRARY: an import library, defined in $(OS_TARGET).mk michael@0: # - (4) PROGRAM: an executable binary michael@0: # michael@0: # NOTE: The names of libraries can be generated by simply specifying michael@0: # LIBRARY_NAME (and LIBRARY_VERSION in the case of non-static libraries). michael@0: # LIBRARY and SHARED_LIBRARY may be defined differently in $(OS_TARGET).mk michael@0: # michael@0: michael@0: ifdef LIBRARY_NAME michael@0: ifndef LIBRARY michael@0: LIBRARY = $(OBJDIR)/$(LIB_PREFIX)$(LIBRARY_NAME).$(LIB_SUFFIX) michael@0: endif michael@0: ifndef SHARED_LIBRARY michael@0: SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(JDK_DEBUG_SUFFIX).$(DLL_SUFFIX) michael@0: endif michael@0: ifndef MAPFILE_SOURCE michael@0: MAPFILE_SOURCE = $(LIBRARY_NAME).def michael@0: endif michael@0: endif michael@0: michael@0: # michael@0: # Common rules used by lots of makefiles... michael@0: # michael@0: michael@0: ifdef PROGRAM michael@0: PROGRAM := $(addprefix $(OBJDIR)/, $(PROGRAM)$(JDK_DEBUG_SUFFIX)$(PROG_SUFFIX)) michael@0: endif michael@0: michael@0: ifdef PROGRAMS michael@0: PROGRAMS := $(addprefix $(OBJDIR)/, $(PROGRAMS:%=%$(JDK_DEBUG_SUFFIX)$(PROG_SUFFIX))) michael@0: endif michael@0: michael@0: ifndef TARGETS michael@0: TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) michael@0: endif michael@0: michael@0: ifndef OBJS michael@0: SIMPLE_OBJS = $(JRI_STUB_CFILES) \ michael@0: $(addsuffix $(OBJ_SUFFIX), $(JMC_GEN)) \ michael@0: $(CSRCS:.c=$(OBJ_SUFFIX)) \ michael@0: $(CPPSRCS:.cpp=$(OBJ_SUFFIX)) \ michael@0: $(ASFILES:$(ASM_SUFFIX)=$(OBJ_SUFFIX)) \ michael@0: $(BUILT_CSRCS:.c=$(OBJ_SUFFIX)) \ michael@0: $(BUILT_CPPSRCS:.cpp=$(OBJ_SUFFIX)) \ michael@0: $(BUILT_ASFILES:$(ASM_SUFFIX)=$(OBJ_SUFFIX)) michael@0: OBJS = $(addprefix $(OBJDIR)/$(PROG_PREFIX), $(SIMPLE_OBJS)) michael@0: endif michael@0: michael@0: ifndef BUILT_SRCS michael@0: BUILT_SRCS = $(addprefix $(OBJDIR)/$(PROG_PREFIX), \ michael@0: $(BUILT_CSRCS) $(BUILT_CPPSRCS) $(BUILT_ASFILES)) michael@0: endif michael@0: michael@0: michael@0: ifeq (,$(filter-out WIN%,$(OS_TARGET))) michael@0: MAKE_OBJDIR = $(INSTALL) -D $(OBJDIR) michael@0: else michael@0: define MAKE_OBJDIR michael@0: if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); fi michael@0: endef michael@0: endif michael@0: michael@0: ifndef PACKAGE michael@0: PACKAGE = . michael@0: endif michael@0: michael@0: ifdef NSBUILDROOT michael@0: JDK_GEN_DIR = $(SOURCE_XP_DIR)/_gen michael@0: JMC_GEN_DIR = $(SOURCE_XP_DIR)/_jmc michael@0: JNI_GEN_DIR = $(SOURCE_XP_DIR)/_jni michael@0: JRI_GEN_DIR = $(SOURCE_XP_DIR)/_jri michael@0: JDK_STUB_DIR = $(SOURCE_XP_DIR)/_stubs michael@0: else michael@0: JDK_GEN_DIR = _gen michael@0: JMC_GEN_DIR = _jmc michael@0: JNI_GEN_DIR = _jni michael@0: JRI_GEN_DIR = _jri michael@0: JDK_STUB_DIR = _stubs michael@0: endif michael@0: michael@0: ALL_TRASH = $(TARGETS) $(OBJS) $(OBJDIR) LOGS TAGS $(GARBAGE) \ michael@0: so_locations $(BUILT_SRCS) $(NOSUCHFILE) michael@0: michael@0: ifdef NS_USE_JDK michael@0: ALL_TRASH += $(JDK_HEADER_CFILES) $(JDK_STUB_CFILES) \ michael@0: $(JMC_HEADERS) $(JMC_STUBS) $(JMC_EXPORT_FILES) \ michael@0: $(JNI_HEADERS) \ michael@0: $(JRI_HEADER_CFILES) $(JRI_STUB_CFILES) \ michael@0: $(JDK_GEN_DIR) $(JMC_GEN_DIR) $(JNI_GEN_DIR) \ michael@0: $(JRI_GEN_DIR) $(JDK_STUB_DIR) michael@0: michael@0: ifdef JAVA_DESTPATH michael@0: ALL_TRASH += $(wildcard $(JAVA_DESTPATH)/$(PACKAGE)/*.class) michael@0: ifdef JDIRS michael@0: ALL_TRASH += $(addprefix $(JAVA_DESTPATH)/,$(JDIRS)) michael@0: endif michael@0: else # !JAVA_DESTPATH michael@0: ALL_TRASH += $(wildcard $(PACKAGE)/*.class) $(JDIRS) michael@0: endif michael@0: michael@0: endif #NS_USE_JDK michael@0: michael@0: ifdef NSS_BUILD_CONTINUE_ON_ERROR michael@0: # Try to build everything. I.e., don't exit on errors. michael@0: EXIT_ON_ERROR = +e michael@0: IGNORE_ERROR = - michael@0: CLICK_STOPWATCH = date michael@0: else michael@0: EXIT_ON_ERROR = -e michael@0: IGNORE_ERROR = michael@0: CLICK_STOPWATCH = true michael@0: endif michael@0: michael@0: ifdef REQUIRES michael@0: MODULE_INCLUDES := $(addprefix -I$(SOURCE_XP_DIR)/public/, $(REQUIRES)) michael@0: INCLUDES += $(MODULE_INCLUDES) michael@0: ifeq ($(MODULE), sectools) michael@0: PRIVATE_INCLUDES := $(addprefix -I$(SOURCE_XP_DIR)/private/, $(REQUIRES)) michael@0: INCLUDES += $(PRIVATE_INCLUDES) michael@0: endif michael@0: endif michael@0: michael@0: ifdef SYSTEM_INCL_DIR michael@0: YOPT = -Y$(SYSTEM_INCL_DIR) michael@0: endif michael@0: michael@0: ifdef DIRS michael@0: define SUBMAKE michael@0: +@echo "cd $2; $(MAKE) $1" michael@0: $(IGNORE_ERROR)@$(MAKE) -C $(2) $(1) michael@0: @$(CLICK_STOPWATCH) michael@0: michael@0: endef michael@0: michael@0: LOOP_OVER_DIRS = $(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir))) michael@0: endif michael@0: michael@0: MK_RULESET = included