File: Jamrules

package info (click to toggle)
libkarma 0.1.2-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 676 kB
  • sloc: ansic: 6,224; sh: 328; makefile: 229; cs: 170
file content (190 lines) | stat: -rw-r--r-- 3,567 bytes parent folder | download | duplicates (6)
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
NOTFILE libs dlls objs lists ;

ALL_LIBS_TO_BUILD ?= libs dlls ;

BUILDMODE     ?= obj ;
LIBPREFIX     ?= lib ;
LIBLISTSUFFIX ?= .list ;
TOUCH          = touch ;

if $(UNIX)
{
  PUSHD          = "( cd" ;
  POPD           = ")" ;
  LDSHARE       ?= ld ;
  LDSHARE_FLAGS ?= -G ;
  SUFLIBSHR     ?= .so ;
  ECHO           = echo ;
}
else if $(BEOS)
{
}

makeDirName LIBDIR : $(TOP) $(BUILDMODE) ;

rule LibMember
{
# $(1) is short name of lib these sources are destined for.
# $(2) is list of source files.

  local l o ;

  SOURCE_GRIST = ; # (Implicit grist is a pain.)

    makeDirName LOCATE_TARGET : $(LIBDIR) lib$(1) ;
#
# e.g., binaries for 'foo' library go in $TOP/debug/libfoo
# directory.

  Objects $(2) ; 

# Set up a list file for this library:

  getLibListName l : $(1) ;
  LOCATE on $(l) = $(LIBDIR) ;
# 
# e.g., for the 'foo' library, the list file is 
# $TOP/debug/libfoo.list.

  if ! $(LIST-STARTED-$(<))
  {
    LIST-STARTED-$(<) = true ;
    RemoveExistingFile $(l) : $(l) ;
#
# The RemoveTarget rule has to be invoked once only,
# and before any of the EchoToFile rules are invoked.
  }

  o = $(2:S=$(SUFOBJ):G=:D=lib$(1)) ;
  NOTFILE $(o) ;
#
# $(o) is a list of object file names, sans grist, and
# qualified by the subdir in which it is stored. Thus,
# each element of $(o) uniquely identifies a compiled object
# associated with a built library. Elements of $(o) will be
# used as dependencies but are not bindable.

  EchoToFile $(l) : $(o) ;
  Depends $(l) : $(2:S=$(SUFOBJ)) ;
#
# The list file depends on the compiled objects. If any
# of them are newer, the list file gets recreated. Seems odd,
# but it works, because a list is only updated when you're
# updating a library.

  Depends objs : $(2:S=$(SUFOBJ)) ;
}

rule BuildLib
{
# $(1) is short name of lib to build.
# $(2) is list of dependent lib short names
# $(3) is .def file, for NT.
# $(4) is list of join lib short names. 

  local list libs ;

  SOURCE_GRIST = ;

  if $(LIB$(1)) 
  {
    Exit BuildLib used more than once on $(1) ;
  }
  LIB$(1) = $(LIBPREFIX)$(1)$(SUFLIB) ;
  DLL$(1) = $(LIBPREFIX)$(1)$(SUFLIBSHR) ;
  libs = $(LIB$(1)) $(DLL$(1)) ;
  MakeLocate $(libs) : $(LIBDIR) ;

  if $(4)
  {
    getLibListName list : $(4) ;
  }
  else
  {
    getLibListName list : $(1) ;
    MakeLocate $(list) : $(LIBDIR) ;
    Clean clean : $(list) ;
    Depends lists : $(list) ;
  }

  Depends $(libs) : $(list) ;

  LIBLIST on $(libs) = $(list) ;

  LDSHARE_FLAGS on $(DLL$(1)) += $(LDSHARE_FLAGS) ;

  if $(BEOS)
  {
  }
  else
  {
    LinkDynamicLib $(DLL$(1)) ;
    RemoveExistingFile $(LIB$(1)) : $(LIB$(1)) ;
    ArchiveStaticLib $(LIB$(1)) ;

    if $(RANLIB)
    {
      Ranlib $(LIB$(<)) ;
    }
  }

  Depends libs : $(LIB$(1)) ;
  Depends dlls : $(DLL$(1)) ;

  Depends all : $(ALL_LIBS_TO_BUILD) ;

  Clean clean : $(libs) ;
}

actions quietly existing RemoveExistingFile
{
  $(RM) $(>)
}

actions quietly together piecemeal EchoToFile
{
  $(ECHO) $(>) >> $(<)
}

rule getLibListName
{
# $(1) is var to set.
# $(2) is lib short name.
#
# E.g., "getLibListName l : foo ;" sets
# l to libfoo.list.

  $(1) = lib$(2:S=$(LIBLISTSUFFIX)) ;
}

if $(UNIX)
{
  actions LinkDynamicLib
  {
    $(PUSHD) $(<:D)
      $(LDSHARE) $(LDSHARE_FLAGS) $(LDSHARE_NAME_FLAG)$(<:BS) -o $(<:BS) `cat $(LIBLIST:BS) `
      $(POPD)
  }

  actions ArchiveStaticLib
  {
    $(PUSHD) $(<:D)
      $(AR) $(<:BS) `cat $(LIBLIST:BS) `  
      $(POPD)
  }
}
else if $(BEOS)
{
  actions LinkDynamicLib
  {
  }

  actions ArchiveStaticLib
  {
  }
}

actions quietly TouchFile
{
  $(TOUCH) $(<)
}