From 74f78a60deb374a00b9c3b91b7c106a6ef6f22a0 Mon Sep 17 00:00:00 2001 From: Ivan Baravy Date: Mon, 13 Dec 2021 01:07:42 +0300 Subject: [PATCH] Build with clang optionally --- makefile | 34 ++++++++++++++++++++++++---------- umka_gen_devices_dat.c | 2 +- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/makefile b/makefile index f306be3..570ba5d 100644 --- a/makefile +++ b/makefile @@ -1,11 +1,25 @@ -KOLIBRIOS ?= /root/Sources/kolibrios -FASM=fasm -dUEFI=1 -dextended_primary_loader=1 -dUMKA=1 -CC=gcc -WARNINGS=-Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op \ - -Wrestrict -Wnull-dereference -Wjump-misses-init -Wshadow -Wformat=2 \ - -Wswitch -Wswitch-enum -Wpedantic \ +ifndef KOLIBRIOS + $(error "Set KOLIBRIOS environment variable to KolibriOS root") +endif + +FASM ?= fasm -dUEFI=1 -dextended_primary_loader=1 -dUMKA=1 +CC ?= gcc +WARNINGS_COMMON=-Wall -Wextra \ + -Wnull-dereference -Wshadow -Wformat=2 -Wswitch -Wswitch-enum \ + -Wpedantic \ #-Wconversion -Wsign-conversion -NOWARNINGS=-Wno-address-of-packed-member +NOWARNINGS_COMMON=-Wno-address-of-packed-member -Wno-missing-prototype-for-cc + +ifeq ($(CC),gcc) + WARNINGS=$(WARNINGS_COMMON) -Wduplicated-cond -Wduplicated-branches -Wrestrict -Wlogical-op -Wjump-misses-init + NOWARNINGS=$(NOWARNINGS_COMMON) +else ifeq ($(CC),clang) + WARNINGS=$(WARNINGS_COMMON) + NOWARNINGS=$(NOWARNINGS_COMMON) +else + $(error compiler $(CC) is not supported) +endif + CFLAGS=$(WARNINGS) $(NOWARNINGS) -std=c11 -g -O0 -D_FILE_OFFSET_BITS=64 \ -DNDEBUG -masm=intel -D_POSIX_C_SOURCE=200809L -Ilinux -fno-pie CFLAGS_32=$(CFLAGS) -m32 @@ -25,17 +39,17 @@ covpreproc: covpreproc.c umka_shell: umka_shell.o umka.o shell.o trace.o trace_lbr.o vdisk.o vnet.o \ lodepng.o pci.o thread.o util.o getopt.o isatty.o - $(CC) $(LDFLAGS_32) $^ -o $@ -static -T umka.ld + $(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld umka_fuse: umka_fuse.o umka.o trace.o trace_lbr.o vdisk.o pci.o thread.o $(CC) $(LDFLAGS_32) $^ -o $@ `pkg-config fuse3 --libs` -T umka.ld umka_os: umka_os.o umka.o shell.o lodepng.o vdisk.o vnet.o trace.o trace_lbr.o \ pci.o thread.o umka_ping.o util.o - $(CC) $(LDFLAGS_32) $^ -o $@ -static -T umka.ld + $(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld umka_gen_devices_dat: umka_gen_devices_dat.o umka.o pci.o thread.o util.o - $(CC) $(LDFLAGS_32) $^ -o $@ -static -T umka.ld + $(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld umka.o umka.fas: umka.asm INCLUDE="$(KOLIBRIOS)/kernel/trunk;$(KOLIBRIOS)/programs/develop/libraries/libcrash/hash" \ diff --git a/umka_gen_devices_dat.c b/umka_gen_devices_dat.c index 0e6596f..21421a8 100644 --- a/umka_gen_devices_dat.c +++ b/umka_gen_devices_dat.c @@ -80,7 +80,7 @@ acpi_node_t *acpi_get(const char *path) { size_t len = fread(acpi_value, 1, ACPI_BUF_SIZE, f); acpi_value[len-1] = '\0'; fclose(f); - acpi_node_t *n; + acpi_node_t *n = NULL; char *str = acpi_value; if (acpi_value[0] == '0') { kos_node_integer_t *aint = (kos_node_integer_t*)kos_aml_constructor_integer();