64b757e46e4f92120b67ee0aa02192e396f8d1dc
[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 ld-acess.so libc.so libposix.so libc++.so
14 USRLIBS += libreadline.so libnet.so liburi.so libpsocket.so
15 USRLIBS += libimage_sif.so libunicode.so libm.so
16 USRLIBS += libaxwin4.so
17
18 EXTLIBS := 
19 #libspiderscript
20 # zlib libpng
21
22 USRAPPS := init login CLIShell cat ls mount automounter
23 USRAPPS += insmod
24 USRAPPS += bomb lspci
25 USRAPPS += ip dhcpclient ping telnet irc wget telnetd
26 USRAPPS += axwin3 gui_ate gui_terminal
27 USRAPPS += axwin4
28
29 define targetclasses
30  AI_$1      := $$(addprefix allinstall-,$$($1))
31  ALL_$1     := $$(addprefix all-,$$($1))
32  CLEAN_$1   := $$(addprefix clean-,$$($1))
33  INSTALL_$1 := $$(addprefix install-,$$($1))
34 endef
35
36 $(eval $(call targetclasses,DYNMODS))
37 $(eval $(call targetclasses,MODULES))
38 $(eval $(call targetclasses,USRLIBS))
39 $(eval $(call targetclasses,EXTLIBS))
40 $(eval $(call targetclasses,USRAPPS))
41
42 targetvars := $$(AI_$1) $$(ALL_$1) $$(CLEAN_$1) $$(INSTALL_$1)
43
44 .PHONY: all clean install \
45         ai-kmode all-kmode clean-kmode install-kmode \
46         ai-user all-user clean-user install-user \
47         utest mtest
48
49 .PHONY: allinstall-Kernel all-Kernel clean-Kernel install-Kernel \
50         $(call targetvars,DYNMODS) \
51         $(call targetvars,MODULES) \
52         $(call targetvars,USRLIBS) \
53         $(call targetvars,EXTLIBS) \
54         $(call targetvars,USRAPPS)
55
56 ai-kmode:       $(AI_MODULES) allinstall-Kernel $(AI_DYNMODS)
57 all-kmode:      $(ALL_MODULES) all-Kernel $(ALL_DYNMODS)
58 clean-kmode:    $(CLEAN_MODULES) $(CLEAN_DYNMODS) clean-Kernel
59 install-kmode:  $(INSTALL_MODULES) install-Kernel $(INSTALL_DYNMODS)
60
61 ai-user:        $(AI_USRLIBS) $(AI_EXTLIBS) $(AI_USRAPPS)
62 all-user:       $(ALL_USRLIBS) $(ALL_EXTLIBS) $(ALL_USRAPPS)
63 clean-user:     $(CLEAN_USRLIBS) $(CLEAN_EXTLIBS) $(CLEAN_USRAPPS)
64 install-user:   $(INSTALL_USRLIBS) $(INSTALL_EXTLIBS) $(INSTALL_USRAPPS)
65
66 all:    SyscallList all-user all-kmode
67 all-install:    install-Filesystem SyscallList ai-user ai-kmode
68 clean:  clean-kmode clean-user
69 install:        install-Filesystem SyscallList install-user install-kmode
70
71 utest-build: $(USRLIBS:%=utest-build-%)
72 utest-run: $(USRLIBS:%=utest-run-%)
73 utest: utest-build utest-run
74
75 utest-build-%:
76         @CC=$(NCC) $(SUBMAKE) -C Usermode/Libraries/$*_src generate_exp
77         @CC=$(NCC) $(SUBMAKE) -C Usermode/Libraries/$*_src utest-build
78 utest-run-%:
79         @CC=$(NCC) $(SUBMAKE) -C Usermode/Libraries/$*_src utest-run -k
80
81 # TODO: Module tests using DiskTool and NetTest
82 mtest: mtest-build mtest-run
83         @echo > /dev/null
84 mtest-build:
85         # Network
86         @CC=$(NCC) $(SUBMAKE) -C Tools/nativelib
87         @CC=$(NCC) $(SUBMAKE) -C Tools/NetTest
88         @CC=$(NCC) $(SUBMAKE) -C Tools/NetTest_Runner
89 mtest-run:
90         @echo "=== Network Module Test ==="
91         @cd Tools && ./nettest_runner
92
93 SyscallList: include/syscalls.h
94 include/syscalls.h: KernelLand/Kernel/Makefile KernelLand/Kernel/syscalls.lst
95         @make -C KernelLand/Kernel/ include/syscalls.h
96
97 _build_dynmod := BUILDTYPE=dynamic $(SUBMAKE) -C KernelLand/Modules/
98 _build_stmod  := BUILDTYPE=static $(SUBMAKE) -C KernelLand/Modules/
99 _build_kernel := $(SUBMAKE) -C KernelLand/Kernel
100
101 define rules
102 $$(ALL_$1): all-%: $(CC)
103         +@echo === $2 && $3 all
104 $$(AI_$1): allinstall-%: $(CC)
105         +@echo === $2 && $3 all install
106 $$(CLEAN_$1): clean-%: $(CC)
107         +@echo === $2 && $3 clean
108 $$(INSTALL_$1): install-%: $(CC)
109         +@$3 install
110 endef
111
112 $(eval $(call rules,DYNMODS,Dynamic Module: $$*,$(_build_dynmod)$$*))
113 $(eval $(call rules,MODULES,Module: $$*,$(_build_stmod)$$*))
114 $(eval $(call rules,USRLIBS,User Library: $$*,$(SUBMAKE) -C Usermode/Libraries/$$*_src))
115 $(eval $(call rules,EXTLIBS,External Library: $$*,$(SUBMAKE) -C Externals/$$*))
116 $(eval $(call rules,USRAPPS,User Application: $$*,$(SUBMAKE) -C Usermode/Applications/$$*_src))
117 all-Kernel: $(CC)
118         +@echo === Kernel && $(_build_kernel) all
119 allinstall-Kernel: $(CC)
120         +@echo === Kernel && $(_build_kernel) all install
121 clean-Kernel: $(CC)
122         +@$(_build_kernel) clean
123 install-Kernel: $(CC)
124         @$(_build_kernel) install
125 install-Filesystem: $(CC)
126         @$(SUBMAKE) install -C Usermode/Filesystem
127
128 ifeq ($(ARCHDIR),native)
129 .PHONY: $(CC)
130 else
131 $(CC):
132         @echo ---
133         @echo $(CC) does not exist, recompiling
134         @echo ---
135         make -C Externals/cross-compiler/
136 endif

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