summaryrefslogtreecommitdiff
path: root/devel/libmalloc/files/patch-ad
blob: 8a92c2b30339527399ed4f3fbf823f0fd540c500 (plain) (blame)
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
--- Makefile.orig	Mon Apr  3 10:55:32 1995
+++ Makefile	Thu Feb  4 22:08:18 1999
@@ -11,8 +11,8 @@
 # puts malloc.h in $INCDIR.
 #
 
-LIBDIR=$(HOME)/lib/$(ARCH)
-INCDIR=$(HOME)/include
+LIBDIR=${PREFIX}/lib
+INCDIR=${PREFIX}/include
 
 # neutralize SystemV genius
 SHELL=/bin/sh
@@ -46,7 +46,7 @@
 # -DHAVE_MMAP can be defined for SunOS4.x and other systems
 # that have a general purpose mmap call that allows memory-mapped files.
 #
-NORMALDEFS=-DHAVE_MMAP # -DSTDHEADERS -DSHORTNAMES -DUSESTDIO
+NORMALDEFS=-DHAVE_MMAP -DSTDHEADERS # -DSHORTNAMES -DUSESTDIO
 
 # CC = gcc -ansi -Wall -O # -pedantic # add -pedantic if you fixed your includes.
 # SGI needs cc -xansi -D__STDC__ on Irix4.0.5.
@@ -62,11 +62,20 @@
 RANLIB = ranlib
 
 LDFLAGS=#-Bstatic
+.if (${PORTOBJFORMAT} == "elf")
+CFLAGS_SHARED=	-shared -Wl,-soname,${LIBSMALLOC}
+VERSION=1
+.else
+CFLAGS_SHARED=	-shared
+VERSION=1.18
+.endif
 
 # only developers should have to change stuff below this line
 
 EXT=_d
 LIBMALLOC=libmalloc$(EXT).a
+LIBSMALLOC=libmalloc${EXT}.so.${VERSION}
+
 PROGS=testmalloc$(EXT) simumalloc$(EXT) teststomp$(EXT) maltrace$(EXT)
 
 DEFINES= $(NORMALDEFS) $(DEBUGDEFS)
@@ -108,9 +117,16 @@
 
 CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(DEFINES)
 
-all: pass clean libmalloc
+.c.o:
+	${CC} -c ${CFLAGS} $< -o $@
+	${CC} -c -fpic ${CFLAGS} $< -o shared/$@
+
+all: mkdir pass clean libmalloc
 
-pass: $(LIBMALLOC) $(PROGS) out$(EXT)
+mkdir:
+	@mkdir -p shared
+
+pass: $(LIBMALLOC) ${LIBSMALLOC} $(PROGS) out$(EXT)
 
 libmalloc:
 	$(MAKE) -f Makefile $(MFLAGS) CC="$(CC)" DEBUGDEFS="$(FASTDEFS)" \
@@ -135,6 +151,12 @@
 	-$(RANLIB) $(LIBMALLOC)
 	touch .lib$(EXT)
 
+${LIBSMALLOC}: ${OBJS}
+	rm -f ${LIBSMALLOC} ${SPLAYOBJ}
+	cd splay; ${MAKE} ${MFLAGS} DEFINES="${DEFINES}" \
+		LIBMALLOC=../${LIBMALLOC} CC="${CC} -fpic"
+	(cd shared; ${CC} ${CFLAGS_SHARED} -o ../${LIBSMALLOC} ${OBJS} ../${SPLAYOBJ})
+
 $(SPLAYOBJ): .foo
 	cd splay; $(MAKE) $(MFLAGS) DEFINES="$(DEFINES)" \
 		LIBMALLOC=../$(LIBMALLOC) CC="$(CC)"
@@ -164,6 +186,7 @@
 
 clean:
 	-rm -f *.o \#* *~ core a.out gmon.out mon.out onefile.c *.sL prof.out
+	-(cd shared; rm -f *.o \#* *~)
 	cd splay; $(MAKE) clean
 
 veryclean: clean cleanprogs
@@ -175,6 +198,8 @@
 	-$(RANLIB) $(LIBDIR)/libmalloc.a
 	install -c -m 644 libmalloc_d.a $(LIBDIR)
 	-$(RANLIB) $(LIBDIR)/libmalloc_d.a
+	install -c -m 644 ${LIBSMALLOC} ${LIBDIR}
+	ln -sf ${LIBDIR}/${LIBSMALLOC} ${LIBDIR}/libmalloc${EXT}.so
 	install -c -m 644 malloc.h $(INCDIR)
 	
 .id: $(SRCS)