mirror of
https://github.com/Fennix-Project/Drivers.git
synced 2025-05-25 22:14:31 +00:00
99 lines
3.3 KiB
Makefile
99 lines
3.3 KiB
Makefile
# Config file
|
|
include ../../../Makefile.conf
|
|
|
|
FILENAME = ExampleDriver.fex
|
|
|
|
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
|
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
|
LD = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)ld
|
|
AS = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)as
|
|
OBJDUMP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)objdump
|
|
|
|
GIT_COMMIT = $(shell git rev-parse HEAD)
|
|
GIT_COMMIT_SHORT = $(shell git rev-parse --short HEAD)
|
|
|
|
ifeq ($(OSARCH), amd64)
|
|
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
|
|
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
|
|
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/i386/*" -not -path "./arch/aarch64/*")
|
|
else ifeq ($(OSARCH), i386)
|
|
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
|
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
|
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
|
else ifeq ($(OSARCH), aarch64)
|
|
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
|
|
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
|
|
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/amd64/*" -not -path "./arch/i386/*")
|
|
endif
|
|
HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
|
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
|
INCLUDE_DIR = ../../include
|
|
|
|
LDFLAGS := \
|
|
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
|
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
|
-nostdlib -nodefaultlibs -nolibc \
|
|
-zmax-page-size=0x1000 \
|
|
-Wl,-Map file.map -static
|
|
|
|
WARNCFLAG = -Wall -Wextra
|
|
|
|
CFLAGS := \
|
|
-I$(INCLUDE_DIR) \
|
|
-DGIT_COMMIT='"$(GIT_COMMIT)"' \
|
|
-DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"'
|
|
|
|
ifeq ($(OSARCH), amd64)
|
|
|
|
LDFLAGS += -Tlinker_amd64.ld
|
|
|
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
|
-mno-red-zone -mno-sse -mno-sse2 \
|
|
-march=x86-64 -pipe -ffunction-sections \
|
|
-msoft-float -fno-builtin
|
|
|
|
else ifeq ($(OSARCH), i386)
|
|
|
|
LDFLAGS += -Tlinker_i386.ld
|
|
|
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
|
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
|
-march=i386 -pipe -msoft-float -fno-builtin
|
|
|
|
else ifeq ($(OSARCH), aarch64)
|
|
|
|
LDFLAGS += -Tlinker_aarch64.ld
|
|
|
|
CFLAGS += -pipe -fno-builtin -fPIC
|
|
|
|
endif
|
|
|
|
build: $(FILENAME)
|
|
ifeq ($(OSARCH), amd64)
|
|
$(OBJDUMP) -b binary -D -m i386:x86-64 -d $(FILENAME) > file_dump.map
|
|
else ifeq ($(OSARCH), i386)
|
|
$(OBJDUMP) -b binary -D -m i386 -d $(FILENAME) > file_dump.map
|
|
else ifeq ($(OSARCH), aarch64)
|
|
$(OBJDUMP) -b binary -D -m aarch64 -d $(FILENAME) > file_dump.map
|
|
endif
|
|
mv $(FILENAME) ../../out/$(FILENAME)
|
|
|
|
$(FILENAME): $(OBJ)
|
|
$(info Linking $@)
|
|
$(CC) $(LDFLAGS) $(OBJ) -o $@
|
|
|
|
%.o: %.c $(HEADERS)
|
|
$(info Compiling $<)
|
|
$(CC) $(CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
|
|
|
%.o: %.cpp $(HEADERS)
|
|
$(info Compiling $<)
|
|
$(CPP) $(CFLAGS) $(WARNCFLAG) -std=c++20 -fexceptions -c $< -o $@
|
|
|
|
%.o: %.S
|
|
$(info Compiling $<)
|
|
$(AS) -o $@ $<
|
|
|
|
clean:
|
|
rm -f file.map file_dump.map $(OBJ)
|