2 TARGET := $(shell gcc -v 2>&1 | grep Targ | awk '{print $$2}')
4 include ../../Makefile.Version.cfg
5 -include Makefile.BuildNum
11 KERNEL_SRC = ../../KernelLand/Kernel/
12 MODULE_SRC = ../../KernelLand/Modules/
15 # Kernel Sources (compiled with -ffreestanding)
17 K_OBJ += drvutil_disk.o drv/proc.o
19 MODULES := Storage/LVM Filesystems/FAT Filesystems/Ext2 Filesystems/NTFS
20 # Local kernel soruces (same as above, but located in same directory as Makefile)
21 L_OBJ = vfs_handles.o nativefs.o actions.o
22 # Native Sources (compiled as usual)
23 N_OBJ = main.o script.o helpers.o
26 CFLAGS := -Wall -std=gnu99 -g -Werror
27 CPPFLAGS := -I include/ -I ../nativelib
28 CPPFLAGS += -I../../Usermode/Libraries/ld-acess.so_src/include_exp/ # Syscalls
29 K_CPPFLAGS := -I $(KERNEL_SRC)include -I $(MODULE_SRC)
30 LDFLAGS += -Wl,--defsym,__buildnum=$(BUILD_NUM) -g -L ../ -lnativelib
32 BUILDINFO_OBJ := obj/$(TARGET)/buildinfo.o
33 BUILDINFO_SRC := $(BUILDINFO_OBJ:%.o=%.c)
35 # ====================
36 # == Start of Magic ==
37 # ====================
39 $(foreach module,$(MODULES), $(eval include $(MODULE_SRC)$(module)/Makefile) $(eval M_OBJ += $(addprefix $(module)/,$(OBJ))) )
41 # -- Apply Prefixes to object paths
42 OBJ_PREFIX = obj/$(TARGET)/
43 K_OBJ_PREFIX = $(OBJ_PREFIX)_Kernel/
44 M_OBJ_PREFIX = $(OBJ_PREFIX)_Module/
45 K_OBJ := $(addprefix $(K_OBJ_PREFIX),$(K_OBJ))
46 M_OBJ := $(addprefix $(M_OBJ_PREFIX),$(M_OBJ))
47 L_OBJ := $(addprefix $(OBJ_PREFIX),$(L_OBJ))
48 N_OBJ := $(addprefix $(OBJ_PREFIX),$(N_OBJ))
50 OBJ := $(N_OBJ) $(L_OBJ) $(K_OBJ) $(M_OBJ) $(BUILDINFO_OBJ)
52 DEPFILES = $(filter %.o,$(OBJ))
53 DEPFILES := $(DEPFILES:%=%.dep)
61 $(RM) -f $(OBJ) $(DEPFILES) $(BIN)
63 $(BIN): $(OBJ) ../libnativelib.a
64 @echo [CC Link] -o $(BIN)
65 @$(CC) -o $(BIN) $(OBJ) $(LDFLAGS)
66 @echo BUILD_NUM = $$(( $(BUILD_NUM) + 1 )) > Makefile.BuildNum
68 $(M_OBJ): $(M_OBJ_PREFIX)%.o: $(MODULE_SRC)%.c
70 @echo [CC Module] -o $@
71 @$(CC) -c $< -o $@ -ffreestanding $(CFLAGS) $(CPPFLAGS) $(K_CPPFLAGS) -MMD -MP -MF
[email protected]
73 $(K_OBJ): $(K_OBJ_PREFIX)%.o: $(KERNEL_SRC)%.c
75 @echo [CC Kernel] -o $@
76 @$(CC) -c $< -o $@ -ffreestanding $(CFLAGS) $(CPPFLAGS) $(K_CPPFLAGS) -MMD -MP -MF
[email protected]
78 $(L_OBJ): $(OBJ_PREFIX)%.o: %.c
80 @echo [CC Local] -o $@
81 @$(CC) -c $< -o $@ -ffreestanding $(CFLAGS) $(CPPFLAGS) $(K_CPPFLAGS) -MMD -MP -MF
[email protected]
83 $(N_OBJ): $(OBJ_PREFIX)%.o: %.c
85 @echo [CC Native] -o $@
88 # Hacky buildinfo.c file
89 $(BUILDINFO_SRC): $(filter-out $(BUILDINFO_OBJ), $(OBJ)) Makefile
91 @echo "const char gsKernelVersion[] = \"$(ACESS_VERSION)\";" >> $@
92 @echo "const char gsGitHash[] = \""`git log -n 1 | head -n 1 | awk '{print $$2}'`"\";" >> $@
93 @echo "const int giBuildNumber = $(BUILD_NUM);" >> $@
94 @echo "const char gsBuildInfo[] = \"Acess2 DiskTool v$(ACESS_VERSION)\";" >> $@
95 $(BUILDINFO_OBJ): $(BUILDINFO_SRC)
97 @$(CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS)