1166124Srafan##############################################################################
2166124Srafan# Copyright (c) 1998-2000,2006 Free Software Foundation, Inc.                #
3166124Srafan#                                                                            #
4166124Srafan# Permission is hereby granted, free of charge, to any person obtaining a    #
5166124Srafan# copy of this software and associated documentation files (the "Software"), #
6166124Srafan# to deal in the Software without restriction, including without limitation  #
7166124Srafan# the rights to use, copy, modify, merge, publish, distribute, distribute    #
8166124Srafan# with modifications, sublicense, and/or sell copies of the Software, and to #
9166124Srafan# permit persons to whom the Software is furnished to do so, subject to the  #
10166124Srafan# following conditions:                                                      #
11166124Srafan#                                                                            #
12166124Srafan# The above copyright notice and this permission notice shall be included in #
13166124Srafan# all copies or substantial portions of the Software.                        #
14166124Srafan#                                                                            #
15166124Srafan# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
16166124Srafan# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
17166124Srafan# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
18166124Srafan# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
19166124Srafan# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
20166124Srafan# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
21166124Srafan# DEALINGS IN THE SOFTWARE.                                                  #
22166124Srafan#                                                                            #
23166124Srafan# Except as contained in this notice, the name(s) of the above copyright     #
24166124Srafan# holders shall not be used in advertising or otherwise to promote the sale, #
25166124Srafan# use or other dealings in this Software without prior written               #
26166124Srafan# authorization.                                                             #
2750276Speter################################################################################
28166124Srafan# $Id: Makefile.os2,v 1.11 2006/04/22 21:46:17 tom Exp $
29166124Srafan#
3050276Speter# Wrapper Makefile for ncurses library under OS/2.
3150276Speter# Author:  Juan Jose Garcia Ripoll <worm@arrakis.es>.
3250276Speter# Webpage: http://www.arrakis.es/~worm/
3350276Speter################################################################################
3450276Speter#
3550276Speter# Notes (from I Zakharevich)
3650276Speter# ~~~~~~~~~~~~~~~~~~~~~~~~~~
3750276Speter# I could build the library with the following sequence of commands:
3850276Speter#
3950276Speter#   touch Makefile
4050276Speter#   make -f Makefile.os2 config
4166963Speter#   make -f Makefile.os2 CC=gcc HOSTCC=gcc CXX=gcc
4250276Speter#
4350276Speter# Ignoring the following errors:
4450276Speter#   Invalid configuration `os2'...
4550276Speter#   ... ac_maketemp="make": not found
4650276Speter#   ... syntax error: `done' unexpected
4750276Speter#   No rule to make target `lib/ncurses4.dll'
4850276Speter#
4950276Speter# You may need to run
5050276Speter#
5150276Speter#   rm make.defs
5250276Speter#   make -f Makefile.os2 make.defs
5350276Speter#
5450276Speter# if the build of misc/panel.def fails.
5550276Speter#
5650276Speter# If you do not have perl, the configuration will fail.  Use autoconf to
5750276Speter# generate the EMX-specific configure script (see README.emx), and run the
5850276Speter# configure script to generate the makefiles.  Then, run
5950276Speter#
6050276Speter#   make -f Makefile.os2 make.dlls
6150276Speter#
6250276Speter# Notes (from J J G Ripoll)
6350276Speter# ~~~~~~~~~~~~~~~~~~~~~~~~~
6450276Speter# The `make.defs' rule creates the new '.def' files and outputs a diagnostic
6550276Speter# about symbols that disappear from one release to the other, as well as
6650276Speter# checks about the new '.def' consistency.  If there were no problems, the
6750276Speter# maintainer is free to replace the `.ref' files with the newer ones using the
6850276Speter# `save.defs' rule.  So, the only tough work is ensuring that the symbols that
6950276Speter# disappear are not essential.
7050276Speter#
7150276Speter# I first thought about killing '_nc_*' symbols, but it seems that some of
7250276Speter# them --_nc_panel_hook, _nc_ada*, etc-- are needed outside ncurses.dll. 
7350276Speter# However, the whole size of the export table will not be larger than 1k or
7450276Speter# so.
7550276Speter#
7650276Speter# [installation]
7750276Speter#
7850276Speter# The way things are handled in misc/Makefile is not well suited for OS/2,
7950276Speter# where only emx.src is needed.  Thus, I've written a few wrapper rules in
8050276Speter# Makefile.os2 that handle installation/deinstallation.
8150276Speter#
8250276Speter# [distribution]
8350276Speter#
8450276Speter# There's also a new rule that configures and builds a sort of binary
8550276Speter# distribution, much like the one I prepared for 1.9.9e.  It's `os2dist'.
8650276Speter#
8750276Speter################################################################################
8850276Speter
8950276Speterall :: config
9050276Speter
9150276Speter# This is for configuring
9250276Speter
9350276Speter# What is a useful value for this?
9450276SpeterCONFIG_OPTS	= --enable-termcap
9550276SpeterWWWGET		= lynx -source
9650276SpeterMV_F		= mv -f
9750276SpeterDLL_LN_OPTS	= -Zcrtdll -Zdll -Zomf -Zmt
9850276Speter
9950276Speterconfig: config.cache
10050276Speter
10150276Speterconfig.cache: configure.cmd configure
10250276Speter	-$(MV_F) $@ $@.ref
10350276Speter	configure.cmd $(CONFIG_OPTS)
10450276Speter
10550276Speterconfigure.cmd: configure convert_configure.pl
10650276Speter	perl convert_configure.pl configure > $@
10750276Speter
10850276Speterconvert_configure.pl:
10950276Speter	$(WWWGET) ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/$@ > $@
11050276Speter
11150276Speterinstall ::
11250276Speter	echo ***
11350276Speter	echo *** Do not use this command. Use install.os2 instead.
11450276Speter	echo ***
11550276Speter	exit 2
11650276Speter
11750276Speterinstall.os2 : install.emxdata install.libs install.progs
11850276Speter
11950276Speterinclude ./Makefile
12050276Speter
12150276Speterall :: make.dlls
12250276Speter
12350276Speter#
12450276Speter# DLLs and that stuff
12550276Speter#
12650276Speter
12750276SpeterLIBRARIES = ncurses form menu panel
12850276Speter
12950276SpeterDLL_TAG = $(NCURSES_MAJOR)
13050276SpeterLIB_TAG = _s
13150276Speter
13250276SpeterDLL_ROOTS = $(addsuffix $(DLL_TAG), $(LIBRARIES))
13350276SpeterDLLS = $(addsuffix .dll, $(addprefix ./lib/, $(DLL_ROOTS)))
13450276Speter
13550276SpeterLIB_ROOTS = $(addsuffix $(LIB_TAG), $(LIBRARIES))
13650276SpeterLIBS = $(addsuffix .lib, $(addprefix ./lib/, $(LIB_ROOTS)))
13750276Speter
13850276SpeterLIBS_AOUT = $(addsuffix .a, $(addprefix ./lib/, $(LIB_ROOTS)))
13950276Speter
14050276SpeterDEFS = $(addsuffix .def, $(addprefix ./misc/, $(LIBRARIES)))
14150276Speter
14250276SpeterDLL_SIGNATURE = NCurses-$(NCURSES_MAJOR)-$(NCURSES_MINOR)-$(NCURSES_PATCH)
14350276Speter
14450276Speter./lib/%$(LIB_TAG).lib : ./misc/%.def
14550276Speter	emximp -o $@ $<
14650276Speter
14750276Speter./lib/%$(LIB_TAG).a : ./misc/%.def
14850276Speter	emximp -o $@ $<
14950276Speter
15050276Speter./lib/%$(DLL_TAG).dll : ./lib/%.a
15150276Speter	emxomf -o ./lib/$*$(DLL_TAG).lib $<
15250276Speter	if [ "$*" = "ncurses" ]; then \
15350276Speter		gcc $(LDFLAGS) $(DLL_LN_OPTS) ./lib/$*$(DLL_TAG).lib \
15450276Speter				./misc/$*.def -o $@; \
15550276Speter	else \
15650276Speter		gcc $(LDFLAGS) $(DLL_LN_OPTS) ./lib/$*$(DLL_TAG).lib \
15750276Speter				./lib/ncurses$(LIB_TAG).lib ./misc/$*.def -o $@; \
15850276Speter	fi
15950276Speter	-rm -f ./lib/$*$(DLL_TAG).lib
16050276Speter
16150276Spetermake.dlls : $(DEFS) $(LIBS) $(DLLS) $(LIBS_AOUT)
16250276Speter
16350276Speter$(DEFS) : make.defs
16450276Speter
16566963SpeterLIBDIR	= $(DESTDIR)$(libdir)
16650276Speter$(LIBDIR) :
16750276Speter	mkdir -p $@
16850276Speter
16950276Speterinstall.libs :: $(LIBS) $(DLLS) $(LIBDIR)
17050276Speter	@for i in $(DLL_ROOTS); do \
17150276Speter	echo installing ./lib/$$i.dll as $(LIBDIR)/$$i.dll; \
17250276Speter	$(INSTALL_DATA) ./lib/$$i.dll $(LIBDIR)/$$i.dll; done
17350276Speter	@for i in $(LIB_ROOTS); do \
17450276Speter	echo installing ./lib/$$i.lib as $(LIBDIR)/$$i.lib; \
17550276Speter	$(INSTALL_DATA) ./lib/$$i.lib $(LIBDIR)/$$i.lib; done
17650276Speter
17750276Speteruninstall.libs ::
17850276Speter	-@for i in $(DLL_ROOTS); do \
17950276Speter	echo uninstalling $(LIBDIR)/$$i.dll; \
18050276Speter	rm -f $(LIBDIR)/$$i.dll; done
18150276Speter	-@for i in $(LIB_ROOTS); do \
18250276Speter	echo uninstalling $(LIBDIR)/$$i.lib; \
18350276Speter	rm -f $(LIBDIR)/$$i.lib; done
18450276Speter
18550276Spetermake.defs :
18650276Speter	for i in $(LIBRARIES); do \
18750276Speter	echo LIBRARY $${i}$(DLL_TAG) INITINSTANCE TERMINSTANCE > ./misc/$$i.def; \
18850276Speter	echo DESCRIPTION \"$(DLL_SIGNATURE), module $$i\" >> ./misc/$$i.def; \
18950276Speter	echo CODE LOADONCALL >> ./misc/$$i.def; \
19050276Speter	echo DATA LOADONCALL NONSHARED MULTIPLE >> ./misc/$$i.def; \
19150276Speter	echo EXPORTS >> ./misc/$$i.def; \
19250276Speter	echo Creating $$i.def; \
19350276Speter	(cmd /C ".\\misc\\makedef.cmd ./lib/$$i.a ./misc/$$i.ref >> ./misc/$$i.def" \
19450276Speter	 && cmd /C ".\\misc\\chkdef.cmd ./misc/$$i.def") \
19550276Speter	|| exit 1; \
19650276Speter	done
19750276Speter	touch make.defs
19850276Speter
19950276Spetersave.defs :
20050276Speter	for i in $(LIBRARIES); do \
20150276Speter	test -f ./misc/$$i.def && cp ./misc/$$i.def ./misc/$$i.ref; \
20250276Speter	done
20350276Speter
20450276Speterclean \
20550276Speteros2clean ::
20650276Speter	-rm -f $(DLLS) $(LIBS)
20750276Speter
20850276Speterrealclean ::
20950276Speter	-rm -f $(addprefix ./misc/, $(addsuffix .def, $(LIBRARIES)))
21050276Speter
21150276Speter#
21250276Speter# This is a simplified version of misc/Makefile
21350276Speter#
21450276Speter
21566963SpeterTICDIR = $(DESTDIR)$(datadir)/terminfo
21666963SpeterTABSETDIR = $(DESTDIR)$(datadir)/tabset
21750276Speter
21850276Speter$(TICDIR) :
21950276Speter	mkdir -p $@
22050276Speter
22150276Speterinstall \
22250276Speterinstall.emxdata :: $(TICDIR)
22350276Speter	-@rm -fr $(TICDIR)/*
22450276Speter	echo Building terminfo database, please wait...
22550276Speter	set TERMINFO=$(TICDIR); ./progs/tic ./misc/emx.src
22650276Speter	echo Installing the terminfo cleaner and the sources...
22750276Speter	cp ./misc/emx.src ./misc/cleantic.cmd $(TICDIR)
22850276Speter	./misc/cleantic.cmd $(TICDIR)
22950276Speter
23050276Speteruninstall \
23150276Speteruninstall.emxdata ::
23250276Speter	-cd $(TICDIR) && rm -rf *
23350276Speter	-cd $(TABSETDIR) && rm -rf *
23450276Speter
23550276Speter#
23650276Speter# This is for preparing binary distributions
23750276Speter#
23850276Speter
23950276SpeterOS2NAME=ncurses-$(NCURSES_MAJOR).$(NCURSES_MINOR)-emx
24050276Speter
24150276Speter#
24250276Speter# FIXME: this assumes that we can rerun the configure script, changing only
24350276Speter# the install-prefix.  That means we cannot provide "interesting" options
24450276Speter# when building.
24550276Speter#
24650276Speteros2dist :
24750276Speter	$(MAKE) -f Makefile.os2 os2clean
24850276Speter	./configure --without-debug --with-install-prefix=`pwd|sed -e 's@^.:@@'`/$(OS2NAME)
24950276Speter	$(MAKE) -f Makefile.os2 $(CF_MFLAGS) install.os2
25050276Speter	-rm -f $(OS2NAME).zip
25150276Speter	echo NCurses-$(NCURSES_MAJOR).$(NCURSES_MINOR)-$(NCURSES_PATCH) for emx > $(OS2NAME)/FILE_ID.DIZ
25250276Speter	echo Binary release. >> $(OS2NAME)/FILE_ID.DIZ
25350276Speter	zip -r $(OS2NAME).zip ./$(OS2NAME)
25450276Speter
25550276Speterclean \
25650276Speteros2clean ::
25750276Speter	-rm -rf $(OS2NAME)
25850276Speter	-rm -f $(OS2NAME).zip
25950276Speter
260