summaryrefslogtreecommitdiff
path: root/dmake/dbug/dbug.mk
blob: 09aa82d7f37dab4e08d6bd25da9bb890658d44f8 (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
# Set the proper macros based on whether we are making the debugging version
# or not.  The valid parameters to this file are:
#
#	DEBUG=1		==> enable the making of the DBUG version
#	DBMALLOC=1	==> enable DBUG version with extensive MALLOC checking
#
#	DB_CFLAGS	==> CFLAGS is set to this value at the end if DEBUG=1
#	DB_LDFLAGS	==> LDFLAGS is set to this at the end if DEBUG=1
#	DB_LDLIBS       ==> LDLIBS is set to this at end if DEBUG=1
#
# The non debug versions of the above three macros are:
#
#	NDB_CFLAGS
#	NDB_LDFLAGS
#	NDB_LDLIBS
#
# One of the set of three should have values set appropriately prior to
# sourcing this file.

.IF $(DEBUG)
   DBUG_SRC	+= dbug.c
   DB_CFLAGS    += -Idbug/dbug

   .SETDIR=dbug/dbug : $(DBUG_SRC)

   # If DBMALLOC is requested (ie non-NULL) then include the sources for
   # compilation.  BSD 4.3 needs the getwd.c source compiled in due to a bug
   # in the clib getwd routine.
   .IF $(DBMALLOC)
      # Serious bug in bsd43 getwd.c would free a string and then use its
      # value.  The DBMALLOC code clears a string when it is free'd so the
      # value was no longer valid and the returned path for the current
      # directory was now completely wrong.
      .IF $(OSRELEASE) == bsd43
     GETWD_SRC += getwd.c
     .SETDIR=dbug : $(GETWD_SRC)
      .END

      MLC_SRC   += malloc.c free.c realloc.c calloc.c string.c\
           mlc_chk.c mlc_chn.c memory.c tostring.c m_perror.c\
           m_init.c mallopt.c dump.c

      .SETDIR=dbug/malloc : $(MLC_SRC)

      DB_CFLAGS += -Idbug/malloc
   .END

   SRC          += $(DBUG_SRC) $(MLC_SRC) $(GETWD_SRC)
   HDR		+= db.h 

   LDFLAGS	+= $(DB_LDFLAGS)
   LDLIBS	+= $(DB_LDLIBS)

   __.SILENT	!:= $(.SILENT)
   .SILENT	!:= yes
   TARGET	:= db$(TARGET)
   OBJDIR	:= $(OBJDIR).dbg
   .SILENT	!:= $(__.SILENT)

   CFLAGS	+= $(DB_CFLAGS)
   .KEEP_STATE  := _dbstate.mk
.ELSE
   CFLAGS       += $(NDB_CFLAGS)
   LDFLAGS      += $(NDB_LDFLAGS)
   LDLIBS       += $(NDB_LDLIBS)
.END