summaryrefslogtreecommitdiff
path: root/BaseTools/Source/C/Makefiles
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/C/Makefiles')
-rw-r--r--BaseTools/Source/C/Makefiles/NmakeSubdirs.bat28
-rw-r--r--BaseTools/Source/C/Makefiles/app.makefile13
-rw-r--r--BaseTools/Source/C/Makefiles/footer.makefile23
-rw-r--r--BaseTools/Source/C/Makefiles/header.makefile40
-rw-r--r--BaseTools/Source/C/Makefiles/lib.makefile7
-rw-r--r--BaseTools/Source/C/Makefiles/ms.app21
-rw-r--r--BaseTools/Source/C/Makefiles/ms.common49
-rw-r--r--BaseTools/Source/C/Makefiles/ms.lib20
-rw-r--r--BaseTools/Source/C/Makefiles/ms.rule13
9 files changed, 214 insertions, 0 deletions
diff --git a/BaseTools/Source/C/Makefiles/NmakeSubdirs.bat b/BaseTools/Source/C/Makefiles/NmakeSubdirs.bat
new file mode 100644
index 0000000000..cacb50baa9
--- /dev/null
+++ b/BaseTools/Source/C/Makefiles/NmakeSubdirs.bat
@@ -0,0 +1,28 @@
+@echo off
+setlocal
+SET NMAKE_COMMAND=%1
+SHIFT
+
+:loop
+if "%1"=="" goto success
+
+ECHO Building %1
+pushd %1
+nmake %NMAKE_COMMAND%
+if ERRORLEVEL 1 goto error
+ECHO %1 built successfully (%NMAKE_COMMAND%)
+ECHO.
+shift
+popd
+goto loop
+
+:success
+goto exit
+
+:error
+popd
+ENDLOCAL
+ECHO Error while making %1!
+VERIFY OTHER 2>NUL
+
+:exit
diff --git a/BaseTools/Source/C/Makefiles/app.makefile b/BaseTools/Source/C/Makefiles/app.makefile
new file mode 100644
index 0000000000..7555556baa
--- /dev/null
+++ b/BaseTools/Source/C/Makefiles/app.makefile
@@ -0,0 +1,13 @@
+MAKEROOT ?= ../..
+
+include $(MAKEROOT)/Makefiles/header.makefile
+
+APPLICATION = $(MAKEROOT)/bin/$(APPNAME)
+
+.PHONY:all
+all: $(MAKEROOT)/bin $(APPLICATION)
+
+$(APPLICATION): $(OBJECTS)
+ $(LINKER) -o $(APPLICATION) $(OBJECTS) -L$(MAKEROOT)/libs $(LIBS)
+
+include $(MAKEROOT)/Makefiles/footer.makefile
diff --git a/BaseTools/Source/C/Makefiles/footer.makefile b/BaseTools/Source/C/Makefiles/footer.makefile
new file mode 100644
index 0000000000..7bdf49c1af
--- /dev/null
+++ b/BaseTools/Source/C/Makefiles/footer.makefile
@@ -0,0 +1,23 @@
+DEPFILES = $(OBJECTS:%.o=%.d)
+
+$(MAKEROOT)/libs-$(ARCH):
+ mkdir -p $(MAKEROOT)/libs-$(ARCH)
+
+.PHONY: install
+install: $(MAKEROOT)/libs-$(ARCH) $(LIBRARY)
+ cp $(LIBRARY) $(MAKEROOT)/libs-$(ARCH)
+
+$(LIBRARY): $(OBJECTS)
+ $(AR) crs $@ $^
+
+%.o : %.c
+ $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
+
+%.o : %.S
+ $(AS) -c $(ASFLAGS) $< -o $@
+
+.PHONY: clean
+clean:
+ @rm -f $(OBJECTS) $(LIBRARY) $(DEPFILES)
+
+-include $(DEPFILES)
diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile
new file mode 100644
index 0000000000..271b141a81
--- /dev/null
+++ b/BaseTools/Source/C/Makefiles/header.makefile
@@ -0,0 +1,40 @@
+# The makefile can be invoked with
+# ARCH = x86_64 or x64 for EM64T build
+# ARCH = ia32 or IA32 for IA32 build
+# ARCH = ia64 or IA64 for IA64 build
+#
+ARCH ?= IA32
+
+CYGWIN:=$(findstring CYGWIN, $(shell uname -s))
+LINUX:=$(findstring Linux, $(shell uname -s))
+DARWIN:=$(findstring Darwin, $(shell uname -s))
+
+CC = gcc
+CXX = g++
+AS = gcc
+AR = ar
+LD = ld
+LINKER ?= $(CC)
+ifeq ($(ARCH), IA32)
+ARCH_INCLUDE = -I $(MAKEROOT)/Include/Ia32/
+endif
+
+ifeq ($(ARCH), X64)
+ARCH_INCLUDE = -I $(MAKEROOT)/Include/X64/
+endif
+
+INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)
+CPPFLAGS = $(INCLUDE)
+CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fno-merge-constants -nostdlib -Wall -c -g
+
+.PHONY: all
+.PHONY: install
+.PHONY: clean
+
+all:
+
+$(MAKEROOT)/libs:
+ mkdir $(MAKEROOT)/libs
+
+$(MAKEROOT)/bin:
+ mkdir $(MAKEROOT)/bin
diff --git a/BaseTools/Source/C/Makefiles/lib.makefile b/BaseTools/Source/C/Makefiles/lib.makefile
new file mode 100644
index 0000000000..2b1a9d4289
--- /dev/null
+++ b/BaseTools/Source/C/Makefiles/lib.makefile
@@ -0,0 +1,7 @@
+include $(MAKEROOT)/Makefiles/header.makefile
+
+LIBRARY = $(MAKEROOT)/libs/lib$(LIBNAME).a
+
+all: $(MAKEROOT)/libs $(LIBRARY)
+
+include $(MAKEROOT)/Makefiles/footer.makefile
diff --git a/BaseTools/Source/C/Makefiles/ms.app b/BaseTools/Source/C/Makefiles/ms.app
new file mode 100644
index 0000000000..fabc0bc656
--- /dev/null
+++ b/BaseTools/Source/C/Makefiles/ms.app
@@ -0,0 +1,21 @@
+!INCLUDE ..\Makefiles\ms.common
+
+APPLICATION = $(BIN_PATH)\$(APPNAME).exe
+
+all: $(APPLICATION)
+
+$(APPLICATION) : $(OBJECTS)
+ -@if not exist $(BIN_PATH) mkdir $(BIN_PATH)
+ $(LD) /nologo /debug /incremental:no /nodefaultlib:libc.lib /out:$@ $(LIBS) $**
+
+.PHONY:clean
+.PHONY:cleanall
+
+clean:
+ del /f /q $(OBJECTS) *.pdb > nul
+
+cleanall:
+ del /f /q $(OBJECTS) $(APPLICATION) *.pdb $(BIN_PATH)\*.pdb > nul
+
+!INCLUDE ..\Makefiles\ms.rule
+
diff --git a/BaseTools/Source/C/Makefiles/ms.common b/BaseTools/Source/C/Makefiles/ms.common
new file mode 100644
index 0000000000..2385518c1b
--- /dev/null
+++ b/BaseTools/Source/C/Makefiles/ms.common
@@ -0,0 +1,49 @@
+!IFNDEF EDK_TOOLS_PATH
+!ERROR "Please set your EDK_TOOLS_PATH!"
+!ENDIF
+
+!IFNDEF BASE_TOOLS_PATH
+!ERROR "BASE_TOOLS_PATH is not set! Please run build_tools.bat at first!"
+!ENDIF
+
+!IFNDEF ARCH
+ARCH = IA32
+!ENDIF
+
+MAKE = nmake -nologo
+
+SOURCE_PATH = $(BASE_TOOLS_PATH)\Source\C
+BIN_PATH = $(BASE_TOOLS_PATH)\Bin
+LIB_PATH = $(BASE_TOOLS_PATH)\Lib
+
+SYS_BIN_PATH=$(EDK_TOOLS_PATH)\Bin
+SYS_LIB_PATH=$(EDK_TOOLS_PATH)\Lib
+
+!IF "$(ARCH)"=="IA32"
+ARCH_INCLUDE = $(SOURCE_PATH)\Include\Ia32
+BIN_PATH = $(BASE_TOOLS_PATH)\Bin\Win32
+LIB_PATH = $(BASE_TOOLS_PATH)\Lib\Win32
+SYS_BIN_PATH = $(EDK_TOOLS_PATH)\Bin\Win32
+SYS_LIB_PATH = $(EDK_TOOLS_PATH)\Lib\Win32
+!ENDIF
+
+!IF "$(ARCH)"=="X64"
+ARCH_INCLUDE = $(SOURCE_PATH)\Include\X64
+BIN_PATH = $(BASE_TOOLS_PATH)\Bin\Win64
+LIB_PATH = $(BASE_TOOLS_PATH)\Lib\Win64
+SYS_BIN_PATH = $(EDK_TOOLS_PATH)\Bin\Win64
+SYS_LIB_PATH = $(EDK_TOOLS_PATH)\Lib\Win64
+!ENDIF
+
+CC = cl.exe
+CXX = cl.exe
+AS = ml.exe
+AR = lib.exe
+LD = link.exe
+LINKER = $(LD)
+
+INC = -I . -I $(SOURCE_PATH)\Include -I $(ARCH_INCLUDE) -I $(SOURCE_PATH)\Common $(INC)
+
+CFLAGS = $(CFLAGS) /nologo /c /Zi /Od /RTC1 /D _DEBUG /MTd /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE
+CPPFLAGS = $(CPPFLAGS) /EHsc /nologo /c /Zi /Od /RTC1 /D _DEBUG /MTd /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE
+
diff --git a/BaseTools/Source/C/Makefiles/ms.lib b/BaseTools/Source/C/Makefiles/ms.lib
new file mode 100644
index 0000000000..79fdf55e41
--- /dev/null
+++ b/BaseTools/Source/C/Makefiles/ms.lib
@@ -0,0 +1,20 @@
+!INCLUDE ..\Makefiles\ms.common
+
+LIBRARY = $(LIB_PATH)\$(LIBNAME).lib
+
+all: $(LIBRARY)
+
+$(LIBRARY) : $(OBJECTS)
+ -@if not exist $(LIB_PATH) mkdir $(LIB_PATH)
+ $(AR) /nologo /out:$@ $**
+
+.PHONY:clean
+clean:
+ del /f /q $(OBJECTS) *.pdb > nul
+
+.PHONY:cleanall
+cleanall:
+ del /f /q $(OBJECTS) $(LIBRARY) *.pdb > nul
+
+!INCLUDE ..\Makefiles\ms.rule
+
diff --git a/BaseTools/Source/C/Makefiles/ms.rule b/BaseTools/Source/C/Makefiles/ms.rule
new file mode 100644
index 0000000000..94687a075d
--- /dev/null
+++ b/BaseTools/Source/C/Makefiles/ms.rule
@@ -0,0 +1,13 @@
+#DEPFILES = $(OBJECTS:%.o=%.d)
+
+.c.obj :
+ $(CC) -c $(CFLAGS) $(INC) $< -Fo$@
+
+.S.obj :
+ $(AS) -c $(ASFLAGS) $< -Fo$@
+
+.cpp.obj :
+ $(CXX) -c $(CPPFLAGS) $(INC) $< -Fo$@
+
+#-include $(DEPFILES)
+