Improve buildsystem, split out generic code

This commit is contained in:
Michael Scire 2019-12-08 19:17:05 -08:00
parent 5797d753bf
commit ef5297acb3
73 changed files with 141 additions and 58 deletions

10
Makefile Normal file
View File

@ -0,0 +1,10 @@
ATMOSPHERE_LIBRARIES := libstratosphere
TOPTARGETS := all clean
$(TOPTARGETS): $(ATMOSPHERE_LIBRARIES)
$(ATMOSPHERE_LIBRARIES):
$(MAKE) -C $@ $(MAKECMDGOALS)
.PHONY: $(TOPTARGETS) $(ATMOSPHERE_LIBRARIES)

11
config/arch/arm64/arch.mk Normal file
View File

@ -0,0 +1,11 @@
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif
include $(DEVKITPRO)/devkitA64/base_rules
export ATMOSPHERE_DEFINES += -DATMOSPHERE_ARCH_ARM64
export ATMOSPHERE_SETTINGS += -march=armv8-a -mtp=soft
export ATMOSPHERE_CFLAGS +=
export ATMOSPHERE_CXXFLAGS +=
export ATMOSPHERE_ASFLAGS +=

View File

@ -0,0 +1,5 @@
export ATMOSPHERE_DEFINES += -DATMOSPHERE_BOARD_NINTENDO_SWITCH -D__SWITCH__
export ATMOSPHERE_SETTINGS += -mtune=cortex-a57
export ATMOSPHERE_CFLAGS +=
export ATMOSPHERE_CXXFLAGS +=
export ATMOSPHERE_ASFLAGS +=

26
config/common.mk Normal file
View File

@ -0,0 +1,26 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
export ATMOSPHERE_CONFIG_MAKE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
export ATMOSPHERE_LIBRARY_DIR := $(ATMOSPHERE_CONFIG_MAKE_DIR)/..
ifeq ($(strip $(ATMOSPHERE_BOARD)),)
export ATMOSPHERE_BOARD := nx-hac-001
endif
export ATMOSPHERE_DEFINES := -DATMOSPHERE
export ATMOSPHERE_SETTINGS := -fPIE -g
export ATMOSPHERE_CFLAGS := -Wall -ffunction-sections -fdata-sections -fno-strict-aliasing -fwrapv \
-fno-asynchronous-unwind-tables -fno-unwind-tables -fno-stack-protector
export ATMOSPHERE_CXXFLAGS := -fno-rtti -fno-exceptions -std=gnu++17
export ATMOSPHERE_ASFLAGS :=
ifeq ($(ATMOSPHERE_BOARD),nx-hac-001)
export ATMOSPHERE_ARCH_MAKE_DIR := $(ATMOSPHERE_CONFIG_MAKE_DIR)/arch/arm64
export ATMOSPHERE_BOARD_MAKE_DIR := $(ATMOSPHERE_CONFIG_MAKE_DIR)/board/nintendo/switch
endif
include $(ATMOSPHERE_ARCH_MAKE_DIR)/arch.mk
include $(ATMOSPHERE_BOARD_MAKE_DIR)/board.mk

View File

@ -1,12 +1,15 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
# pull in common atmosphere configuration
#---------------------------------------------------------------------------------
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../config/common.mk
#---------------------------------------------------------------------------------
# pull in switch rules
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
@ -16,26 +19,20 @@ include $(DEVKITPRO)/libnx/switch_rules
# INCLUDES is a list of directories containing header files
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
SOURCES ?= $(shell find source -type d)
DATA := data
INCLUDES := include
DEFINES :=
SOURCES ?= $(shell find source -type d)
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
DEFINES := $(ATMOSPHERE_DEFINES) -DATMOSPHERE_IS_STRATOSPHERE
SETTINGS := $(ATMOSPHERE_SETTINGS) -O2
CFLAGS := $(ATMOSPHERE_CFLAGS) $(SETTINGS) $(DEFINES) $(INCLUDE)
CXXFLAGS := $(CFLAGS) $(ATMOSPHERE_CXXFLAGS) -flto
ASFLAGS := $(ATMOSPHERE_ASFLAGS) $(SETTINGS)
CFLAGS := -g -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES)
CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 -flto
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LDFLAGS := -specs=$(DEVKITPRO)/libnx/switch.specs $(SETTINGS) -Wl,-Map,$(notdir $.map)
LIBS := -lnx
@ -43,7 +40,7 @@ LIBS := -lnx
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX)
LIBDIRS := $(PORTLIBS) $(LIBNX) $(ATMOSPHERE_LIBRARY_DIR)/libvapours
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
@ -81,8 +78,7 @@ 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/
-I.
.PHONY: clean all

