aboutsummaryrefslogtreecommitdiff
path: root/Makefile.vc
blob: 4d8f60a0f460257629af0b6d95eb286605a87259 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# -*- Makefile -*- 
#
# This is a Microsoft Visual C NMAKE makefile to use in building the
# Jim interpreter.
#
# Usage:
#   nmake -f Makefile.vc clean all
#
# To build a debug build, add DEBUG=1 to the command line. To build
# for profiling, add PROFILE=1. eg:
#   nmake -f Makefile.vc DEBUG=1 clean all
#
#
# Copyright (C) 2005 Pat Thoyts <patthoyts@users.sourceforge.net>
#

SRCDIR =.

!ifndef DEBUG
DEBUG   =0
!endif
!ifndef PROFILE
PROFILE =0
!endif
!ifndef SYMBOLS
SYMBOLS = 0
!endif
!ifndef CC
CC=cl
!endif
!ifndef LINK
LINK=link
!endif

# If you have sqlite3 installed and want to build the extension add
# SQLITE3DIR=c:\path\to\sqlite3
#
!ifndef SQLITE3DIR
SQLITE3    =0
!else
SQLITE3    =1
SQLITE_INC=-I$(SQLITE3DIR)
SQLITE_LIB=-libpath:$(SQLITE3DIR) libsqlite3.lib
!endif

#-------------------------------------------------------------------------
# There should be no need to edit below this point.
#-------------------------------------------------------------------------

!if $(DEBUG)
OUTDIR =Debug
CFLAGS =-Od -Zi -GZ -MDd -D_DEBUG
LDFLAGS=-debug:full -debugtype:cv
!else
OUTDIR =Release
!if $(SYMBOLS)
CFLAGS =-Od -Zi -Op -Gs -MD -DNDEBUG
LDFLAGS=-debug -opt:ref -opt:icf,3
!else
CFLAGS =-O2 -Otip -Gs -MD -DNDEBUG
LDFLAGS=-release -opt:ref -opt:icf,3
!endif
!endif

!if $(PROFILE)
CFLAGS =$(CFLAGS) -Zi
LDFLAGS=$(LDFLAGS) -profile -map
!endif

!if "$(OS)" == "Windows_NT"
RMDIR = rmdir /s /q >NUL
!else
RMDIR = deltree /y
!endif
DEL   = del /f /q

TMPDIR =$(OUTDIR)\Objects

CC     =$(CC) -nologo
LD     =$(LINK) -nologo

CFLAGS =$(CFLAGS) -W3 -YX -Fp$(TMPDIR)^\
INC    =
DEFS   =-DWIN32
LIBS   =

all:      jim aio win32 win32com win32api dll #sqlite3 eventloop
jim:      setup $(OUTDIR)\jim.exe
jimwish:  setup $(OUTDIR)\jimwish.exe
dll:      setup $(OUTDIR)\jim.dll
aio:      setup $(OUTDIR)\jim-aio-1.0.dll
sqlite3:  setup $(OUTDIR)\jim-sqlite3-1.0.dll
eventloop: setup $(OUTDIR)\jim-eventloop-1.0.dll
win32:    setup $(OUTDIR)\jim-win32-1.0.dll
win32api: setup $(OUTDIR)\jim-win32api-1.0.dll
win32com: setup $(OUTDIR)\jim-win32com-1.0.dll

$(OUTDIR)\jim.exe: $(TMPDIR)\jim.obj $(TMPDIR)\jimsh.obj
	@$(LD) $(LDFLAGS) -out:$@ $** $(LIBS)

$(OUTDIR)\jim.dll: $(TMPDIR)\jim.dll.obj
	@$(LD) $(LDFLAGS) -dll -out:$@ $** $(LIBS)
	@if exist $(@:.dll=.exp) $(DEL) $(@:.dll=.exp)

$(OUTDIR)\jim-win32-1.0.dll: $(TMPDIR)\jim-win32.obj
	@$(LD) $(LDFLAGS) -dll -out:$@ $** $(LIBS) >NUL
	@if exist $(@:.dll=.exp) $(DEL) $(@:.dll=.exp)

$(OUTDIR)\jim-win32api-1.0.dll: $(TMPDIR)\jim-win32api.obj
	@$(LD) $(LDFLAGS) -dll -out:$@ $** $(LIBS) >NUL
	@if exist $(@:.dll=.exp) $(DEL) $(@:.dll=.exp)

