1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
|
#!/usr/bin/make -f
# Copyright 1994,1995 by Ian Jackson.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself. (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)
# This file may have to be extensively modified
# Rather paranoid than sorry. Make the shell exit with an error if an
# untested command fails.
SHELL+= -e
# S-lang's does not support --srcdir properly. If it would, this rules file
# could be made a lot easier. Now we have to do this by hand. We build the
# libc6 stuff in the regular place, and the libc5 stuff under
# debian/libc5build. This rules file is being invoked recursively, from
# different directories, for certain targets.
ARCH=$(shell dpkg --print-gnu-build-architecture)
# Determine whether it makes sense to build libc5 binaries for this
# architecture.
# architectures that need libc5-compat support
COMPAT_ARCHS=i486 m68k sparc
ifneq (,$(findstring $(ARCH), $(COMPAT_ARCHS)))
COMPAT := /bin/true
else
COMPAT := /bin/false
endif
# For which libc do we build? This variable is also used to determine if
# this is the top invocation, or a recursive one.
buildforlibc=top
ifeq ($(buildforlibc),top)
export DEBIAN=$(shell pwd)/debian
endif
ifeq ($(buildforlibc),5)
# libc5 compatibility packages
CC=/usr/$(ARCH)-linuxlibc1/bin/gcc
package=slang0.99.34
package-dev=slang0.99.34-dev
SONAME=libslang.so.0.99.34
prefix=usr/$(ARCH)-linuxlibc1
LIBDIR = $(DEBIAN)/tmp-lib-libc5
DEVDIR = $(DEBIAN)/tmp-dev-libc5
SHAREDLIBDIR = usr/lib/libc5-compat
else
CC=gcc
package=slang0.99.38
package-dev=slang0.99.38-dev
package-pic=slang0.99.38-pic
SONAME=libslang.so.0.99.38
PICNAME=libslang0.99.38_pic.a
# both for configure and make install. Don't use a leading slash!
prefix=usr
LIBDIR = $(DEBIAN)/tmp-lib-libc6
DEVDIR = $(DEBIAN)/tmp-dev-libc6
PICDIR = $(DEBIAN)/tmp-pic-libc6
SHAREDLIBDIR = lib
endif
# The version of the package (for example, `19.28').
version=0.99.38
make_directory= install -p -d -o root -g root -m 755
install_binary= install -p -s -o root -g root -m 755
install_library= install -p -o root -g root -m 644
install_script= install -p -o root -g root -m 755
install_files= install -p -o root -g root -m 644
CFLAGS = -O2 -g -Wall
THIS_LIB_DEFINES = -DSLANG -D_REENTRANT
CURRENT=libslang.so.$(version)
CONFIGJUNK = Makefile config.cache config.log config.status config.h
# TODO: remove
#LIBDIR = debian/tmp-lib
#DEVDIR = debian/tmp-dev
PWD = `pwd`
# The next section may have to be extensively modified
$(DEBIAN)/../build: build
build: $(checkdir)
ifeq ($(buildforlibc),top)
debian/rules copy
if $(COMPAT) ; then \
cd debian/libc5build ; \
../rules buildforlibc=5 checklibcenvironment build ; \
fi
debian/rules buildforlibc=6 checklibcenvironment build
touch $(DEBIAN)/../build
else
@echo "Building the binaries for libc$(buildforlibc)..."
env CC=$(CC) INSTALL="install -p" ./configure --prefix=/$(prefix)
# ELFLIB_MAJOR is the SONAME
# ELFLIB_MAJOR_MINOR is the -o filename
$(MAKE) CC="$(CC)" elf THIS_LIB_DEFINES="$(THIS_LIB_DEFINES)" \
CFLAGS="$(CFLAGS)" ELFLIB_MAJOR="$(SONAME)" \
ELFLIB_MAJOR_MINOR="$(CURRENT)" \
LIBDIR=-L$(LIBDIR)
(cd src; for i in calc worm untic; do \
$(MAKE) $i CFLAGS="$(CFLAGS)" OBJDIR=elfobjs ; done)
$(MAKE) CC="$(CC)" THIS_LIB_DEFINES="$(THIS_LIB_DEFINES)" CFLAGS="$(CFLAGS)"
endif
copy:
if $(COMPAT) ; then \
mkdir -p debian/libc5build ; \
cp -r autoconf configure demo doc help src debian/libc5build ; \
fi
checklibcenvironment:
# Sanity check: make sure that we are actually building against the libc
# we want to build against.
@if ( cd /tmp ; \
echo "int main() { exit(0); }" > libctest.c && \
$(CC) -o libctest libctest.c && \
ldd libctest | grep -q 'libc\.so\.$(buildforlibc)' ) ; \
then \
echo "Checked: libc6 environment" ; \
else \
echo "Error: this targets requires libc$(buildforlibc)"; \
echo "PATH=$$PATH" ; \
echo "gcc = `which gcc`" ; \
exit 1 ; \
fi
-@rm -f debian/a.out debian/test.c
clean:
$(checkdir)
@echo "Cleaning up after 'make build' ..."
-rm -f build
-$(MAKE) -i clean || $(MAKE) -f Makefile.in distclean
-rm -f $(CONFIGJUNK) man/index.db
-cd debian && rm -rf tmp-lib-libc5 tmp-lib-libc6 \
tmp-dev-libc5 tmp-dev-libc6 tmp-pic-libc6 \
debian*~ substvars files files.new \
a.out test.c libc5build
-cd src && rm -rf objs elfobjs Makefile config.h sysconf.h
-cd demo && rm -rf Makefile config.status config.h config.log
binary-indep:
# There are no architecture-independent files to be uploaded
# generated by this package. If there were any they would be
# made here.
binary-lib:
@echo "Making the binary package: $(package) for libc$(buildforlibc)..."
rm -rf $(LIBDIR)
$(make_directory) $(LIBDIR)/DEBIAN
$(make_directory) $(LIBDIR)/$(SHAREDLIBDIR)
$(make_directory) $(LIBDIR)/usr/doc/$(package)
ifeq ($(buildforlibc),6)
ln -s $(package) $(LIBDIR)/usr/doc/slang
endif
$(install_script) $(DEBIAN)/postinst.$(package) $(LIBDIR)/DEBIAN/postinst
-$(install_script) $(DEBIAN)/preinst.$(package) $(LIBDIR)/DEBIAN/preinst
$(install_files) $(DEBIAN)/shlibs.$(package) $(LIBDIR)/DEBIAN/shlibs
$(install_files) $(DEBIAN)/copyright $(LIBDIR)/usr/doc/$(package)
$(install_files) $(DEBIAN)/../changes.txt $(LIBDIR)/usr/doc/$(package)/changelog
$(install_files) $(DEBIAN)/changelog \
$(LIBDIR)/usr/doc/$(package)/changelog.Debian
$(install_library) src/elfobjs/$(CURRENT) $(LIBDIR)/$(SHAREDLIBDIR)
strip --strip-unneeded $(LIBDIR)/$(SHAREDLIBDIR)/$(CURRENT)
ifeq ($(buildforlibc),5)
# Compatibility links (may help someone)
cd $(LIBDIR)/$(SHAREDLIBDIR) ; \
ln -fs $(CURRENT) libslang.so.0.99.37 ; \
ln -fs $(CURRENT) libslang.so.0 ; \
ln -fs $(CURRENT) $(SONAME)
endif
gzip -9 $(LIBDIR)/usr/doc/$(package)/changelog*
# undefined LD_PRELOAD to prevent spurious libcx dependency due to fakeroot
HLP=`pwd` ; cd $(DEBIAN)/.. ; \
env LD_PRELOAD= \
dpkg-shlibdeps $$HLP/src/elfobjs/$(CURRENT) ; \
dpkg-gencontrol -P$(LIBDIR) -p$(package) ; \
chown -R root.root $(LIBDIR) ; \
dpkg --build $(LIBDIR) ..
binary-dev:
@echo "Making the binary package: $(package-dev) for libc$(buildforlibc)..."
rm -rf $(DEVDIR)
$(make_directory) $(DEVDIR)/DEBIAN
$(make_directory) $(DEVDIR)/$(prefix)/lib
$(make_directory) $(DEVDIR)/$(prefix)/include
$(make_directory) $(DEVDIR)/usr/doc/$(package)/doc
$(make_directory) $(DEVDIR)/usr/doc/$(package)/demo
$(make_directory) $(DEVDIR)/usr/doc/$(package)/help
$(install_script) $(DEBIAN)/postinst.$(package-dev) $(DEVDIR)/DEBIAN/postinst
ln -s $(package) $(DEVDIR)/usr/doc/$(package-dev)
$(install_files) $(DEBIAN)/README.examples $(DEVDIR)/usr/doc/$(package)
$(MAKE) install INSTALL="install -p" prefix=$(DEVDIR)/$(prefix)
# Make the .so link needed for the linker to find the library
ifeq ($(buildforlibc),6)
(cd $(DEVDIR)/$(prefix)/lib; ln -s ../../$(SHAREDLIBDIR)/$(CURRENT) libslang.so)
else
(cd $(DEVDIR)/$(prefix)/lib; ln -s ../../../$(SHAREDLIBDIR)/$(CURRENT) libslang.so)
endif
strip --strip-debug $(DEVDIR)/$(prefix)/lib/libslang.a
(cd demo; $(MAKE) clean; rm -f $(CONFIGJUNK))
$(install_files) `ls demo/[^o]*` \
src/jdmacros.h src/sltermin.c src/_slang.h src/worm.c \
src/untic.c \
$(DEVDIR)/usr/doc/$(package)/demo
ln -s ../../../include/slang.h $(DEVDIR)/usr/doc/$(package)/demo/slang.h
cd $(DEVDIR)/usr/doc/$(package)/demo &&\
rm -f Makefile.in config* makefile.dos
$(install_files) doc/* $(DEVDIR)/usr/doc/$(package)/doc
$(install_files) help/* $(DEVDIR)/usr/doc/$(package)/help
ln -s ../demo/jdmacros.h $(DEVDIR)/usr/doc/$(package)/help/jdmacros.h
ln -s ../demo/config.h $(DEVDIR)/usr/doc/$(package)/help/config.h
$(install_files) src/config.h src/calc.c src/calc.sl \
$(DEVDIR)/usr/doc/$(package)/demo
ln -s ../demo/calc.c $(DEVDIR)/usr/doc/$(package)/doc/calc.c
cd $(DEVDIR)/usr/doc/$(package)/help && rm -f makefile.djg makefile.os2
# there must be a better way to do this...
# dpkg-shlibdeps will not have noted the slang dependency if we're compiling
# on a machine that doesn't have slang installed yet. Hack around this:
HLP=`pwd` ; cd $(DEBIAN)/.. ; \
dpkg-shlibdeps $$HLP/src/elfobjs/calc ; \
if ! grep slang debian/substvars ; then \
mv debian/substvars debian/substvars.old ; \
sed -e 's/)$$/), $(package) (>= $(version))/' debian/substvars.old > debian/substvars ; \
rm debian/substvars.old ; \
fi
ifeq ($(buildforlibc),5)
cd $(DEVDIR)/usr/doc/$(package) && rm -rf doc demo help
endif
cd $(DEBIAN)/.. ; dpkg-gencontrol -P$(DEVDIR) -p$(package-dev)
chown -R root.root $(DEVDIR)
dpkg --build $(DEVDIR) $(DEBIAN)/../..
binary-pic:
ifeq ($(buildforlibc),6)
@echo "Making the binary package: $(package-pic) for libc$(buildforlibc)..."
rm -rf $(PICDIR)
$(make_directory) $(PICDIR)/DEBIAN
$(make_directory) $(PICDIR)/$(prefix)/lib
$(make_directory) $(PICDIR)/usr/doc
cd $(PICDIR)/usr/doc ; ln -s $(package-dev) $(package-pic)
ar cqv $(PICDIR)/$(prefix)/lib/$(PICNAME) \
`lorder src/elfobjs/*.o | tsort`
cd $(DEBIAN)/.. ; dpkg-gencontrol -P$(PICDIR) -p$(package-pic)
chown -R root.root $(PICDIR)
dpkg --build $(PICDIR) $(DEBIAN)/../..
endif
binary-join-us: binary-indep binary-lib binary-dev binary-pic
binary-arch: checkroot $(DEBIAN)/../build
ifeq ($(buildforlibc),top)
if $(COMPAT) ; then \
cd debian/libc5build ; \
../rules buildforlibc=5 binary-join-us ; \
fi
debian/rules buildforlibc=6 binary-join-us
endif
binary: binary-indep binary-arch
checkroot:
test root = "`whoami`"
define checkdir
test -f slang.lis -a -f debian/rules
endef
.PHONY: binary binary-indep binary-lib binary-dev binary-pic binary-arch dist update clean checkroot
|