Merge branch 'master' of github.com:thepowersgang/acess2
[tpg/acess2.git] / Makefile
1 #
2 # Acess2 Core Makefile
3 #
4 # (Oh man! This is hacky, but beautiful at the same time, much like the
5 # rest of Acess)
6
7 -include Makefile.cfg
8
9 .PHONY: all clean SyscallList all-user
10
11 SUBMAKE = $(MAKE) --no-print-directory
12
13 USRLIBS := crt0.o acess.ld ld-acess.so libc.so libc++.so libposix.so
14 USRLIBS += libreadline.so libnet.so liburi.so libpsocket.so
15 USRLIBS += libimage_sif.so libunicode.so libm.so
16
17 EXTLIBS := 
18 #libspiderscript
19 # zlib libpng
20
21 USRAPPS := init login CLIShell cat ls mount automounter
22 USRAPPS += insmod
23 USRAPPS += bomb lspci
24 USRAPPS += ip dhcpclient ping telnet irc wget telnetd
25 USRAPPS += axwin3 gui_ate gui_terminal
26
27 define targetclasses
28  AI_$1      := $$(addprefix allinstall-,$$($1))
29  ALL_$1     := $$(addprefix all-,$$($1))
30  CLEAN_$1   := $$(addprefix clean-,$$($1))
31  INSTALL_$1 := $$(addprefix install-,$$($1))
32 endef
33
34 $(eval $(call targetclasses,DYNMODS))
35 $(eval $(call targetclasses,MODULES))
36 $(eval $(call targetclasses,USRLIBS))
37 $(eval $(call targetclasses,EXTLIBS))
38 $(eval $(call targetclasses,USRAPPS))
39
40 targetvars := $$(AI_$1) $$(ALL_$1) $$(CLEAN_$1) $$(INSTALL_$1)
41
42 .PHONY: all clean install \
43         ai-kmode all-kmode clean-kmode install-kmode \
44         ai-user all-user clean-user install-user \
45         utest mtest
46
47 .PHONY: allinstall-Kernel all-Kernel clean-Kernel install-Kernel \
48         $(call targetvars,DYNMODS) \
49         $(call targetvars,MODULES) \
50         $(call targetvars,USRLIBS) \
51         $(call targetvars,EXTLIBS) \
52         $(call targetvars,USRAPPS)
53
54 ai-kmode:       $(AI_MODULES) allinstall-Kernel $(AI_DYNMODS)
55 all-kmode:      $(ALL_MODULES) all-Kernel $(ALL_DYNMODS)
56 clean-kmode:    $(CLEAN_MODULES) $(CLEAN_DYNMODS) clean-Kernel
57 install-kmode:  $(INSTALL_MODULES) install-Kernel $(INSTALL_DYNMODS)
58
59 ai-user:        $(AI_USRLIBS) $(AI_EXTLIBS) $(AI_USRAPPS)
60 all-user:       $(ALL_USRLIBS) $(ALL_EXTLIBS) $(ALL_USRAPPS)
61 clean-user:     $(CLEAN_USRLIBS) $(CLEAN_EXTLIBS) $(CLEAN_USRAPPS)
62 install-user:   $(INSTALL_USRLIBS) $(INSTALL_EXTLIBS) $(INSTALL_USRAPPS)
63
64 all:    SyscallList all-user all-kmode
65 all-install:    install-Filesystem SyscallList ai-user ai-kmode
66 clean:  clean-kmode clean-user
67 install:        install-Filesystem SyscallList install-user install-kmode
68
69 utest-build: $(USRLIBS:%=utest-build-%)
70 utest-run: $(USRLIBS:%=utest-run-%)
71 utest: utest-build utest-run
72
73 utest-build-%:
74         @CC=$(NCC) $(SUBMAKE) -C Usermode/Libraries/$*_src generate_exp
75         @CC=$(NCC) $(SUBMAKE) -C Usermode/Libraries/$*_src utest-build
76 utest-run-%:
77         @CC=$(NCC) $(SUBMAKE) -C Usermode/Libraries/$*_src utest-run -k
78
79 # TODO: Module tests using DiskTool and NetTest
80 mtest: mtest-build mtest-run
81         @echo > /dev/null
82 mtest-build:
83         # Network
84         @CC=$(NCC) $(SUBMAKE) -C Tools/nativelib
85         @CC=$(NCC) $(SUBMAKE) -C Tools/NetTest
86         @CC=$(NCC) $(SUBMAKE) -C Tools/NetTest_Runner
87 mtest-run:
88         @echo "=== Network Module Test ==="
89         @cd Tools && ./nettest_runner
90
91 SyscallList: include/syscalls.h
92 include/syscalls.h: KernelLand/Kernel/Makefile KernelLand/Kernel/syscalls.lst
93         @make -C KernelLand/Kernel/ include/syscalls.h
94
95 _build_dynmod := BUILDTYPE=dynamic $(SUBMAKE) -C KernelLand/Modules/
96 _build_stmod  := BUILDTYPE=static $(SUBMAKE) -C KernelLand/Modules/
97 _build_kernel := $(SUBMAKE) -C KernelLand/Kernel
98
99 define rules
100 $$(ALL_$1): all-%:
101         +@echo === $2 && $3 all
102 $$(AI_$1): allinstall-%:
103         +@echo === $2 && $3 all install
104 $$(CLEAN_$1): clean-%:
105         +@echo === $2 && $3 clean
106 $$(INSTALL_$1): install-%:
107         +@$3 install
108 endef
109
110 $(eval $(call rules,DYNMODS,Dynamic Module: $$*,$(_build_dynmod)$$*))
111 $(eval $(call rules,MODULES,Module: $$*,$(_build_stmod)$$*))
112 $(eval $(call rules,USRLIBS,User Library: $$*,$(SUBMAKE) -C Usermode/Libraries/$$*_src))
113 $(eval $(call rules,EXTLIBS,External Library: $$*,$(SUBMAKE) -C Externals/$$*))
114 $(eval $(call rules,USRAPPS,User Application: $$*,$(SUBMAKE) -C Usermode/Applications/$$*_src))
115 all-Kernel:
116         +@echo === Kernel && $(_build_kernel) all
117 allinstall-Kernel:
118         +@echo === Kernel && $(_build_kernel) all install
119 clean-Kernel:
120         +@$(_build_kernel) clean
121 install-Kernel:
122         @$(_build_kernel) install
123 install-Filesystem:
124         @$(SUBMAKE) install -C Usermode/Filesystem

UCC git Repository :: git.ucc.asn.au