1# Visual C++ NMakefile for PDCurses library - Win32 VC++ 2.0+
2#
3# Usage: nmake -f [path\]vcwin32.mak [DEBUG=] [DLL=] [WIDE=] [UTF8=] [target]
4#
5# where target can be any of:
6# [all|demos|pdcurses.lib|testcurs.exe...]
7
8O = obj
9
10!ifndef PDCURSES_SRCDIR
11PDCURSES_SRCDIR = ..
12!endif
13
14!include $(PDCURSES_SRCDIR)\version.mif
15!include $(PDCURSES_SRCDIR)\libobjs.mif
16
17osdir		= $(PDCURSES_SRCDIR)\win32
18
19PDCURSES_WIN_H	= $(osdir)\pdcwin.h
20
21CC		= cl.exe -nologo
22
23!ifdef DEBUG
24CFLAGS		= -Z7 -DPDCDEBUG
25LDFLAGS		= -debug -pdb:none
26!else
27CFLAGS		= -O1
28LDFLAGS		=
29!endif
30
31BASEDEF		= $(PDCURSES_SRCDIR)\exp-base.def
32WIDEDEF		= $(PDCURSES_SRCDIR)\exp-wide.def
33
34DEFDEPS		= $(BASEDEF)
35
36!ifdef WIDE
37WIDEOPT		= -DPDC_WIDE
38DEFDEPS		= $(DEFDEPS) $(WIDEDEF)
39!endif
40
41!ifdef UTF8
42UTF8OPT		= -DPDC_FORCE_UTF8
43!endif
44
45DEFFILE		= pdcurses.def
46SHL_LD = link $(LDFLAGS) /NOLOGO /DLL /OUT:pdcurses.dll /DEF:$(DEFFILE)
47
48LINK		= link.exe -nologo
49
50CCLIBS		= user32.lib advapi32.lib
51# may need to add msvcrt.lib for VC 2.x, VC 5.0 doesn't want it
52#CCLIBS		= msvcrt.lib user32.lib advapi32.lib
53
54LIBEXE		= lib -nologo
55
56LIBCURSES	= pdcurses.lib
57CURSESDLL	= pdcurses.dll
58
59!ifdef DLL
60DLLOPT		= -DPDC_DLL_BUILD
61PDCLIBS		= $(CURSESDLL)
62!else
63PDCLIBS		= $(LIBCURSES)
64!endif
65
66BUILD		= $(CC) -I$(PDCURSES_SRCDIR) -c $(CFLAGS) $(DLLOPT) \
67$(WIDEOPT) $(UTF8OPT)
68
69all:	$(PDCLIBS) $(DEMOS)
70
71clean:
72	-del *.obj
73	-del *.lib
74	-del *.exe
75	-del *.dll
76	-del *.exp
77	-del *.res
78	-del *.def
79
80DEMOOBJS = $(DEMOS:.exe=.obj) tui.obj
81
82$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
83$(PDCOBJS) : $(PDCURSES_WIN_H)
84$(DEMOOBJS) : $(PDCURSES_CURSES_H)
85$(DEMOS) : $(LIBCURSES)
86panel.obj : $(PANEL_HEADER)
87terminfo.obj: $(TERM_HEADER)
88
89!ifndef DLL
90$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
91	$(LIBEXE) -out:$@ $(LIBOBJS) $(PDCOBJS)
92	-copy $(LIBCURSES) panel.lib
93!endif
94
95$(DEFFILE) : $(DEFDEPS)
96	echo LIBRARY pdcurses > $(DEFFILE)
97	echo EXPORTS >> $(DEFFILE)
98	type $(BASEDEF) >> $(DEFFILE)
99!ifdef WIDE
100	type $(WIDEDEF) >> $(DEFFILE)
101!endif
102
103$(CURSESDLL) : $(LIBOBJS) $(PDCOBJS) $(DEFFILE) pdcurses.obj
104	$(SHL_LD) $(LIBOBJS) $(PDCOBJS) pdcurses.obj $(CCLIBS)
105	-copy $(LIBCURSES) panel.lib
106
107pdcurses.res pdcurses.obj: $(osdir)\pdcurses.rc $(osdir)\pdcurses.ico
108	rc /r /fopdcurses.res $(osdir)\pdcurses.rc
109	cvtres /MACHINE:IX86 /NOLOGO /OUT:pdcurses.obj pdcurses.res
110
111{$(srcdir)\}.c{}.obj::
112	$(BUILD) $<
113
114{$(osdir)\}.c{}.obj::
115	$(BUILD) $<
116
117{$(demodir)\}.c{}.obj::
118	$(BUILD) $<
119
120.obj.exe:
121	$(LINK) $(LDFLAGS) $< $(LIBCURSES) $(CCLIBS)
122
123tuidemo.exe: tuidemo.obj tui.obj
124	$(LINK) $(LDFLAGS) $*.obj tui.obj $(LIBCURSES) $(CCLIBS)
125
126tui.obj: $(demodir)\tui.c $(demodir)\tui.h
127	$(BUILD) -I$(demodir) $(demodir)\tui.c
128
129tuidemo.obj: $(demodir)\tuidemo.c
130	$(BUILD) -I$(demodir) $(demodir)\tuidemo.c
131
132PLATFORM1 = Visual C++
133PLATFORM2 = Microsoft Visual C/C++ for Win32
134ARCNAME = pdc$(VER)_vc_w32
135
136!include $(PDCURSES_SRCDIR)\makedist.mif
137