$(OUTDIR)\jim-win32com-1.0.dll: $(TMPDIR)\jim-win32com.obj
	@$(LD) $(LDFLAGS) -dll -out:$@ $** $(LIBS) >NUL
	@if exist $(@:.dll=.exp) $(DEL) $(@:.dll=.exp)

$(OUTDIR)\jim-aio-1.0.dll: $(TMPDIR)\jim-aio.obj
	@$(LD) $(LDFLAGS) -dll -out:$@ $** $(LIBS) >NUL
	@if exist $(@:.dll=.exp) $(DEL) $(@:.dll=.exp)

$(OUTDIR)\jim-eventloop-1.0.dll: $(TMPDIR)\jim-eventloop.obj
	@$(LD) $(LDFLAGS) -dll -out:$@ $** $(LIBS) >NUL
	@if exist $(@:.dll=.exp) $(DEL) $(@:.dll=.exp)

$(OUTDIR)\jim-sqlite3-1.0.dll: $(TMPDIR)\jim-sqlite3.obj
!if $(SQLITE3)
	@$(LD) $(LDFLAGS) -dll -out:$@ $** $(LIBS) $(SQLITE_LIB) >NUL
	@if exist $(@:.dll=.exp) $(DEL) $(@:.dll=.exp)
!else
	@echo cannot build sqlite3 extension - SQLITE3DIR not defined
!endif

$(OUTDIR)\jimwish.exe: $(TMPDIR)\jim.obj $(TMPDIR)\jimwish.obj
	@$(LD) $(LDFLAGS) -out:$@ $** $(LIBS) user32.lib

.PHONY: all jim dll win32 win32api win32com jim jimwish aio sqlite3

#-------------------------------------------------------------------------
setup:
	@if not exist $(OUTDIR) mkdir $(OUTDIR)
	@if not exist $(TMPDIR) mkdir $(TMPDIR)

test: jim
	$(OUTDIR)\jim.exe test.tcl

clean:
	@if exist $(TMPDIR)\NUL $(RMDIR) $(TMPDIR) >NUL

realclean: clean
	@if exist $(OUTDIR)\NUL $(RMDIR) $(OUTDIR) >NUL

#-------------------------------------------------------------------------

.SUFFIXES:.c .cpp

{$(SRCDIR)}.c{$(TMPDIR)}.obj::
	@$(CC) $(CFLAGS) $(DEFS) $(INC) -Fo$(TMPDIR)\ -c @<<
$<
<<

{$(SRCDIR)}.cpp{$(TMPDIR)}.obj::
	@$(CC) $(CFLAGS) $(DEFS) $(INC) -Fo$(TMPDIR)\ -c @<<
$<
<<

$(TMPDIR)\jim.obj: $(SRCDIR)\jim.c $(SRCDIR)\jim.h
$(TMPDIR)\jim-aio.obj: $(SRCDIR)\jim-aio.c $(SRCDIR)\jim.h
$(TMPDIR)\jim-eventloop.obj: $(SRCDIR)\jim-eventloop.c $(SRCDIR)\jim.h
$(TMPDIR)\jim-win32.obj: $(SRCDIR)\jim-win32.c $(SRCDIR)\jim.h
$(TMPDIR)\jim-win32api.obj: $(SRCDIR)\jim-win32api.c $(SRCDIR)\jim.h
$(TMPDIR)\jim-win32com.obj: $(SRCDIR)\jim-win32com.c $(SRCDIR)\jim.h
$(TMPDIR)\jim.dll.obj: $(SRCDIR)\jim.c $(SRCDIR)\jim.h
	@$(CC) -DBUILD_Jim $(CFLAGS) $(DEFS) $(INC) -Fo$@ -c $(SRCDIR)\jim.c
$(TMPDIR)\jim-sqlite3.obj: $(SRCDIR)\jim-sqlite3.c  $(SRCDIR)\jim.h
!if $(SQLITE3)
	@$(CC) $(CFLAGS) $(DEFS) $(INC) $(SQLITE_INC) -Fo$(TMPDIR)\ -c $(SRCDIR)\jim-sqlite3.c
!else
	@echo cannot build sqlite3 extension - SQLITE3DIR not defined
!endif

#-------------------------------------------------------------------------