Add ROS_ARCH environment variable
[reactos.git] / reactos / Makefile
index 6eeb315..d85357f 100644 (file)
@@ -1,5 +1,58 @@
+# Well-known targets:
+#
+#    all (default target)
+#        This target builds all of ReactOS.
+#
+#    module
+#        These targets builds a single module. Replace module with the name of
+#        the module you want to build.
+#
+#    bootcd
+#        This target builds an ISO (ReactOS.iso) from which ReactOS can be booted
+#        and installed.
+#
+#    livecd
+#        This target builds an ISO (ReactOS-Live.iso) from which ReactOS can be
+#        booted, but not installed.
+#
+#    install
+#        This target installs all of ReactOS to a location specified by the
+#        ROS_INSTALL environment variable.
+#
+#    module_install
+#        These targets installs a single module to a location specified by the
+#        ROS_INSTALL environment variable. Replace module with the name of the
+#        module you want to install.
+#
+#    clean
+#        This target cleans (deletes) all files that are generated when building
+#        ReactOS.
+#
+#    module_clean
+#        These targets cleans (deletes) files that are generated when building a
+#        single module. Replace module with the name of the module you want to
+#        clean.
+#
+#    depends
+#        This target does a complete dependency check of the ReactOS codebase.
+#        This can require several minutes to complete. If you only need to check
+#        dependencies for a single or few modules then you can use the
+#        module_depends targets instead. This target can also repair a damaged or
+#        missing makefile.auto if needed.
+#
+#    module_depends
+#        These targets do a dependency check of individual modules. Replace module
+#        with the name of the module for which you want to check dependencies.
+#        This is faster than the depends target which does a complete dependency
+#        check of the ReactOS codebase.
+#
+#
 # Accepted environment variables:
 #
+#    ROS_ARCH
+#        This variable specifies the name of the architecture to build ReactOS for.
+#        The variable defaults to i386.
+#
 #    ROS_PREFIX
 #        This variable specifies the prefix of the MinGW installation. On Windows
 #        a prefix is usually not needed, but on linux it is usually "mingw32". If
 #        Examples of output files include *.exe, *.dll, and *.sys. N.B. Don't
 #        put a path separator at the end. The variable defaults to .\output-i386.
 #
+#    ROS_CDOUTPUT
+#        This variable controls the name of the ReactOS directory on cdrom.
+#        The variable defaults to reactos.
+#        Warning: setting this value may lead to a not bootable/installable cdrom.
+#
 #    ROS_TEMPORARY
 #        This variable controls where to put temporary files. Temporary files
 #        are (usually small) generated files that are needed to generate the
 #        output files) or no (to not build non-symbol-stripped versions of
 #        executable output files). The variable defaults to no.
 #
+#    ROS_LEAN_AND_MEAN
+#        This variable controls if all binaries should be stripped out of useless
+#        data added by GCC/LD as well as of RSYM symbol data. Output binary size
+#        will go from 80 to 40MB, memory usage from 58 to 38MB and the install CD
+#        from 18 to 13MB. The variable defaults to no.
+#
 #    ROS_RBUILDFLAGS
 #        Pass parameters to rbuild.
