5 # Copyright (C) 2008-2009 Pawel Dziepak
9 # make help describes all possible targets
12 MAKEFLAGS
+= --no-print-directory
19 $(info Quarn OS
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
))
20 $(info Copyright
(C
) 2008 Pawel Dziepak
)
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
))
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)
57 CFLAGS
= -Wall
-pedantic
-std
=c99
$(OPTIMIZE
) -fno-builtin
-nostartfiles
-nostdlib
-I
$(DIR
) $(CONF
)
58 CPPFLAGS
= -Wall
-pedantic
$(OPTIMIZE
) -fno-builtin
-fno-exceptions
-nostartfiles
-nostdlib
-I
$(DIR
) -isystem
$(DIR
) $(CONF
)
63 ifeq ($(shell $(PERL
) scripts
/mk_conf.pl USE_MULTIBOOT
), 0)
66 MB
= arch
/$(ARCH
)/loaders
/systemload.o
69 ifeq ($(shell $(PERL
) scripts
/mk_conf.pl DEBUG_MODE
), 0)
74 $(if
$(shell which sed
), , $(error GDB is needed to debug Quarn
))
82 # Directories that consist of code has to be compiled
83 DIRS
= actors
/ arch
/low
/ libs
/ arch
/low
/loaders manes
/ modules
/ services
/ resources
/ hydra
/
87 LOOPDEV
= $(shell $(SUDO
) /sbin
/losetup
-f
)
89 # Compile whole kernel
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)" \
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
)
104 # Clean all and then compile
105 rebuild
: clean compile
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); \
115 @
(cd docs
; $(MAKE
) clean)
116 @
(cd tests
; $(MAKE
) clean)
117 @
rm -rf Documentation
118 @echo
-e
"\t\t[rm]\tquarn"
122 # Clean also built tools
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"
129 @echo
-e
"\t\t[rm]\tfd.img"
133 # Compile configuration program (ncurses) and run it
134 config
: scripts
/nc_config
135 @echo
-e
"\t\t[sh]\tscripts/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
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)
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
155 $(info Creating floppy image...
)
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
)
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
)
169 @
$(SUDO
) /sbin
/losetup
-d
$(LOOPDEV
)
172 @qemu
-fda fd.img
-usb
-net nic
,model
=ne2k_pci
-net user
175 @qemu
-fda fd.img
-usb
-net nic
,model
=ne2k_pci
-net user
$(QFLAGS
)
178 # Put bootable image on the floppy
180 $(info Putting image on a floppy...
)
181 @
$(SUDO
) dd if
=fd.img of
=/dev
/fd0
183 # Create build package
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
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
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
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
))
217 @
#cd libs/tests; $(MAKE)
220 # Show possible targets
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"