mirror of
				https://github.com/Atmosphere-NX/Atmosphere.git
				synced 2025-11-04 12:51:17 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			123 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
			
		
		
	
	
			123 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
#---------------------------------------------------------------------------------
 | 
						|
# Define the atmosphere board and cpu
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
export ATMOSPHERE_BOARD := nx-hac-001
 | 
						|
export ATMOSPHERE_CPU   := arm7tdmi
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
# pull in common atmosphere configuration
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
include  $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../../libraries/config/templates/exosphere.mk
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
# no real need to edit anything past this point unless you need to add additional
 | 
						|
# rules for different file extensions
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
ifneq ($(BUILD),$(notdir $(CURDIR)))
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
 | 
						|
export OUTPUT	:=	$(CURDIR)/$(TARGET)
 | 
						|
export TOPDIR	:=	$(CURDIR)
 | 
						|
export DEPSDIR  :=  $(CURDIR)/$(BUILD)
 | 
						|
 | 
						|
export VPATH	:=	$(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
 | 
						|
			$(foreach dir,$(DATA),$(CURDIR)/$(dir))
 | 
						|
 | 
						|
CFILES      :=	$(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.c)) $(notdir $(wildcard $(dir)/*.board.*.c)) $(notdir $(wildcard $(dir)/*.os.*.c)), \
 | 
						|
                                                      $(notdir $(wildcard $(dir)/*.c))))
 | 
						|
CFILES      +=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).c)))
 | 
						|
CFILES      +=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).c)))
 | 
						|
CFILES      +=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).c)))
 | 
						|
 | 
						|
CPPFILES    :=	$(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.cpp)) $(notdir $(wildcard $(dir)/*.board.*.cpp)) $(notdir $(wildcard $(dir)/*.os.*.cpp)), \
 | 
						|
                                                      $(notdir $(wildcard $(dir)/*.cpp))))
 | 
						|
CPPFILES    +=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).cpp)))
 | 
						|
CPPFILES    +=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).cpp)))
 | 
						|
CPPFILES    +=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).cpp)))
 | 
						|
 | 
						|
SFILES      :=	$(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.s)) $(notdir $(wildcard $(dir)/*.board.*.s)) $(notdir $(wildcard $(dir)/*.os.*.s)), \
 | 
						|
                                                      $(notdir $(wildcard $(dir)/*.s))))
 | 
						|
SFILES      +=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).s)))
 | 
						|
SFILES      +=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).s)))
 | 
						|
SFILES      +=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).s)))
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
# use CXX for linking C++ projects, CC for standard C
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
ifeq ($(strip $(CPPFILES)),)
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
	export LD	:=	$(CC)
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
else
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
	export LD	:=	$(CXX)
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
endif
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
 | 
						|
export OFILES_BIN	:=	$(addsuffix .o,$(BINFILES))
 | 
						|
export OFILES_SRC	:=	$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
 | 
						|
export OFILES 	:=	$(OFILES_BIN) $(OFILES_SRC)
 | 
						|
export HFILES_BIN	:=	$(addsuffix .h,$(subst .,_,$(subst -,_,$(BINFILES))))
 | 
						|
 | 
						|
export INCLUDE	:=	$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
 | 
						|
			$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
 | 
						|
			-I.
 | 
						|
 | 
						|
export LIBPATHS	:=	$(foreach dir,$(LIBDIRS),-L$(dir)/lib -L$(dir)/$(ATMOSPHERE_LIBRARY_DIR))
 | 
						|
 | 
						|
.PHONY: $(BUILD) clean all
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
all: $(BUILD) check_libexo
 | 
						|
 | 
						|
$(BUILD): check_libexo
 | 
						|
	@[ -d $@ ] || mkdir -p $@
 | 
						|
	@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
 | 
						|
 | 
						|
check_libexo:
 | 
						|
	@$(MAKE) --no-print-directory -C ../../libraries/libexosphere arm
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
clean:
 | 
						|
	@echo clean ...
 | 
						|
	@rm -fr $(BUILD) $(OUTPUT).bin $(OUTPUT).elf *.lz4
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
else
 | 
						|
.PHONY:	all
 | 
						|
 | 
						|
DEPENDS	:=	$(OFILES:.o=.d)
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
# main targets
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
all	:	$(OUTPUT).bin
 | 
						|
 | 
						|
$(OUTPUT).bin	:	$(OUTPUT).elf
 | 
						|
	$(OBJCOPY) -S -O binary --set-section-flags .bss=alloc,load,contents $< $@
 | 
						|
	@echo built ... $(notdir $@)
 | 
						|
 | 
						|
$(OUTPUT).elf	:	$(OFILES) ../../../libraries/libexosphere/$(ATMOSPHERE_LIBRARY_DIR)/libexosphere.a
 | 
						|
 | 
						|
%.elf:
 | 
						|
	@echo linking $(notdir $@)
 | 
						|
	$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
 | 
						|
	@$(NM) -CSn $@ > $(notdir $*.lst)
 | 
						|
 | 
						|
$(OFILES_SRC)	: $(HFILES_BIN)
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
# you need a rule like this for each extension you use as binary data
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
%.bin.o	%_bin.h:	%.bin
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
	@echo $(notdir $<)
 | 
						|
	@$(bin2o)
 | 
						|
 | 
						|
-include $(DEPENDS)
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------------
 | 
						|
endif
 | 
						|
#---------------------------------------------------------------------------------------
 |