initial actors interface, compilation scripts improvements
[quarnos.git] / Makefile
blob07b365fa97e6115eb02bd2e03e47eb593b5e7299
1 # Quarn OS
3 # Main Makefile
5 # Copyright (C) 2008 Pawel Dziepak
8 MAKEFLAGS += --no-print-directory
10 MAJREL = 0
11 MINREL = 0
12 PROREL = 90
13 ADDONS = -dev
15 # Check host OS
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))
22 PERL = perl
24 # Main tools
25 CC = gcc
26 CPP = g++
27 LD = ld
29 DIR = $(shell pwd)
30 DIR_SHORT = $(shell pwd | sed 's/\/.*\///')
32 # Main flags
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)
35 LDFLAGS =
37 ARCH=x86
39 MB =
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/
45 SUDO = sudo
47 # Compile whole kernel
48 compile:
49 @for dir in $(DIRS); do \
50 (cd $$dir; $(MAKE) CC=$(CC) CPP=$(CPP) LD=$(LD) \
51 CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \
52 LDFLAGS=$(LDFAGS)); \
53 done
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
60 # Clean object files
61 clean:
62 @for dir in $(DIRS); do \
63 (cd $$dir; $(MAKE) clean); \
64 done
65 @echo -e "\t\t[rm]\tquarn"
66 @rm -f quarn
68 # Clean also built tools
69 allclean: clean
70 @echo -e "\t\t[rm]\tscripts/nc_config"
71 @rm -f scripts/nc_config
72 @echo -e "\t\t[rm]\tquarnconf.h"
73 @rm -f quarnconf.h
74 @echo -e "\t\t[rm]\tfd.img"
75 @rm -f fd.img
77 # Compile configuration program (ncurses) and run it
78 config: scripts/nc_config
79 @echo -e "\t\t[sh]\tscripts/nc_config"
80 @scripts/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)
87 textconfig:
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
93 fd_img: compile
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
97 @mkdir image
98 @$(SUDO) mount /dev/loop0 image
99 @$(SUDO) cp arch/$(ARCH)/loaders/loader image/
100 @strip quarn
101 @$(SUDO) cp quarn image/
102 @$(SUDO) cp AUTHORS image/
103 @$(SUDO) cp modules/*.ko image/
104 @$(SUDO) umount /dev/loop0
105 @rmdir image
106 @$(SUDO) /sbin/losetup -d /dev/loop0
108 qemu: fd_img
109 @qemu -fda fd.img
111 # Put bootable image on the floppy
112 floppy: fd_img
113 @$(SUDO) dd if=fd.img of=/dev/fd0
115 #Create build package
116 build: fd_img
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
124 pack: fd_img
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
133 help:
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"