+#            -v           Be verbose.
+#            -c           Clean as you go. Delete generated files as soon as they are not needed anymore.
+#            -dd          Disable automatic dependencies.
+#            -dm{module}  Check only automatic dependencies for this module.
+#            -mi          Let make handle creation of install directories. Rbuild will not generate the directories.
+#            -ps          Generate proxy makefiles in source tree instead of the output tree.
+#            -ud          Disable compilation units.
+#            -r           Input XML
+#
+#    ROS_AUTOMAKE
+#        Alternate name of makefile.auto
+#
+
+# check for versions of make that don't have features we need...
+# the function "eval" is only available in 3.80+, which happens to be the minimum
+# version that has the features we use...
+# THIS CHECK IS BORROWED FROM THE "GMSL" PROJECT, AND IS COVERED BY THE GPL LICENSE
+# YOU CAN FIND OUT MORE ABOUT GMSL - A VERY COOL PROJECT - AT:
+# http://gmsl.sourceforge.net/
+
+__gmsl_have_eval :=
+__gmsl_ignore := $(eval __gmsl_have_eval := T)
+
+ifndef __gmsl_have_eval
+$(error ReactOS's makefiles use GNU Make 3.80+ features, you have $(MAKE_VERSION), you MUST UPGRADE in order to build ReactOS - Sorry)
+endif
+# END of code borrowed from GMSL ( http://gmsl.sourceforge.net/ )
 
 .PHONY: all
 .PHONY: clean
-all: makefile.auto
+.PHONY: world
+.PHONY: universe
+
+ifeq ($(ROS_AUTOMAKE),)
+ROS_AUTOMAKE=makefile.auto
+endif
+
+all: $(ROS_AUTOMAKE)
 
 
 .SUFFIXES:
 
 ifeq ($(HOST),)
 ifeq ($(word 1,$(shell gcc -dumpmachine)),mingw32)
+ifeq ($(findstring msys,$(shell sh --version 2>nul)),msys)
+export OSTYPE = msys
+HOST=mingw32-linux
+CFLAGS+=-fshort-wchar
+CPPFLAGS+=-fshort-wchar
+else
 HOST=mingw32-windows
+endif
 else
 HOST=mingw32-linux
+CFLAGS+=-fshort-wchar
+CPPFLAGS+=-fshort-wchar
 endif
 endif
 
@@ -114,6 +221,8 @@ ifeq ($(HALFVERBOSEECHO),yes)
   ECHO_MKHIVE  =@echo $(QUOTE)[MKHIVE]   $@$(QUOTE)
   ECHO_REGTESTS=@echo $(QUOTE)[REGTESTS] $@$(QUOTE)
   ECHO_TEST    =@echo $(QUOTE)[TEST]     $@$(QUOTE)
+  ECHO_GENDIB  =@echo $(QUOTE)[GENDIB]   $@$(QUOTE)
+  ECHO_STRIP   =@echo $(QUOTE)[STRIP]    $@$(QUOTE)
 else
   ECHO_CP      =
   ECHO_MKDIR   =
@@ -141,6 +250,8 @@ else
   ECHO_MKHIVE  =
   ECHO_REGTESTS=
   ECHO_TEST    =
+  ECHO_GENDIB  =
+  ECHO_STRIP   =
 endif
 
 
@@ -150,9 +261,13 @@ host_ld = $(Q)ld
 host_ar = $(Q)ar
 host_objcopy = $(Q)objcopy
 ifeq ($(HOST),mingw32-linux)
-       EXEPREFIX = ./
-       EXEPOSTFIX =
-       SEP = /
+       export EXEPREFIX = ./
+ifeq ($(OSTYPE),msys)
+       export EXEPOSTFIX = .exe
+else
+       export EXEPOSTFIX =
+endif
+       export SEP = /
        mkdir = -$(Q)mkdir -p
        gcc = $(Q)$(PREFIX)-gcc
        gpp = $(Q)$(PREFIX)-g++
@@ -162,44 +277,91 @@ ifeq ($(HOST),mingw32-linux)
        ar = $(Q)$(PREFIX)-ar
        objcopy = $(Q)$(PREFIX)-objcopy
        dlltool = $(Q)$(PREFIX)-dlltool
+       strip = $(Q)$(PREFIX)-strip
        windres = $(Q)$(PREFIX)-windres
        rm = $(Q)rm -f
        cp = $(Q)cp
        NUL = /dev/null
 else # mingw32-windows
-       EXEPREFIX =
-       EXEPOSTFIX = .exe
-       ROS_EMPTY =
-       SEP = \$(ROS_EMPTY)
-       mkdir = -$(Q)mkdir
-       gcc = $(Q)gcc
-       gpp = $(Q)g++
-       ld = $(Q)ld
-       nm = $(Q)nm
-       objdump = $(Q)objdump
-       ar = $(Q)ar
-       objcopy = $(Q)objcopy
-       dlltool = $(Q)dlltool
-       windres = $(Q)windres
-       rm = $(Q)del /f /q
-       cp = $(Q)copy /y
-       NUL = NUL
+       ifeq ($(OSTYPE),msys)
+               HOST=mingw32-linux
+               export EXEPREFIX = ./
+               export EXEPOSTFIX = .exe
+               export SEP = /
+               mkdir = -$(Q)mkdir -p
+               rm = $(Q)rm -f
+               cp = $(Q)cp
+               NUL = /dev/null
+       else
+               export EXEPREFIX =
+               export EXEPOSTFIX = .exe
+               ROS_EMPTY =
+               export SEP = \$(ROS_EMPTY)
+               mkdir = -$(Q)mkdir
+               rm = $(Q)del /f /q
+               cp = $(Q)copy /y
+               NUL = NUL
+       endif
+       ifeq ($(ROS_PREFIX),)
+               gcc = $(Q)gcc
+               gpp = $(Q)g++
+               ld = $(Q)ld
+               nm = $(Q)nm
+               objdump = $(Q)objdump
+               ar = $(Q)ar
+               objcopy = $(Q)objcopy
+               dlltool = $(Q)dlltool
+               strip = $(Q)strip
+               windres = $(Q)windres
+       else
+               gcc = $(Q)$(ROS_PREFIX)-gcc
+               gpp = $(Q)$(ROS_PREFIX)-g++
+               ld = $(Q)$(ROS_PREFIX)-ld
+               nm = $(Q)$(ROS_PREFIX)-nm
+               objdump = $(Q)$(ROS_PREFIX)-objdump
+               ar = $(Q)$(ROS_PREFIX)-ar
+               objcopy = $(Q)$(ROS_PREFIX)-objcopy
+               dlltool = $(Q)$(ROS_PREFIX)-dlltool
+               strip = $(Q)$(ROS_PREFIX)-strip
+               windres = $(Q)$(ROS_PREFIX)-windres
+       endif
+endif
+
+ifneq ($(ROS_ARCH),)
+  ARCH := $(ROS_ARCH)
+else
+  ARCH := i386
 endif
 
 ifneq ($(ROS_INTERMEDIATE),)
   INTERMEDIATE := $(ROS_INTERMEDIATE)
 else
-  INTERMEDIATE := obj-i386
+  ifneq ($(ROS_CDOUTPUT),)
+    INTERMEDIATE := obj-$(ROS_CDOUTPUT)
+  else
+    INTERMEDIATE := obj-$(ARCH)
+  endif
 endif
 INTERMEDIATE_ := $(INTERMEDIATE)$(SEP)
 
 ifneq ($(ROS_OUTPUT),)
   OUTPUT := $(ROS_OUTPUT)
 else
-  OUTPUT := output-i386
+  ifneq ($(ROS_CDOUTPUT),)
+    OUTPUT := output-$(ROS_CDOUTPUT)
+  else
+    OUTPUT := output-$(ARCH)
+  endif
 endif
 OUTPUT_ := $(OUTPUT)$(SEP)
 
+ifneq ($(ROS_CDOUTPUT),)
+  CDOUTPUT := $(ROS_CDOUTPUT)
+else
+  CDOUTPUT := reactos
+endif
+CDOUTPUT_ := $(CDOUTPUT)$(SEP)
+
 ifneq ($(ROS_TEMPORARY),)
   TEMPORARY := $(ROS_TEMPORARY)
 else
@@ -210,7 +372,11 @@ TEMPORARY_ := $(TEMPORARY)$(SEP)
 ifneq ($(ROS_INSTALL),)
   INSTALL := $(ROS_INSTALL)
 else
-  INSTALL := reactos
+  ifneq ($(ROS_CDOUTPUT),)
+    INSTALL := reactos.$(ROS_CDOUTPUT)
+  else
+    INSTALL := reactos
+  endif
 endif
 INSTALL_ := $(INSTALL)$(SEP)
 
@@ -224,30 +390,108 @@ endif
 
 
 NTOSKRNL_MC = ntoskrnl$(SEP)ntoskrnl.mc
-KERNEL32_MC = lib$(SEP)kernel32$(SEP)kernel32.mc
+KERNEL32_MC = dll$(SEP)win32$(SEP)kernel32$(SEP)kernel32.mc
 BUILDNO_H = include$(SEP)reactos$(SEP)buildno.h
 BUGCODES_H = include$(SEP)reactos$(SEP)bugcodes.h
 BUGCODES_RC = ntoskrnl$(SEP)bugcodes.rc
 ERRCODES_H = include$(SEP)reactos$(SEP)errcodes.h
-ERRCODES_RC = lib$(SEP)kernel32$(SEP)errcodes.rc
+ERRCODES_RC = dll$(SEP)win32$(SEP)kernel32$(SEP)errcodes.rc
+
 
 include lib/lib.mak
 include tools/tools.mak
--include makefile.auto
+include boot/freeldr/bootsect/bootsect.mak
+-include $(ROS_AUTOMAKE)
 
 PREAUTO := \
+       $(BIN2C_TARGET) \
        $(BIN2RES_TARGET) \
        $(BUILDNO_H) \
        $(BUGCODES_H) \
        $(BUGCODES_RC) \
        $(ERRCODES_H) \
        $(ERRCODES_RC) \
+       $(GENDIB_DIB_FILES) \
        $(NCI_SERVICE_FILES)
 
-makefile.auto: $(RBUILD_TARGET) $(PREAUTO) $(XMLBUILDFILES)
+POSTAUTO : \
+       psdk \
+       $(IDL_FILES)
+
+$(ROS_AUTOMAKE): $(RBUILD_TARGET) $(PREAUTO) $(XMLBUILDFILES)
+       ${mkdir} $(INTERMEDIATE_)media$(SEP)inf 2>$(NUL)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -rReactOS-$(ARCH).rbuild mingw
+       @$(MAKE) POSTAUTO
+
+world: all bootcd livecd
+
+universe:
+       $(MAKE) KDBG=1 DBG=1 \
+               ROS_AUTOMAKE=makefile-$(ARCH)-kd.auto \
+               ROS_INSTALL=reactos-$(ARCH)-kd \
+               ROS_INTERMEDIATE=obj-$(ARCH)-kd \
+               ROS_OUTPUT=output-$(ARCH)-kd \
+               world
+       $(MAKE) KDBG=0 DBG=1 \
+               ROS_AUTOMAKE=makefile-$(ARCH)-d.auto \
+               ROS_INSTALL=reactos-$(ARCH)-d \
+               ROS_INTERMEDIATE=obj-$(ARCH)-d \
+               ROS_OUTPUT=output-$(ARCH)-d \
+               world
+       $(MAKE) KDBG=0 DBG=0 \
+               ROS_AUTOMAKE=makefile-$(ARCH)-r.auto \
+               ROS_INSTALL=reactos-$(ARCH)-r \
+               ROS_INTERMEDIATE=obj-$(ARCH)-r \
+               ROS_OUTPUT=output-$(ARCH)-r \
+               world
+
+sysregtest:
+       -mkdir $(OUTPUT_)cd$(SEP)reactos
+       $(cp) boot$(SEP)bootdata$(SEP)unattend.inf.sample boot$(SEP)bootdata$(SEP)unattend.inf
+       $(cp) boot$(SEP)bootdata$(SEP)unattend.inf.sample $(OUTPUT_)cd$(SEP)reactos$(SEP)unattend.inf
+       $(cp) boot$(SEP)bootdata$(SEP)bootcdregtest$(SEP)testboot.bat.sample boot$(SEP)bootdata$(SEP)bootcdregtest$(SEP)testboot.bat
+       $(MAKE) dbgprint
+       $(MAKE) bootcdregtest
+       $(MAKE) sysreg
+       $(OUTPUT_)tools$(SEP)sysreg$(SEP)sysreg$(EXEPOSTFIX) tools$(SEP)sysreg$(SEP)txtmode.cfg rosboot
+       $(OUTPUT_)tools$(SEP)sysreg$(SEP)sysreg$(EXEPOSTFIX) tools$(SEP)sysreg$(SEP)secstage.cfg rosboot
+       $(OUTPUT_)tools$(SEP)sysreg$(SEP)sysreg$(EXEPOSTFIX) tools$(SEP)sysreg$(SEP)runonce.cfg rosboot
+
+sysregtest_clean:
+       $(rm) boot$(SEP)bootdata$(SEP)unattend.inf
+       $(rm) boot$(SEP)bootdata$(SEP)bootcdregtest$(SEP)testboot.bat
+       $(rm) $(OUTPUT_)cd$(SEP)reactos$(SEP)unattend.inf
+
+regtest:
+       $(cp) boot$(SEP)bootdata$(SEP)unattend.inf.sample $(OUTPUT_)cd$(SEP)reactos$(SEP)unattend.inf
+       $(MAKE) bootcdregtest
+       $(rm) $(OUTPUT_)cd$(SEP)reactos$(SEP)unattend.inf
+
+.PHONY: cb
+cb: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) cb
+
+.PHONY: msbuild
+msbuild: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) msbuild
+
+.PHONY: msbuild_clean
+msbuild_clean: $(RBUILD_TARGET)
        $(ECHO_RBUILD)
