4 # (Oh man! This is hacky, but beautiful at the same time, much like the
9 .PHONY: all clean SyscallList all-user
11 SUBMAKE = $(MAKE) --no-print-directory
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
22 USRAPPS := init login CLIShell cat ls mount automounter
25 USRAPPS += ip dhcpclient ping telnet irc wget telnetd
26 USRAPPS += axwin3 gui_ate gui_terminal
30 AI_$1 := $$(addprefix allinstall-,$$($1))
31 ALL_$1 := $$(addprefix all-,$$($1))
32 CLEAN_$1 := $$(addprefix clean-,$$($1))
33 INSTALL_$1 := $$(addprefix install-,$$($1))
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))
42 targetvars := $$(AI_$1) $$(ALL_$1) $$(CLEAN_$1) $$(INSTALL_$1)
44 .PHONY: all clean install \
45 ai-kmode all-kmode clean-kmode install-kmode \
46 ai-user all-user clean-user install-user \
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)
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)
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)
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
71 utest-build: $(USRLIBS:%=utest-build-%)
72 utest-run: $(USRLIBS:%=utest-run-%)
73 utest: utest-build utest-run
76 @CC=$(NCC) $(SUBMAKE) -C Usermode/Libraries/$*_src generate_exp
77 @CC=$(NCC) $(SUBMAKE) -C Usermode/Libraries/$*_src utest-build
79 @CC=$(NCC) $(SUBMAKE) -C Usermode/Libraries/$*_src utest-run -k
81 # TODO: Module tests using DiskTool and NetTest
82 mtest: mtest-build mtest-run
86 @CC=$(NCC) $(SUBMAKE) -C Tools/nativelib
87 @CC=$(NCC) $(SUBMAKE) -C Tools/NetTest
88 @CC=$(NCC) $(SUBMAKE) -C Tools/NetTest_Runner
90 @echo "=== Network Module Test ==="
91 @cd Tools && ./nettest_runner
93 SyscallList: include/syscalls.h
94 include/syscalls.h: KernelLand/Kernel/Makefile KernelLand/Kernel/syscalls.lst
95 @make -C KernelLand/Kernel/ include/syscalls.h
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
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)
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))
118 +@echo === Kernel && $(_build_kernel) all
119 allinstall-Kernel: $(CC)
120 +@echo === Kernel && $(_build_kernel) all install
122 +@$(_build_kernel) clean
123 install-Kernel: $(CC)
124 @$(_build_kernel) install
125 install-Filesystem: $(CC)
126 @$(SUBMAKE) install -C Usermode/Filesystem
128 ifeq ($(ARCHDIR),native)
133 @echo $(CC) does not exist, recompiling
135 make -C Externals/cross-compiler/