1# Copyright (c) 2007-2009, 2013-2020 Paul Mattes.
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions
6# are met:
7#     * Redistributions of source code must retain the above copyright
8#       notice, this list of conditions and the following disclaimer.
9#     * Redistributions in binary form must reproduce the above copyright
10#       notice, this list of conditions and the following disclaimer in the
11#       documentation and/or other materials provided with the distribution.
12#     * Neither the name of Paul Mattes nor his contributors may be used
13#       to endorse or promote products derived from this software without
14#       specific prior written permission.
15#
16# THIS SOFTWARE IS PROVIDED BY PAUL MATTES "AS IS" AND ANY EXPRESS OR
17# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
19# NO EVENT SHALL PAUL MATTES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27# Makefile for ws3270
28
29# Set GT_PFX, NATIVE_SFX, NATIVECC, CC, WINDRES and WIN32_FLAGS.
30include winenv.mk
31
32MKFB = mkfb$(NATIVE_SFX)
33
34XCPPFLAGS = $(WIN32_FLAGS) -I$(THIS) -I$(TOP)/Common/s3270 -I$(TOP)/include
35CFLAGS = $(EXTRA_FLAGS) -g -Wall -Werror -MMD -MP $(XCPPFLAGS)
36
37ifdef WIN64
38HOST = win64
39else
40HOST = win32
41endif
42W = w
43include ws3270_files.mk libs.mk
44
45VOBJS = $(WS3270_OBJECTS) fallbacks.o ws3270res.o
46
47OBJECTS = $(VOBJS) version.o
48LIBS = -lws2_32 -lcomdlg32 -lgdi32 -lwinspool -lcrypt32 -lsecur32
49LIBDEPS = $(DEP3270) $(DEP32XX) $(DEP3270STUBS)
50SHRTLIBS = -lole32 -luuid
51DLLFLAGS = $(EXTRA_FLAGS) -mno-cygwin -shared -Wl,--export-all-symbols -Wl,--enable-auto-import
52
53PROGS = ws3270.exe s3270.exe x3270if.exe
54all: $(PROGS)
55
56XVERSION = xversion.c
57version.o: mkversion.sh $(VOBJS) $(LIBDEPS) version.txt
58	$(RM) $(XVERSION)
59	sh $< s3270 $(filter %.txt,$^) >$(XVERSION)
60	$(CC) $(CFLAGS) -c -o $@ $(XVERSION)
61	$(RM) $(XVERSION)
62
63FALLBACKS = fb-common
64fallbacks.c: $(MKFB) $(FALLBACKS)
65	$(RM) $@
66	./$(MKFB) -c -o $@ $(filter-out $(MKFB),$^)
67
68$(MKFB): mkfb.c
69	$(NATIVECC) -DFOR_WIN32 -I$(THIS) -MMD -MP -o $@ $^
70
71ws3270.exe.manifest: mkmanifest.sh version.txt manifest.tmpl
72	sh $< $(filter %.txt,$^) $(filter %.tmpl,$^) ws3270 "ws3270 scripting terminal emulator" $(WIN64) >$@.tmp
73	mv -f $@.tmp $@
74
75ws3270res.o: ws3270.rc ws3270.ico Makefile ws3270.exe.manifest
76	$(WINDRES) -i $< -o $@
77
78ws3270.exe: $(OBJECTS) $(LIBDEPS) Makefile
79	$(CC) -o ws3270.exe $(CFLAGS) $(OBJECTS) $(LD3270) $(LD32XX) $(LD3270STUBS) $(LIBS)
80
81s3270.exe: ws3270.exe
82	cp -p ws3270.exe $@
83
84x3270if.exe: ../x3270if/x3270if.exe
85	cp -p ../x3270if/x3270if.exe $@
86
87wversion.o: mkwversion.sh version.txt
88	sh $< ws3270 $(CC) $(filter %.txt,$^)
89
90clean:
91	rm -f *.o mkfb mkfb.exe fallbacks.c ws3270.exe.manifest
92
93clobber: clean
94	rm -f $(PROGS) *.d
95
96# Include auto-generated eependencies
97-include $(OBJS:.o=.d) mkfb.d
98