summaryrefslogtreecommitdiff
blob: 0b4c71309a76e73b716614c057f4ac97988eb601 (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
# Copyright (C) 2004,2005 Martin Schlemmer <azarah@nosferatu.za.org>
#
#
#      This program is free software; you can redistribute it and/or modify it
#      under the terms of the GNU General Public License as published by the
#      Free Software Foundation version 2 of the License.
#
#      This program is distributed in the hope that it will be useful, but
#      WITHOUT ANY WARRANTY; without even the implied warranty of
#      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#      General Public License for more details.
#
#      You should have received a copy of the GNU General Public License along
#      with this program; if not, write to the Free Software Foundation, Inc.,
#      675 Mass Ave, Cambridge, MA 02139, USA.
#
# $Header$

CC = gcc
override CFLAGS += -Wall
EXTRA_CFLAGS = -DLEGACY_DEPSCAN
STRIP = strip

DEPSCAN = depscan
TEST_REGEX = test-regex

TARGETS = $(DEPSCAN)
CHECK_TARGETS = $(TEST_REGEX)

all: $(TARGETS)

.ALL: all

OBJS = \
	parse.o \
	depend.o \
	simple-regex.o \
	misc.o

HEADERS = \
	parse.h \
	depend.h \
	simple-regex.h \
	misc.h \
	debug.h


# cc-option (from linux kernel sources)
# Usage: cflags-y += $(call gcc-option, -march=winchip-c6, -march=i586)

cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
              > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)


ifeq ($(DEBUG),1)
  override CFLAGS += -ggdb3
  EXTRA_CFLAGS += -DRC_DEBUG
endif
ifeq ($(BOUNDS),1)
  override CFLAGS += $(call cc-option, -fbounds-checking, -pipe)
endif

$(DEPSCAN): $(OBJS) $(DEPSCAN).o
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $^

$(TEST_REGEX): $(TEST_REGEX).o simple-regex.o
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $^

$(OBJS): $(HEADERS)

.c.o:
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<

check: $(CHECK_TARGETS)
	@for x in $^; do \
		./$${x} || exit 1; \
	done

strip: $(TARGETS)
	$(STRIP) -s --remove-section=.note --remove-section=.comment $(TARGETS)

clean:
	rm -f *.o $(TARGETS) $(CHECK_TARGETS)