| 1 |
# Makefile for Windows (Win32/64). Assumes Microsoft compiler. |
| 2 |
# Should be invoked as "nmake -f NT_MAKEFILE [<args>]"; the optional arguments |
| 3 |
# are: "cpu=AMD64" - to target x64, "cpu=i386" - to target x86, |
| 4 |
# "enable_static=1" - to build it as a static library, "nodebug=1" - to produce |
| 5 |
# the release variant of the library, "disable_threads=1" - to build the |
| 6 |
# library and the tests without threads support. |
| 7 |
|
| 8 |
cc = cl |
| 9 |
link = link |
| 10 |
rc = rc |
| 11 |
|
| 12 |
!IF !DEFINED(CPU) || "$(CPU)" == "" |
| 13 |
CPU = $(PROCESSOR_ARCHITECTURE) |
| 14 |
!ENDIF |
| 15 |
!IF "$(CPU)" == "I386" || "$(CPU)" == "X86" || "$(CPU)" == "x86" |
| 16 |
CPU = i386 |
| 17 |
!ELSEIF "$(CPU)" == "X64" || "$(CPU)" == "x64" || "$(CPU)" == "amd64" |
| 18 |
CPU = AMD64 |
| 19 |
!ENDIF |
| 20 |
|
| 21 |
!IF !DEFINED(NMAKE_WINVER) |
| 22 |
NMAKE_WINVER = 0x0600 |
| 23 |
!ENDIF |
| 24 |
|
| 25 |
cflags = $(cflags) -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -GS -D_WINNT -W4 |
| 26 |
!IF "$(CPU)" == "i386" |
| 27 |
cflags = $(cflags) -D_X86_=1 -DWIN32 -D_WIN32 |
| 28 |
!ELSEIF "$(CPU)" == "AMD64" |
| 29 |
cflags = $(cflags) -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 |
| 30 |
!ENDIF |
| 31 |
cflags = $(cflags) -D_WIN32_WINNT=$(NMAKE_WINVER) -DWINVER=$(NMAKE_WINVER) |
| 32 |
|
| 33 |
!IFDEF NODEBUG |
| 34 |
cvarsmt = -D_MT -MT |
| 35 |
cdebug = -Ox -DNDEBUG |
| 36 |
rcvars = -DWIN32 -D_WIN32 -DWINVER=$(NMAKE_WINVER) |
| 37 |
ldebug = /RELEASE |
| 38 |
!ELSE |
| 39 |
cvarsmt = -D_MT -MTd |
| 40 |
cdebug = -Zi -Od -DDEBUG |
| 41 |
rcvars = -DWIN32 -D_WIN32 -DWINVER=$(NMAKE_WINVER) -DDEBUG -D_DEBUG |
| 42 |
ldebug = /DEBUG /DEBUGTYPE:cv |
| 43 |
!ENDIF |
| 44 |
|
| 45 |
!IF "$(CPU)" == "i386" |
| 46 |
CVTRES_CPU=X86 |
| 47 |
!ELSEIF "$(CPU)" == "AMD64" |
| 48 |
CVTRES_CPU=X64 |
| 49 |
!ENDIF |
| 50 |
|
| 51 |
!IFNDEF NODEBUG |
| 52 |
CFLAGS_DEBUG=-DGC_ASSERTIONS |
| 53 |
!ENDIF |
| 54 |
|
| 55 |
!IFDEF ENABLE_STATIC |
| 56 |
CFLAGS_GCDLL=-DGC_NOT_DLL |
| 57 |
CORDFLAG= |
| 58 |
!ELSE |
| 59 |
CFLAGS_GCDLL=-DGC_DLL |
| 60 |
# cord.dll and its clients should not link C library statically otherwise |
| 61 |
# FILE-related functions might not work (because own set of opened FILEs |
| 62 |
# is maintained by each copy of the C library thus making impossible to pass |
| 63 |
# FILE pointer from .exe code to .dll code). |
| 64 |
cvarsmt= |
| 65 |
!IFDEF NODEBUG |
| 66 |
CORDFLAG=-MD |
| 67 |
!ELSE |
| 68 |
CORDFLAG=-MDd |
| 69 |
!ENDIF |
| 70 |
!ENDIF |
| 71 |
|
| 72 |
!IFNDEF DISABLE_THREADS |
| 73 |
CFLAGS_MT=$(cvarsmt) -DGC_THREADS -DTHREAD_LOCAL_ALLOC -DPARALLEL_MARK |
| 74 |
!ENDIF |
| 75 |
|
| 76 |
CFLAGS_SPECIFIC=$(CFLAGS_DEBUG) $(CFLAGS_GCDLL) $(CFLAGS_MT) |
| 77 |
|
| 78 |
CFLAGS_DEFAULT=-DALL_INTERIOR_POINTERS -DENABLE_DISCLAIM -DGC_ATOMIC_UNCOLLECTABLE -DGC_GCJ_SUPPORT -DJAVA_FINALIZATION -DNO_EXECUTE_PERMISSION -DUSE_MUNMAP |
| 79 |
|
| 80 |
CXXFLAGS_SPECIFIC=/EHsc |
| 81 |
|
| 82 |
# Make sure that .cc is not viewed as a suffix. It is for VC++2005, but |
| 83 |
# not earlier versions. We can deal with either, but not inconsistency. |
| 84 |
.SUFFIXES: |
| 85 |
.SUFFIXES: .obj .cpp .c |
| 86 |
|
| 87 |
# Atomic_ops installation directory. For Win32, the source directory |
| 88 |
# should do, since we only need the headers. |
| 89 |
# We assume this was manually unpacked. |
| 90 |
AO_SRC_DIR=libatomic_ops/src |
| 91 |
AO_INCLUDE_DIR=$(AO_SRC_DIR) |
| 92 |
|
| 93 |
!IFDEF ENABLE_STATIC |
| 94 |
OBJS= misc.obj win32_threads.obj alloc.obj reclaim.obj allchblk.obj mach_dep.obj os_dep.obj mark_rts.obj headers.obj mark.obj obj_map.obj blacklst.obj finalize.obj new_hblk.obj dbg_mlc.obj fnlz_mlc.obj malloc.obj dyn_load.obj typd_mlc.obj ptr_chck.obj gcj_mlc.obj mallocx.obj extra\msvc_dbg.obj thread_local_alloc.obj |
| 95 |
!ELSE |
| 96 |
OBJS= extra\gc.obj extra\msvc_dbg.obj |
| 97 |
!ENDIF |
| 98 |
|
| 99 |
COBJS= cord\cordbscs.obj cord\cordxtra.obj cord\cordprnt.obj |
| 100 |
|
| 101 |
all: gc.lib cord.lib gccpp.lib gctba.lib |
| 102 |
|
| 103 |
check: gctest.exe test_cpp.exe cordtest.exe de.exe |
| 104 |
gctest.exe |
| 105 |
cordtest.exe |
| 106 |
test_cpp.exe |
| 107 |
|
| 108 |
.c.obj: |
| 109 |
$(cc) $(cdebug) $(cflags) $(CFLAGS_SPECIFIC) $(CORDFLAG) -Iinclude -I$(AO_INCLUDE_DIR) $(CFLAGS_DEFAULT) -D_CRT_SECURE_NO_DEPRECATE $*.c /Fo$*.obj /wd4100 /wd4127 /wd4701 |
| 110 |
# Disable crt security warnings, since unfortunately they warn about all sorts |
| 111 |
# of safe uses of strncpy. It would be nice to leave the rest enabled. |
| 112 |
|
| 113 |
.cpp.obj: |
| 114 |
$(cc) $(cdebug) $(cflags) $(CFLAGS_SPECIFIC) -Iinclude $(CFLAGS_DEFAULT) $(CXXFLAGS_SPECIFIC) -D_CRT_SECURE_NO_DEPRECATE $*.cpp /Fo$*.obj |
| 115 |
|
| 116 |
$(OBJS) tests\test.obj: include\private\gc_priv.h include\private\gc_hdrs.h include\gc.h include\private\gcconfig.h include\private\gc_locks.h include\private\gc_pmark.h include\gc_mark.h include\gc_disclaim.h include\private\msvc_dbg.h |
| 117 |
|
| 118 |
!IFDEF ENABLE_STATIC |
| 119 |
|
| 120 |
gc.lib: $(OBJS) |
| 121 |
lib /out:gc.lib /MACHINE:$(CPU) $(OBJS) |
| 122 |
|
| 123 |
cord.lib: $(COBJS) |
| 124 |
lib /out:cord.lib /MACHINE:$(CPU) $(COBJS) |
| 125 |
|
| 126 |
gccpp.lib: gc_badalc.obj gc_cpp.obj |
| 127 |
lib /out:gccpp.lib /MACHINE:$(CPU) gc_badalc.obj gc_cpp.obj |
| 128 |
|
| 129 |
# The same as gccpp.lib but contains only gc_badalc.obj. |
| 130 |
gctba.lib: gc_badalc.obj |
| 131 |
lib /out:gctba.lib /MACHINE:$(CPU) gc_badalc.obj |
| 132 |
|
| 133 |
!ELSE |
| 134 |
|
| 135 |
gc.lib: $(OBJS) |
| 136 |
$(link) $(ldebug) kernel32.lib user32.lib /subsystem:windows /dll /INCREMENTAL:NO /pdb:"gc.pdb" /out:gc.dll /implib:gc.lib /MACHINE:$(CPU) $(OBJS) |
| 137 |
|
| 138 |
cord.lib: $(COBJS) gc.lib |
| 139 |
$(link) $(ldebug) gc.lib /subsystem:windows /dll /INCREMENTAL:NO /pdb:"cord.pdb" /out:cord.dll /implib:cord.lib /MACHINE:$(CPU) $(COBJS) |
| 140 |
|
| 141 |
gccpp.lib: gc_badalc.obj gc_cpp.obj gc.lib |
| 142 |
$(link) $(ldebug) gc.lib /subsystem:windows /dll /INCREMENTAL:NO /pdb:"gccpp.pdb" /out:gccpp.dll /implib:gccpp.lib /MACHINE:$(CPU) gc_badalc.obj gc_cpp.obj |
| 143 |
|
| 144 |
gctba.lib: gc_badalc.obj gc.lib |
| 145 |
$(link) $(ldebug) gc.lib /subsystem:windows /dll /INCREMENTAL:NO /pdb:"gctba.pdb" /out:gctba.dll /implib:gctba.lib /MACHINE:$(CPU) gc_badalc.obj |
| 146 |
|
| 147 |
!ENDIF |
| 148 |
|
| 149 |
gctest.exe: gc.lib tests\test.obj |
| 150 |
$(link) /MACHINE:$(CPU) /INCREMENTAL:NO $(ldebug) $(lflags) user32.lib -out:$*.exe tests\test.obj gc.lib |
| 151 |
# mapsympe -n -o gctest.sym gctest.exe |
| 152 |
# This produces a GUI app that opens no window and writes to gctest.gc.log. |
| 153 |
|
| 154 |
cord\tests\de_win.rbj: cord\tests\de_win.res |
| 155 |
cvtres /MACHINE:$(CVTRES_CPU) /OUT:cord\tests\de_win.rbj cord\tests\de_win.res |
| 156 |
|
| 157 |
cord\tests\de.obj cord\tests\de_win.obj: include\cord.h include\cord_pos.h cord\tests\de_win.h cord\tests\de_cmds.h |
| 158 |
|
| 159 |
cord\tests\de_win.res: cord\tests\de_win.rc cord\tests\de_win.h cord\tests\de_cmds.h |
| 160 |
$(rc) $(rcvars) -r -fo cord\tests\de_win.res cord\tests\de_win.rc |
| 161 |
|
| 162 |
# Cord/de is a real Windows GUI app. |
| 163 |
de.exe: cord\tests\de.obj cord\tests\de_win.obj cord\tests\de_win.rbj gc.lib cord.lib |
| 164 |
$(link) /MACHINE:$(CPU) /INCREMENTAL:NO $(ldebug) $(lflags) -out:de.exe cord\tests\de.obj cord\tests\de_win.obj cord\tests\de_win.rbj gc.lib cord.lib gdi32.lib user32.lib |
| 165 |
|
| 166 |
cordtest.exe: cord\tests\cordtest.obj gc.lib cord.lib |
| 167 |
$(link) /subsystem:console /MACHINE:$(CPU) /INCREMENTAL:NO $(ldebug) $(lflags) -out:cordtest.exe cord\tests\cordtest.obj gc.lib cord.lib user32.lib |
| 168 |
|
| 169 |
gc_badalc.obj: gc_badalc.cc include\gc_cpp.h include\gc.h |
| 170 |
|
| 171 |
gc_cpp.obj: gc_cpp.cc include\gc_cpp.h include\gc.h |
| 172 |
|
| 173 |
test_cpp.cpp: tests\test_cpp.cc |
| 174 |
copy tests\test_cpp.cc test_cpp.cpp |
| 175 |
|
| 176 |
# This generates the C++ test executable. The executable expects |
| 177 |
# a single numeric argument, which is the number of iterations. |
| 178 |
# The output appears in test_cpp.gc.log file. |
| 179 |
test_cpp.exe: test_cpp.obj include\gc_cpp.h include\gc.h gc.lib gccpp.lib |
| 180 |
$(link) /MACHINE:$(CPU) /INCREMENTAL:NO $(ldebug) $(lflags) user32.lib -out:test_cpp.exe test_cpp.obj gc.lib gccpp.lib |
| 181 |
|
| 182 |
$(AO_SRC_DIR): |
| 183 |
tar xvfz $(AO_SRC_DIR).tar.gz |
| 184 |
|
| 185 |
clean: |
| 186 |
del *.dll *.exe *.exp *.lib *.log *.obj *.pdb cordtst*.tmp cord\*.obj cord\tests\*.rbj cord\tests\*.res cord\tests\*.obj extra\*.obj test_cpp.cpp tests\*.obj 2> nul |