2014-01-28 21:46:11 +00:00
|
|
|
#
|
|
|
|
# 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 \
|
2021-12-20 13:16:50 +00:00
|
|
|
$(MAKE) -f $*.mk; \
|
2014-01-28 21:46:11 +00:00
|
|
|
else \
|
|
|
|
grep '((constructor))' $*.c > .constructor; \
|
|
|
|
if [ -s .constructor ]; then \
|
2015-04-24 14:42:54 +00:00
|
|
|
echo "gcc -Wall -g -shared -rdynamic -o $@ $*.c -fPIC -D$(TARGET) $(TARGET_CFLAGS) $(GDB_FLAGS)"; \
|
|
|
|
gcc -Wall -g -shared -rdynamic -o $@ $*.c -fPIC -D$(TARGET) $(TARGET_CFLAGS) $(GDB_FLAGS); \
|
2014-01-28 21:46:11 +00:00
|
|
|
fi; \
|
|
|
|
if [ ! -s .constructor ]; then \
|
2015-04-24 14:42:54 +00:00
|
|
|
echo "gcc -Wall -g -nostartfiles -shared -rdynamic -o $@ $*.c -fPIC -D$(TARGET) $(TARGET_CFLAGS) $(GDB_FLAGS)"; \
|
|
|
|
gcc -Wall -g -nostartfiles -shared -rdynamic -o $@ $*.c -fPIC -D$(TARGET) $(TARGET_CFLAGS) $(GDB_FLAGS); \
|
2014-01-28 21:46:11 +00:00
|
|
|
fi; \
|
2015-05-18 15:00:31 +00:00
|
|
|
rm -f .constructor; \
|
2014-01-28 21:46:11 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(CONTRIB_SO)
|
|
|
|
@for MAKEFILE in `grep -sl "^clean:" *.mk`; \
|
2021-12-20 13:16:50 +00:00
|
|
|
do $(MAKE) -f $$MAKEFILE clean; \
|
2014-01-28 21:46:11 +00:00
|
|
|
done
|