Fix compiling on macOS by adding the Homebrew library includes, fix clang compilation warnings (missing newlines, fixed some printf arguments, updated old POSIX standard causing clang not to define vsnprintf)

This commit is contained in:
Aurora Wright 2018-01-24 23:18:27 +01:00
parent 9e5c20c465
commit 6a4b94bec3
10 changed files with 23 additions and 17 deletions

View file

@ -2,11 +2,17 @@ include config.mk
ifeq ($(OS),Windows_NT)
LDFLAGS += -liconv
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
CFLAGS += -I/usr/local/opt/libgcrypt/include
LDFLAGS += -L/usr/local/opt/libgcrypt/lib
endif
endif
.PHONY: clean
CFLAGS += -D_BSD_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=2 -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -D_FILE_OFFSET_BITS=64
CFLAGS += -D_BSD_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -D_FILE_OFFSET_BITS=64
all: ncatool

View file

@ -42,4 +42,4 @@ oschar_t *filepath_get(filepath_t *fpath);
#endif
#endif

2
nca.h
View file

@ -202,4 +202,4 @@ void nca_save_pfs0_section(nca_section_ctx_t *ctx);
void nca_save_ivfc_section(nca_section_ctx_t *ctx);
void nca_save_bktr_section(nca_section_ctx_t *ctx);
#endif
#endif

16
npdm.c
View file

@ -370,17 +370,17 @@ void kac_print(uint32_t *descriptors, uint32_t num_descriptors) {
}
if (kac.has_kern_flags) {
printf(" Lowest Allowed Priority: %"PRId8"\n", kac.lowest_thread_prio);
printf(" Highest Allowed Priority: %"PRId8"\n", kac.highest_thread_prio);
printf(" Lowest Allowed CPU ID: %"PRId8"\n", kac.lowest_cpu_id);
printf(" Highest Allowed CPU ID: %"PRId8"\n", kac.highest_cpu_id);
printf(" Lowest Allowed Priority: %"PRId32"\n", kac.lowest_thread_prio);
printf(" Highest Allowed Priority: %"PRId32"\n", kac.highest_thread_prio);
printf(" Lowest Allowed CPU ID: %"PRId32"\n", kac.lowest_cpu_id);
printf(" Highest Allowed CPU ID: %"PRId32"\n", kac.highest_cpu_id);
}
int first_svc = 1;
for (unsigned int i = 0; i < 0x80; i++) {
if (kac.svcs_allowed[i]) {
printf(first_svc ? " Allowed SVCs: %-35s (0x%02"PRIx8")\n" : " %-35s (0x%02"PRIx8")\n", svc_names[i], i);
printf(first_svc ? " Allowed SVCs: %-35s (0x%02"PRIx32")\n" : " %-35s (0x%02"PRIx32")\n", svc_names[i], i);
first_svc = 0;
}
}
@ -567,10 +567,10 @@ void sac_print(char *acid_sac, uint32_t acid_size, char *aci0_sac, uint32_t aci0
void fac_print(fac_t *fac, fah_t *fah) {
if (fac->version == fah->version) {
printf(" Version: %"PRId8"\n", fac->version);
printf(" Version: %"PRId32"\n", fac->version);
} else {
printf(" Control Version: %"PRId8"\n", fac->version);
printf(" Header Version: %"PRId8"\n", fah->version);
printf(" Control Version: %"PRId32"\n", fac->version);
printf(" Header Version: %"PRId32"\n", fah->version);
}
uint64_t perms = fac->perms & fah->perms;
printf(" Raw Permissions: 0x%016"PRIx64"\n", perms);

2
npdm.h
View file

@ -134,4 +134,4 @@ static inline npdm_aci0_t *npdm_get_aci0(npdm_t *npdm) {
void npdm_print(npdm_t *npdm, ncatool_ctx_t *tool_ctx);
#endif
#endif

2
pfs0.h
View file

@ -38,4 +38,4 @@ static inline char *pfs0_get_file_name(pfs0_header_t *hdr, uint32_t i) {
return pfs0_get_string_table(hdr) + pfs0_get_file_entry(hdr, i)->string_table_offset;
}
#endif
#endif

2
pki.h
View file

@ -241,4 +241,4 @@ static inline void pki_initialize_keyset(nca_keyset_t *keyset, keyset_variant_t
}
}
#endif
#endif

2
rsa.h
View file

@ -6,4 +6,4 @@
int rsa2048_pss_verify(const void *data, size_t len, const unsigned char *signature, const unsigned char *modulus);
#endif
#endif

View file

@ -56,4 +56,4 @@ typedef struct {
} ncatool_ctx_t;
#endif
#endif

2
sha.h
View file

@ -18,4 +18,4 @@ void sha_free(sha_ctx_t *ctx);
void sha_hash_buffer(unsigned char *hash, const void *data, size_t l);
#endif
#endif