File: Makefile

package info (click to toggle)
ustr 1.0.4-6.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,676 kB
  • sloc: ansic: 19,041; makefile: 935; perl: 779; sh: 686; xml: 97
file content (162 lines) | stat: -rw-r--r-- 3,888 bytes parent folder | download | duplicates (5)
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


CC = cc
AR = ar
RANLIB = ranlib


WARNS = -W -Wall -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wno-format-zero-length -Wformat-nonliteral -Wformat-security # -Wfloat-equal -- no floats

# DEF_CFLAGS = -Os -g
DEF_CFLAGS = -O2 -g # $(WARNS)

CFLG_LFS = -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

CFLAGS  = $(DEF_CFLAGS) $(CFLG_LFS)

CFLG_LIB_OPT = $(CFLAGS) -DUSTR_DEBUG=0 -DNDEBUG
CFLG_LIB_DBG = $(CFLAGS)

# Compile "normal" using /ustr/include/ustr*.h and /usr/lib/libustr.so
PCFLAGS = $(CFLAGS)
LDFLAGS = -lustr
DEPS    =

## Compile "debug" using /ustr/include/ustr*.h and /usr/lib/libustr-debug.so
#PCFLAGS = $(CFLAGS) $(WARNS) -DUSTR_DEBUG=1
#LDFLAGS = -lustr-debug
#DEPS    =

## Compile "inline" using parent dir.
#PCFLAGS = $(CFLAGS) -DUSTR_CONF_INCLUDE_CODEONLY_HEADERS=1 -I..
#LDFLAGS =

## Compile "static" using parent dir.
#PCFLAGS = $(CFLAGS) -I..
#LDFLAGS = ../libustr.a
#PCFLAGS = $(CFLAGS) $(WARNS) -I.. -DUSTR_DEBUG=1
#LDFLAGS = ../libustr-debug.a

## Compile "inline" using ustr-import output
# - do nothing

## Compile "inline" using /ustr/include/ustr*.h / ustr-import -c
#PCFLAGS = $(CFLAGS) -DUSTR_CONF_INCLUDE_CODEONLY_HEADERS=1
#LDFLAGS  =

## Compile "static" opt using ustr-import
#PCFLAGS = $(CFLAGS)
#DEPS    = libustr.a
#LDFLAGS = libustr.a

## Compile "static" dbg using ustr-import
#PCFLAGS = $(CFLAGS) $(WARNS)
#DEPS    = libustr-debug.a
#LDFLAGS = libustr-debug.a


# This is a simple makefile for example programs...

ALL = hello_world netstr hexdump nums mkdir_p fgrep txt2html custr \
      linecat_buf linecat_sized basename dirname

DBG_LIB_STATIC      = libustr-debug.a
OPT_LIB_STATIC      = libustr.a
LIB_STATIC = $(DBG_LIB_STATIC) $(OPT_LIB_STATIC)

LIB_STATIC_DBG = \
  ustr-b-code-a-dbg.o \
  ustr-cmp-code-a-dbg.o \
  ustr-fmt-code-a-dbg.o \
  ustr-io-code-a-dbg.o \
  ustr-ins-code-a-dbg.o \
  ustr-main-code-a-dbg.o \
  ustr-parse-code-a-dbg.o \
  ustr-pool-code-a-dbg.o \
  ustr-sc-code-a-dbg.o \
  ustr-set-code-a-dbg.o \
  ustr-spn-code-a-dbg.o \
  ustr-srch-code-a-dbg.o \
  ustr-utf8-code-a-dbg.o
LIB_STATIC_OPT = \
  ustr-b-code-a-opt.o \
  ustr-cmp-code-a-opt.o \
  ustr-fmt-code-a-opt.o \
  ustr-io-code-a-opt.o \
  ustr-ins-code-a-opt.o \
  ustr-main-code-a-opt.o \
  ustr-parse-code-a-opt.o \
  ustr-pool-code-a-opt.o \
  ustr-sc-code-a-opt.o \
  ustr-set-code-a-opt.o \
  ustr-spn-code-a-opt.o \
  ustr-srch-code-a-opt.o \
  ustr-utf8-code-a-opt.o




all: $(DEPS) $(ALL)

libustr.a: $(LIB_STATIC_OPT)
		@echo Linking A OPT lib: $@
		@$(AR) ru $@ $^
		@$(RANLIB) $@
libustr-debug.a: $(LIB_STATIC_DBG)
		@echo Linking A DBG lib: $@
		@$(AR) ru $@ $^
		@$(RANLIB) $@

%-code-a-opt.o:  %-opt-code.c %-code.h %.h
		@echo Compiling for A OPT lib: $<
		@$(CC) $(CFLG_LIB_OPT) -o $@ -c $<

%-code-a-dbg.o:  %-dbg-code.c %-code.h %.h
		@echo Compiling for A DBG lib: $<
		@$(CC) $(CFLG_LIB_DBG) -o $@ -c $<

hello_world: hello_world.c
		$(CC) $(PCFLAGS) -o $@ $< $(LDFLAGS)

netstr: netstr.c
		$(CC) $(PCFLAGS) -o $@ $< $(LDFLAGS)

hexdump: hexdump.c
		$(CC) $(PCFLAGS) -o $@ $< $(LDFLAGS)

nums: nums.c
		$(CC) $(PCFLAGS) -o $@ $< $(LDFLAGS)

mkdir_p: mkdir_p.c
		$(CC) $(PCFLAGS) -o $@ $< $(LDFLAGS)

fgrep: fgrep.c
		$(CC) $(PCFLAGS) -o $@ $< $(LDFLAGS)

txt2html: txt2html.c
		$(CC) $(PCFLAGS) -o $@ $< $(LDFLAGS)

custr: custr.c
		$(CC) $(PCFLAGS) -o $@ $< $(LDFLAGS)

linecat_buf: linecat.c
		$(CC) $(PCFLAGS) -o $@ $< $(LDFLAGS) -DCAT_TYPE=1

linecat_sized: linecat.c
		$(CC) $(PCFLAGS) -o $@ $< $(LDFLAGS) -DCAT_TYPE=2

basename: basename.c
		$(CC) $(PCFLAGS) -o $@ $< $(LDFLAGS)

dirname: dirname.c
		$(CC) $(PCFLAGS) -o $@ $< $(LDFLAGS)


strip: $(ALL)
		@for i in $(ALL); do \
		echo "Creating: $$i-s"; cp $$i $$i-s; strip $$i-s; \
		done

clean:
		rm -f *.o $(ALL) $(LIB_STATIC) *-s