View File

@ -16,8 +16,8 @@
#pragma once
/* Pulls in util, svc. */
#include "atmosphere/common.hpp"
/* libvapours (pulls in util, svc, results). */
#include <vapours.hpp>
/* Critical modules with no dependencies. */
#include "stratosphere/ams.hpp"

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
#include "../sf/sf_buffer_tags.hpp"
#include "../hos.hpp"

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::boot2 {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::dd {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::dd {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
#include "../ncm/ncm_types.hpp"
#include "../sf/sf_buffer_tags.hpp"

View File

@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
#include "../os.hpp"
#include "../ncm.hpp"
#include "../sf.hpp"

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::hos {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::kvdb {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::kvdb {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
#include "../ncm/ncm_types.hpp"
#include "../sf/sf_buffer_tags.hpp"

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::map {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::ncm {

View File

@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::os {

View File

@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::os {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::reg {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::rnd {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
#include "../ncm/ncm_types.hpp"
namespace ams::ro {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
#include "settings_fwdbg_types.hpp"
namespace ams::settings::fwdbg {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
#include "../sf/sf_buffer_tags.hpp"
namespace ams::settings::fwdbg {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::settings {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
#include "../ams.hpp"
#include "../os.hpp"
#include "../sm/sm_types.hpp"

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
#include "../ncm/ncm_types.hpp"
#include "../cfg/cfg_types.hpp"

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::spl {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include <atmosphere/common.hpp>
#include <vapours.hpp>
namespace ams::updater {

View File

@ -15,8 +15,6 @@
*/
#pragma once
#include "common_includes.hpp"
#include "defines.hpp"
#include "util.hpp"
#include "results.hpp"
#include "svc.hpp"
#include "util/util_compression.hpp"
#include "util/util_ini.hpp"

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include "../defines.hpp"
#include <vapours.hpp>
namespace ams::util {

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include "../defines.hpp"
#include <vapours.hpp>
namespace ams::util::ini {

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2018-2019 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "vapours/includes.hpp"
#include "vapours/defines.hpp"
#include "vapours/util.hpp"
#include "vapours/results.hpp"
#include "vapours/svc.hpp"

View File

@ -15,7 +15,7 @@
*/
#pragma once
#include "common_includes.hpp"
#include "includes.hpp"
/* Any broadly useful language defines should go here. */

View File

@ -26,17 +26,23 @@
#include <climits>
#include <cctype>
/* C++ headers. */
#include <type_traits>
#include <algorithm>
#include <iterator>
#include <limits>
#include <random>
/* Stratosphere wants stdlib headers, others do not.. */
#ifdef ATMOSPHERE_IS_STRATOSPHERE
/* C++ headers. */
#include <atomic>
#include <utility>
#include <iterator>
#include <optional>
#include <memory>
#include <mutex>
#include <shared_mutex>
#include <algorithm>
#include <functional>
#include <tuple>
#include <array>
@ -44,9 +50,19 @@
#include <unordered_map>
#include <set>
#endif /* ATMOSPHERE_IS_STRATOSPHERE */
#ifdef ATMOSPHERE_BOARD_NINTENDO_SWITCH
/* Libnx. */
#include <switch.h>
#else
#error "Unsupported board"
#endif /* ATMOSPHERE_BOARD_NINTENDO_SWITCH */
/* Atmosphere meta. */
#if __has_include(<atmosphere.h>)
#include <atmosphere.h>

View File

@ -23,5 +23,3 @@
#include "util/util_typed_storage.hpp"
#include "util/util_intrusive_list.hpp"
#include "util/util_intrusive_red_black_tree.hpp"
#include "util/util_compression.hpp"
#include "util/util_ini.hpp"