diff --git a/reactos/ChangeLog b/reactos/ChangeLog index b15df4fc1a4..0b57a145b41 100644 --- a/reactos/ChangeLog +++ b/reactos/ChangeLog @@ -1,3 +1,8 @@ +2004-10-02 Casper S. Hornstrup + + * tools/helper.mk: Support for kernel TARGET_TYPE. + * ntoskrnl/Makefile: Simplified makefile. + 2004-10-02 Casper S. Hornstrup * lib/gdiplus/tests/.cvsignore: Ignore _hooks.c and _stubs.S. diff --git a/reactos/ntoskrnl/Makefile b/reactos/ntoskrnl/Makefile index aad5ee15bb9..d12eac07458 100644 --- a/reactos/ntoskrnl/Makefile +++ b/reactos/ntoskrnl/Makefile @@ -1,28 +1,23 @@ -# $Id: Makefile,v 1.144 2004/09/28 15:02:28 weiden Exp $ -# -# ReactOS Operating System -# +preall: all -# -# Path to the directory containing the root makefile -# PATH_TO_TOP := .. -# -# Include details of the host OS configuration -# include $(PATH_TO_TOP)/config +TARGET_TYPE = kernel + +TARGET_NAME = ntoskrnl + +TARGET_BASE = 0xc0000000 + +TARGET_BOOTSTRAP = yes + CONFIG := ifeq ($(DBG), 1) CFLAGS_DBG := -g -LINKER_SCRIPT := ntoskrnl.lnk -STRIP_FLAGS := -Wl,-s else CFLAGS_DBG := -LINKER_SCRIPT := ntoskrnl.lnk -STRIP_FLAGS := -Wl,-s endif ifeq ($(OPTIMIZED), 1) @@ -52,9 +47,6 @@ ASFLAGS += -I./include -I$(SDK_PATH_INC) CFLAGS += -I./include -I$(SDK_PATH_INC) -D__NTOSKRNL__ $(CFLAGS_DBG) -Wall -Werror $(CFLAGS_OPT) endif -# ASFLAGS += -D__USE_W32API -D_NTOSKRNL_ -# CFLAGS += -D__USE_W32API -D_NTOSKRNL_ - # require os code to explicitly request A/W version of structs/functions CFLAGS += -D_DISABLE_TIDENTS @@ -68,26 +60,16 @@ CFLAGS += $(STD_CFLAGS) ASFLAGS += $(STD_ASFLAGS) RCFLAGS += $(STD_RCFLAGS) -# -# Build configuration -# -include $(PATH_TO_TOP)/rules.mak +TARGET_CFLAGS = $(CFLAGS) +TARGET_ASFLAGS = $(ASFLAGS) +TARGET_RCFLAGS = $(RCFLAGS) # # Javascript extension for kdb # -TARGETNAME := ntoskrnl - OBJECTS_PATH = objects -all: $(OBJECTS_PATH) \ - bugcodes.rc $(PATH_TO_TOP)/include/reactos/bugcodes.h \ - $(TARGETNAME).nostrip.exe \ - $(TARGETNAME).exe \ - $(TARGETNAME).sym \ - ntoskrnl.map - # # Architecture specific Makefile # Defines $(OBJECTS_ARCH) @@ -387,44 +369,21 @@ DEP_OBJECTS := $(OBJECTS_NT) $(OBJECTS_MM) $(OBJECTS_ARCH) \ $(OBJECTS_IO) $(OBJECTS_KE) $(OBJECTS_OB) \ $(OBJECTS_PS) $(OBJECTS_EX) $(OBJECTS_CC) $(OBJECTS_FS) $(OBJECTS_SE) \ $(OBJECTS_DBG) $(OBJECTS_CM) $(OBJECTS_LDR) $(OBJECTS_LPC) \ - $(OBJECTS_PO) $(OBJECTS_KD) $(OBJECTS_RTL) + $(OBJECTS_PO) $(OBJECTS_KD) $(OBJECTS_RTL) $(OBJECTS_INBV) TAG_OBJECTS := $(join $(dir $(DEP_OBJECTS)),$(patsubst %.o, .%.TAG, $(notdir $(DEP_OBJECTS)))) TARGET_PCH = include/ntoskrnl.h -# Precompiled header support -# When using PCHs, use dependency tracking to keep the .gch files up-to-date. - -MK_PCHNAME = -ifeq ($(ROS_USE_PCH),yes) -MK_PCHNAME = $(TARGET_PCH).gch - -PCH_CC := $(CC) - - -endif # ROS_USE_PCH - -# -# Include automatic dependancy tracking -# -DEP_EXCLUDE_FILTER := ex/napi.% nt/zw.% -GENERATED_HEADER_FILES := $(PATH_TO_TOP)/include/reactos/bugcodes.h -include $(PATH_TO_TOP)/tools/depend.mk - # Resources OBJECTS_RESOURCE = \ - $(TARGETNAME).coff - -# IMPORTS/EXPORTS -IE_DATA = \ - $(TARGETNAME).def + $(TARGET_NAME).coff $(OBJECTS_PATH): mkdir $(OBJECTS_PATH) -$(OBJECTS_RESOURCE): $(TARGETNAME).rc bugcodes.rc $(PATH_TO_TOP)/include/reactos/resource.h +$(OBJECTS_RESOURCE): $(TARGET_NAME).rc bugcodes.rc $(PATH_TO_TOP)/include/reactos/resource.h # # Build subsystem intermediate objects @@ -563,211 +522,43 @@ OBJECTS := \ $(OBJECTS_PATH)/inbv.o \ $(OBJECTS_RESOURCE) -NTOSKRNL_LIBS := \ +EXTRA_OBJECTS = $(PATH_TO_TOP)/include/reactos/bugcodes.h + +TARGET_OBJECTS = $(EXTRA_OBJECTS) $(OBJECTS) + +TARGET_LIBS = \ $(DDK_PATH_LIB)/hal.a \ $(SDK_PATH_LIB)/rtl.a \ $(SDK_PATH_LIB)/string.a \ $(SDK_PATH_LIB)/rosrtl.a \ $(SDK_PATH_LIB)/pseh.a -NTOSKRNL_LD_FLAGS := \ +TARGET_LFLAGS = \ + -Wl,-T,ntoskrnl.lnk \ -Wl,--subsystem,native \ -Wl,--image-base,0xc0000000 \ -Wl,--file-alignment,0x1000 \ -Wl,--section-alignment,0x1000 \ -Wl,--entry,_NtProcessStartup -$(TARGETNAME).nostrip.exe: $(TARGETNAME).all.o $(IE_DATA) $(NTOSKRNL_LIBS) - $(CC) \ - -Wl,-T,ntoskrnl.lnk \ - -nostartfiles \ - -nostdlib \ - -mdll \ - -o junk.tmp \ - $(NTOSKRNL_LD_FLAGS) \ - -Wl,--base-file,base.tmp \ - $(TARGETNAME).all.o -lgcc \ - $(NTOSKRNL_LIBS) - - $(RM) junk.tmp - $(DLLTOOL) \ - --dllname $(TARGETNAME).exe \ - --base-file base.tmp \ - --output-exp temp.exp \ - --def $(TARGETNAME).def \ - --kill-at - - $(RM) base.tmp - $(CC) \ - -nostartfiles \ - -nostdlib \ - -Wl,-T,ntoskrnl.lnk \ - -mdll \ - -o $(TARGETNAME).nostrip.exe \ - $(NTOSKRNL_LD_FLAGS) \ - -Wl,temp.exp \ - $(TARGETNAME).all.o -lgcc \ - $(NTOSKRNL_LIBS) - - $(RM) temp.exp - -$(TARGETNAME).exe: $(TARGETNAME).all.o $(LINKER_SCRIPT) $(NTOSKRNL_LIBS) - - $(CC) \ - -Wl,-T,$(LINKER_SCRIPT) \ - -nostartfiles \ - -nostdlib \ - -mdll \ - -o junk.tmp \ - $(NTOSKRNL_LD_FLAGS) \ - -Wl,--base-file,base.tmp \ - $(TARGETNAME).all.o -lgcc \ - $(NTOSKRNL_LIBS) - - $(RM) junk.tmp - $(DLLTOOL) \ - --dllname $(TARGETNAME).exe \ - --base-file base.tmp \ - --output-exp temp.exp \ - --def $(TARGETNAME).def \ - --kill-at - - $(RM) base.tmp - $(CC) \ - -Wl,-T,$(LINKER_SCRIPT) $(STRIP_FLAGS)\ - -nostartfiles \ - -nostdlib \ - -mdll \ - -o $(TARGETNAME).exe \ - $(NTOSKRNL_LD_FLAGS) \ - -Wl,temp.exp \ - $(TARGETNAME).all.o -lgcc \ - $(NTOSKRNL_LIBS) - - $(RM) temp.exp - -$(TARGETNAME).dbg.o: $(TARGETNAME).all.o - $(STRIP) --strip-debug -o $(TARGETNAME).dbg.o $(TARGETNAME).all.o - -$(TARGETNAME).dbg: $(TARGETNAME).dbg.o $(TARGETNAME).a $(TARGETNAME).dbg.lnk $(NTOSKRNL_LIBS) - $(CC) \ - -Wl,-T,$(TARGETNAME).dbg.lnk \ - -nostartfiles \ - -nostdlib \ - -mdll \ - -o junk.tmp \ - $(NTOSKRNL_LD_FLAGS) \ - -Wl,--base-file,base.tmp \ - $(TARGETNAME).dbg.o -lgcc \ - $(NTOSKRNL_LIBS) - - $(RM) junk.tmp - $(DLLTOOL) \ - --dllname $(TARGETNAME).dbg \ - --base-file base.tmp \ - --output-exp temp.exp \ - --def $(TARGETNAME).def \ - --kill-at - - $(RM) base.tmp - $(CC) \ - -Wl,-T,$(TARGETNAME).dbg.lnk \ - -nostartfiles \ - -nostdlib \ - -mdll \ - -o $(TARGETNAME).dbg \ - $(NTOSKRNL_LD_FLAGS) \ - -Wl,temp.exp \ - $(TARGETNAME).dbg.o -lgcc \ - $(NTOSKRNL_LIBS) - - $(RM) temp.exp - -$(TARGETNAME).sym: $(TARGETNAME).nostrip.exe - $(RSYM) $(TARGETNAME).nostrip.exe $(TARGETNAME).sym - TAGS: $(TAG_OBJECTS) etags $(addprefix -i , $(TAG_OBJECTS)) -$(TARGETNAME).map: $(TARGETNAME).nostrip.exe -ifeq ($(FULL_MAP),yes) - $(OBJDUMP) -d -S $(TARGETNAME).nostrip.exe > $(TARGETNAME).map -else - $(NM) --numeric-sort $(TARGETNAME).nostrip.exe > $(TARGETNAME).map -endif - -$(TARGETNAME).all.o: $(OBJECTS) - $(LD) \ - -r \ - -o $(TARGETNAME).all.o \ - $(OBJECTS) - $(PATH_TO_TOP)/include/reactos/bugcodes.h bugcodes.rc: ntoskrnl.mc $(MC) \ -H $(PATH_TO_TOP)/include/reactos/bugcodes.h \ -o bugcodes.rc \ - $(TARGETNAME).mc - -$(DDK_PATH_LIB)/$(TARGETNAME).a: $(TARGETNAME).def - - $(DLLTOOL) \ - --dllname $(TARGETNAME).exe \ - --def $(TARGETNAME).def \ - --output-lib $(DDK_PATH_LIB)/$(TARGETNAME).a \ - --kill-at - -implib: $(DDK_PATH_LIB)/$(TARGETNAME).a - -test: - - - -clean: - - $(RM) depend.d $(MK_PCHNAME) $(MK_PCHFAKE) $(OBJECTS_PATH)/*.o cc/*.o cm/*.o dbg/*.o dbg/i386/*.o ex/*.o \ - ex/i386/*.o inbv/*.o io/*.o ke/*.o ldr/*.o mm/*.o nt/*.o ob/*.o \ - ps/*.o ps/i386/*.o rtl/*.o rtl/i386/*.o se/*.o ke/i386/*.o \ - mm/i386/*.o fs/*.o po/*.o lpc/*.o kd/*.o $(TARGETNAME).all.o \ - junk.tmp base.tmp temp.exp $(TARGETNAME).exe \ - $(TARGETNAME).nostrip.exe $(TARGETNAME).sym ntoskrnl.map \ - $(TARGETNAME).coff bugcodes.rc msg?????.bin $(DEP_FILES) \ - $(TAG_OBJECTS) $(PATH_TO_TOP)/include/reactos/bugcodes.h - - -.PHONY: clean - -ifneq ($(BOOTCD_INSTALL),) - -install: - - $(CP) $(TARGETNAME).exe $(INSTALL_DIR)/$(TARGETNAME).exe - -else # BOOTCD_INSTALL - -install: - - $(CP) $(TARGETNAME).exe $(INSTALL_DIR)/system32/$(TARGETNAME).exe - - $(CP) $(TARGETNAME).sym $(INSTALL_DIR)/symbols/$(TARGETNAME).sym - -endif # BOOTCD_INSTALL - - -.PHONY: install - -bootcd: - - $(CP) $(TARGETNAME).exe $(BOOTCD_DIR)/reactos/$(TARGETNAME).exe - -.PHONY: bootcd + $(TARGET_NAME).mc +TARGET_CLEAN = \ + $(PATH_TO_TOP)/include/reactos/bugcodes.h \ + $(DEP_OBJECTS) ex/napi.o: ex/napi.c $(PATH_TO_TOP)/include/ntdll/napi.h ke/main.o: ke/main.c $(PATH_TO_TOP)/include/reactos/buildno.h -%.o: %.cc $(MK_PCHNAME) - $(CC) $(CFLAGS) -c $< -o $@ -%.o: %.c $(MK_PCHNAME) - $(CC) $(CFLAGS) -c $< -o $@ -%.o: %.S - $(AS) $(ASFLAGS) -c $< -o $@ -%.o: %.s - $(AS) $(ASFLAGS) -c $< -o $@ -%.o: %.asm - $(NASM_CMD) $(NFLAGS) $< -o $@ -%.coff: %.rc - $(RC) $(RCFLAGS) $< -o $@ -%.h.gch: %.h - $(PCH_CC) $(CFLAGS) $< - -# -# -# .%.TAG: %.S etags -o $@ $< @@ -783,5 +574,8 @@ docu: .PHONY: docu +include $(PATH_TO_TOP)/rules.mak -# EOF +include $(TOOLS_PATH)/helper.mk + +include $(TOOLS_PATH)/depend.mk diff --git a/reactos/tools/helper.mk b/reactos/tools/helper.mk index c1ea98c4e97..b3ea0d7bf74 100644 --- a/reactos/tools/helper.mk +++ b/reactos/tools/helper.mk @@ -1,4 +1,4 @@ -# $Id: helper.mk,v 1.81 2004/10/02 08:44:54 chorns Exp $ +# $Id: helper.mk,v 1.82 2004/10/02 14:03:51 chorns Exp $ # # Helper makefile for ReactOS modules # Variables this makefile accepts: @@ -18,6 +18,7 @@ # subsystem = Kernel subsystem # kmdll = Kernel mode DLL # winedll = DLL imported from wine +# kernel = ReactOS kernel # $TARGET_APPTYPE = Application type (windows,native,console). # Required only for TARGET_TYPEs program and proglib # $TARGET_NAME = Base name of output file and .rc, .def, and .edf files @@ -334,6 +335,24 @@ ifeq ($(TARGET_TYPE),gdi_driver) MK_RES_BASE := $(TARGET_NAME) endif +ifeq ($(TARGET_TYPE),kernel) + MK_MODE := kernel + MK_EXETYPE := dll + MK_DEFEXT := .exe + MK_DEFENTRY := _NtProcessStartup + MK_DDKLIBS := hal.a + MK_SDKLIBS := + MK_CFLAGS := -D__NTOSKRNL__ -I. + MK_CPPFLAGS := -D__NTOSKRNL__ -I. + MK_IMPLIB := yes + MK_IMPLIBONLY := no + MK_IMPLIBDEFPATH := $(DDK_PATH_LIB) + MK_IMPLIB_EXT := .a + MK_INSTALLDIR := system32 + MK_BOOTCDDIR := . + MK_RES_BASE := $(TARGET_NAME) +endif + # can be overidden with $(CXX) for linkage of c++ executables LD_CC = $(CC) @@ -554,6 +573,10 @@ ifeq ($(MK_MODE),kernel) MK_LIBS := $(addprefix $(DDK_PATH_LIB)/, $(TARGET_DDKLIBS) $(MK_DDKLIBS)) MK_CFLAGS += -D_SEH_NO_NATIVE_NLG MK_CPPFLAGS += -D_SEH_NO_NATIVE_NLG + MK_LFLAGS += -nostartfiles +ifneq ($(TARGET_TYPE),kernel) + MK_LFLAGS += -nostdlib +endif endif @@ -592,6 +615,8 @@ TARGET_ASFLAGS += $(MK_ASFLAGS) $(STD_ASFLAGS) TARGET_NFLAGS += $(MK_NFLAGS) $(STD_NFLAGS) +TARGET_LFLAGS += $(MK_LFLAGS) $(STD_LFLAGS) + MK_GCCLIBS := $(addprefix -l, $(TARGET_GCCLIBS)) @@ -609,6 +634,8 @@ MK_IMPLIB_FULLNAME := $(MK_BASENAME)$(MK_IMPLIB_EXT) MK_NOSTRIPNAME := $(MK_BASENAME).nostrip$(MK_EXT) +MK_EXTRADEP := $(filter %.h,$(TARGET_OBJECTS)) + # We don't want to link header files MK_OBJECTS := $(filter-out %.h,$(TARGET_OBJECTS)) @@ -646,7 +673,6 @@ $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME): $(MK_OBJECTS) $(MK_DEFNAME) --output-lib $(MK_IMPLIBPATH)/$(MK_BASENAME).a \ --kill-at - else # MK_IMPLIBONLY all: $(REGTEST_TARGETS) $(MK_FULLNAME) $(MK_NOSTRIPNAME) $(SUBDIRS:%=%_all) @@ -658,22 +684,22 @@ else MK_EXTRACMD := endif + # User mode targets ifeq ($(MK_MODE),user) ifeq ($(MK_EXETYPE),dll) TARGET_LFLAGS += -mdll -Wl,--image-base,$(TARGET_BASE) - MK_EXTRADEP := $(MK_DEFNAME) + MK_EXTRADEP += $(MK_DEFNAME) MK_EXTRACMD2 := -Wl,temp.exp else - MK_EXTRADEP := MK_EXTRACMD2 := endif $(MK_BASENAME).a: $(MK_OBJECTS) $(AR) -r $(MK_BASENAME).a $(MK_OBJECTS) -$(MK_NOSTRIPNAME): $(MK_FULLRES) $(MK_BASENAME).a $(MK_EXTRADEP) $(MK_LIBS) +$(MK_NOSTRIPNAME): $(MK_EXTRADEP) $(MK_FULLRES) $(MK_BASENAME).a $(MK_LIBS) ifeq ($(MK_EXETYPE),dll) $(LD_CC) -Wl,--base-file,base.tmp \ -Wl,--entry,$(TARGET_ENTRY) \ @@ -761,14 +787,12 @@ ifeq ($(MK_IMPLIB),yes) MK_EXTRACMD := --def $(MK_DEFNAME) else MK_EXTRACMD := - MK_EXTRADEP := endif -$(MK_NOSTRIPNAME): $(MK_FULLRES) $(MK_OBJECTS) $(MK_EXTRADEP) $(MK_LIBS) +$(MK_NOSTRIPNAME): $(MK_EXTRADEP) $(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(LD_CC) -Wl,--base-file,base.tmp \ -Wl,--entry,$(TARGET_ENTRY) \ $(TARGET_LFLAGS) \ - -nostartfiles -nostdlib \ -o junk.tmp \ $(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(MK_GCCLIBS) - $(RM) junk.tmp @@ -782,8 +806,7 @@ $(MK_NOSTRIPNAME): $(MK_FULLRES) $(MK_OBJECTS) $(MK_EXTRADEP) $(MK_LIBS) -Wl,--file-alignment,0x1000 \ -Wl,--section-alignment,0x1000 \ -Wl,--entry,$(TARGET_ENTRY) \ - -Wl,temp.exp \ - -mdll -nostartfiles -nostdlib \ + -Wl,temp.exp -mdll \ -o $(MK_NOSTRIPNAME) \ $(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(MK_GCCLIBS) - $(RM) temp.exp @@ -794,7 +817,7 @@ else $(NM) --numeric-sort $(MK_NOSTRIPNAME) > $(MK_BASENAME).map endif -$(MK_FULLNAME): $(MK_FULLRES) $(MK_OBJECTS) $(MK_EXTRADEP) $(MK_LIBS) $(MK_NOSTRIPNAME) +$(MK_FULLNAME): $(MK_EXTRADEP) $(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(MK_NOSTRIPNAME) - ifneq ($(TARGET_CPPAPP),yes) $(LD) --strip-debug -r -o $(MK_STRIPPED_OBJECT) $(MK_OBJECTS) @@ -802,7 +825,6 @@ endif $(LD_CC) -Wl,--base-file,base.tmp \ -Wl,--entry,$(TARGET_ENTRY) \ $(TARGET_LFLAGS) \ - -nostartfiles -nostdlib \ -o junk.tmp \ $(MK_FULLRES) $(MK_STRIPPED_OBJECT) $(MK_LIBS) $(MK_GCCLIBS) - $(RM) junk.tmp @@ -816,8 +838,7 @@ endif -Wl,--file-alignment,0x1000 \ -Wl,--section-alignment,0x1000 \ -Wl,--entry,$(TARGET_ENTRY) \ - -Wl,temp.exp \ - -mdll -nostartfiles -nostdlib \ + -Wl,temp.exp -mdll \ -o $(MK_FULLNAME) \ $(MK_FULLRES) $(MK_STRIPPED_OBJECT) $(MK_LIBS) $(MK_GCCLIBS) ifneq ($(TARGET_CPPAPP),yes)