usb: getting string descriptors, minor improvements
[quarnos.git] / Makefile
blobcd041c1888d19ad39dae3fb8bdffc2ec954b8a88
1 # Quarn OS
3 # Main Makefile
5 # Copyright (C) 2008-2009 Pawel Dziepak
9 # make help describes all possible targets
12 MAKEFLAGS += --no-print-directory
14 MAJREL = 0
15 MINREL = 0
16 PROREL = 95
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 LATEX=latex
35 DVIPDF=dvipdf
37 # Main tools
38 CC = gcc
39 CPP = g++
40 LD = ld
42 DIR = $(shell pwd)
43 DIR_SHORT = $(shell pwd | sed 's/\/.*\///')
45 CONFFILE = quarnconf.h
46 CONF = -include $(CONFFILE)
48 ifeq ($(shell $(PERL) scripts/mk_conf.pl OPT_SIZE), 0)
49 OPTIMIZE = -O2
50 POSTLD =
51 else
52 OPTIMIZE = -Os
53 POSTLD = #strip quarn
54 endif
56 # Main flags
57 CFLAGS = -Wall -pedantic -std=c99 $(OPTIMIZE) -fno-builtin -nostartfiles -nostdlib -I$(DIR) $(CONF)
58 CPPFLAGS = -Wall -pedantic $(OPTIMIZE) -fno-builtin -nostartfiles -nostdlib -I$(DIR) -isystem$(DIR) $(CONF)
59 LDFLAGS =
61 ARCH=x86
63 ifeq ($(shell $(PERL) scripts/mk_conf.pl USE_MULTIBOOT), 0)
64 MB =
65 else
66 MB = arch/$(ARCH)/loaders/systemload.o
67 endif
69 ifeq ($(shell $(PERL) scripts/mk_conf.pl DEBUG_MODE), 0)
70 MAP =
71 QFLAGS =
72 POSTQEMU =
73 else
74 $(if $(shell which sed), , $(error GDB is needed to debug Quarn))
75 MAP = -Map quarn.map
76 CFLAGS += #-g
77 CPPFLAGS += #-g
78 QFLAGS = #-s -S &
79 POSTQEMU = gdb quarn
80 endif
82 # Directories that consist of code has to be compiled
83 DIRS = actors/ arch/low/ libs/ arch/low/loaders manes/ modules/ services/ resources/ hydra/
85 SUDO = sudo
87 LOOPDEV = $(shell $(SUDO) /sbin/losetup -f)
89 # Compile whole kernel
90 compile:
91 $(info Compiling Quarn OS...)
92 $(shell rm -f arch/low)
93 $(shell ln -s $(DIR)/arch/$(ARCH)/ arch/low)
94 @$(if $(wildcard $(CONFFILE)), , $(error You have to configure Quarn OS first.))
95 @for dir in $(DIRS); do \
96 (cd $$dir; $(MAKE) CC=$(CC) CPP=$(CPP) LD=$(LD) \
97 CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \
98 LDFLAGS=$(LDFAGS)); \
99 done
100 @echo -e "\t\t[$(LD)]\tquarn"
101 @$(LD) -Tscripts/x86_kernel.ld $(MB) `find . -name *.o | grep -v -E 'loaders|modules_start|rs232|test|hydra'` -o quarn $(MAP)
102 @$(POSTLD)
104 # Clean all and then compile
105 rebuild: clean compile
107 # Clean object files
108 clean:
109 $(shell rm -f arch/low)
110 $(shell ln -s $(DIR)/arch/$(ARCH)/ arch/low)
111 $(info Cleaning project directory...)
112 @for dir in $(DIRS); do \
113 (cd $$dir; $(MAKE) clean); \
114 done
115 @(cd docs; $(MAKE) clean)
116 @(cd tests; $(MAKE) clean)
117 @rm -rf Documentation
118 @echo -e "\t\t[rm]\tquarn"
119 @rm -f quarn
120 @rm -f quarn.map
122 # Clean also built tools
123 allclean: clean
124 $(info Cleaning configuration files...)
125 @echo -e "\t\t[rm]\tscripts/nc_config"
126 @rm -f scripts/nc_config
127 @echo -e "\t\t[rm]\tquarnconf.h"
128 @rm -f quarnconf.h
129 @echo -e "\t\t[rm]\tfd.img"
130 @rm -f fd.img
131 @rm -f arch/low
133 # Compile configuration program (ncurses) and run it
134 config: scripts/nc_config
135 @echo -e "\t\t[sh]\tscripts/nc_config"
136 @scripts/nc_config
138 scripts/nc_config: scripts/nc_config.c
139 @echo -e "\t\t[$(CC)]\tscripts/nc_config.c"
140 @$(CC) scripts/nc_config.c -lmenu -lncurses -I/usr/include/ncurses -o scripts/nc_config
142 defconf: clean
143 $(info Restoring default configuration...)
144 @echo -e "\t\t[$(PERL)]\tscripts/text_config.pl"
145 @$(PERL) scripts/text_config.pl def
147 # Run configuration script (doesn't need ncurses)
148 textconf: clean
149 $(info Launching configuration tool...)
150 @echo -e "\t\t[$(PERL)]\tscripts/text_config.pl"
151 @$(PERL) scripts/text_config.pl $(MAJREL).$(MINREL).$(PROREL)$(ADDONS)
153 # Create bootable floppy image
154 fd_img: compile
155 $(info Creating floppy image...)
156 @rm -f fd.img
157 @/sbin/mkdosfs -F 12 -C fd.img 1440
158 @$(SUDO) /sbin/losetup $(LOOPDEV) fd.img
159 @$(SUDO) dd if=arch/low/loaders/boot of=$(LOOPDEV)
160 @mkdir image
161 @$(SUDO) mount $(LOOPDEV) image
162 @-$(SUDO) cp arch/low/loaders/loader image/
163 @$(SUDO) cp quarn image/
164 @$(SUDO) cp AUTHORS image/
165 @-$(SUDO) cp modules/*.ko image/
166 @-$(SUDO) cp hydra/*.ko image/
167 @$(SUDO) umount $(LOOPDEV)
168 @rmdir image
169 @$(SUDO) /sbin/losetup -d $(LOOPDEV)
171 qemu: fd_img
172 @qemu -fda fd.img -usb -net nic,model=ne2k_pci -net user
174 debug: fd_img
175 @qemu -fda fd.img -usb -net nic,model=ne2k_pci -net user $(QFLAGS)
176 @$(POSTQEMU)
178 # Put bootable image on the floppy
179 floppy: fd_img
180 $(info Putting image on a floppy...)
181 @$(SUDO) dd if=fd.img of=/dev/fd0
183 # Create build package
184 build: fd_img doc
185 $(if $(shell which tar), , $(error TAR is needed to compile Quarn))
186 $(if $(shell which gzip), , $(error GZIP is needed to compile Quarn))
187 $(info Creating build package...)
188 @-rm -f ../quarnos_`date +%Y-%m-%d`.tar
189 @tar -cf ../quarnos_`date +%Y-%m-%d`.tar ../$(DIR_SHORT)
190 @tar --delete -f ../quarnos_`date +%Y-%m-%d`.tar $(DIR_SHORT)/.git
191 @gzip -f ../quarnos_`date +%Y-%m-%d`.tar
193 pack: allclean
194 $(if $(shell which tar), , $(error TAR is needed to compile Quarn))
195 $(if $(shell which gzip), , $(error GZIP is needed to compile Quarn))
196 $(info Creating release package...)
197 @-rm -f ../quarnos_$(MAJREL).$(MINREL).$(PROREL)$(ADDONS).tar
198 @tar -cf ../quarnos_$(MAJREL).$(MINREL).$(PROREL)$(ADDONS).tar ../$(DIR_SHORT)
199 @tar --delete -f ../quarnos_$(MAJREL).$(MINREL).$(PROREL)$(ADDONS).tar $(DIR_SHORT)/.git
200 @gzip -f ../quarnos_$(MAJREL).$(MINREL).$(PROREL)$(ADDONS).tar
202 # Run doxygen
203 doxygen:
204 $(if $(shell which doxygen), , $(error doxygen is needed to compile Quarn))
205 @echo -e "\t\t[doxygen]\tquarnos"
206 @doxygen scripts/Doxyfile > /dev/null
207 @cp scripts/tabs.css Documentation/html/
209 # Create documentation files
210 doc: doxygen
211 $(if $(shell which $(LATEX)), , $(error $(LATEX) is needed to compile Quarn))
212 $(if $(shell which $(DVIPDF)), , $(error $(DVIPDF) is needed to compile Quarn))
213 @(cd docs; $(MAKE) LATEX=$(LATEX) DVIPDF=$(DVIPDF))
215 # Run tests
216 test:
217 @#cd libs/tests; $(MAKE)
218 @cd tests; $(MAKE)
220 # Show possible targets
221 help:
222 @echo -e "\t\tQuarn OS $(MAJREL).$(MINREL).$(PROREL) Makefile"
223 @echo -e "\t\t------------------------"
224 @echo -e "\nCopyright (C) 2008-2009 Pawel Dziepak"
225 @echo -e "\nConfiguration:"
226 @echo -e "\tconfig\t\t- ncurses configuration tool (WIP)"
227 @echo -e "\tdefconf\t\t- uses default configuration"
228 @echo -e "\ttextconf\t- text configuration tool"
229 @echo -e "\nCompiling:"
230 @echo -e "\tcompile\t\t- compile whole kernel (default)"
231 @echo -e "\trebuild\t\t- allclean + compile"
232 @echo -e "\tdoc\t\t- create all documentation files"
233 @echo -e "\ttest\t\t- run all tests"
234 @echo -e "\nInstallation:"
235 @echo -e "\tfd_img\t\t- create floppy image (requires root)"
236 @echo -e "\tfloppy\t\t- fd_img + put image on the floppy (requires root)"
237 @echo -e "\nPackaging:"
238 @echo -e "\tbuild\t\t- create build package in the upper directory"
239 @echo -e "\tpack\t\t- create release package in upper directory"
240 @echo -e "\nCleaning:"
241 @echo -e "\tallclean\t- clean + remove configuration files"
242 @echo -e "\tclean\t\t- remove all files generated by target compile"
243 @echo ""