summaryrefslogtreecommitdiff
path: root/src/common.make
blob: 71cea37f2fa8a873b76ff89a2d5797d53d0a9236 (plain) (blame)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
.PHONY: clean, mrproper

# ============== ENVIRONMENT VARIABLES

CC = i586-elf-gcc
CFLAGS = -m32 -nostdlib -nostdinc -nostartfiles -nodefaultlibs -fno-builtin -ffreestanding -fno-stack-protector -Wall -Werror -g -Wno-error=main
CCFLAGS = 
CXX = i586-elf-g++
CXXFLAGS = -fno-rtti -fno-exceptions -Wno-write-strings -Wno-main -Wno-error=unused-parameter

LD = i586-elf-ld
LDFLAGS = -oformat=elf32-i386 -m elf_i386

ASM = nasm
AFLAGS = -f elf

# ============== GENERAL BUILD PROCEDURES

all: $(Out)

$(Out): $(Obj) $(ExtObj)
	echo ""; echo "- Linking $@..."
	$(LD) $(LDFLAGS) $^ -o $@

# ============== GENERAL CLEAINING PROCEDURES

clean:
	rm $(Obj) || exit 0
	rm *.o */*.o || exit 0

mrproper: clean
	rm $(Out) || exit 0

# ============== SOURCE FILE BUILD PROCEDURES

%.o: %.asm
	echo ""; echo "- $<"
	$(ASM) $(AFLAGS) -o $@ $<
	
%.o: %.c
	echo ""; echo "- $<"
	$(CC) -c $< -o $@ $(CFLAGS) $(CCFLAGS)

%.o: %.cpp
	echo ""; echo "- $<"
	$(CXX) -c $< -o $@ $(CFLAGS) $(CXXFLAGS)