diff --git a/reactos/ChangeLog b/reactos/ChangeLog index 82b07c4f2f7..b15df4fc1a4 100644 --- a/reactos/ChangeLog +++ b/reactos/ChangeLog @@ -1,12 +1,3 @@ -2004-10-02 Casper S. Hornstrup - - * ntoskrnl/Makefile: Fix dependencies when PCH is enabled. - -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 2a85a2dc5ff..7bf5d145453 100644 --- a/reactos/ntoskrnl/Makefile +++ b/reactos/ntoskrnl/Makefile @@ -1,23 +1,28 @@ -preall: all +# $Id: Makefile,v 1.147 2004/10/04 10:16:59 chorns Exp $ +# +# ReactOS Operating System +# +# +# 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) @@ -47,6 +52,9 @@ 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 @@ -60,16 +68,26 @@ CFLAGS += $(STD_CFLAGS) ASFLAGS += $(STD_ASFLAGS) RCFLAGS += $(STD_RCFLAGS) -TARGET_CFLAGS = $(CFLAGS) -TARGET_ASFLAGS = $(ASFLAGS) -TARGET_RCFLAGS = $(RCFLAGS) +# +# Build configuration +# +include $(PATH_TO_TOP)/rules.mak # # 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) @@ -369,21 +387,44 @@ 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_INBV) + $(OBJECTS_PO) $(OBJECTS_KD) $(OBJECTS_RTL) 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 = \ - $(TARGET_NAME).coff + $(TARGETNAME).coff + +# IMPORTS/EXPORTS +IE_DATA = \ + $(TARGETNAME).def $(OBJECTS_PATH): mkdir $(OBJECTS_PATH) -$(OBJECTS_RESOURCE): $(TARGET_NAME).rc bugcodes.rc $(PATH_TO_TOP)/include/reactos/resource.h +$(OBJECTS_RESOURCE): $(TARGETNAME).rc bugcodes.rc $(PATH_TO_TOP)/include/reactos/resource.h # # Build subsystem intermediate objects @@ -522,45 +563,211 @@ OBJECTS := \ $(OBJECTS_PATH)/inbv.o \ $(OBJECTS_RESOURCE) -EXTRA_OBJECTS = $(PATH_TO_TOP)/include/reactos/bugcodes.h - -TARGET_OBJECTS = $(EXTRA_OBJECTS) $(OBJECTS) - -TARGET_LIBS = \ +NTOSKRNL_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 -TARGET_LFLAGS = \ - -Wl,-T,ntoskrnl.lnk \ +NTOSKRNL_LD_FLAGS := \ -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 \ - $(TARGET_NAME).mc + $(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_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 -$(TARGET_PCH): $(PATH_TO_TOP)/include/reactos/bugcodes.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 $@ $< @@ -576,8 +783,5 @@ docu: .PHONY: docu -include $(PATH_TO_TOP)/rules.mak -include $(TOOLS_PATH)/helper.mk - -include $(TOOLS_PATH)/depend.mk +# EOF diff --git a/reactos/tools/helper.mk b/reactos/tools/helper.mk index 3805b13ac0f..7c9bf081e37 100644 --- a/reactos/tools/helper.mk +++ b/reactos/tools/helper.mk @@ -1,4 +1,4 @@ -# $Id: helper.mk,v 1.83 2004/10/03 14:24:43 weiden Exp $ +# $Id: helper.mk,v 1.84 2004/10/04 10:16:59 chorns Exp $ # # Helper makefile for ReactOS modules # Variables this makefile accepts: @@ -18,7 +18,6 @@ # 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 @@ -335,24 +334,6 @@ 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) @@ -578,10 +559,6 @@ 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 @@ -620,8 +597,6 @@ TARGET_ASFLAGS += $(MK_ASFLAGS) $(STD_ASFLAGS) TARGET_NFLAGS += $(MK_NFLAGS) $(STD_NFLAGS) -TARGET_LFLAGS += $(MK_LFLAGS) $(STD_LFLAGS) - MK_GCCLIBS := $(addprefix -l, $(TARGET_GCCLIBS)) @@ -639,8 +614,6 @@ 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)) @@ -678,6 +651,7 @@ $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME): $(MK_OBJECTS) $(MK_DEFNAME) --output-lib $(MK_IMPLIBPATH)/$(MK_BASENAME).a \ $(MK_KILLAT) + else # MK_IMPLIBONLY all: $(REGTEST_TARGETS) $(MK_FULLNAME) $(MK_NOSTRIPNAME) $(SUBDIRS:%=%_all) @@ -689,22 +663,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_EXTRADEP) $(MK_FULLRES) $(MK_BASENAME).a $(MK_LIBS) +$(MK_NOSTRIPNAME): $(MK_FULLRES) $(MK_BASENAME).a $(MK_EXTRADEP) $(MK_LIBS) ifeq ($(MK_EXETYPE),dll) $(LD_CC) -Wl,--base-file,base.tmp \ -Wl,--entry,$(TARGET_ENTRY) \ @@ -792,12 +766,14 @@ ifeq ($(MK_IMPLIB),yes) MK_EXTRACMD := --def $(MK_DEFNAME) else MK_EXTRACMD := + MK_EXTRADEP := endif -$(MK_NOSTRIPNAME): $(MK_EXTRADEP) $(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) +$(MK_NOSTRIPNAME): $(MK_FULLRES) $(MK_OBJECTS) $(MK_EXTRADEP) $(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 @@ -811,7 +787,8 @@ $(MK_NOSTRIPNAME): $(MK_EXTRADEP) $(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) -Wl,--file-alignment,0x1000 \ -Wl,--section-alignment,0x1000 \ -Wl,--entry,$(TARGET_ENTRY) \ - -Wl,temp.exp -mdll \ + -Wl,temp.exp \ + -mdll -nostartfiles -nostdlib \ -o $(MK_NOSTRIPNAME) \ $(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(MK_GCCLIBS) - $(RM) temp.exp @@ -822,7 +799,7 @@ else $(NM) --numeric-sort $(MK_NOSTRIPNAME) > $(MK_BASENAME).map endif -$(MK_FULLNAME): $(MK_EXTRADEP) $(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(MK_NOSTRIPNAME) +$(MK_FULLNAME): $(MK_FULLRES) $(MK_OBJECTS) $(MK_EXTRADEP) $(MK_LIBS) $(MK_NOSTRIPNAME) - ifneq ($(TARGET_CPPAPP),yes) $(LD) --strip-debug -r -o $(MK_STRIPPED_OBJECT) $(MK_OBJECTS) @@ -830,6 +807,7 @@ 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 @@ -843,7 +821,8 @@ endif -Wl,--file-alignment,0x1000 \ -Wl,--section-alignment,0x1000 \ -Wl,--entry,$(TARGET_ENTRY) \ - -Wl,temp.exp -mdll \ + -Wl,temp.exp \ + -mdll -nostartfiles -nostdlib \ -o $(MK_FULLNAME) \ $(MK_FULLRES) $(MK_STRIPPED_OBJECT) $(MK_LIBS) $(MK_GCCLIBS) ifneq ($(TARGET_CPPAPP),yes)