5 # Copyright (C) 2008 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
))
40 DIR_SHORT
= $(shell pwd | sed
's/\/.*\///')
42 CONFFILE
= quarnconf.h
43 CONF
= -include $(CONFFILE
)
45 ifeq ($(shell $(PERL
) scripts
/mk_conf.pl OPT_SIZE
), 0)
54 CFLAGS
= -Wall
-pedantic
-std
=c99
$(OPTIMIZE
) -fno-builtin
-nostartfiles
-nostdlib
-I
$(DIR
) $(CONF
)
55 CPPFLAGS
= -Wall
-pedantic
$(OPTIMIZE
) --no-rtti
--no-exceptions
-fno-builtin
-nostartfiles
-nostdlib
-I
$(DIR
) $(CONF
)
60 ifeq ($(shell $(PERL
) scripts
/mk_conf.pl USE_MULTIBOOT
), 0)
63 MB
= arch
/$(ARCH
)/loaders
/systemload.o
66 ifeq ($(shell $(PERL
) scripts
/mk_conf.pl DEBUG_MODE
), 0)
71 $(if
$(shell which sed
), , $(error GDB is needed to debug Quarn
))
79 # Directories that consist of code has to be compiled
80 DIRS
= actors
/ arch
/low
/ libs
/ arch
/low
/loaders manes
/ modules
/ services
/ resources
/ hydra
/
84 LOOPDEV
= $(shell $(SUDO
) /sbin
/losetup
-f
)
86 # Compile whole kernel
88 $(info Compiling Quarn OS...
)
89 $(shell rm -f arch
/low
)
90 $(shell ln
-s
$(DIR
)/arch
/$(ARCH
)/ arch
/low
)
91 @
$(if
$(wildcard $(CONFFILE
)), , $(error You have to configure Quarn OS first.
))
92 @for
dir in
$(DIRS
); do \
93 (cd
$$dir; $(MAKE
) CC
=$(CC
) CPP
=$(CPP
) LD
=$(LD
) \
94 CFLAGS
="$(CFLAGS)" CPPFLAGS
="$(CPPFLAGS)" \
97 @echo
-e
"\t\t[$(LD)]\tquarn"
98 @
$(LD
) -Tscripts
/x86_kernel.
ld $(MB
) `find . -name *.o | grep -v -E 'loaders|modules_start|rs232|test'` -o quarn
$(MAP
)
101 # Clean all and then compile
102 rebuild
: clean compile
106 $(shell rm -f arch
/low
)
107 $(shell ln
-s
$(DIR
)/arch
/$(ARCH
)/ arch
/low
)
108 $(info Cleaning project directory...
)
109 @for
dir in
$(DIRS
); do \
110 (cd
$$dir; $(MAKE
) clean); \
112 @echo
-e
"\t\t[rm]\tquarn"
116 # Clean also built tools
118 $(info Cleaning configuration files...
)
119 @echo
-e
"\t\t[rm]\tscripts/nc_config"
120 @
rm -f scripts
/nc_config
121 @echo
-e
"\t\t[rm]\tquarnconf.h"
123 @echo
-e
"\t\t[rm]\tfd.img"
127 # Compile configuration program (ncurses) and run it
128 config
: scripts
/nc_config
129 @echo
-e
"\t\t[sh]\tscripts/nc_config"
132 scripts
/nc_config
: scripts
/nc_config.c
133 @echo
-e
"\t\t[$(CC)]\tscripts/nc_config.c"
134 @
$(CC
) scripts
/nc_config.c
-lmenu
-lncurses
-I
/usr
/include/ncurses
-o scripts
/nc_config
137 $(info Restoring default configuration...
)
138 @echo
-e
"\t\t[$(PERL)]\tscripts/text_config.pl"
139 @
$(PERL
) scripts
/text_config.pl def
141 # Run configuration script (doesn't need ncurses)
143 $(info Launching configuration tool...
)
144 @echo
-e
"\t\t[$(PERL)]\tscripts/text_config.pl"
145 @
$(PERL
) scripts
/text_config.pl
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
)
147 # Create bootable floppy image
149 $(info Creating floppy image...
)
150 @
/sbin
/mkdosfs
-F
12 -C fd.img
1440
151 @
$(SUDO
) /sbin
/losetup
$(LOOPDEV
) fd.img
152 @
$(SUDO
) dd if
=arch
/low
/loaders
/boot of
=$(LOOPDEV
)
154 @
$(SUDO
) mount
$(LOOPDEV
) image
155 @
-$(SUDO
) cp arch
/low
/loaders
/loader image
/
156 @
$(SUDO
) cp quarn image
/
157 @
$(SUDO
) cp AUTHORS image
/
158 #@$(SUDO) cp modules/*.ko image/
159 #@$(SUDO) cp hydra/*.ko image/
160 @
$(SUDO
) umount
$(LOOPDEV
)
162 @
$(SUDO
) /sbin
/losetup
-d
$(LOOPDEV
)
165 @qemu
-fda fd.img
-usb
-net nic
,model
=ne2k_pci
-net user
168 @qemu
-fda fd.img
-usb
-net nic
,model
=ne2k_pci
-net user
$(QFLAGS
)
171 # Put bootable image on the floppy
173 $(info Putting image on a floppy...
)
174 @
$(SUDO
) dd if
=fd.img of
=/dev
/fd0
176 #Create build package
178 $(if
$(shell which
tar), , $(error TAR is needed to compile Quarn
))
179 $(if
$(shell which gzip
), , $(error GZIP is needed to compile Quarn
))
180 $(info Creating build package...
)
181 @
-rm -f ..
/quarnos_
`date +%Y-%m-%d`.
tar
182 @
tar -cf ..
/quarnos_
`date +%Y-%m-%d`.
tar ..
/$(DIR_SHORT
)
183 @
tar --delete
-f ..
/quarnos_
`date +%Y-%m-%d`.
tar $(DIR_SHORT
)/.git
184 @gzip
-f ..
/quarnos_
`date +%Y-%m-%d`.
tar
187 $(if
$(shell which
tar), , $(error TAR is needed to compile Quarn
))
188 $(if
$(shell which gzip
), , $(error GZIP is needed to compile Quarn
))
189 $(info Creating release package...
)
190 @
-rm -f ..
/quarnos_
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
).
tar
191 @
tar -cf ..
/quarnos_
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
).
tar ..
/$(DIR_SHORT
)
192 @
tar --delete
-f ..
/quarnos_
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
).
tar $(DIR_SHORT
)/.git
193 @gzip
-f ..
/quarnos_
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
).
tar
195 # Show possible targets
197 @echo
-e
"\t\tQuarn OS $(MAJREL).$(MINREL).$(PROREL) Makefile"
198 @echo
-e
"\t\t-----------------------"
199 @echo
-e
"\nConfiguration:"
200 @echo
-e
"\tconfig\t\t- ncurses configuration tool (WIP)"
201 @echo
-e
"\tdefconf\t\t- uses default configuration"
202 @echo
-e
"\ttextconf\t- text configuration tool"
203 @echo
-e
"\nCompiling:"
204 @echo
-e
"\tcompile\t\t- compile whole kernel (default)"
205 @echo
-e
"\trebuild\t\t- allclean + compile"
206 @echo
-e
"\nInstallation:"
207 @echo
-e
"\tfd_img\t\t- create floppy image (requires root)"
208 @echo
-e
"\tfloppy\t\t- fd_img + put image on the floppy (requires root)"
209 @echo
-e
"\nPackaging:"
210 @echo
-e
"\tbuild\t\t- create build package in the upper directory"
211 @echo
-e
"\tpack\t\t- create release package in upper directory"
212 @echo
-e
"\nCleaning:"
213 @echo
-e
"\tallclean\t- clean + remove configuration files"
214 @echo
-e
"\tclean\t\t- remove all files generated by target compile"