buffer new implementation, first step of implementing fs
[quarnos.git] / Makefile
blob23806a22b0527d2cfc06196dec98a306bd11fbea
1 # Quarn OS
3 # Main Makefile
5 # Copyright (C) 2008 Pawel Dziepak
9 # make help describes all possible targets
12 MAKEFLAGS += --no-print-directory
14 MAJREL = 0
15 MINREL = 0
16 PROREL = 90
17 ADDONS = -dev
19 $(info Quarn OS $(MAJREL).$(MINREL).$(PROREL)$(ADDONS))
20 $(info Copyright (C) 2008 Pawel Dziepak)
21 $(info )
23 # Check host OS
24 $(info Checking host environment...)
25 $(if $(shell which gcc), , $(error GCC is needed to compile Quarn))
26 $(if $(shell which g++), , $(error G++ is needed to compile Quarn))
27 $(if $(shell which ld), , $(error LD is needed to compile Quarn))
28 $(if $(shell which sed), , $(error SED is needed to compile Quarn))
29 $(if $(shell which pwd), , $(error PWD is needed to compile Quarn))
30 $(if $(shell which perl), , $(error PERL is needed to compile Quarn))
32 PERL = perl
34 # Main tools
35 CC = gcc
36 CPP = g++
37 LD = ld
39 DIR = $(shell pwd)
40 DIR_SHORT = $(shell pwd | sed 's/\/.*\///')
42 CONFFILE = quarnconf.h
43 CONF = -include $(CONFFILE)
45 # Main flags
46 CFLAGS = -Wall -pedantic -O2 -fno-builtin -nostartfiles -nostdlib -I$(DIR) $(CONF)
47 CPPFLAGS = -Wall -O2 --no-rtti --no-exceptions -fno-builtin -nostartfiles -nostdlib -I$(DIR) $(CONF)
48 LDFLAGS =
50 ARCH=x86
52 ifeq ($(shell $(PERL) scripts/mk_conf.pl USE_MULTIBOOT), 0)
53 MB =
54 else
55 MB = arch/$(ARCH)/loaders/systemload.o
56 endif
58 # Directories that consist of code has to be compiled
59 DIRS = actors/ arch/$(ARCH)/ libs/ arch/$(ARCH)/loaders manes/ modules/ services/ resources/ hydra/
61 SUDO = sudo
63 LOOPDEV = $(shell $(SUDO) /sbin/losetup -f)
65 # Compile whole kernel
66 compile:
67 $(info Compiling Quarn OS...)
68 @$(if $(wildcard $(CONFFILE)), , $(error You have to configure Quarn OS first.))
69 @for dir in $(DIRS); do \
70 (cd $$dir; $(MAKE) CC=$(CC) CPP=$(CPP) LD=$(LD) \
71 CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \
72 LDFLAGS=$(LDFAGS)); \
73 done
74 @echo -e "\t\t[$(LD)]\tquarn"
75 @$(LD) -Tscripts/x86_kernel.ld $(MB) `find . -name *.o | grep -v -E 'loaders|modules_start|rs232|test'` -o quarn
77 # Clean all and then compile
78 rebuild: clean compile
80 # Clean object files
81 clean:
82 $(info Cleaning project directory...)
83 @for dir in $(DIRS); do \
84 (cd $$dir; $(MAKE) clean); \
85 done
86 @echo -e "\t\t[rm]\tquarn"
87 @rm -f quarn
89 # Clean also built tools
90 allclean: clean
91 $(info Cleaning configuration files...)
92 @echo -e "\t\t[rm]\tscripts/nc_config"
93 @rm -f scripts/nc_config
94 @echo -e "\t\t[rm]\tquarnconf.h"
95 @rm -f quarnconf.h
96 @echo -e "\t\t[rm]\tfd.img"
97 @rm -f fd.img
99 # Compile configuration program (ncurses) and run it
100 config: scripts/nc_config
101 @echo -e "\t\t[sh]\tscripts/nc_config"
102 @scripts/nc_config
104 scripts/nc_config: scripts/nc_config.c
105 @echo -e "\t\t[$(CC)]\tscripts/nc_config.c"
106 @$(CC) scripts/nc_config.c -lmenu -lncurses -I/usr/include/ncurses -o scripts/nc_config
108 defconf:
109 @echo -e "\t\t[$(PERL)]\tscripts/text_config.pl"
110 @$(PERL) scripts/text_config.pl def
112 # Run configuration script (doesn't need ncurses)
113 textconf:
114 @echo -e "\t\t[$(PERL)]\tscripts/text_config.pl"
115 @$(PERL) scripts/text_config.pl $(MAJREL).$(MINREL).$(PROREL)$(ADDONS)
117 # Create bootable floppy image
118 fd_img: compile
119 $(info Creating floppy image...)
120 @/sbin/mkdosfs -F 12 -C fd.img 1440
121 @$(SUDO) /sbin/losetup $(LOOPDEV) fd.img
122 @$(SUDO) dd if=arch/$(ARCH)/loaders/boot of=$(LOOPDEV)
123 @mkdir image
124 @$(SUDO) mount $(LOOPDEV) image
125 @-$(SUDO) cp arch/$(ARCH)/loaders/loader image/
126 @strip quarn
127 @$(SUDO) cp quarn image/
128 @$(SUDO) cp AUTHORS image/
129 #@$(SUDO) cp modules/*.ko image/
130 #@$(SUDO) cp hydra/*.ko image/
131 @$(SUDO) umount $(LOOPDEV)
132 @rmdir image
133 @$(SUDO) /sbin/losetup -d $(LOOPDEV)
135 qemu: fd_img
136 @qemu -fda fd.img
138 # Put bootable image on the floppy
139 floppy: fd_img
140 $(info Putting image on a floppy...)
141 @$(SUDO) dd if=fd.img of=/dev/fd0
143 #Create build package
144 build: fd_img
145 $(if $(shell which tar), , $(error TAR is needed to compile Quarn))
146 $(if $(shell which gzip), , $(error GZIP is needed to compile Quarn))
147 $(info Creating build package...)
148 @-rm -f ../quarnos_`date +%Y-%m-%d`.tar
149 @tar -cf ../quarnos_`date +%Y-%m-%d`.tar ../$(DIR_SHORT)
150 @tar --delete -f ../quarnos_`date +%Y-%m-%d`.tar $(DIR_SHORT)/.git
151 @gzip -f ../quarnos_`date +%Y-%m-%d`.tar
153 pack: allclean
154 $(if $(shell which tar), , $(error TAR is needed to compile Quarn))
155 $(if $(shell which gzip), , $(error GZIP is needed to compile Quarn))
156 $(info Creating release package...)
157 @-rm -f ../quarnos_$(MAJREL).$(MINREL).$(PROREL)$(ADDONS).tar
158 @tar -cf ../quarnos_$(MAJREL).$(MINREL).$(PROREL)$(ADDONS).tar ../$(DIR_SHORT)
159 @tar --delete -f ../quarnos_$(MAJREL).$(MINREL).$(PROREL)$(ADDONS).tar $(DIR_SHORT)/.git
160 @gzip -f ../quarnos_$(MAJREL).$(MINREL).$(PROREL)$(ADDONS).tar
162 # Show possible targets
163 help:
164 @echo -e "\t\tQuarn OS $(MAJREL).$(MINREL).$(PROREL) Makefile"
165 @echo -e "\t\t-----------------------"
166 @echo -e "\nConfiguration:"
167 @echo -e "\tconfig\t\t- ncurses configuration tool (WIP)"
168 @echo -e "\tdefconf\t\t- uses default configuration"
169 @echo -e "\ttextconf\t- text configuration tool"
170 @echo -e "\nCompiling:"
171 @echo -e "\tcompile\t\t- compile whole kernel (default)"
172 @echo -e "\trebuild\t\t- allclean + compile"
173 @echo -e "\nInstallation:"
174 @echo -e "\tfd_img\t\t- create floppy image (requires root)"
175 @echo -e "\tfloppy\t\t- fd_img + put image on the floppy (requires root)"
176 @echo -e "\nPackaging:"
177 @echo -e "\tbuild\t\t- create build package in the upper directory"
178 @echo -e "\tpack\t\t- create release package in upper directory"
179 @echo -e "\nCleaning:"
180 @echo -e "\tallclean\t- clean + remove configuration files"
181 @echo -e "\tclean\t\t- remove all files generated by target compile"
182 @echo ""