aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 2d6485cad24f3b9ecf22b2a8010265cd75053604 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Compiler, Linker, and Assembler
CC := clang
AR := ar
AS := nasm

# All needed build directories
INC_DIR := include
SRC_DIR := sys
BIN_DIR := bin
LIB_DIR := lib
OBJ_DIR := build

# C runtime library
CINIT := $(LIB_DIR)/crt/crt1.o $(LIB_DIR)/crt/x86_64/crti.o `gcc --print-file-name=crtbeginT.o`
CFINI := `gcc --print-file-name=crtendS.o` $(LIB_DIR)/crt/x86_64/crtn.o 

# Flags, Libraries and Includes
CFLAGS := -g -O3 -march=native \
				 -ffast-math -fno-strict-aliasing -fwrapv -fms-extensions \
				 -Wno-microsoft-anon-tag -Wno-incompatible-function-pointer-types
STATIC := -static -nodefaultlibs -nostartfiles
AFLAGS := -f elf64 
INCS   := -isystem $(INC_DIR)/vendor/libc -I $(INC_DIR) 
ELIBS  := -L$(LIB_DIR) -lc 

# Named generic rules (must be evaluated lazily)
COMPILE  = $(CC) -MMD $(CFLAGS) $(TCFLAGS) $(INCS) $(TCINCS) -o $@ -c $< 
LINK 	 = $(CC) -MMD $(CFLAGS) $(STATIC) $(TCFLAGS) -o $@ $(CINIT) $^ $(CFINI) $(TCLIBS) $(ELIBS) 
COMPLINK = $(CC) -MMD $(CFLAGS) $(STATIC) $(TCFLAGS) $u$(INCS) $(TCINCS) -o $@ $(CINIT) $^ $(CFINI) $(TCLIBS) $(ELIBS)
ASSEMBLE = $(AS) $(AFLAGS) $(TCFLAGS) -o $@ $< 
ARCHIVE  = $(AR) crs $@ $^

include rules.mk