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
)
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
)
52 ifeq ($(shell $(PERL
) scripts
/mk_conf.pl USE_MULTIBOOT
), 0)
55 MB
= arch
/$(ARCH
)/loaders
/systemload.o
58 # Directories that consist of code has to be compiled
59 DIRS
= actors
/ arch
/$(ARCH
)/ libs
/ arch
/$(ARCH
)/loaders manes
/ modules
/ services
/ resources
/ hydra
/
63 LOOPDEV
= $(shell $(SUDO
) /sbin
/losetup
-f
)
65 # Compile whole kernel
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)" \
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
82 $(info Cleaning project directory...
)
83 @for
dir in
$(DIRS
); do \
84 (cd
$$dir; $(MAKE
) clean); \
86 @echo
-e
"\t\t[rm]\tquarn"
89 # Clean also built tools
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"
96 @echo
-e
"\t\t[rm]\tfd.img"
99 # Compile configuration program (ncurses) and run it
100 config
: scripts
/nc_config
101 @echo
-e
"\t\t[sh]\tscripts/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
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)
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
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
)
124 @
$(SUDO
) mount
$(LOOPDEV
) image
125 @
-$(SUDO
) cp arch
/$(ARCH
)/loaders
/loader image
/
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
)
133 @
$(SUDO
) /sbin
/losetup
-d
$(LOOPDEV
)
138 # Put bootable image on the floppy
140 $(info Putting image on a floppy...
)
141 @
$(SUDO
) dd if
=fd.img of
=/dev
/fd0
143 #Create build package
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
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
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"