xref: /freebsd/contrib/ncurses/Makefile.os2 (revision 81966bce06dac45f42bda62b14dba0756ef28505)
1##############################################################################
2# Copyright (c) 1998-2000,2006 Free Software Foundation, Inc.                #
3#                                                                            #
4# Permission is hereby granted, free of charge, to any person obtaining a    #
5# copy of this software and associated documentation files (the "Software"), #
6# to deal in the Software without restriction, including without limitation  #
7# the rights to use, copy, modify, merge, publish, distribute, distribute    #
8# with modifications, sublicense, and/or sell copies of the Software, and to #
9# permit persons to whom the Software is furnished to do so, subject to the  #
10# following conditions:                                                      #
11#                                                                            #
12# The above copyright notice and this permission notice shall be included in #
13# all copies or substantial portions of the Software.                        #
14#                                                                            #
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
18# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
20# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
21# DEALINGS IN THE SOFTWARE.                                                  #
22#                                                                            #
23# Except as contained in this notice, the name(s) of the above copyright     #
24# holders shall not be used in advertising or otherwise to promote the sale, #
25# use or other dealings in this Software without prior written               #
26# authorization.                                                             #
27################################################################################
28# $Id: Makefile.os2,v 1.11 2006/04/22 21:46:17 tom Exp $
29#
30# Wrapper Makefile for ncurses library under OS/2.
31# Author:  Juan Jose Garcia Ripoll <worm@arrakis.es>.
32# Webpage: http://www.arrakis.es/~worm/
33################################################################################
34#
35# Notes (from I Zakharevich)
36# ~~~~~~~~~~~~~~~~~~~~~~~~~~
37# I could build the library with the following sequence of commands:
38#
39#   touch Makefile
40#   make -f Makefile.os2 config
41#   make -f Makefile.os2 CC=gcc HOSTCC=gcc CXX=gcc
42#
43# Ignoring the following errors:
44#   Invalid configuration `os2'...
45#   ... ac_maketemp="make": not found
46#   ... syntax error: `done' unexpected
47#   No rule to make target `lib/ncurses4.dll'
48#
49# You may need to run
50#
51#   rm make.defs
52#   make -f Makefile.os2 make.defs
53#
54# if the build of misc/panel.def fails.
55#
56# If you do not have perl, the configuration will fail.  Use autoconf to
57# generate the EMX-specific configure script (see README.emx), and run the
58# configure script to generate the makefiles.  Then, run
59#
60#   make -f Makefile.os2 make.dlls
61#
62# Notes (from J J G Ripoll)
63# ~~~~~~~~~~~~~~~~~~~~~~~~~
64# The `make.defs' rule creates the new '.def' files and outputs a diagnostic
65# about symbols that disappear from one release to the other, as well as
66# checks about the new '.def' consistency.  If there were no problems, the
67# maintainer is free to replace the `.ref' files with the newer ones using the
68# `save.defs' rule.  So, the only tough work is ensuring that the symbols that
69# disappear are not essential.
70#
71# I first thought about killing '_nc_*' symbols, but it seems that some of
72# them --_nc_panel_hook, _nc_ada*, etc-- are needed outside ncurses.dll.
73# However, the whole size of the export table will not be larger than 1k or
74# so.
75#
76# [installation]
77#
78# The way things are handled in misc/Makefile is not well suited for OS/2,
79# where only emx.src is needed.  Thus, I've written a few wrapper rules in
80# Makefile.os2 that handle installation/deinstallation.
81#
82# [distribution]
83#
84# There's also a new rule that configures and builds a sort of binary
85# distribution, much like the one I prepared for 1.9.9e.  It's `os2dist'.
86#
87################################################################################
88
89all :: config
90
91# This is for configuring
92
93# What is a useful value for this?
94CONFIG_OPTS	= --enable-termcap
95WWWGET		= lynx -source
96MV_F		= mv -f
97DLL_LN_OPTS	= -Zcrtdll -Zdll -Zomf -Zmt
98
99config: config.cache
100
101config.cache: configure.cmd configure
102	-$(MV_F) $@ $@.ref
103	configure.cmd $(CONFIG_OPTS)
104
105configure.cmd: configure convert_configure.pl
106	perl convert_configure.pl configure > $@
107
108convert_configure.pl:
109	$(WWWGET) ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/$@ > $@
110
111install ::
112	echo ***
113	echo *** Do not use this command. Use install.os2 instead.
114	echo ***
115	exit 2
116
117install.os2 : install.emxdata install.libs install.progs
118
119include ./Makefile
120
121all :: make.dlls
122
123#
124# DLLs and that stuff
125#
126
127LIBRARIES = ncurses form menu panel
128
129DLL_TAG = $(NCURSES_MAJOR)
130LIB_TAG = _s
131
132DLL_ROOTS = $(addsuffix $(DLL_TAG), $(LIBRARIES))
133DLLS = $(addsuffix .dll, $(addprefix ./lib/, $(DLL_ROOTS)))
134
135LIB_ROOTS = $(addsuffix $(LIB_TAG), $(LIBRARIES))
136LIBS = $(addsuffix .lib, $(addprefix ./lib/, $(LIB_ROOTS)))
137
138LIBS_AOUT = $(addsuffix .a, $(addprefix ./lib/, $(LIB_ROOTS)))
139
140DEFS = $(addsuffix .def, $(addprefix ./misc/, $(LIBRARIES)))
141
142DLL_SIGNATURE = NCurses-$(NCURSES_MAJOR)-$(NCURSES_MINOR)-$(NCURSES_PATCH)
143
144./lib/%$(LIB_TAG).lib : ./misc/%.def
145	emximp -o $@ $<
146
147./lib/%$(LIB_TAG).a : ./misc/%.def
148	emximp -o $@ $<
149
150./lib/%$(DLL_TAG).dll : ./lib/%.a
151	emxomf -o ./lib/$*$(DLL_TAG).lib $<
152	if [ "$*" = "ncurses" ]; then \
153		gcc $(LDFLAGS) $(DLL_LN_OPTS) ./lib/$*$(DLL_TAG).lib \
154				./misc/$*.def -o $@; \
155	else \
156		gcc $(LDFLAGS) $(DLL_LN_OPTS) ./lib/$*$(DLL_TAG).lib \
157				./lib/ncurses$(LIB_TAG).lib ./misc/$*.def -o $@; \
158	fi
159	-rm -f ./lib/$*$(DLL_TAG).lib
160
161make.dlls : $(DEFS) $(LIBS) $(DLLS) $(LIBS_AOUT)
162
163$(DEFS) : make.defs
164
165LIBDIR	= $(DESTDIR)$(libdir)
166$(LIBDIR) :
167	mkdir -p $@
168
169install.libs :: $(LIBS) $(DLLS) $(LIBDIR)
170	@for i in $(DLL_ROOTS); do \
171	echo installing ./lib/$$i.dll as $(LIBDIR)/$$i.dll; \
172	$(INSTALL_DATA) ./lib/$$i.dll $(LIBDIR)/$$i.dll; done
173	@for i in $(LIB_ROOTS); do \
174	echo installing ./lib/$$i.lib as $(LIBDIR)/$$i.lib; \
175	$(INSTALL_DATA) ./lib/$$i.lib $(LIBDIR)/$$i.lib; done
176
177uninstall.libs ::
178	-@for i in $(DLL_ROOTS); do \
179	echo uninstalling $(LIBDIR)/$$i.dll; \
180	rm -f $(LIBDIR)/$$i.dll; done
181	-@for i in $(LIB_ROOTS); do \
182	echo uninstalling $(LIBDIR)/$$i.lib; \
183	rm -f $(LIBDIR)/$$i.lib; done
184
185make.defs :
186	for i in $(LIBRARIES); do \
187	echo LIBRARY $${i}$(DLL_TAG) INITINSTANCE TERMINSTANCE > ./misc/$$i.def; \
188	echo DESCRIPTION \"$(DLL_SIGNATURE), module $$i\" >> ./misc/$$i.def; \
189	echo CODE LOADONCALL >> ./misc/$$i.def; \
190	echo DATA LOADONCALL NONSHARED MULTIPLE >> ./misc/$$i.def; \
191	echo EXPORTS >> ./misc/$$i.def; \
192	echo Creating $$i.def; \
193	(cmd /C ".\\misc\\makedef.cmd ./lib/$$i.a ./misc/$$i.ref >> ./misc/$$i.def" \
194	 && cmd /C ".\\misc\\chkdef.cmd ./misc/$$i.def") \
195	|| exit 1; \
196	done
197	touch make.defs
198
199save.defs :
200	for i in $(LIBRARIES); do \
201	test -f ./misc/$$i.def && cp ./misc/$$i.def ./misc/$$i.ref; \
202	done
203
204clean \
205os2clean ::
206	-rm -f $(DLLS) $(LIBS)
207
208realclean ::
209	-rm -f $(addprefix ./misc/, $(addsuffix .def, $(LIBRARIES)))
210
211#
212# This is a simplified version of misc/Makefile
213#
214
215TICDIR = $(DESTDIR)$(datadir)/terminfo
216TABSETDIR = $(DESTDIR)$(datadir)/tabset
217
218$(TICDIR) :
219	mkdir -p $@
220
221install \
222install.emxdata :: $(TICDIR)
223	-@rm -fr $(TICDIR)/*
224	echo Building terminfo database, please wait...
225	set TERMINFO=$(TICDIR); ./progs/tic ./misc/emx.src
226	echo Installing the terminfo cleaner and the sources...
227	cp ./misc/emx.src ./misc/cleantic.cmd $(TICDIR)
228	./misc/cleantic.cmd $(TICDIR)
229
230uninstall \
231uninstall.emxdata ::
232	-cd $(TICDIR) && rm -rf *
233	-cd $(TABSETDIR) && rm -rf *
234
235#
236# This is for preparing binary distributions
237#
238
239OS2NAME=ncurses-$(NCURSES_MAJOR).$(NCURSES_MINOR)-emx
240
241#
242# FIXME: this assumes that we can rerun the configure script, changing only
243# the install-prefix.  That means we cannot provide "interesting" options
244# when building.
245#
246os2dist :
247	$(MAKE) -f Makefile.os2 os2clean
248	./configure --without-debug --with-install-prefix=`pwd|sed -e 's@^.:@@'`/$(OS2NAME)
249	$(MAKE) -f Makefile.os2 $(CF_MFLAGS) install.os2
250	-rm -f $(OS2NAME).zip
251	echo NCurses-$(NCURSES_MAJOR).$(NCURSES_MINOR)-$(NCURSES_PATCH) for emx > $(OS2NAME)/FILE_ID.DIZ
252	echo Binary release. >> $(OS2NAME)/FILE_ID.DIZ
253	zip -r $(OS2NAME).zip ./$(OS2NAME)
254
255clean \
256os2clean ::
257	-rm -rf $(OS2NAME)
258	-rm -f $(OS2NAME).zip
259
260