File: Makefile.gcc

package info (click to toggle)
libkaz 1.21-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 544 kB
  • sloc: ansic: 4,323; cpp: 70; makefile: 17; perl: 10
file content (112 lines) | stat: -rw-r--r-- 2,851 bytes parent folder | download
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
# Copyright 2009
# Kaz Kylheku <kkylheku@gmail.com>
# Vancouver, Canada
# All rights reserved.
#
# BSD License:
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
#   1. Redistributions of source code must retain the above copyright
#      notice, this list of conditions and the following disclaimer.
#   2. Redistributions in binary form must reproduce the above copyright
#      notice, this list of conditions and the following disclaimer in
#      the documentation and/or other materials provided with the
#      distribution.
#   3. The name of the author may not be used to endorse or promote
#      products derived from this software without specific prior
#      written permission.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

CFLAGS	 ?= -Wall -W -Wmissing-prototypes -ansi -O2 -DNDEBUG
CXXFLAGS ?= $(filter-out -Wmissing-prototypes,$(CFLAGS))
prefix   ?= /usr/local

CLEAN := ID tags

OBJS := except.o hash.o dict.o sfx.o list.o
PROGS := tdict tlist thash teh tsfx
TESTS := tests/dict-1

SLIB := libkaz.a
SO_VERSION := 1.1.0
DLIB := $(SLIB:.a=.so.$(SO_VERSION))

CLEAN += $(PROGS) $(TESTS) $(OBJS) $(SLIB) $(DLIB)
project: $(PROGS) $(TESTS) $(SLIB) $(DLIB)

tlist tdict thash teh tsfx: CFLAGS += -DKAZLIB_TEST_MAIN

# with GNU Make 3.82+ we can make the above target specific assignment 
# private instead of the following hack:
%.o: CFLAGS := $(filter-out -DKAZLIB_TEST_MAIN,$(CFLAGS))

.depend tests/%.o: CFLAGS += -I$(shell pwd)

TESTSOBJS := $(patsubst %,%.o,$(TESTS))
CLEAN += $(TESTSOBJS)
$(TESTS): $(TESTSOBJS)

$(filter tests/dict-%,$(TESTS)): dict.o

tlist tdict thash teh tsfx:
	$(CC) $(CFLAGS) -o $@ $^

tlist: list.c list.h

tdict: dict.c dict.h

thash: hash.c hash.h

teh: except.c except.h

tsfx: sfx.c sfx.h except.o hash.o

tests/dict-1:
	$(CXX) -o $@ $^

CLEAN += docs
docs: docs.dvi

$(SLIB): $(OBJS)
	ar rcs $@ $^

$(DLIB): $(SLIB)
	$(CC) $(LDFLAGS) -shared -Wl,-soname,$(patsubst %.so.$(SO_VERSION),%.so.1,$@) -Wl,--whole-archive,$< -Wl,--no-whole-archive -o $@ 

CLEAN += docs.dvi docs.aux docs.log
docs.dvi: docs.ltx docs.toc docs.ind
	latex docs.ltx

CLEAN += docs.ind
docs.ind: docs.idx docs.ist
	makeindex -s docs.ist docs.idx

CLEAN += docs.toc
docs.toc: docs.ltx
	latex docs.ltx

CLEAN += docs.idx docs.ilg
docs.idx: docs.ltx
	latex docs.ltx

install: $(DLIB) $(SLIB)
	install -m 0644 $(DLIB) $(SLIB) $(prefix)/lib
	mkdir -p $(prefix)/include/kazlib ; \
	install -m 0644 *.h $(prefix)/include/kazlib

clean:
	-rm $(CLEAN)

ifneq ($(MAKECMDGOALS),clean)
.depend:
	$(CC) $(CXXFLAGS) -MM *.c tests/*.cc > .depend

CLEAN += .depend
-include .depend
endif