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
$(OPTIMIZE
) -fno-builtin
-nostartfiles
-nostdlib
-I
$(DIR
) $(CONF
)
55 CPPFLAGS
= -Wall
$(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 # Directories that consist of code has to be compiled
67 DIRS
= actors
/ arch
/$(ARCH
)/ libs
/ arch
/$(ARCH
)/loaders manes
/ modules
/ services
/ resources
/ hydra
/
71 LOOPDEV
= $(shell $(SUDO
) /sbin
/losetup
-f
)
73 # Compile whole kernel
75 $(info Compiling Quarn OS...
)
76 @
$(if
$(wildcard $(CONFFILE
)), , $(error You have to configure Quarn OS first.
))
77 @for
dir in
$(DIRS
); do \
78 (cd
$$dir; $(MAKE
) CC
=$(CC
) CPP
=$(CPP
) LD
=$(LD
) \
79 CFLAGS
="$(CFLAGS)" CPPFLAGS
="$(CPPFLAGS)" \
82 @echo
-e
"\t\t[$(LD)]\tquarn"
83 @
$(LD
) -Tscripts
/x86_kernel.
ld $(MB
) `find . -name *.o | grep -v -E 'loaders|modules_start|rs232|test'` -o quarn
86 # Clean all and then compile
87 rebuild
: clean compile
91 $(info Cleaning project directory...
)
92 @for
dir in
$(DIRS
); do \
93 (cd
$$dir; $(MAKE
) clean); \
95 @echo
-e
"\t\t[rm]\tquarn"
98 # Clean also built tools
100 $(info Cleaning configuration files...
)
101 @echo
-e
"\t\t[rm]\tscripts/nc_config"
102 @
rm -f scripts
/nc_config
103 @echo
-e
"\t\t[rm]\tquarnconf.h"
105 @echo
-e
"\t\t[rm]\tfd.img"
108 # Compile configuration program (ncurses) and run it
109 config
: scripts
/nc_config
110 @echo
-e
"\t\t[sh]\tscripts/nc_config"
113 scripts
/nc_config
: scripts
/nc_config.c
114 @echo
-e
"\t\t[$(CC)]\tscripts/nc_config.c"
115 @
$(CC
) scripts
/nc_config.c
-lmenu
-lncurses
-I
/usr
/include/ncurses
-o scripts
/nc_config
118 @echo
-e
"\t\t[$(PERL)]\tscripts/text_config.pl"
119 @
$(PERL
) scripts
/text_config.pl def
121 # Run configuration script (doesn't need ncurses)
123 @echo
-e
"\t\t[$(PERL)]\tscripts/text_config.pl"
124 @
$(PERL
) scripts
/text_config.pl
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
)
126 # Create bootable floppy image
128 $(info Creating floppy image...
)
129 @
/sbin
/mkdosfs
-F
12 -C fd.img
1440
130 @
$(SUDO
) /sbin
/losetup
$(LOOPDEV
) fd.img
131 @
$(SUDO
) dd if
=arch
/$(ARCH
)/loaders
/boot of
=$(LOOPDEV
)
133 @
$(SUDO
) mount
$(LOOPDEV
) image
134 @
-$(SUDO
) cp arch
/$(ARCH
)/loaders
/loader image
/
135 @
$(SUDO
) cp quarn image
/
136 @
$(SUDO
) cp AUTHORS image
/
137 #@$(SUDO) cp modules/*.ko image/
138 #@$(SUDO) cp hydra/*.ko image/
139 @
$(SUDO
) umount
$(LOOPDEV
)
141 @
$(SUDO
) /sbin
/losetup
-d
$(LOOPDEV
)
146 # Put bootable image on the floppy
148 $(info Putting image on a floppy...
)
149 @
$(SUDO
) dd if
=fd.img of
=/dev
/fd0
151 #Create build package
153 $(if
$(shell which
tar), , $(error TAR is needed to compile Quarn
))
154 $(if
$(shell which gzip
), , $(error GZIP is needed to compile Quarn
))
155 $(info Creating build package...
)
156 @
-rm -f ..
/quarnos_
`date +%Y-%m-%d`.
tar
157 @
tar -cf ..
/quarnos_
`date +%Y-%m-%d`.
tar ..
/$(DIR_SHORT
)
158 @
tar --delete
-f ..
/quarnos_
`date +%Y-%m-%d`.
tar $(DIR_SHORT
)/.git
159 @gzip
-f ..
/quarnos_
`date +%Y-%m-%d`.
tar
162 $(if
$(shell which
tar), , $(error TAR is needed to compile Quarn
))
163 $(if
$(shell which gzip
), , $(error GZIP is needed to compile Quarn
))
164 $(info Creating release package...
)
165 @
-rm -f ..
/quarnos_
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
).
tar
166 @
tar -cf ..
/quarnos_
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
).
tar ..
/$(DIR_SHORT
)
167 @
tar --delete
-f ..
/quarnos_
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
).
tar $(DIR_SHORT
)/.git
168 @gzip
-f ..
/quarnos_
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
).
tar
170 # Show possible targets
172 @echo
-e
"\t\tQuarn OS $(MAJREL).$(MINREL).$(PROREL) Makefile"
173 @echo
-e
"\t\t-----------------------"
174 @echo
-e
"\nConfiguration:"
175 @echo
-e
"\tconfig\t\t- ncurses configuration tool (WIP)"
176 @echo
-e
"\tdefconf\t\t- uses default configuration"
177 @echo
-e
"\ttextconf\t- text configuration tool"
178 @echo
-e
"\nCompiling:"
179 @echo
-e
"\tcompile\t\t- compile whole kernel (default)"
180 @echo
-e
"\trebuild\t\t- allclean + compile"
181 @echo
-e
"\nInstallation:"
182 @echo
-e
"\tfd_img\t\t- create floppy image (requires root)"
183 @echo
-e
"\tfloppy\t\t- fd_img + put image on the floppy (requires root)"
184 @echo
-e
"\nPackaging:"
185 @echo
-e
"\tbuild\t\t- create build package in the upper directory"
186 @echo
-e
"\tpack\t\t- create release package in upper directory"
187 @echo
-e
"\nCleaning:"
188 @echo
-e
"\tallclean\t- clean + remove configuration files"
189 @echo
-e
"\tclean\t\t- remove all files generated by target compile"