#! make -f #---------------------------------------------------------------------------- # Project: CtrFirm - modulerules - common rules for build system # File: modulerules.x86 # # Copyright 2008 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. # # $Date:: $ # $Rev$ # $Author$ #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # Implicit RULES #---------------------------------------------------------------------------- WARNING = -Wall LEX = flex YACC = bison -y # workaround for flex gen code to avoid warnings %.yy.o:WARNING += -Wno-unused-label -Wno-unused-function ifdef DEBUG MACROS += -DDEBUG -g endif ifdef CTR_DEBUG MACROS += -g endif define COMPILE_C $(CC_X86) $(MACROS) -DSDK_WIN32 $(WARNING) -c -I. -I$(CTR_INCDIR) $< -o $@ endef define COMPILE_CXX $(CXX_X86) $(MACROS) -DSDK_WIN32 $(WARNING) -c -I. -I$(CTR_INCDIR) $< -o $@ endef %.o: %.c $(COMPILE_C) %.o: %.cpp $(COMPILE_CXX) %.yy.c: %.l $(LEX) -P$(basename $<)_yy -o$@ $< %.tab.c: %.y $(YACC) -d -p $(basename $<)_yy -b $(basename $<) $< %.tab.h: %.tab.c #---------------------------------------------------------------------------- # MAKE TARGETS #---------------------------------------------------------------------------- .PHONY: all default build do-build install do-install \ clean clobber super-clobber #---------------------------------------------------------------------------- define MAKE_SUBDIR +$(foreach DIR,$(SUBDIRS),$(MAKE) -C $(DIR) $(MAKECMDGOALS) $(AND)) true +$(foreach FILE,$(SUBMAKES),$(MAKE) -C $(dir $(FILE)) -f $(notdir $(FILE)) $(MAKECMDGOALS) $(AND)) true endef ifeq ($(MAKEFILE),Makefile) MAKEFILE_ = else MAKEFILE_ = /$(MAKEFILE) endif define ECHO_CURDIR $(ECHO) "==== $(CURDIR)$(MAKEFILE_)"; endef #---------------------------------------------------------------------------- # make build #---------------------------------------------------------------------------- build: @$(MAKE_SUBDIR) @$(ECHO_CURDIR) ifdef TARGETS ifdef NEWDIRS @$(MKDIRP) $(NEWDIRS) endif @+$(REMAKE) do-build ifdef INSTALL_TARGETS @+$(REMAKE) do-install endif endif #---------------------------------------------------------------------------- # make install #---------------------------------------------------------------------------- install: @$(MAKE_SUBDIR) @$(ECHO_CURDIR) ifdef INSTALL_TARGETS @+$(REMAKE) do-install endif define DO_INSTALL $(INSTALL) -d $(INSTALL_DIR) $(AND) \ $(foreach FILE, $(INSTALL_TARGETS), \ if [ ! -e $(INSTALL_DIR)/$(notdir $(FILE)) -o \ $(FILE) -nt $(INSTALL_DIR)/$(notdir $(FILE)) ]; \ then \ $(ECHO) " install: $(FILE) -> $(INSTALL_DIR)" $(AND) \ $(INSTALL) $(FILE) $(INSTALL_DIR)/$(notdir $(FILE)); \ fi $(AND) ) true endef do-install: @$(DO_INSTALL) #---------------------------------------------------------------------------- # make do-autotest #---------------------------------------------------------------------------- do-autotest: @$(MAKE_SUBDIR) @$(ECHO_CURDIR) #---------------------------------------------------------------------------- # make clobber & clean #---------------------------------------------------------------------------- super-clobber clobber: @$(MAKE_SUBDIR) @$(ECHO_CURDIR) -$(RM) $(GDIRT_CLEAN) $(LDIRT_CLEAN) -$(RM) $(GDIRT_CLOBBER) $(LDIRT_CLOBBER) -$(RM) $(GDIRT_INSTALLED) #---------------------------------------------------------------------------- clean: @$(MAKE_SUBDIR) @$(ECHO_CURDIR) -$(RM) $(GDIRT_CLEAN) $(LDIRT_CLEAN) #----- End of modulerules -----