summaryrefslogtreecommitdiff
path: root/include/makeinclude/rules.lib.GNU
blob: a988330d2d4ec0011928517e33812e74c0abb496 (plain)
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
#----------------------------------------------------------------------------
#	$Id$
#
#	Build libraries (i.e., contain no binary executables)
#	GNU version
#	Requires GNU make
#----------------------------------------------------------------------------

#----------------------------------------------------------------------------
# The following targets arrange to build both unshared and shared libraries
#----------------------------------------------------------------------------

VSHLIB  = $(SHLIB:%.so=%$(VAR).so)
VOBJS   = $(LSRC:%.cpp=$(VDIR)%.o)

ifdef TEMPINCDIR
VSHOBJS1 = 
else
LSRC    += $(LSRC2)
ifdef PRELIB
VSHOBJS	= $(LSRC:%.cpp=$(VSHDIR)%.so)
VSHOBJS1 = $(VSHOBJS)
else
VSHOBJS = $(LSRC:%.cpp=$(VSHDIR)%.so)
VSHOBJS1 = $(LSRC:%.cpp=$(VSHDIR)%.o)
endif
endif

# Comment out for now... 
# $(DEFS:%=$(INSINC)/%) \

INSTALL = $(VLIB:%.a=$(INSLIB)/%.a) \
	  $(VSHLIB:%.so=$(INSLIB)/%.so)

ifdef PRELIB
# Unfortunately, gcc has to do a link of all of the objects (during which
# it may decide to recompile some of the objects), before we can safely build
# any libraries or shared objects.  Comment this line if no shared
# libraries or objects are used.
$(VSHOBJS): $(VSHLIB)
endif

# Comment these lines out if you want to build both *.a and *.so libraries...
#$(VSHLIB): $(VSHOBJS) $(STATLIB)
#ifdef PRELIB
#	$(PRELIB)
#endif
#	$(SOLINK.cc) -o $@ $(LDFLAGS) $(VSHDIR)*.o

# Uncomment the remaining lines if you want to build both *.a and *.so libraries...
VLIB	= $(LIB:%.a=%$(VAR).a)

$(VLIB): $(VOBJS)
ifdef PRELIB
	$(PRELIB)
endif
	$(AR) $(ARFLAGS) $@ $?
ifdef TEMPINCDIR
# This is required for AIX!!!
	if test -e xxx; \
	then  \
		rm xxx; \
	fi
	(if test -s ./$(TEMPINCDIR)/*.C; \
	then  \
		while ! test -e xxx; \
		do  \
			touch xxx; \
			cd ./$(TEMPINCDIR); \
			for temp in *.C; \
	 		do  \
				if ! test -d ./$(TEMPINCDIR); \
				then  \
					cd ..; \
				fi; \
				if $(COMPILE.cc) -o $(VDIR)$$temp.o ./$(TEMPINCDIR)/$$temp; \
				then  \
					$(AR) $(ARFLAGS) $@ $(VDIR)$$temp.o;\
				else  \
					rm $@; \
					rm xxx; \
					exit; \
				fi \
	 		done;  \
			for temp in ./$(TEMPINCDIR)/*.C; \
	 		do  \
				if test $$temp -nt xxx; \
				then \
					rm xxx; \
					break; \
				fi \
	 		done  \
	 	done;  \
	fi)
	rm xxx 
endif
	-chmod a+r $@
	-$(RANLIB) $@

# Note that if you don't want to build shared libraries, just remove the $(VSHOBJS)
$(VSHLIB): $(VSHOBJS) $(STATLIB)
ifdef PRELIB
	$(PRELIB)
endif
	$(SOLINK.cc) -o $@ $(VSHOBJS1) $(LDFLAGS) $(LIBS) $(STATLIB)
	-chmod a+rx $@

ifdef SHLIBA
$(SHLIBA): $(VSHLIB)
	$(AR) $(ARFLAGS) $@ $?
	-chmod a+rx $@
	-$(RANLIB) $@
endif