# Copyright (c) 2015-2025 Paul Mattes.
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of Paul Mattes nor his contributors may be used
#       to endorse or promote products derived from this software without
#       specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY PAUL MATTES "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
# NO EVENT SHALL PAUL MATTES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Top-level auxiliary Makefile for suite3270.

all:
	@echo "Must pick a specific make target."
	@false

FORCE:

src.tgz: prepare man Webpage program-src
	./mktar.sh

prepare: configure
configure: configure.in
	autoconf
PREPARE = Webpage-prepare b3270-prepare c3270-prepare ibm_hosts-prepare \
	lib-prepare mitm-prepare pr3287-prepare s3270-prepare tcl3270-prepare \
	wb3270-prepare wc3270-prepare ws3270-prepare x3270-prepare \
	x3270if-prepare
prepare: $(PREPARE)
$(PREPARE):
	$(MAKE) -C $(@:-prepare=) -f Makefile.aux prepare VPATH=../Common -I../Common

man: prepare
MAN = b3270-man c3270-man ibm_hosts-man mitm-man pr3287-man s3270-man \
	tcl3270-man wb3270-man wc3270-man wmitm-man wpr3287-man ws3270-man \
	wx3270if-man x3270-man x3270if-man
man: $(MAN)
$(MAN):
	$(MAKE) -C $(@:-man=) -f Makefile.aux man VPATH=../Common -I../Common

Webpage: program-src man FORCE
	$(MAKE) -C Webpage VPATH=../Common -I../Common

PROGRAMSRC = b3270-src.tgz c3270-src.tgz ibm_hosts-src.tgz lib-src.tgz \
	mitm-src.tgz playback-src.tgz pr3287-src.tgz s3270-src.tgz \
	tcl3270-src.tgz wb3270-src.tgz wc3270-src.tgz wmitm-src.tgz \
	wpr3287-src.tgz ws3270-src.tgz wx3270if-src.tgz x3270-src.tgz \
	x3270if-src.tgz
program-src: $(PROGRAMSRC)
$(PROGRAMSRC):
	$(MAKE) -C $(@:-src.tgz=) -f Makefile.aux src.tgz VPATH=../Common -I../Common

# Target for building the Inno Setup .exe file and the .zip file.
include Common/dirnames
windows-release: man
	rm -f config.cache
	./configure -C --host=$(win32)
	$(MAKE) -j12
	rm -f config.cache
	./configure -C --host=$(win64)
	$(MAKE) -j12
	$(MAKE) -C wc3270 -f Makefile.aux $@ VPATH=../Common -I../Common

clean: release-clean doxygen-clean

release-clean:
	rm -rf obj/release/*

DOXY = Common/doxygen/mkdoxy -v Common/version.txt -t Common/doxygen/Doxyfile.tmpl
UDOXYGEN = doxygen-b3270 doxygen-c3270 doxygen-pr3287 doxygen-s3270 doxygen-x3270 doxygen-x3270if
WDOXYGEN = doxygen-wb3270 doxygen-wc3270 doxygen-wpr3287 doxygen-ws3270 doxygen-wx3270if
doxygen: $(UDOXYGEN) $(WDOXYGEN) doxygen-wizard
$(UDOXYGEN):
	$(DOXY) -p $(@:doxygen-%=%)/Doxygen.opts -o obj/doxygen/posix/$(@:doxygen-%=%)
$(WDOXYGEN):
	$(DOXY) -p $(@:doxygen-%=%)/Doxygen.opts -o obj/doxygen/windows/$(@:doxygen-w%=%)
doxygen-wizard:
	$(DOXY) -p wc3270/Doxygen-wizard.opts -o obj/doxygen/windows/wizard
doxygen-clean:
	rm -rf obj/doxygen/*
