#! make -f #---------------------------------------------------------------------------- # Project: RVLDWC - Library - build - buildtools # File: modulerules # # Copyright 2005 Nintendo. All rights reserved. # # These coded instructions, statements, and computer programs contain # proprietary information of Nintendo of America Inc. and/or Nintendo # Company Ltd., and are protected by Federal copyright law. They may # not be disclosed to third parties or copied or duplicated in any form, # in whole or in part, without the prior written consent of Nintendo. # # $Revision: 1.4 $ #---------------------------------------------------------------------------- ifndef RVLDWC_MODULERULES_ #---------------------------------------------------------------------------- # Implicit RULES #---------------------------------------------------------------------------- .SUFFIXES: # Delete all suffix rules VPATH = $(SRCDIR) SSRCFILES = $(addprefix $(OBJDIR)/,$(notdir $(SRCS))) SOBJS_CC = $(filter %.o,$(SSRCFILES:.c=.o)) SOBJS_AS = $(filter %.o,$(SSRCFILES:.s=.o)) SOBJS_CXX = $(filter %.o,$(SSRCFILES:.cpp=.o)) OBJS_CC = $(SOBJS_CC) $(AOBJS_CC) $(VOBJS_CC) OBJS_AS = $(SOBJS_AS) $(AOBJS_AS) $(VOBJS_AS) OBJS_CXX = $(SOBJS_CXX) $(AOBJS_CXX) $(VOBJS_CXX) OBJS_STATIC = $(SOBJS_CC) $(SOBJS_AS) $(SOBJS_CXX) $(EXT_OBJS) OBJS = $(OBJS_STATIC) #---------------------------------------------------------------------------- # Precompile header PCHSRCS = $(filter %.pch,$(SRCS)) PCHFILES = $(addprefix $(PCHDIR)/,$(notdir $(SRCS))) -include $(RVLDWC_BUILDTOOLSDIR)/compiler/modulerules.cctype.$(RVLDWC_CCTYPE) #---------------------------------------------------------------------------- # MAKE TARGETS #---------------------------------------------------------------------------- .PHONY: all default build install clean clobber full BUILDCMDS = all default build #---------------------------------------------------------------------------- #SUBDIR_FLAGS += $(if $(NITRO_CODEGEN_ALL),NITRO_CODEGEN_ALL=) define MAKE_SUBDIR +$(foreach DIR,$(SUBDIRS),$(MAKE) $(SUBDIR_FLAGS) -C $(DIR) $(MAKECMDGOALS) $(AND)) true +$(foreach FILE,$(SUBMAKES),$(MAKE) $(SUBDIR_FLAGS) -C $(dir $(FILE)) -f $(notdir $(FILE)) $(MAKECMDGOALS) $(AND)) true endef # ----------------------------------------------------------------------------- # # echo current directory name. ifeq ($(MAKEFILE),Makefile) MAKEFILE_ = else MAKEFILE_ = /$(MAKEFILE) endif define ECHO_CURDIR $(ECHO) $(ECHO) "==== $(CURDIR)$(MAKEFILE_)"; endef # ----------------------------------------------------------------------------- # # install file. define DO_INSTALL_FILES $(INSTALL) -d $(1) $(AND) \ $(foreach FILE, $(2), \ if [ ! -e $(1)/$(notdir $(FILE)) -o \ $(FILE) -nt $(1)/$(notdir $(FILE)) ]; \ then \ $(ECHO) " install: $(FILE) -> $(1)" $(AND) \ $(INSTALL) $(FILE) $(1)/$(notdir $(FILE)); \ fi $(AND) ) true endef DO_INSTALL = $(call DO_INSTALL_FILES,$(INSTALL_DIR),$(INSTALL_TARGETS)) #---------------------------------------------------------------------------- # make parallelly #---------------------------------------------------------------------------- SUBDIRS_PREFIX = make-subdir-p- SUBDIRS_PARALLEL = $(addprefix $(SUBDIRS_PREFIX),$(SUBDIRS_P)) $(SUBDIRS_PARALLEL):$(SUBDIRS_PREFIX)%: $(MAKE) -C $(*F) $(MAKECMDGOALS) #---------------------------------------------------------------------------- # make build #---------------------------------------------------------------------------- .PHONY: do-build do-install build: @$(MAKE_SUBDIR) @$(ECHO_CURDIR) ifneq ($(strip $(NEWDIRS)),) @$(MKDIRP) $(NEWDIRS) endif @+$(REMAKE) do-build ifdef INSTALL_TARGETS @$(DO_INSTALL) endif @+$(REMAKE) do-install #---------------------------------------------------------------------------- # make install #---------------------------------------------------------------------------- install: @$(MAKE_SUBDIR) @$(ECHO_CURDIR) ifdef INSTALL_TARGETS @$(DO_INSTALL) endif @+$(REMAKE) do-install #---------------------------------------------------------------------------- # make full #---------------------------------------------------------------------------- define makefull @echo [[[ make full $(1) $(CURDIR) ]]] @+unset RVLDWC_DEBUG RVLDWC_RELEASE RVLDWC_FINAL; \ $(foreach a,FINAL RELEASE DEBUG, \ $(REMAKE) RVLDWC_$a=TRUE $(1) $(AND) \ ) true endef full: $(call makefull,build) full-install: $(call makefull,install) #---------------------------------------------------------------------------- # make super-full #---------------------------------------------------------------------------- define makesuperfull @echo [[[ make super-full $(1) $(CURDIR) ]]] @+unset RVLDWC_DEBUG RVLDWC_RELEASE RVLDWC_FINAL; \ $(foreach p,RVL0 GC, \ $(foreach a,FINAL RELEASE DEBUG, \ $(REMAKE) RVLDWC_$a=TRUE RVLDWC_PLATFORM=$p $(1) $(AND) \ )\ ) true endef super-full: $(call makesuperfull,build) super-full-install: $(call makesuperfull,install) #---------------------------------------------------------------------------- # make clobber & clean #---------------------------------------------------------------------------- .PHONY: clobber-installed clobber: @$(MAKE_SUBDIR) @$(ECHO_CURDIR) -$(RM) $(GDIRT_CLEAN) $(LDIRT_CLEAN) $(GDIRT_CLOBBER) $(LDIRT_CLOBBER) ifneq ($(GDIRT_INSTALLED),) $(call makefull,clobber-installed) endif clobber-installed: -$(RM) $(GDIRT_INSTALLED) #---------------------------------------------------------------------------- clean: @$(MAKE_SUBDIR) @$(ECHO_CURDIR) -$(RM) $(GDIRT_CLEAN) $(LDIRT_CLEAN) -include $(RVLDWC_BUILDTOOLSDIR)/emulator/modulerules.emtype.$(RVLDWC_EMTYPE) #---------------------------------------------------------------------------- # source file dependancies #---------------------------------------------------------------------------- # # dynamic dependancy generation # like as $(OBJDIR)/main.o: main.c # DEP_SRCS_ALL = $(SRCS) define RuleCtoObj $$(OBJDIR)/$$(notdir $$(basename $(1))).o: $(1) endef endif # RVLDWC_MODULERULES_ # Put this sentance out of include-guard to avoid $(eval xxx) limitation $(foreach FILE,$(DEP_SRCS_ALL),$(eval $(call RuleCtoObj,$(FILE)))) ifndef RVLDWC_MODULERULES_ # # include dependancies file # ifeq ($(MAKECMDGOALS),do-build) ifdef SRCS -include $(DEPDIR)/*.d endif endif #---------------------------------------------------------------------------- # PRIVATE FLAGS # -include $(RVLDWC_BUILDTOOLSDIR)/_privaterules #---------------------------------------------------------------------------- RVLDWC_MODULERULES_ = TRUE endif # RVLDWC_MODULERULES_