[go: up one dir, main page]

Menu

[r49]: / tags / 0.12.2 / Makefile  Maximize  Restore  History

Download this file

256 lines (205 with data), 6.9 kB

  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
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# Toplevel makefile for Minirighi
#
# Copyright (C) 2004 Andrea Righi <righiandr@users.sf.net>
.EXPORT_ALL_VARIABLES:
export MAKE
# Kernel name #
KERNELNAME = minirighi32 (ia-32)
# Kenrel version #
MAINVERSION = 0
SUBVERSION = 12
SUBLEVEL = 2
VERSION = $(MAINVERSION).$(SUBVERSION).$(SUBLEVEL)
# Directories #
TOPDIR = $(shell /bin/pwd)
APPS = $(TOPDIR)/apps
APPSBIN = $(TOPDIR)/apps/bin
BIN = $(TOPDIR)/bin
DOC = $(TOPDIR)/doc
INCLUDE = $(TOPDIR)/include
LIB = $(TOPDIR)/lib
KERNEL = $(TOPDIR)/os
SCRIPTS = $(TOPDIR)/scripts
# Files #
CONFIG = $(TOPDIR)/.config
CONFIGH = $(INCLUDE)/kernel/config.h
TARGET = $(TOPDIR)/bin/mr32.elf
ASMDUMP = $(TOPDIR)/bin/mr32.dis
GZTARGET = $(TOPDIR)/bin/mr32.gz
MAP = $(TOPDIR)/bin/mr32.map
MTOOLSRC = $(TOPDIR)/.mtoolsrc
FDIMAGE = $(BIN)/minirighi-floppy.img
CDIMAGE = $(BIN)/minirighi-cdrom.iso
ifeq ($(TOPDIR)/.config,$(wildcard $(TOPDIR)/.config))
include $(TOPDIR)/.config
endif
# this is needed to speed-up the build process.
NCPUS := $(shell egrep -c '^processor' /proc/cpuinfo)
# Options #
LDFLAGS = -melf_i386 -g -nostdlib -X -L$(LIB) -lc
CFLAGS = -fno-stack-protector -m32 -mtune=i386 -Wall -pipe \
-I$(INCLUDE) \
-O3 \
-fomit-frame-pointer -mpreferred-stack-boundary=2 \
-nostdinc -fno-builtin
ifeq ($(CONFIG_DEBUG),y)
CFLAGS += -g
else
LDFLAGS += -S
endif
ifdef CONFIG_M386
CFLAGS += -march=i386
endif
ifdef CONFIG_M486
CFLAGS += -march=i486
endif
ifdef CONFIG_M586
CFLAGS += -march=i586
endif
ifdef CONFIG_M586TSC
CFLAGS += -march=i586
endif
ifdef CONFIG_M586MMX
CFLAGS += -march=i586 -march=pentium-mmx
endif
ifdef CONFIG_M686
CFLAGS += -march=i686
endif
ifdef CONFIG_MPENTIUMII
CFLAGS += -march=i686 -march=pentium2
endif
ifdef CONFIG_MPENTIUMIII
CFLAGS += -march=i686 -march=pentium3
endif
ifdef CONFIG_MPENTIUM4
CFLAGS += -march=i686 -march=pentium4
endif
ifdef CONFIG_MK6
CFLAGS += $(shell if $(CC) -march=k6 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=k6"; else echo "-march=i586"; fi)
endif
ifdef CONFIG_MK7
CFLAGS += $(shell if $(CC) -march=athlon -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=athlon"; else echo "-march=i686 -malign-functions=4"; fi)
endif
ifdef CONFIG_MATHLONXP
CFLAGS += $(shell if $(CC) -march=athlon-xp -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=athlon-xp"; else echo "-march=i686 -malign-functions=4"; fi)
endif
ifdef CONFIG_MK8
CFLAGS += $(shell if $(CC) -march=k8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=k8"; else echo "-march=i686 -malign-functions=4"; fi)
endif
# Programs #
MAKE = make -s
AS = gcc
CC = gcc
LD = ld
OBJDUMP = objdump -D -l -x -t
NASM = nasm -f elf
GRUB = /usr/sbin/grub
#########################################################################
# #
# Rules for kernel, library & applications. #
# #
#########################################################################
all: kernel
@/bin/echo -e "Well done."
@/bin/echo -e "Don't forget to run \"make install\" to copy the kernel on the floppy image."
@echo
world:
@/bin/echo -e "\n--- Configuration ---\n"
$(MAKE) config
@/bin/echo -e "\n--- Make dependencies ---\n"
$(MAKE) dep
@/bin/echo -e "\n--- Cleaning ---\n"
$(MAKE) clean
@/bin/echo -e "\n--- Making the kernel ---\n"
$(MAKE) -j$(NCPUS) all
@/bin/echo -e "\n--- Installing the kernel to floppy image ---\n"
$(MAKE) install
@/bin/echo -e "\n--- Making applications ---\n"
$(MAKE) -j$(NCPUS) apps
@/bin/echo -e "\n--- Installing applications to floppy image ---\n"
$(MAKE) apps_install
@/bin/echo -e "\nWorld done... enjoy!\n"
kernel: .config .depend lib
@echo Making kernel...
@$(MAKE) -C $(KERNEL)
install: .config .depend kernel $(FDIMAGE)
@echo "Copying kernel to floppy image $(FDIMAGE)"
@mcopy -n $(GZTARGET) a:/kernel/
@sync
@echo "done."
lib:
@echo Making library...
@$(MAKE) -C $(LIB)
apps: .config lib $(FDIMAGE)
@echo Making applications...
@$(MAKE) -C $(APPS) all
@echo "done."
apps_install:
@echo -n "Copying applications to floppy image $(FDIMAGE)... "
@mcopy -n $(APPSBIN)/* a:/bin/
@sync
@echo "done."
apps_clean:
@$(MAKE) -C $(APPS) clean
clean: apps_clean
@$(MAKE) -C $(KERNEL) clean
@$(MAKE) -C $(LIB) clean
@find . -name *~ -print | xargs rm -f
config:
@$(SCRIPTS)/config.sh
@/bin/echo -e "Configuration done."
@/bin/echo -e "Now it's time to run \"make dep\" to find all dependencies.\n"
depend dep: .config
@rm -f .depend
@echo -n "Finding dependencies for all C files... "
@$(foreach i, $(shell find ${TOPDIR} -name \*.c -print), \
echo -n $(dir $i) >> .depend; $(CC) -I$(INCLUDE) -M $i >> .depend;)
@echo "done."
@/bin/echo -e "Now it's time to run \"make\" to compile the kernel.\n"
.depend:
@/bin/echo -e "\nYou have to run \"make dep\" before!!!\n"
@exit 1
.config:
@/bin/echo -e "\nYou have to run \"make config\" before!!!\n"
@exit 1
#########################################################################
# #
# Rules for the installation device images. #
# #
#########################################################################
$(FDIMAGE):
@$(SCRIPTS)/mkfdimg.sh
isocd: install $(FDIMAGE)
@mkdir cd_root
@cp $(FDIMAGE) cd_root/`basename $(FDIMAGE)`
@mkisofs -o $(CDIMAGE) -b `basename $(FDIMAGE)` -R -J cd_root
@rm -rf cd_root
@/bin/echo -e "\nISO bootable cd image created $(CDIMAGE)\n"
disk: install
dd bs=8192 if=$(FDIMAGE) of=/dev/fd0
#########################################################################
# #
# Rules for backup, documentation, etc... #
# #
#########################################################################
distclean: clean
@$(MAKE) -C $(KERNEL) distclean
@$(MAKE) -C $(DOC) clean
@find $(TOPDIR) -type f -name \*.o -exec rm -f {} \;
@rm -f $(CDIMAGE) $(FDIMAGE) $(MTOOLSRC) $(CONFIG) $(CONFIGH) .depend tags
@echo Clean done.
backup: distclean
cd .. && tar cf - `basename $(TOPDIR)`/ | bzip2 -c -9 > minirighi32-$(VERSION).tar.bz2
sync
@/bin/echo -e "Backup done.\n"
documentation doc:
@$(MAKE) -C $(DOC) all
@echo
@/bin/echo -e "Documentation done in $(DOC).\n"
tags:
find . -name '*.[chS]' | xargs ctags -a
wc:
find . -type f -name *.[Sch] -print | sort | xargs wc -l
.PHONY: config depend dep kernel all lib install apps disk isocd clean \
distclean backup doc documentation wc world
include Rules.make