mirror of
				https://github.com/switchbrew/libnx.git
				synced 2025-11-04 14:51:17 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			167 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
			
		
		
	
	
			167 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
#---------------------------------------------------------------------------------
 | 
						|
.SUFFIXES:
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
 | 
						|
ifeq ($(strip $(DEVKITPRO)),)
 | 
						|
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
 | 
						|
endif
 | 
						|
 | 
						|
include $(DEVKITPRO)/devkitA64/base_rules
 | 
						|
 | 
						|
export LIBNX_MAJOR	:= 4
 | 
						|
export LIBNX_MINOR	:= 2
 | 
						|
export LIBNX_PATCH	:= 0
 | 
						|
 | 
						|
 | 
						|
VERSION	:=	$(LIBNX_MAJOR).$(LIBNX_MINOR).$(LIBNX_PATCH)
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
# TARGET is the name of the output
 | 
						|
# BUILD is the directory where object files & intermediate files will be placed
 | 
						|
# SOURCES is a list of directories containing source code
 | 
						|
# DATA is a list of directories containing data files
 | 
						|
# INCLUDES is a list of directories containing header files
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
TARGET		:=	nx
 | 
						|
#BUILD		:=	build
 | 
						|
SOURCES		:=	source/arm source/kernel source/sf source/services source/crypto source/nvidia source/nvidia/ioctl source/display source/audio source/applets source/runtime source/runtime/devices source/runtime/util source/runtime/util/utf
 | 
						|
DATA		:=	data
 | 
						|
INCLUDES	:=	include external/bsd/include
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
# options for code generation
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
ARCH	:=	-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec
 | 
						|
 | 
						|
CFLAGS	:=	-g -Wall -Werror \
 | 
						|
			-ffunction-sections \
 | 
						|
			-fdata-sections \
 | 
						|
			$(ARCH) \
 | 
						|
			$(BUILD_CFLAGS)
 | 
						|
 | 
						|
CFLAGS	+=	$(INCLUDE) -D__SWITCH__ -DLIBNX_NO_DEPRECATION
 | 
						|
 | 
						|
CXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
 | 
						|
 | 
						|
ASFLAGS	:=	-g $(ARCH)
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
# list of directories containing libraries, this must be the top level containing
 | 
						|
# include and lib
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
LIBDIRS	:=
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
# 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 VPATH	:=	$(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
 | 
						|
			$(foreach dir,$(DATA),$(CURDIR)/$(dir))
 | 
						|
 | 
						|
CFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
 | 
						|
CPPFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
 | 
						|
SFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
 | 
						|
BINFILES	:=	$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
# 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	:=	$(addsuffix .h,$(subst .,_,$(BINFILES)))
 | 
						|
 | 
						|
export INCLUDE	:=	$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
 | 
						|
			$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
 | 
						|
			-I. \
 | 
						|
			-iquote $(CURDIR)/include/switch/
 | 
						|
 | 
						|
.PHONY: clean all
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
all: lib/libnx.a lib/libnxd.a
 | 
						|
 | 
						|
dist-bin: all
 | 
						|
	@tar --exclude=*~ -cjf libnx-$(VERSION).tar.bz2 include lib default_icon.jpg switch_rules switch.ld switch.specs -C external/bsd include
 | 
						|
 | 
						|
dist-src:
 | 
						|
	@tar --exclude=*~ -cjf libnx-src-$(VERSION).tar.bz2 include source data external Makefile default_icon.jpg switch_rules switch.ld switch.specs
 | 
						|
 | 
						|
dist: dist-src dist-bin
 | 
						|
 | 
						|
install: dist-bin
 | 
						|
	mkdir -p $(DESTDIR)$(DEVKITPRO)/libnx
 | 
						|
	bzip2 -cd libnx-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/libnx
 | 
						|
 | 
						|
#dox:
 | 
						|
#	@doxygen Doxyfile
 | 
						|
#	@doxygen Doxyfile.internal
 | 
						|
 | 
						|
lib:
 | 
						|
	@[ -d $@ ] || mkdir -p $@
 | 
						|
 | 
						|
release:
 | 
						|
	@[ -d $@ ] || mkdir -p $@
 | 
						|
 | 
						|
debug:
 | 
						|
	@[ -d $@ ] || mkdir -p $@
 | 
						|
 | 
						|
lib/libnx.a : lib release $(SOURCES) $(INCLUDES)
 | 
						|
	@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
 | 
						|
	BUILD_CFLAGS="-DNDEBUG=1 -O2" \
 | 
						|
	DEPSDIR=$(CURDIR)/release \
 | 
						|
	--no-print-directory -C release \
 | 
						|
	-f $(CURDIR)/Makefile
 | 
						|
 | 
						|
lib/libnxd.a : lib debug $(SOURCES) $(INCLUDES)
 | 
						|
	@$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \
 | 
						|
	BUILD_CFLAGS="-DDEBUG=1 -Og" \
 | 
						|
	DEPSDIR=$(CURDIR)/debug \
 | 
						|
	--no-print-directory -C debug \
 | 
						|
	-f $(CURDIR)/Makefile
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
clean:
 | 
						|
	@echo clean ...
 | 
						|
	@rm -fr release debug lib docs internal_docs
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
else
 | 
						|
 | 
						|
DEPENDS	:=	$(OFILES:.o=.d)
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
# main targets
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
$(OUTPUT)	:	$(OFILES)
 | 
						|
 | 
						|
$(OFILES_SRC)	: $(HFILES)
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
%_bin.h %.bin.o	:	%.bin
 | 
						|
#---------------------------------------------------------------------------------
 | 
						|
	@echo $(notdir $<)
 | 
						|
	@$(bin2o)
 | 
						|
 | 
						|
 | 
						|
-include $(DEPENDS)
 | 
						|
 | 
						|
#---------------------------------------------------------------------------------------
 | 
						|
endif
 | 
						|
#---------------------------------------------------------------------------------------
 | 
						|
 |