1!ifndef MSDOS WIN16 WIN32 OS2
2# -*- mode: sh; mode: fold -*-
3# This file has been folded.  It is far more comprehensible when viewed with
4# an editor that supports folding.
5
6#{{{ MACRO descriptions
7
8This is a master makefile that from which DOS/Windows/OS2 makefiles
9may be derived.  A makefile for a particular system may be derived by
10passing this through the standalone DOS executable 'mkmake' which
11should be present in this directory.  For example, to produce a makefile
12suitable for OS2 using the EMX compiler use:
13
14    mkmake OS2 EMX < makefile.all > Makefile
15
16Similarly,
17
18    mkmake MSDOS BCC < makefile.all > Makefile
19
20will produce a makefile for MSDOS and the Borland C compiler.
21
22Currently supported environments include:
23
24   MSDOS WIN16 WIN32 OS2
25
26Currently supported compilers include:
27
28   MSDOS - BCC, DJGPP, DJGPP_V1
29   WIN16 - BCC
30   WIN32 - BCC, VC, CYGWIN32, MINGW32
31     OS2 - EMX, ICC
32
33If are linking against a dll version of slang,
34add a 'DLL' parameter to mkmake:
35
36   mkmake WIN32 VC DLL < makefile.all > Makefile
37
38(right now this is known to work only with Visual Studio).
39
40Each section must define the following macros:
41
42 CC             : The C compiler
43 CFLAGS		: Compiler flags
44 P		: Path separator used by make/compiler
45 O		: Object file extension
46 SRCDIR		: SRC location (.)
47 OBJDIR		: Directory where objects are placed
48 COMPILE_CMD	: Command used to produce object from .c file
49 LINK_CMD       : Command used to produce executable
50 LIBDEPS	: Other dependencies library depends upon
51 TARGET		: Primary target name
52 SLANGLIB       : Location of slang library
53 SLANGINC       : Location of slang.h
54 TARGET_DEPS    : Misc stuff to build
55 COMPILE_DEPS   : Dependencies associated with COMPILE_CMD
56 COPY		: Copy command
57 RM		: What to use to delete a file
58
59Other macros include:
60
61 RSPFILE	: Name of response file
62 RSP_PREFIX	: Prefix for response file line (See its usage)
63 RSP_POSTFIX	: Postfix for response file line (See its usage)
64 DEF_FILE       : *.def file
65 RC		: resource compiler
66 RC_FILE	: resource compiler base name (e.g. wjed)
67
68Special notes:
69
70 The P macro could be problematic when its value is a backslash (\).  Some
71 make programs may require it to be doubled, i.e., \\.  Whatever its value is,
72 it should expand to something that does not include whitespace.  Usually
73 this requires that it be followed by a '#' character; however, this may
74 result in the '#' character being quoted, or, escaped if the value of P is
75 a backslash.
76
77#}}}
78!else   #rest of file
79# Note:
80# This makefile was automatically generated from the master makefile.all.
81TOOL_PREFIX =
82!ifdef MSDOS #{{{
83! ifdef DJGPP DJGPP_V1 #{{{
84CC = gcc
85CFLAGS = -O2 -fno-strength-reduce -Wall
86P = /# path sep
87O = o # Object extension
88SRCDIR = .# Location of sources
89OBJDIR = djgobjs# Location of objects
90TARGET = $(OBJDIR)/slsh.exe
91RSPFILE = $(OBJDIR)/link.rsp
92RSP_PREFIX =
93RSP_POSTFIX =
94SLANGINC = ../src
95SLANGLIB = $(SLANGINC)/$(OBJDIR)
96COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -o #
97!   ifndef DJGPP_V1
98LINK_CMD = $(CC) -s -L$(SLANGLIB) -o $(TARGET) @$(RSPFILE) -lslang
99!   else
100GO32 = G:/djgpp/bin/go32.exe
101!   endif
102COMPILE_DEPS =
103TARGET_DEPS =
104RM = rm
105COPY = cp
106#}}}
107! elifdef BCC #{{{
108CC = bcc
109CFLAGS = -G- -H -N -O1 -w -ml -Dmsdos
110P = \\
111O = obj
112SRCDIR = .
113OBJDIR = bccobjs
114TARGET = $(OBJDIR)\slsh.exe
115RSPFILE = $(OBJDR)\bcc.rsp
116RSP_PREFIX =
117RSP_POSTFIX =
118SLANGINC = ..\src
119SLANGLIB = $(SLANGINC)\$(OBJDIR)
120COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -o#  <-- no tailing space
121LINK_CMD = $(CC) -ml -L$(SLANGLIB) -e$(TARGET) /P=4096 @$(RSPFILE) slang.lib
122COMPILE_DEPS =
123TARGET_DEPS =
124RM = del
125COPY = copy /y
126#}}}
127! endif
128#}}}
129!endif
130!ifdef WIN16 #{{{
131! ifdef BCC #{{{
132CC = bcc
133CFLAGS = -G- -H -N -w -ml -Dmsdos -D__WIN16__ -W
134#CFLAGS = -N -v  -H -w -ml -Dmsdos -DMSWINDOWS -WS
135OBJDIR = mswobjs# Location of objects
136TARGET = $(OBJDIR)\slsh.exe
137BCCLIB = C:\BCC31\LIB
138O = obj # Object extension
139P = \\
140SRCDIR = .# Location of sources
141SLANGINC = ..\src
142SLANGLIB = $(SLANGINC)\$(OBJDIR)
143RSPFILE = $(OBJDIR)\mswin.rsp
144RSP_PREFIX =
145RSP_POSTFIX = +
146COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -o#
147LINK_CMD = tlink /Twe/m/v/c/P/i/s $(BCCLIB)\c0wl @$(RSPFILE)
148MSWSHELL_EXE = ..\bin\mswshell.exe
149DEF_FILE = $(OBJDIR)\slsh.def
150TARGET_DEPS = $(MSWSHELL_EXE) $(DEF_FILE)
151COMPILE_DEPS =
152RM = del
153COPY = copy /y
154#}}}
155! endif
156#}}}
157!endif
158!ifdef WIN32 #{{{
159! ifdef BCC #{{{
160CC = bcc32
161#CFLAGS = -G- -H -N -w -D__WIN32__ -W
162CFLAGS = -G- -H -N -w -W -w-sig -w-stu
163# Location of objects
164OBJDIR = bw32objs
165TARGET = $(OBJDIR)\slsh.exe
166BCCLIB = C:\BC5\LIB
167# Object extension
168O = obj
169P = \\ # Comment to prevent continuation marker confusion with Borland Make
170SRCDIR = .
171RSPFILE = $(OBJDIR)\link.rsp
172RSPFILE2 = $(OBJDIR)\link2.rsp
173RSP_PREFIX =
174RSP_POSTFIX = +
175COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -o
176LINK_CMD = tlink32 /Tpe /ap /c /x $(BCCLIB)\c0x32 @$(RSPFILE), $(OBJDIR)$(P)slsh.exe, @$(RSPFILE2)
177DEF_FILE =
178TARGET_DEPS = $(RSPFILE2)
179COMPILE_DEPS =
180RM = del
181COPY = copy /y
182#}}}
183! elifdef VC #{{{
184# Makefile for slang as Win32 GUI using nmake under Visual C.
185CC = cl
186CFLAGS = /nologo /W3 /O2 /D "NDEBUG" /D $(CPU) /D "__WIN32__" /D "_CRT_SECURE_NO_WARNINGS" /D "_CRT_NONSTDC_NO_DEPRECATE" /I "." /I $(SLANGINC)
187P = \\
188O = obj # Object extension
189SRCDIR = .# Location of sources
190OBJDIR = mw32objs# Location of objects
191RSPFILE = $(OBJDIR)\link.rsp
192RSP_PREFIX =
193RSP_POSTFIX =
194COMPILE_RSP = $(OBJDIR)\comp.rsp
195COMPILE_CMD = $(CC) /c $(CFLAGS) @$(COMPILE_RSP) /Fo # /Fo specifies object file name
196RC = rc
197RC_FILE = mkfiles\slsh
198RES_FILE = $(OBJDIR)\slsh.res
199TARGET_DEPS = $(RES_FILE)
200COMPILE_DEPS = $(COMPILE_RSP)
201RM = del
202COPY = copy /y
203LINK_CMD = link -out:$(OBJDIR)$(P)slsh.exe /SUBSYSTEM:console @$(RSPFILE) $(RES_FILE)
204# This needs changing for Windows NT on non-Intel processors
205CPU = _X86_
206#}}}
207! elifdef CYGWIN32 MINGW32 #{{{
208CC = $(TOOL_PREFIX)gcc
209P = /
210WFLAGS = -W -Wall
211!  ifdef CYGWIN32
212CFLAGS = -DWIN32 -O2 -fno-strength-reduce $(WFLAGS) -mno-cygwin
213!  else
214!   ifdef DLL
215DLL_FLAGS = -DSLANG_DLL=1
216!   endif
217CFLAGS = -DWIN32 -O2 -fno-strength-reduce $(WFLAGS) $(DLL_FLAGS)
218!  endif
219LINK_CMD = $(CC) -s -L$(SLANGLIB) -o $(OBJDIR)$(P)slsh.exe $(OBJS) -lslang -luser32
220OBJDIR = gw32objs# Location of objects
221O = o # Object extension
222SRCDIR = .# Location of sources
223RSPFILE =
224RSP_PREFIX =
225RSP_POSTFIX =
226DEFS = -DSLSH_CONF_DIR='"$(SLSH_CONF_DIR)"' -DSLSH_PATH='"$(SLSH_LIB_DIR)"'
227COMPILE_CMD = $(CC) -c $(CFLAGS) $(DEFS) -I$(SLANGINC) -o #
228SLSH_CONF_DIR = /etc
229SLSH_LIB_DIR = /usr/share/slsh
230COMPILE_DEPS =
231RM = rm
232COPY = cp
233#}}}
234! endif
235TARGET = $(OBJDIR)$(P)slsh.exe
236SLANGINC = ..$(P)src
237SLANGLIB = ..$(P)src$(P)$(OBJDIR)
238#}}}
239!endif
240!ifdef OS2 #{{{
241! ifdef EMX #{{{
242CC = gcc -Zmtd
243CFLAGS = -DOS2 -D__os2__
244P = /
245O = o # Object extension
246SRCDIR = .# Location of sources
247OBJDIR = emxobjs# Location of objects
248SLANGINC = ../src
249SLANGLIB = ../src/$(OBJDIR)
250TARGET = $(OBJDIR)/slsh.exe
251COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -o #
252DEF_FILE = $(OBJDIR)/slsh.def
253LINK_CMD = $(CC) -o $(TARGET) $(OBJS) -L$(SLANGLIB) $(DEF_FILE) -lslang -lvideo
254TARGET_DEPS = $(DEF_FILE)
255COMPILE_DEPS =
256RM = rm
257COPY = cp
258#}}}
259! elifdef WCC #{{{
260CC = wcc386
261CFLAGS = -DOS2 -D__os2__ -bm -bt=os2 #
262P = \#
263O = obj # Object extension
264SRCDIR = .# Location of sources
265OBJDIR = wccobjs# Location of objects
266SLANGINC = ..\src
267SLANGLIB = ..\src\$(OBJDIR)\slang.lib
268TARGET = $(OBJDIR)\slsh.exe
269COMPILE_CMD = $(CC) $(CFLAGS) -I=$(SLANGINC) -fo=#
270DEF_FILE =
271LINK_CMD = wcl386 -fe=$(TARGET) $(OBJS) $(SLANGLIB) -k150000 # -lvideo
272TARGET_DEPS =
273COMPILE_DEPS =
274RM = del
275COPY = copy /y
276#}}}
277! elifdef ICC #{{{
278CC = icc
279CFLAGS = -Q+ -W3 -DOS2 -D__os2__ -Gm+ -Wcnd-
280P = \#
281O = obj
282SRCDIR = .
283OBJDIR = iccobjs
284SLANGINC = ..\src
285SLANGLIB = ..\src\$(OBJDIR)\slang.lib
286TARGET = $(OBJDIR)\slsh.exe
287COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -Fo#  <-- no trailing space
288DEF_FILE =
289LINK_CMD = $(CC) -Fe$(TARGET) $(OBJS) $(SLANGLIB)
290TARGET_DEPS =
291COMPILE_DEPS =
292RM = del
293COPY = copy /y
294#}}}
295! endif
296#}}}
297!endif
298#-------------------------------------------------------------------------------
299
300# End of compiler specific section
301
302#{{{ OBJS =
303OBJS = $(OBJDIR)$(P)slsh.$(O) $(OBJDIR)$(P)readline.$(O)
304#}}}
305
306! ifdef WIN32
307slsh: $(TARGET)
308	@echo slsh created in $(OBJDIR)
309$(TARGET): $(OBJDIR) $(RSPFILE) $(OBJS) $(TARGET_DEPS)
310	$(LINK_CMD)
311!  ifdef VC
312$(RES_FILE): $(RC_FILE).rc
313	$(RC) /fo $(RES_FILE) $(RC_FILE).rc
314$(COMPILE_RSP) :
315	echo $(CFLAGS) > $(COMPILE_RSP)
316!   ifdef DLL
317	echo /DSLANG_DLL=1 >> $(COMPILE_RSP)
318!   endif
319!  elifdef BCC
320$(RSPFILE2) : makefile
321	@echo $(OBJDIR)$(P)slsh.map > $(RSPFILE2)
322	@echo $(SLANGLIB)$(P)wslang+ >> $(RSPFILE2)
323	@echo $(BCCLIB)$(P)import32+ >> $(RSPFILE2)
324	@echo $(BCCLIB)$(P)cw32 >> $(RSPFILE2)
325!   ifdef WIN16 EMX
326	@echo $(DEF_FILE) >> $(RSPFILE2)
327!   endif
328!  endif
329! else
330$(TARGET): $(OBJDIR) $(RSPFILE) $(OBJS) $(TARGET_DEPS)
331!  ifndef DJGPP_V1
332	$(LINK_CMD)
333!  else
334	$(CC) -s @$(RSPFILE) -L$(SLANGLIB) -lslang -lpc -o $(OBJDIR)/slsh.386
335	strip $(OBJDIR)/slsh.386
336	coff2exe -s $(GO32) $(OBJDIR)/slsh.386
337!  endif
338! endif # WIN32
339
340! ifndef EMX CYGWIN32 MINGW32 ICC
341#{{{ $(RSPFILE)
342$(RSPFILE) : makefile
343	echo Creating response file $(RSPFILE)
344!  ifdef VC
345	@echo /NOLOGO user32.lib gdi32.lib > $(RSPFILE)
346	@echo winspool.lib comdlg32.lib advapi32.lib shell32.lib >> $(RSPFILE)
347!  endif
348	@echo $(RSP_PREFIX)$(OBJDIR)$(P)slsh.$(O) >> $(RSPFILE)
349	@echo $(RSP_PREFIX)$(OBJDIR)$(P)readline.$(O) >> $(RSPFILE)
350!  ifdef WIN16
351	@echo $(TARGET) >> $(RSPFILE)
352	@echo slsh.map >> $(RSPFILE)
353	@echo $(SLANGLIB)\wslang+ >> $(RSPFILE)
354	@echo $(BCCLIB)\import+ >> $(RSPFILE)
355	@echo $(BCCLIB)\mathwl+ >> $(RSPFILE)
356	@echo $(BCCLIB)\cwl >> $(RSPFILE)
357	@echo $(DEF_FILE) >> $(RSPFILE)
358!endif
359!ifdef WIN32
360!ifdef VC
361	@echo $(SLANGLIB)\WSLANG32.LIB >> $(RSPFILE)
362!endif
363!endif
364#}}}
365!endif  #NOT EMX
366
367$(OBJDIR) :
368	-mkdir $(OBJDIR)
369
370! ifdef WIN16 EMX
371#{{{ $(DEF_FILE)
372
373$(DEF_FILE) :
374	@echo creating $(DEF_FILE)
375! ifdef WIN16
376	@echo NAME      SLSH > $(DEF_FILE)
377	@echo EXETYPE   WINDOWS >> $(DEF_FILE)
378	@echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(DEF_FILE)
379	@echo DATA PRELOAD MOVEABLE >> $(DEF_FILE)
380	@echo HEAPSIZE 100 >> $(DEF_FILE)
381	@echo STACKSIZE 16384 >> $(DEF_FILE)
382! endif
383! ifdef EMX
384	@echo NAME SLSH WINDOWCOMPAT > $(DEF_FILE)
385	@echo DESCRIPTION 'SLSH for OS/2' >> $(DEF_FILE)
386	@echo STACKSIZE 150000 >> $(DEF_FILE)
387! endif
388
389#}}}
390!endif
391
392$(OBJDIR)$(P)slsh.$(O) : $(SRCDIR)$(P)slsh.c $(COMPILE_DEPS)
393	$(COMPILE_CMD)$(OBJDIR)$(P)slsh.$(O) $(SRCDIR)$(P)slsh.c
394$(OBJDIR)$(P)readline.$(O) : $(SRCDIR)$(P)readline.c $(COMPILE_DEPS)
395	$(COMPILE_CMD)$(OBJDIR)$(P)readline.$(O) $(SRCDIR)$(P)readline.c
396
397clean:
398	-cd $(OBJDIR) && $(RM) *.$(O) *.exe
399
400!endif   #NOT HELP
401
402