5 # Copyright (C) 2008 Pawel Dziepak
8 MAKEFLAGS
+= --no-print-directory
16 $(if
$(shell which gcc
), , $(error GCC is needed to compile Quarn
))
17 $(if
$(shell which g
++), , $(error G
++ is needed to compile Quarn
))
18 $(if
$(shell which
ld), , $(error LD is needed to compile Quarn
))
19 $(if
$(shell which sed
), , $(error SED is needed to compile Quarn
))
20 $(if
$(shell which pwd
), , $(error PWD is needed to compile Quarn
))
30 DIR_SHORT
= $(shell pwd | sed
's/\/.*\///')
33 CFLAGS
= -Wall
-pedantic
-O2
-fno-builtin
-nostartfiles
-nostdlib
-I
$(DIR
)
34 CPPFLAGS
= -Wall
-pedantic
-O2
--no-rtti
--no-exceptions
-fno-builtin
-nostartfiles
-nostdlib
-I
$(DIR
)
40 #arch/$(ARCH)/loaders/systemload.o
42 # Directories that consist of code has to be compiled
43 DIRS
= actors
/ arch
/$(ARCH
)/ libs
/ arch
/$(ARCH
)/loaders manes
/ modules
/ services
/ resources
/
47 # Compile whole kernel
49 @for
dir in
$(DIRS
); do \
50 (cd
$$dir; $(MAKE
) CC
=$(CC
) CPP
=$(CPP
) LD
=$(LD
) \
51 CFLAGS
="$(CFLAGS)" CPPFLAGS
="$(CPPFLAGS)" \
54 @echo
-e
"\t\t[$(LD)]\tquarn"
55 @
$(LD
) -Tscripts
/x86_kernel.
ld $(MB
) `find . -name *.o | grep -v -E 'loaders|modules_start|rs232'` -o quarn
57 # Clean all and then compile
58 rebuild
: allclean compile
62 @for
dir in
$(DIRS
); do \
63 (cd
$$dir; $(MAKE
) clean); \
65 @echo
-e
"\t\t[rm]\tquarn"
68 # Clean also built tools
70 @echo
-e
"\t\t[rm]\tscripts/nc_config"
71 @
rm -f scripts
/nc_config
72 @echo
-e
"\t\t[rm]\tquarnconf.h"
74 @echo
-e
"\t\t[rm]\tfd.img"
77 # Compile configuration program (ncurses) and run it
78 config
: scripts
/nc_config
79 @echo
-e
"\t\t[sh]\tscripts/nc_config"
82 scripts
/nc_config
: scripts
/nc_config.c
83 @echo
-e
"\t\t[$(CC)]\tscripts/nc_config.c"
84 @
$(CC
) scripts
/nc_config.c
-lmenu
-lncurses
-I
/usr
/include/ncurses
-o scripts
/nc_config
86 # Run configuration script (doesn't need ncurses)
88 $(if
$(shell which perl
), , $(error PERL is needed to compile Quarn
))
89 @echo
-e
"\t\t[$(PERL)]\tscripts/text_config.pl"
90 @
$(PERL
) scripts
/text_config.pl
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
)
92 # Create bootable floppy image
94 @
/sbin
/mkdosfs
-F
12 -C fd.img
1440
95 @
$(SUDO
) /sbin
/losetup
/dev
/loop0 fd.img
96 @
$(SUDO
) dd if
=arch
/$(ARCH
)/loaders
/boot of
=/dev
/loop0
98 @
$(SUDO
) mount
/dev
/loop0 image
99 @
$(SUDO
) cp arch
/$(ARCH
)/loaders
/loader image
/
101 @
$(SUDO
) cp quarn image
/
102 @
$(SUDO
) cp AUTHORS image
/
103 @
$(SUDO
) cp modules
/*.ko image
/
104 @
$(SUDO
) umount
/dev
/loop0
106 @
$(SUDO
) /sbin
/losetup
-d
/dev
/loop0
111 # Put bootable image on the floppy
113 @
$(SUDO
) dd if
=fd.img of
=/dev
/fd0
115 #Create build package
117 $(if
$(shell which
tar), , $(error TAR is needed to compile Quarn
))
118 $(if
$(shell which gzip
), , $(error GZIP is needed to compile Quarn
))
119 @
-rm -f ..
/quarnos_
`date +%Y-%m-%d`.
tar
120 @
tar -cf ..
/quarnos_
`date +%Y-%m-%d`.
tar ..
/$(DIR_SHORT
)
121 @
tar --delete
-f ..
/quarnos_
`date +%Y-%m-%d`.
tar $(DIR_SHORT
)/.git
122 @gzip
-f ..
/quarnos_
`date +%Y-%m-%d`.
tar
125 $(if
$(shell which
tar), , $(error TAR is needed to compile Quarn
))
126 $(if
$(shell which gzip
), , $(error GZIP is needed to compile Quarn
))
127 @
-rm -f ..
/quarnos_
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
).
tar
128 @
tar -cf ..
/quarnos_
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
).
tar ..
/$(DIR_SHORT
)
129 @
tar --delete
-f ..
/quarnos_
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
).
tar $(DIR_SHORT
)/.git
130 @gzip
-f ..
/quarnos_
$(MAJREL
).
$(MINREL
).
$(PROREL
)$(ADDONS
).
tar
132 # Show possible targets
134 @echo
-e
"\t\tQuarn OS $(MAJREL).$(MINREL).$(PROREL) Makefile"
135 @echo
-e
"\t\t-----------------------\n"
136 @echo
-e
"Possible targets:"
137 @echo
-e
"\tallclean\t- clean + remove configuration files"
138 @echo
-e
"\tbuild\t\t- create build package in the upper directory"
139 @echo
-e
"\tclean\t\t- remove all files generated by target compile"
140 @echo
-e
"\tcompile\t\t- compile whole kernel (default)"
141 @echo
-e
"\tconfig\t\t- ncurses configuration tool (WIP)"
142 @echo
-e
"\tfd_img\t\t- create floppy image (requires root)"
143 @echo
-e
"\tfloppy\t\t- fd_img + put image on the floppy (requires root)"
144 @echo
-e
"\trebuild\t\t- allclean + compile"
145 @echo
-e
"\ttextconfig\t- text configuration tool (WIP)\n"