build: Reorganise warning flags

This commit is contained in:
mintsuki 2023-04-11 17:15:41 +02:00
parent 86632c703f
commit d1cb337894
5 changed files with 37 additions and 30 deletions

View File

@ -76,6 +76,9 @@ export LDFLAGS
$(eval $(call DEFAULT_VAR,LIBS,@LIBS@))
export LIBS
override WERROR_FLAG := @WERROR_FLAG@
export WERROR_FLAG
$(eval $(call DEFAULT_VAR,CFLAGS_FOR_TARGET,@CFLAGS_FOR_TARGET@))
export CFLAGS_FOR_TARGET
$(eval $(call DEFAULT_VAR,CPPFLAGS_FOR_TARGET,@CPPFLAGS_FOR_TARGET@))
@ -203,12 +206,12 @@ uninstall:
$(call MKESCAPE,$(BUILDDIR))/stage1.stamp: $(STAGE1_FILES) $(call MKESCAPE,$(BUILDDIR))/decompressor-build/decompressor.bin $(call MKESCAPE,$(BUILDDIR))/common-bios/stage2.bin.gz
$(MKDIR_P) '$(call SHESCAPE,$(BINDIR))'
cd '$(call SHESCAPE,$(SRCDIR))/stage1/hdd' && nasm bootsect.asm @WERROR@ -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-hdd.bin'
cd '$(call SHESCAPE,$(SRCDIR))/stage1/hdd' && nasm bootsect.asm $(WERROR_FLAG) -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-hdd.bin'
ifneq ($(BUILD_CD),no)
cd '$(call SHESCAPE,$(SRCDIR))/stage1/cd' && nasm bootsect.asm @WERROR@ -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-cd.bin'
cd '$(call SHESCAPE,$(SRCDIR))/stage1/cd' && nasm bootsect.asm $(WERROR_FLAG) -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-cd.bin'
endif
ifneq ($(BUILD_PXE),no)
cd '$(call SHESCAPE,$(SRCDIR))/stage1/pxe' && nasm bootsect.asm @WERROR@ -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-pxe.bin'
cd '$(call SHESCAPE,$(SRCDIR))/stage1/pxe' && nasm bootsect.asm $(WERROR_FLAG) -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-pxe.bin'
endif
cp '$(call SHESCAPE,$(BUILDDIR))/common-bios/limine.sys' '$(call SHESCAPE,$(BINDIR))/'
touch '$(call SHESCAPE,$(BUILDDIR))/stage1.stamp'

View File

@ -43,6 +43,12 @@ override BASE_CFLAGS := $(CFLAGS_FOR_TARGET)
override CFLAGS_FOR_TARGET += \
-g \
-Wall \
-Wextra \
-Wshadow \
-Wvla \
-Wno-deprecated-declarations \
$(WERROR_FLAG) \
-std=gnu11 \
-nostdinc \
-ffreestanding \
@ -50,10 +56,7 @@ override CFLAGS_FOR_TARGET += \
-fno-stack-check \
-fno-omit-frame-pointer \
-fno-strict-aliasing \
-fno-lto \
-Wshadow \
-Wvla \
-Wno-deprecated-declarations
-fno-lto
override CPPFLAGS_FOR_TARGET := \
-I../freestanding-headers \
@ -465,29 +468,29 @@ endif
ifeq ($(TARGET),bios)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_ia32
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR_FLAG) -f elf32 -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_bios_ia32
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR_FLAG) -f elf32 -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_x86
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR_FLAG) -f elf32 -o '$(call SHESCAPE,$@)'
endif
ifeq ($(TARGET),uefi-x86-64)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_x86_64
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf64 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR_FLAG) -f elf64 -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_uefi_x86_64
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf64 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR_FLAG) -f elf64 -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_x86
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf64 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR_FLAG) -f elf64 -o '$(call SHESCAPE,$@)'
endif
ifeq ($(TARGET),uefi-aarch64)
@ -503,13 +506,13 @@ endif
ifeq ($(TARGET),uefi-ia32)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_ia32
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR_FLAG) -f elf32 -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_uefi_ia32
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR_FLAG) -f elf32 -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_x86
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR) -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' -F dwarf -g $(WERROR_FLAG) -f elf32 -o '$(call SHESCAPE,$@)'
endif