-       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) mingw
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c msbuild
 
+.PHONY: depmap
+depmap: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) depmap
+
+.PHONY: msvc
+msvc: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) msvc
 
 $(BUGCODES_H) $(BUGCODES_RC): $(WMC_TARGET) $(NTOSKRNL_MC)
        $(ECHO_WMC)
@@ -255,11 +499,110 @@ $(BUGCODES_H) $(BUGCODES_RC): $(WMC_TARGET) $(NTOSKRNL_MC)
 
 $(ERRCODES_H) $(ERRCODES_RC): $(WMC_TARGET) $(KERNEL32_MC)
        $(ECHO_WMC)
-       $(Q)$(WMC_TARGET) -i -H $(ERRCODES_H) -o $(ERRCODES_RC) $(KERNEL32_MC)
+       $(Q)$(WMC_TARGET) -i -U -H $(ERRCODES_H) -o $(ERRCODES_RC) $(KERNEL32_MC)
+
+.PHONY: msvc6
+msvc6: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs6.00 -voversionconfiguration msvc
+
+.PHONY: msvc7
+msvc7: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs7.00 -voversionconfiguration msvc
+
+.PHONY: msvc71
+msvc71: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs7.10 -voversionconfiguration msvc
+
+.PHONY: msvc8
+msvc8: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs8.00 -voversionconfiguration msvc
+
+.PHONY: msvc6_clean
+msvc6_clean: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs6.00 -voversionconfiguration msvc
+
+.PHONY: msvc7_clean
+msvc7_clean: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs7.00 -voversionconfiguration msvc
+
+.PHONY: msvc71_clean
+msvc71_clean: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs7.10 -voversionconfiguration msvc
+
+.PHONY: msvc8_clean
+msvc8_clean: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs8.00 -voversionconfiguration msvc
+
+.PHONY: msvc_clean
+msvc_clean: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c msvc
+
+.PHONY: msvc_clean_all
+msvc_clean_all: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs6.00 -voversionconfiguration msvc
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs7.00 -voversionconfiguration msvc
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs7.10 -voversionconfiguration msvc
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs8.10 -voversionconfiguration msvc
+
+.PHONY: msvc7_install_debug
+msvc7_install_debug: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs7.00 -vcdebug -voversionconfiguration msvc
+
+.PHONY: msvc7_install_release
+msvc7_install_release: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs7.00 -vcrelease -voversionconfiguration msvc
+
+.PHONY: msvc7_install_speed
+msvc7_install_speed: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs7.00 -vcspeed -voversionconfiguration msvc
+
+.PHONY: msvc71_install_debug
+msvc71_install_debug: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs7.10 -vcdebug -voversionconfiguration msvc
+
+.PHONY: msvc71_install_release
+msvc71_install_release: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs7.10 -vcrelease -voversionconfiguration msvc
+
+
+.PHONY: msvc71_install_speed
+msvc71_install_speed: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs7.10 -vcspeed -voversionconfiguration msvc
+
+.PHONY: msvc8_install_debug
+msvc8_install_debug: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs8.00 -vcdebug -voversionconfiguration msvc
+
+.PHONY: msvc8_install_release
+msvc8_install_release: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs8.00 -vcrelease -voversionconfiguration msvc
+
+.PHONY: msvc8_install_speed
+msvc8_install_speed: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs8.00 -vcspeed -voversionconfiguration msvc
 
 .PHONY: makefile_auto_clean
 makefile_auto_clean:
-       -@$(rm) makefile.auto $(PREAUTO) 2>$(NUL)
+       -@$(rm) $(ROS_AUTOMAKE) $(PREAUTO) 2>$(NUL)
 
 .PHONY: clean
 clean: makefile_auto_clean