diff options
author | twinaphex | 2018-12-28 00:32:13 +0100 |
---|---|---|
committer | twinaphex | 2018-12-28 00:32:13 +0100 |
commit | c007afe6fd51827fade7aa15a0a798be8bd97839 (patch) | |
tree | 3b8aca538bec3b42ef9bd33549a15110c3a20e37 /Makefile | |
parent | 29db3cf00f552808b3f1dc5d11fcdbbefc659ec4 (diff) | |
download | snes9x2002-c007afe6fd51827fade7aa15a0a798be8bd97839.tar.gz snes9x2002-c007afe6fd51827fade7aa15a0a798be8bd97839.tar.bz2 snes9x2002-c007afe6fd51827fade7aa15a0a798be8bd97839.zip |
Start significantly refactoring this codebase so we can get it
to work with MSVC
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 123 |
1 files changed, 115 insertions, 8 deletions
@@ -16,6 +16,13 @@ else ifneq ($(findstring win,$(shell uname -a)),) endif endif +ifneq (,$(findstring msvc,$(platform))) +LIBM := +else +LIBM := -lm +endif +LIBS := + ifeq ($(platform), unix) TARGET := $(TARGET_NAME)_libretro.so fpic := -fPIC @@ -185,6 +192,94 @@ else ifeq ($(platform), gcw0) CFLAGS += -std=c99 -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float CFLAGS += -fno-builtin -fno-exceptions CFLAGS += -DPATH_MAX=256 + +# Windows MSVC 2010 x86 +else ifeq ($(platform), windows_msvc2010_x86) + CC = cl.exe + CXX = cl.exe + +PATH := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin"):$(PATH) +PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE") +INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/include") +LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS100COMNTOOLS)../../VC/lib") +BIN := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin") + +WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib +WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib + +WindowsSdkDirInc := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')Include +WindowsSdkDirInc ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')Include + +INCFLAGS_PLATFORM = -I"$(WindowsSdkDirInc)" +export INCLUDE := $(INCLUDE) +export LIB := $(LIB);$(WindowsSdkDir) +TARGET := $(TARGET_NAME)_libretro.dll +PSS_STYLE :=2 +LDFLAGS += -DLL +OLD_GCC = 1 + +# Windows MSVC 2008 x86 +else ifeq ($(platform), windows_msvc2008_x86) + CC = cl.exe + CXX = cl.exe + +PATH := $(shell IFS=$$'\n'; cygpath "$(VS90COMNTOOLS)../../VC/bin"):$(PATH) +PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS90COMNTOOLS)../IDE") +INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS90COMNTOOLS)../../VC/include") +LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS90COMNTOOLS)../../VC/lib") +BIN := $(shell IFS=$$'\n'; cygpath "$(VS90COMNTOOLS)../../VC/bin") + +WindowsSdkDir := $(INETSDK) + +export INCLUDE := $(INCLUDE);$(INETSDK)/Include;libretro-common/include/compat/msvc +export LIB := $(LIB);$(WindowsSdkDir);$(INETSDK)/Lib +TARGET := $(TARGET_NAME)_libretro.dll +PSS_STYLE :=2 +LDFLAGS += -DLL +CFLAGS += -D_CRT_SECURE_NO_DEPRECATE +NO_GCC = 1 + +# Windows MSVC 2005 x86 +else ifeq ($(platform), windows_msvc2005_x86) + CC = cl.exe + CXX = cl.exe + +PATH := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/bin"):$(PATH) +PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../IDE") +INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/include") +LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS80COMNTOOLS)../../VC/lib") +BIN := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/bin") + +WindowsSdkDir := $(INETSDK) + +export INCLUDE := $(INCLUDE);$(INETSDK)/Include;libretro-common/include/compat/msvc +export LIB := $(LIB);$(WindowsSdkDir);$(INETSDK)/Lib +TARGET := $(TARGET_NAME)_libretro.dll +PSS_STYLE :=2 +LDFLAGS += -DLL +CFLAGS += -D_CRT_SECURE_NO_DEPRECATE +NO_GCC = 1 + +# Windows MSVC 2003 x86 +else ifeq ($(platform), windows_msvc2003_x86) + CC = cl.exe + CXX = cl.exe + +PATH := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/bin"):$(PATH) +PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../IDE") +INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/include") +LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS71COMNTOOLS)../../Vc7/lib") +BIN := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/bin") + +WindowsSdkDir := $(INETSDK) + +export INCLUDE := $(INCLUDE);$(INETSDK)/Include;libretro-common/include/compat/msvc +export LIB := $(LIB);$(WindowsSdkDir);$(INETSDK)/Lib +TARGET := $(TARGET_NAME)_libretro.dll +PSS_STYLE :=2 +LDFLAGS += -DLL +CFLAGS += -D_CRT_SECURE_NO_DEPRECATE +NO_GCC = 1 else TARGET := $(TARGET_NAME)_libretro.dll CC = gcc @@ -203,12 +298,25 @@ else DEFINES += -O2 -DNDEBUG=1 endif +LDFLAGS += $(LIBM) + include Makefile.common -OBJS := $(SOURCES:.c=.o) $(SOURCES_ASM:.S=.o) +OBJECTS := $(SOURCES:.c=.o) $(SOURCES_ASM:.S=.o) CFLAGS += $(DEFINES) $(COMMON_DEFINES) $(INCLUDES) +ifneq (,$(findstring msvc,$(platform))) + LIBM = + OBJOUT = -Fo + LINKOUT = -out: + LD = link.exe +else + OBJOUT = -o + LINKOUT = -o + LD = $(CC) +endif + ifeq ($(platform), theos_ios) COMMON_FLAGS := -DIOS $(COMMON_DEFINES) $(INCFLAGS) -I$(THEOS_INCLUDE_PATH) -Wno-error $(LIBRARY_NAME)_CFLAGS += $(CFLAGS) $(COMMON_FLAGS) @@ -218,23 +326,22 @@ include $(THEOS_MAKE_PATH)/library.mk else all: $(TARGET) -$(TARGET): $(OBJS) +$(TARGET): $(OBJECTS) @echo "** BUILDING $(TARGET) FOR PLATFORM $(platform) **" ifeq ($(STATIC_LINKING), 1) - $(AR) rcs $@ $(OBJS) + $(AR) rcs $@ $(OBJECTS) else - $(CC) $(fpic) $(SHARED) $(INCLUDES) -o $@ $(OBJS) -lm + $(LD) $(LINKOUT)$@ $(SHARED) $(fpic) $(LDFLAGS) $(LIBS) endif - @echo "** BUILD SUCCESSFUL! GG NO RE **" %.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CFLAGS) -c $(OBJOUT)$@ $< %.o: %.S - $(CC) $(CFLAGS) -Wa,-I./src/ -c -o $@ $< + $(CC) $(CFLAGS) -Wa,-I./src/ -c $(OBJOUT)$@ $< clean: - rm -f $(OBJS) $(TARGET) + rm -f $(OBJECTS) $(TARGET) .PHONY: clean |