xref: /freebsd/contrib/ncurses/Makefile.os2 (revision 21817992b3314c908ab50f0bb88d2ee750b9c4ac)
14a1a9510SRong-En Fan##############################################################################
2*21817992SBaptiste Daroussin# Copyright 2020,2021 Thomas E. Dickey                                       #
3e1865124SBaptiste Daroussin# Copyright 1998-2000,2006 Free Software Foundation, Inc.                    #
44a1a9510SRong-En Fan#                                                                            #
54a1a9510SRong-En Fan# Permission is hereby granted, free of charge, to any person obtaining a    #
64a1a9510SRong-En Fan# copy of this software and associated documentation files (the "Software"), #
74a1a9510SRong-En Fan# to deal in the Software without restriction, including without limitation  #
84a1a9510SRong-En Fan# the rights to use, copy, modify, merge, publish, distribute, distribute    #
94a1a9510SRong-En Fan# with modifications, sublicense, and/or sell copies of the Software, and to #
104a1a9510SRong-En Fan# permit persons to whom the Software is furnished to do so, subject to the  #
114a1a9510SRong-En Fan# following conditions:                                                      #
124a1a9510SRong-En Fan#                                                                            #
134a1a9510SRong-En Fan# The above copyright notice and this permission notice shall be included in #
144a1a9510SRong-En Fan# all copies or substantial portions of the Software.                        #
154a1a9510SRong-En Fan#                                                                            #
164a1a9510SRong-En Fan# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
174a1a9510SRong-En Fan# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
184a1a9510SRong-En Fan# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
194a1a9510SRong-En Fan# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
204a1a9510SRong-En Fan# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
214a1a9510SRong-En Fan# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
224a1a9510SRong-En Fan# DEALINGS IN THE SOFTWARE.                                                  #
234a1a9510SRong-En Fan#                                                                            #
244a1a9510SRong-En Fan# Except as contained in this notice, the name(s) of the above copyright     #
254a1a9510SRong-En Fan# holders shall not be used in advertising or otherwise to promote the sale, #
264a1a9510SRong-En Fan# use or other dealings in this Software without prior written               #
274a1a9510SRong-En Fan# authorization.                                                             #
280e3d5408SPeter Wemm################################################################################
29*21817992SBaptiste Daroussin# $Id: Makefile.os2,v 1.13 2021/06/17 21:20:30 tom Exp $
300e3d5408SPeter Wemm#
314a1a9510SRong-En Fan# Wrapper Makefile for ncurses library under OS/2.
320e3d5408SPeter Wemm# Author:  Juan Jose Garcia Ripoll <worm@arrakis.es>.
330e3d5408SPeter Wemm# Webpage: http://www.arrakis.es/~worm/
340e3d5408SPeter Wemm################################################################################
350e3d5408SPeter Wemm#
360e3d5408SPeter Wemm# Notes (from I Zakharevich)
370e3d5408SPeter Wemm# ~~~~~~~~~~~~~~~~~~~~~~~~~~
380e3d5408SPeter Wemm# I could build the library with the following sequence of commands:
390e3d5408SPeter Wemm#
400e3d5408SPeter Wemm#   touch Makefile
410e3d5408SPeter Wemm#   make -f Makefile.os2 config
4218259542SPeter Wemm#   make -f Makefile.os2 CC=gcc HOSTCC=gcc CXX=gcc
430e3d5408SPeter Wemm#
440e3d5408SPeter Wemm# Ignoring the following errors:
450e3d5408SPeter Wemm#   Invalid configuration `os2'...
460e3d5408SPeter Wemm#   ... ac_maketemp="make": not found
470e3d5408SPeter Wemm#   ... syntax error: `done' unexpected
480e3d5408SPeter Wemm#   No rule to make target `lib/ncurses4.dll'
490e3d5408SPeter Wemm#
500e3d5408SPeter Wemm# You may need to run
510e3d5408SPeter Wemm#
520e3d5408SPeter Wemm#   rm make.defs
530e3d5408SPeter Wemm#   make -f Makefile.os2 make.defs
540e3d5408SPeter Wemm#
550e3d5408SPeter Wemm# if the build of misc/panel.def fails.
560e3d5408SPeter Wemm#
570e3d5408SPeter Wemm# If you do not have perl, the configuration will fail.  Use autoconf to
580e3d5408SPeter Wemm# generate the EMX-specific configure script (see README.emx), and run the
590e3d5408SPeter Wemm# configure script to generate the makefiles.  Then, run
600e3d5408SPeter Wemm#
610e3d5408SPeter Wemm#   make -f Makefile.os2 make.dlls
620e3d5408SPeter Wemm#
630e3d5408SPeter Wemm# Notes (from J J G Ripoll)
640e3d5408SPeter Wemm# ~~~~~~~~~~~~~~~~~~~~~~~~~
650e3d5408SPeter Wemm# The `make.defs' rule creates the new '.def' files and outputs a diagnostic
660e3d5408SPeter Wemm# about symbols that disappear from one release to the other, as well as
670e3d5408SPeter Wemm# checks about the new '.def' consistency.  If there were no problems, the
680e3d5408SPeter Wemm# maintainer is free to replace the `.ref' files with the newer ones using the
690e3d5408SPeter Wemm# `save.defs' rule.  So, the only tough work is ensuring that the symbols that
700e3d5408SPeter Wemm# disappear are not essential.
710e3d5408SPeter Wemm#
720e3d5408SPeter Wemm# I first thought about killing '_nc_*' symbols, but it seems that some of
730e3d5408SPeter Wemm# them --_nc_panel_hook, _nc_ada*, etc-- are needed outside ncurses.dll.
740e3d5408SPeter Wemm# However, the whole size of the export table will not be larger than 1k or
750e3d5408SPeter Wemm# so.
760e3d5408SPeter Wemm#
770e3d5408SPeter Wemm# [installation]
780e3d5408SPeter Wemm#
790e3d5408SPeter Wemm# The way things are handled in misc/Makefile is not well suited for OS/2,
800e3d5408SPeter Wemm# where only emx.src is needed.  Thus, I've written a few wrapper rules in
810e3d5408SPeter Wemm# Makefile.os2 that handle installation/deinstallation.
820e3d5408SPeter Wemm#
830e3d5408SPeter Wemm# [distribution]
840e3d5408SPeter Wemm#
850e3d5408SPeter Wemm# There's also a new rule that configures and builds a sort of binary
860e3d5408SPeter Wemm# distribution, much like the one I prepared for 1.9.9e.  It's `os2dist'.
870e3d5408SPeter Wemm#
880e3d5408SPeter Wemm################################################################################
890e3d5408SPeter Wemm
900e3d5408SPeter Wemmall :: config
910e3d5408SPeter Wemm
920e3d5408SPeter Wemm# This is for configuring
930e3d5408SPeter Wemm
940e3d5408SPeter Wemm# What is a useful value for this?
950e3d5408SPeter WemmCONFIG_OPTS	= --enable-termcap
960e3d5408SPeter WemmWWWGET		= lynx -source
970e3d5408SPeter WemmMV_F		= mv -f
980e3d5408SPeter WemmDLL_LN_OPTS	= -Zcrtdll -Zdll -Zomf -Zmt
990e3d5408SPeter Wemm
1000e3d5408SPeter Wemmconfig: config.cache
1010e3d5408SPeter Wemm
1020e3d5408SPeter Wemmconfig.cache: configure.cmd configure
1030e3d5408SPeter Wemm	-$(MV_F) $@ $@.ref
1040e3d5408SPeter Wemm	configure.cmd $(CONFIG_OPTS)
1050e3d5408SPeter Wemm
1060e3d5408SPeter Wemmconfigure.cmd: configure convert_configure.pl
1070e3d5408SPeter Wemm	perl convert_configure.pl configure > $@
1080e3d5408SPeter Wemm
1090e3d5408SPeter Wemmconvert_configure.pl:
1100e3d5408SPeter Wemm	$(WWWGET) ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/$@ > $@
1110e3d5408SPeter Wemm
1120e3d5408SPeter Wemminstall ::
1130e3d5408SPeter Wemm	echo ***
1140e3d5408SPeter Wemm	echo *** Do not use this command. Use install.os2 instead.
1150e3d5408SPeter Wemm	echo ***
1160e3d5408SPeter Wemm	exit 2
1170e3d5408SPeter Wemm
1180e3d5408SPeter Wemminstall.os2 : install.emxdata install.libs install.progs
1190e3d5408SPeter Wemm
1200e3d5408SPeter Wemminclude ./Makefile
1210e3d5408SPeter Wemm
1220e3d5408SPeter Wemmall :: make.dlls
1230e3d5408SPeter Wemm
1240e3d5408SPeter Wemm#
1250e3d5408SPeter Wemm# DLLs and that stuff
1260e3d5408SPeter Wemm#
1270e3d5408SPeter Wemm
1280e3d5408SPeter WemmLIBRARIES = ncurses form menu panel
1290e3d5408SPeter Wemm
1300e3d5408SPeter WemmDLL_TAG = $(NCURSES_MAJOR)
1310e3d5408SPeter WemmLIB_TAG = _s
1320e3d5408SPeter Wemm
1330e3d5408SPeter WemmDLL_ROOTS = $(addsuffix $(DLL_TAG), $(LIBRARIES))
1340e3d5408SPeter WemmDLLS = $(addsuffix .dll, $(addprefix ./lib/, $(DLL_ROOTS)))
1350e3d5408SPeter Wemm
1360e3d5408SPeter WemmLIB_ROOTS = $(addsuffix $(LIB_TAG), $(LIBRARIES))
1370e3d5408SPeter WemmLIBS = $(addsuffix .lib, $(addprefix ./lib/, $(LIB_ROOTS)))
1380e3d5408SPeter Wemm
1390e3d5408SPeter WemmLIBS_AOUT = $(addsuffix .a, $(addprefix ./lib/, $(LIB_ROOTS)))
1400e3d5408SPeter Wemm
1410e3d5408SPeter WemmDEFS = $(addsuffix .def, $(addprefix ./misc/, $(LIBRARIES)))
1420e3d5408SPeter Wemm
1430e3d5408SPeter WemmDLL_SIGNATURE = NCurses-$(NCURSES_MAJOR)-$(NCURSES_MINOR)-$(NCURSES_PATCH)
1440e3d5408SPeter Wemm
1450e3d5408SPeter Wemm./lib/%$(LIB_TAG).lib : ./misc/%.def
1460e3d5408SPeter Wemm	emximp -o $@ $<
1470e3d5408SPeter Wemm
1480e3d5408SPeter Wemm./lib/%$(LIB_TAG).a : ./misc/%.def
1490e3d5408SPeter Wemm	emximp -o $@ $<
1500e3d5408SPeter Wemm
1510e3d5408SPeter Wemm./lib/%$(DLL_TAG).dll : ./lib/%.a
1520e3d5408SPeter Wemm	emxomf -o ./lib/$*$(DLL_TAG).lib $<
1530e3d5408SPeter Wemm	if [ "$*" = "ncurses" ]; then \
1540e3d5408SPeter Wemm		gcc $(LDFLAGS) $(DLL_LN_OPTS) ./lib/$*$(DLL_TAG).lib \
1550e3d5408SPeter Wemm				./misc/$*.def -o $@; \
1560e3d5408SPeter Wemm	else \
1570e3d5408SPeter Wemm		gcc $(LDFLAGS) $(DLL_LN_OPTS) ./lib/$*$(DLL_TAG).lib \
1580e3d5408SPeter Wemm				./lib/ncurses$(LIB_TAG).lib ./misc/$*.def -o $@; \
1590e3d5408SPeter Wemm	fi
1600e3d5408SPeter Wemm	-rm -f ./lib/$*$(DLL_TAG).lib
1610e3d5408SPeter Wemm
1620e3d5408SPeter Wemmmake.dlls : $(DEFS) $(LIBS) $(DLLS) $(LIBS_AOUT)
1630e3d5408SPeter Wemm
1640e3d5408SPeter Wemm$(DEFS) : make.defs
1650e3d5408SPeter Wemm
16618259542SPeter WemmLIBDIR	= $(DESTDIR)$(libdir)
1670e3d5408SPeter Wemm$(LIBDIR) :
1680e3d5408SPeter Wemm	mkdir -p $@
1690e3d5408SPeter Wemm
1700e3d5408SPeter Wemminstall.libs :: $(LIBS) $(DLLS) $(LIBDIR)
1710e3d5408SPeter Wemm	@for i in $(DLL_ROOTS); do \
1720e3d5408SPeter Wemm	echo installing ./lib/$$i.dll as $(LIBDIR)/$$i.dll; \
1730e3d5408SPeter Wemm	$(INSTALL_DATA) ./lib/$$i.dll $(LIBDIR)/$$i.dll; done
1740e3d5408SPeter Wemm	@for i in $(LIB_ROOTS); do \
1750e3d5408SPeter Wemm	echo installing ./lib/$$i.lib as $(LIBDIR)/$$i.lib; \
1760e3d5408SPeter Wemm	$(INSTALL_DATA) ./lib/$$i.lib $(LIBDIR)/$$i.lib; done
1770e3d5408SPeter Wemm
1780e3d5408SPeter Wemmuninstall.libs ::
1790e3d5408SPeter Wemm	-@for i in $(DLL_ROOTS); do \
1800e3d5408SPeter Wemm	echo uninstalling $(LIBDIR)/$$i.dll; \
1810e3d5408SPeter Wemm	rm -f $(LIBDIR)/$$i.dll; done
1820e3d5408SPeter Wemm	-@for i in $(LIB_ROOTS); do \
1830e3d5408SPeter Wemm	echo uninstalling $(LIBDIR)/$$i.lib; \
1840e3d5408SPeter Wemm	rm -f $(LIBDIR)/$$i.lib; done
1850e3d5408SPeter Wemm
1860e3d5408SPeter Wemmmake.defs :
1870e3d5408SPeter Wemm	for i in $(LIBRARIES); do \
1880e3d5408SPeter Wemm	echo LIBRARY $${i}$(DLL_TAG) INITINSTANCE TERMINSTANCE > ./misc/$$i.def; \
1890e3d5408SPeter Wemm	echo DESCRIPTION \"$(DLL_SIGNATURE), module $$i\" >> ./misc/$$i.def; \
1900e3d5408SPeter Wemm	echo CODE LOADONCALL >> ./misc/$$i.def; \
1910e3d5408SPeter Wemm	echo DATA LOADONCALL NONSHARED MULTIPLE >> ./misc/$$i.def; \
1920e3d5408SPeter Wemm	echo EXPORTS >> ./misc/$$i.def; \
1930e3d5408SPeter Wemm	echo Creating $$i.def; \
1940e3d5408SPeter Wemm	(cmd /C ".\\misc\\makedef.cmd ./lib/$$i.a ./misc/$$i.ref >> ./misc/$$i.def" \
1950e3d5408SPeter Wemm	 && cmd /C ".\\misc\\chkdef.cmd ./misc/$$i.def") \
1960e3d5408SPeter Wemm	|| exit 1; \
1970e3d5408SPeter Wemm	done
1980e3d5408SPeter Wemm	touch make.defs
1990e3d5408SPeter Wemm
2000e3d5408SPeter Wemmsave.defs :
2010e3d5408SPeter Wemm	for i in $(LIBRARIES); do \
2020e3d5408SPeter Wemm	test -f ./misc/$$i.def && cp ./misc/$$i.def ./misc/$$i.ref; \
2030e3d5408SPeter Wemm	done
2040e3d5408SPeter Wemm
2050e3d5408SPeter Wemmclean \
2060e3d5408SPeter Wemmos2clean ::
2070e3d5408SPeter Wemm	-rm -f $(DLLS) $(LIBS)
2080e3d5408SPeter Wemm
2090e3d5408SPeter Wemmrealclean ::
2100e3d5408SPeter Wemm	-rm -f $(addprefix ./misc/, $(addsuffix .def, $(LIBRARIES)))
2110e3d5408SPeter Wemm
2120e3d5408SPeter Wemm#
2130e3d5408SPeter Wemm# This is a simplified version of misc/Makefile
2140e3d5408SPeter Wemm#
2150e3d5408SPeter Wemm
21618259542SPeter WemmTICDIR = $(DESTDIR)$(datadir)/terminfo
21718259542SPeter WemmTABSETDIR = $(DESTDIR)$(datadir)/tabset
2180e3d5408SPeter Wemm
2190e3d5408SPeter Wemm$(TICDIR) :
2200e3d5408SPeter Wemm	mkdir -p $@
2210e3d5408SPeter Wemm
2220e3d5408SPeter Wemminstall \
2230e3d5408SPeter Wemminstall.emxdata :: $(TICDIR)
2240e3d5408SPeter Wemm	-@rm -fr $(TICDIR)/*
2250e3d5408SPeter Wemm	echo Building terminfo database, please wait...
2260e3d5408SPeter Wemm	set TERMINFO=$(TICDIR); ./progs/tic ./misc/emx.src
2270e3d5408SPeter Wemm	echo Installing the terminfo cleaner and the sources...
2280e3d5408SPeter Wemm	cp ./misc/emx.src ./misc/cleantic.cmd $(TICDIR)
2290e3d5408SPeter Wemm	./misc/cleantic.cmd $(TICDIR)
2300e3d5408SPeter Wemm
2310e3d5408SPeter Wemmuninstall \
2320e3d5408SPeter Wemmuninstall.emxdata ::
2330e3d5408SPeter Wemm	-cd $(TICDIR) && rm -rf *
2340e3d5408SPeter Wemm	-cd $(TABSETDIR) && rm -rf *
2350e3d5408SPeter Wemm
2360e3d5408SPeter Wemm#
2370e3d5408SPeter Wemm# This is for preparing binary distributions
2380e3d5408SPeter Wemm#
2390e3d5408SPeter Wemm
2400e3d5408SPeter WemmOS2NAME=ncurses-$(NCURSES_MAJOR).$(NCURSES_MINOR)-emx
2410e3d5408SPeter Wemm
2420e3d5408SPeter Wemm#
2430e3d5408SPeter Wemm# FIXME: this assumes that we can rerun the configure script, changing only
2440e3d5408SPeter Wemm# the install-prefix.  That means we cannot provide "interesting" options
2450e3d5408SPeter Wemm# when building.
2460e3d5408SPeter Wemm#
2470e3d5408SPeter Wemmos2dist :
2480e3d5408SPeter Wemm	$(MAKE) -f Makefile.os2 os2clean
2490e3d5408SPeter Wemm	./configure --without-debug --with-install-prefix=`pwd|sed -e 's@^.:@@'`/$(OS2NAME)
2500e3d5408SPeter Wemm	$(MAKE) -f Makefile.os2 $(CF_MFLAGS) install.os2
2510e3d5408SPeter Wemm	-rm -f $(OS2NAME).zip
2520e3d5408SPeter Wemm	echo NCurses-$(NCURSES_MAJOR).$(NCURSES_MINOR)-$(NCURSES_PATCH) for emx > $(OS2NAME)/FILE_ID.DIZ
2530e3d5408SPeter Wemm	echo Binary release. >> $(OS2NAME)/FILE_ID.DIZ
2540e3d5408SPeter Wemm	zip -r $(OS2NAME).zip ./$(OS2NAME)
2550e3d5408SPeter Wemm
2560e3d5408SPeter Wemmclean \
2570e3d5408SPeter Wemmos2clean ::
2580e3d5408SPeter Wemm	-rm -rf $(OS2NAME)
2590e3d5408SPeter Wemm	-rm -f $(OS2NAME).zip
2600e3d5408SPeter Wemm
261