-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathMakefile
83 lines (70 loc) · 1.94 KB
/
Makefile
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# fiwix/Makefile
#
# Copyright 2018-2022, Jordi Sanfeliu. All rights reserved.
# Distributed under the terms of the Fiwix License.
#
TOPDIR := $(shell if [ "$$PWD" != "" ] ; then echo $$PWD ; else pwd ; fi)
INCLUDE = $(TOPDIR)/include
TMPFILE := $(shell mktemp)
ARCH = -m32
CPU = -march=i386
LANG = -std=c89
# CCEXE can be overridden at the command line. For example: make CCEXE="tcc"
# To use tcc see docs/tcc.txt
CCEXE=gcc
CC = $(CROSS_COMPILE)$(CCEXE) $(ARCH) $(CPU) $(LANG) -D__KERNEL__ $(CONFFLAGS) #-D__DEBUG__
CFLAGS = -I$(INCLUDE) -O2 -fno-pie -fno-common -ffreestanding -Wall -Wstrict-prototypes #-Wextra -Wno-unused-parameter
ifeq ($(CCEXE),gcc)
LD = $(CROSS_COMPILE)ld
CPP = $(CROSS_COMPILE)cpp -P -I$(INCLUDE)
LIBGCC := -L$(shell dirname `$(CC) -print-libgcc-file-name`) -lgcc
LDFLAGS = -m elf_i386
endif
ifeq ($(CCEXE),tcc)
LD = $(CROSS_COMPILE)$(CCEXE) $(ARCH)
LDFLAGS = -static -nostdlib -nostdinc
# If you define CONFIG_VM_SPLIT22 this should be 0x80100000: make CCEXE="tcc" TEXTADDR="0x80100000"
TEXTADDR = 0xC0100000
endif
DIRS = kernel \
kernel/syscalls \
mm \
fs \
drivers/char \
drivers/block \
drivers/pci \
drivers/video \
net \
lib
OBJS = kernel/*.o \
kernel/syscalls/*.o \
mm/*.o \
fs/*.o \
fs/ext2/*.o \
fs/iso9660/*.o \
fs/minix/*.o \
fs/pipefs/*.o \
fs/procfs/*.o \
fs/sockfs/*.o \
drivers/char/*.o \
drivers/block/*.o \
drivers/pci/*.o \
drivers/video/*.o \
net/*.o \
lib/*.o
export CC LD CFLAGS LDFLAGS INCLUDE
all:
@echo "#define UTS_VERSION \"`date -u`\"" > include/fiwix/version.h
@for n in $(DIRS) ; do (cd $$n ; $(MAKE)) || exit ; done
ifeq ($(CCEXE),gcc)
$(CPP) $(CONFFLAGS) fiwix.ld > $(TMPFILE)
$(LD) -N -T $(TMPFILE) $(LDFLAGS) $(OBJS) $(LIBGCC) -o fiwix
rm -f $(TMPFILE)
nm fiwix | sort | gzip -9c > System.map.gz
endif
ifeq ($(CCEXE),tcc)
$(LD) -Wl,-Ttext=$(TEXTADDR) $(LDFLAGS) $(OBJS) -o fiwix
endif
clean:
@for n in $(DIRS) ; do (cd $$n ; $(MAKE) clean) ; done
rm -f *.o fiwix System.map.gz