File: Makefile

package info (click to toggle)
crash 7.0.8-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 36,348 kB
  • ctags: 13,100
  • sloc: ansic: 135,839; makefile: 495
file content (54 lines) | stat: -rw-r--r-- 2,009 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
#
# Makefile for building crash shared object extensions
#
# Copyright (C) 2005, 2007, 2009, 2011, 2013 David Anderson
# Copyright (C) 2005, 2007, 2009, 2011, 2013 Red Hat, Inc. All rights reserved.
#
# 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; either version 2 of the License, or
# (at your option) any later version.
#
# 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.
#
# To build the extension shared objects in this directory, run 
# "make extensions" from the top-level directory.
#
# To add a new extension object, simply copy your module's .c file
# to this directory, and it will be built automatically using
# the "standard" compile line.  If that compile line does not 
# suffice, create a .mk file with the same prefix as the .c file,
# and that makefile will be invoked. 
# 

CONTRIB_SO := $(patsubst %.c,%.so,$(wildcard *.c))

all: link_defs $(CONTRIB_SO)
	
link_defs:
	@rm -f defs.h
	@ln ../defs.h 

$(CONTRIB_SO): %.so: %.c defs.h
	@if [ -f $*.mk ]; then \
		make -f $*.mk; \
	else \
		grep '((constructor))' $*.c > .constructor; \
		if [ -s .constructor ]; then \
			echo "gcc -Wall -shared -rdynamic -o $@ $*.c -fPIC -D$(TARGET) $(TARGET_CFLAGS) $(GDB_FLAGS)"; \
			gcc -Wall -shared -rdynamic -o $@ $*.c -fPIC -D$(TARGET) $(TARGET_CFLAGS) $(GDB_FLAGS); \
		fi; \
		if [ ! -s .constructor ]; then \
			echo "gcc -Wall -nostartfiles -shared -rdynamic -o $@ $*.c -fPIC -D$(TARGET) $(TARGET_CFLAGS) $(GDB_FLAGS)"; \
			gcc -Wall -nostartfiles -shared -rdynamic -o $@ $*.c -fPIC -D$(TARGET) $(TARGET_CFLAGS) $(GDB_FLAGS); \
		fi; \
	fi

clean:
	rm -f $(CONTRIB_SO)
	@for MAKEFILE in `grep -sl "^clean:" *.mk`; \
	  do make --no-print-directory -f $$MAKEFILE clean; \
	done