#
# Acess2 Core Makefile
#
+# (Oh man! This is hacky, but beautiful at the same time, much like the
+# rest of Acess)
+
+-include Makefile.cfg
.PHONY: all clean
-MODULES = IPStack
-USRLIBS = ld-acess.so libacess.so libgcc.so libc.so
-USRAPPS = init login CLIShell cat ls mount
+SUBMAKE = $(MAKE) --no-print-directory
+
+USRLIBS := crt0.o acess.ld ld-acess.so libgcc.so libc.so
+USRLIBS += libreadline.so libnet.so liburi.so
+
+USRAPPS := init login CLIShell cat ls mount
+USRAPPS += bomb pcidump
+USRAPPS += ifconfig ping irc
+
+ALL_DYNMODS = $(addprefix all-,$(DYNMODS))
+ALL_MODULES := $(addprefix all-,$(MODULES))
+ALL_USRLIBS := $(addprefix all-,$(USRLIBS))
+ALL_USRAPPS := $(addprefix all-,$(USRAPPS))
+CLEAN_DYNMODS := $(addprefix clean-,$(DYNMODS))
+CLEAN_MODULES := $(addprefix clean-,$(MODULES))
+CLEAN_USRLIBS := $(addprefix clean-,$(USRLIBS))
+CLEAN_USRAPPS := $(addprefix clean-,$(USRAPPS))
+INSTALL_DYNMODS := $(addprefix install-,$(DYNMODS))
+INSTALL_MODULES := $(addprefix install-,$(MODULES))
+INSTALL_USRLIBS := $(addprefix install-,$(USRLIBS))
+INSTALL_USRAPPS := $(addprefix install-,$(USRAPPS))
+AI_DYNMODS := $(addprefix allinstall-,$(DYNMODS))
+AI_MODULES := $(addprefix allinstall-,$(MODULES))
+AI_USRLIBS := $(addprefix allinstall-,$(USRLIBS))
+AI_USRAPPS := $(addprefix allinstall-,$(USRAPPS))
+
+.PHONY: all clean install \
+ $(ALL_MODULES) all-Kernel $(ALL_USRLIBS) $(ALL_USRAPPS) \
+ $(AI_MODULES) allinstall-Kernel $(AI_USRLIBS) $(AI_USRAPPS) \
+ $(CLEAN_MODULES) clean-Kernel $(CLEAN_USRLIBS) $(CLEAN_USRAPPS) \
+ $(INSTALL_MODULES) install-Kernel $(INSTALL_USRLIBS) $(INSTALL_USRAPPS)
+
+kmode: $(AI_MODULES) $(AI_DYNMODS) allinstall-Kernel
+
+all-user: $(ALL_USRLIBS) $(ALL_USRAPPS)
+clean-user: $(CLEAN_USRLIBS) $(CLEAN_USRAPPS)
+
+all: $(ALL_DYNMODS) $(ALL_MODULES) all-Kernel $(ALL_USRLIBS) $(ALL_USRAPPS)
+all-install: $(AI_DYNMODS) $(AI_MODULES) allinstall-Kernel $(AI_USRLIBS) $(AI_USRAPPS)
+clean: $(CLEAN_DYNMODS) $(CLEAN_MODULES) clean-Kernel $(CLEAN_USRLIBS) $(CLEAN_USRAPPS)
+install: install-Filesystem $(INSTALL_DYNMODS) $(INSTALL_MODULES) install-Kernel $(INSTALL_USRLIBS) $(INSTALL_USRAPPS)
-all:
- @for mod in $(MODULES); do \
- (echo === $$mod && $(MAKE) all --no-print-directory -C Modules/$$mod) \
- done
-
- @echo === Kernel
- @$(MAKE) all --no-print-directory -C Kernel
-
- @for lib in $(USRLIBS); do \
- (echo === $$lib && $(MAKE) all --no-print-directory -C Usermode/Libraries/`echo $$lib`_src) \
- done
-
- @for app in $(USRAPPS); do \
- (echo === $$app && $(MAKE) all --no-print-directory -C Usermode/Applications/`echo $$app`_src) \
- done
+# Compile Only
+$(ALL_DYNMODS): all-%:
+ @echo === Dynamic Module: $* && BUILDTYPE=dynamic $(SUBMAKE) all -C Modules/$*
+$(ALL_MODULES): all-%:
+ @echo === Module: $* && BUILDTYPE=static $(SUBMAKE) all -C Modules/$*
+all-Kernel:
+ @echo === Kernel && $(SUBMAKE) all -C Kernel
+$(ALL_USRLIBS): all-%:
+ @echo === User Library: $* && $(SUBMAKE) all -C Usermode/Libraries/$*_src
+$(ALL_USRAPPS): all-%:
+ @echo === User Application: $* && $(SUBMAKE) all -C Usermode/Applications/$*_src
-# @echo === ld-acess.so
-# @$(MAKE) all --no-print-directory -C Usermode/Libraries/ld-acess.so_src
-# @echo === libacess.so
-# @$(MAKE) all --no-print-directory -C Usermode/Libraries/libacess.so_src
-# @echo === libgcc.so
-# @$(MAKE) all --no-print-directory -C Usermode/Libraries/libgcc.so_src
-# @echo === libc.so
-# @$(MAKE) all --no-print-directory -C Usermode/Libraries/libc.so_src
-# @echo === init
-# @$(MAKE) all --no-print-directory -C Usermode/Applications/init_src
-# @echo === login
-# @$(MAKE) all --no-print-directory -C Usermode/Applications/login_src
-# @echo === CLIShell
-# @$(MAKE) all --no-print-directory -C Usermode/Applications/CLIShell_src
-# @echo === cat
-# @$(MAKE) all --no-print-directory -C Usermode/Applications/cat_src
-# @echo === ls
-# @$(MAKE) all --no-print-directory -C Usermode/Applications/ls_src
-# @echo === mount
-# @$(MAKE) all --no-print-directory -C Usermode/Applications/mount_src
+# Compile & Install
+$(AI_DYNMODS): allinstall-%:
+ @echo === Dynamic Module: $* && BUILDTYPE=dynamic $(SUBMAKE) all install -C Modules/$*
+$(AI_MODULES): allinstall-%:
+ @echo === Module: $* && BUILDTYPE=static $(SUBMAKE) all install -C Modules/$*
+allinstall-Kernel:
+ @echo === Kernel && $(SUBMAKE) all install -C Kernel
+$(AI_USRLIBS): allinstall-%:
+ @echo === User Library: $* && $(SUBMAKE) all install -C Usermode/Libraries/$*_src
+$(AI_USRAPPS): allinstall-%:
+ @echo === User Application: $* && $(SUBMAKE) all install -C Usermode/Applications/$*_src
-clean:
- @make clean --no-print-directory -C Kernel/
-
- @for lib in $(USRLIBS); do \
- ($(MAKE) clean --no-print-directory -C Usermode/Libraries/`echo $$lib`_src) \
- done
-
- @for app in $(USRAPPS); do \
- ($(MAKE) clean --no-print-directory -C Usermode/Applications/`echo $$app`_src) \
- done
+# Clean up compilation
+$(CLEAN_DYNMODS): clean-%:
+ @BUILDTYPE=dynamic $(SUBMAKE) clean -C Modules/$*
+$(CLEAN_MODULES): clean-%:
+ @BUILDTYPE=static $(SUBMAKE) clean -C Modules/$*
+clean-Kernel:
+ @$(SUBMAKE) clean -C Kernel
+$(CLEAN_USRLIBS): clean-%:
+ @$(SUBMAKE) clean -C Usermode/Libraries/$*_src
+$(CLEAN_USRAPPS): clean-%:
+ @$(SUBMAKE) clean -C Usermode/Applications/$*_src
-# @make clean --no-print-directory -C Usermode/Libraries/ld-acess.so_src
-# @make clean --no-print-directory -C Usermode/Libraries/libacess.so_src
-# @make clean --no-print-directory -C Usermode/Libraries/libc.so_src
-# @make clean --no-print-directory -C Usermode/Libraries/libgcc.so_src
-# @make clean --no-print-directory -C Usermode/Applications/init_src
-# @make clean --no-print-directory -C Usermode/Applications/login_src
-# @make clean --no-print-directory -C Usermode/Applications/CLIShell_src
-# @make clean --no-print-directory -C Usermode/Applications/cat_src
-# @make clean --no-print-directory -C Usermode/Applications/ls_src
-# @make clean --no-print-directory -C Usermode/Applications/mount_src
+# Install
+$(INSTALL_DYNMODS): install-%:
+ @BUILDTYPE=dynamic $(SUBMAKE) install -C Modules/$*
+$(INSTALL_MODULES): install-%:
+ @BUILDTYPE=static $(SUBMAKE) install -C Modules/$*
+install-Filesystem:
+ @$(SUBMAKE) install -C Usermode/Filesystem
+install-Kernel:
+ @$(SUBMAKE) install -C Kernel
+$(INSTALL_USRLIBS): install-%:
+ @$(SUBMAKE) install -C Usermode/Libraries/$*_src
+$(INSTALL_USRAPPS): install-%:
+ @$(SUBMAKE) install -C Usermode/Applications/$*_src