View File

@ -19,7 +19,7 @@ AC_DEFUN([PROG_ABSPATH], [
esac
])
test "x$CFLAGS" = "x" && CFLAGS='-g -O2 -pipe -Wall -Wextra'
test "x$CFLAGS" = "x" && CFLAGS='-g -O2 -pipe'
AC_LANG([C])
AC_PROG_CC
@ -33,8 +33,9 @@ AC_ARG_ENABLE([werror],
[AS_HELP_STRING([--enable-werror], [treat warnings as errors])],
[werror_state="$enableval"])
if test "$werror_state" = "yes"; then
AC_SUBST([WERROR], [-Werror])
CFLAGS="$CFLAGS -Werror"
AC_SUBST([WERROR_FLAG], [-Werror])
else
AC_SUBST([WERROR_FLAG], [-Wno-error])
fi
AC_PROG_MKDIR_P
@ -254,12 +255,9 @@ AC_ARG_VAR([OBJCOPY_FOR_TARGET], [objcopy command for Limine])
AC_ARG_VAR([OBJDUMP_FOR_TARGET], [objdump command for Limine])
AC_ARG_VAR([READELF_FOR_TARGET], [readelf command for Limine])
m4_define([DEFAULT_CFLAGS_FOR_TARGET], [-g -O2 -pipe -Wall -Wextra])
m4_define([DEFAULT_CFLAGS_FOR_TARGET], [-g -O2 -pipe])
AC_ARG_VAR([CFLAGS_FOR_TARGET], [C flags for Limine @<:@default: ]DEFAULT_CFLAGS_FOR_TARGET[@:>@])
test "x$CFLAGS_FOR_TARGET" = "x" && CFLAGS_FOR_TARGET="DEFAULT_CFLAGS_FOR_TARGET"
if test "$werror_state" = "yes"; then
CFLAGS_FOR_TARGET="$CFLAGS_FOR_TARGET -Werror"
fi
m4_define([DEFAULT_CPPFLAGS_FOR_TARGET], [])
AC_ARG_VAR([CPPFLAGS_FOR_TARGET], [C preprocessor flags for Limine @<:@default: ]DEFAULT_CPPFLAGS_FOR_TARGET[@:>@])

View File

@ -21,6 +21,11 @@ endif
override CFLAGS_FOR_TARGET += \
-Os \
-Wall \
-Wextra \
-Wshadow \
-Wvla \
$(WERROR_FLAG) \
-std=gnu11 \
-nostdinc \
-ffreestanding \
@ -34,9 +39,7 @@ override CFLAGS_FOR_TARGET += \
-m32 \
-march=i686 \
-mabi=sysv \
-mno-80387 \
-Wshadow \
-Wvla
-mno-80387
override CPPFLAGS_FOR_TARGET := \
-I../freestanding-headers \

View File

@ -4,7 +4,7 @@ INSTALL ?= ./install-sh
PREFIX ?= /usr/local
CFLAGS ?= -g -O2 -pipe -Wall -Wextra
CFLAGS ?= -g -O2 -pipe
.PHONY: all
all: limine-deploy limine-version limine-enroll-config
@ -39,10 +39,10 @@ clean:
rm -f limine-enroll-config limine-enroll-config.exe
limine-deploy: limine-deploy.c limine-hdd.h
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -std=c99 limine-deploy.c $(LIBS) -o $@
$(CC) $(CFLAGS) -Wall -Wextra $(WERROR_FLAG) $(CPPFLAGS) $(LDFLAGS) -std=c99 limine-deploy.c $(LIBS) -o $@
limine-version: limine-version.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -std=c99 limine-version.c $(LIBS) -o $@
$(CC) $(CFLAGS) -Wall -Wextra $(WERROR_FLAG) $(CPPFLAGS) $(LDFLAGS) -std=c99 limine-version.c $(LIBS) -o $@
limine-enroll-config: limine-enroll-config.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -std=c99 limine-enroll-config.c $(LIBS) -o $@
$(CC) $(CFLAGS) -Wall -Wextra $(WERROR_FLAG) $(CPPFLAGS) $(LDFLAGS) -std=c99 limine-enroll-config.c $(LIBS) -o $@