# NOTE: due to suckage of make that I can't figure out how to work # around, you'll have to run make twice after you update a .cdl file # in order to make sure that any code that includes the generated # headers has been rebuilt. This is despite having an explicit # dependency of the .cc file on the normal .h, of the normal .h on # the generated .h, of the generated headers on the server directory, # and of the server directory on the CDL file. The CDL->directory rule # is used to generated the headers, but even if it's done specifically # for the .cc file up the chain, it doesn't rebuild the .cc file. include ../../Makefile.target TOP := $(shell pwd) INCS := -Iinclude -I../include/c++ -I../include/generated/c++ \ -I../include/c DEFS += -D_KERNEL CXXFLAGS += $(INCS) $(DEFS) -Wall -Werror -O3 -g3 -fno-rtti \ -fno-exceptions -fno-builtin ASFLAGS += $(INCS) .PHONY: symlinks all default rerun dep servers clean distclean all: default symlinks: rm -f include/arch ln -sfn arch-$(ARCH) include/arch # Make sure "make" treats thse as the right type of variable # when += is used later. OBJS := DIRS := # Must come first: contains boot entry code include arch/$(ARCH)/Makefile include core/Makefile include mem/Makefile include io/Makefile include lib/Makefile # Must come last: contains kernel target include arch/$(ARCH)/Makefile.final clean: $(EXTRACLEAN) rm -rf $(foreach dir,$(DIRS),$(dir)*.o $(dir)*-server) rm -f kernel kernel.stripped distclean: clean rm -f .depend .gdb_history include/arch # Every .o file which has a corresponding .cdl file will # depend on the server stubs. SERVERS := $(foreach obj,$(OBJS),$(wildcard $(obj:.o=).cdl)) SERVERS := $(SERVERS:%.cdl=%) $(SERVERS:%=%-server): %-server: %.cdl $(TOP)/../ifaces rm -rf "$(BUILDDIR)/$@" $(IDLC) -t $(ARCH) -l c++ -r -i "$(TOP)/../ifaces" -o "$(BUILDDIR)/$@" "$<" $(SERVERS:%=%.cc): %.cc: %-server servers: symlinks $(SERVERS:%=%-server) dep: servers rm -f .depend for i in $(OBJS:.o=); do \ for j in cc S; do \ if [ -e "$$i".$$j ]; then \ FILE="$$i".$$j; \ fi; \ done; \ \ if [ "$$FILE" ]; then \ $(CXX) $(CXXFLAGS) -M -MT "$$i".o "$$FILE" >> .depend; \ fi \ done; \ for i in $(SERVERS); do \ $(IDLC) -M -l c++ -r -i "$(TOP)/../ifaces" -o "$$i-server" "$$i.cdl" >> .depend; \ done ifeq (.depend,$(wildcard .depend)) include .depend default: kernel kernel.stripped else rerun: dep @$(MAKE) default: rerun endif