Add makefiles: some useful debug and build utils.
parent
75a77440e6
commit
b1f19b30d2
10
c/makefile
10
c/makefile
|
@ -1,15 +1,19 @@
|
||||||
CC ?= cc
|
CC ?= cc
|
||||||
|
USR_LDFLAGS ?=
|
||||||
LDFLAGS ?= -lipc
|
LDFLAGS ?= -lipc
|
||||||
|
LDFLAGS += $(USR_LDFLAGS)
|
||||||
include makefile.valgrind
|
LDFLAGS += $(STATIC_BUILD)
|
||||||
|
CFLAGS ?= -Wall -Wextra
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
|
include ../mk/makefile.utils
|
||||||
|
|
||||||
BINS = pong pongd
|
BINS = pong pongd
|
||||||
build: $(BINS)
|
build: $(BINS)
|
||||||
|
|
||||||
$(BINS):
|
$(BINS):
|
||||||
$(CC) -o $@ $@.c $(LDFLAGS)
|
$(CC) -o $@ $@.c $(CFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm $(BINS) 2>/dev/null
|
rm $(BINS) 2>/dev/null
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
ifeq ($(SRC),)
|
||||||
|
test-src:
|
||||||
|
@echo SRC must be set via command line.
|
||||||
|
@exit 1
|
||||||
|
else
|
||||||
|
test-src:
|
||||||
|
endif
|
||||||
|
|
||||||
|
list-obj-files: test-src
|
||||||
|
@# List all .o included in a .a archive.
|
||||||
|
ar t $(SRC)
|
||||||
|
list-symbols: test-src
|
||||||
|
@# List all symbols in a .so.
|
||||||
|
nm -D $(SRC)
|
||||||
|
list-symbols-alt: test-src
|
||||||
|
@# Alternative: grep .text section in an objdump output.
|
||||||
|
objdump -T $(SRC) | grep text
|
|
@ -0,0 +1,6 @@
|
||||||
|
ifdef STATIC
|
||||||
|
STATIC_BUILD ?= -static
|
||||||
|
endif
|
||||||
|
|
||||||
|
# For interactive completion in the shell.
|
||||||
|
STATIC ?=
|
|
@ -0,0 +1,3 @@
|
||||||
|
include ../mk/makefile.valgrind
|
||||||
|
include ../mk/makefile.bin-inspection
|
||||||
|
include ../mk/makefile.static-build
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Debug with valgrind.
|
||||||
|
ifdef VG_SUPPRESS_WARNINGS
|
||||||
|
VALGRIND_SUPPRESS_WARNINGS ?= --suppressions=./valgrind.suppr
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef VG_GENERATE_SUPPRESSION
|
||||||
|
VALGRIND_GEN_SUPPRESSION ?= --gen-suppressions=all
|
||||||
|
endif
|
||||||
|
|
||||||
|
VALGRIND_OPTS ?= -v --leak-check=full --track-origins=yes
|
||||||
|
|
||||||
|
ifdef USE_VALGRIND
|
||||||
|
VALGRIND ?= valgrind $(VALGRIND_SUPPRESS_WARNINGS) \
|
||||||
|
$(VALGRIND_GEN_SUPPRESSION) \
|
||||||
|
$(VALGRIND_OPTS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Optional parameters (copied here to help with autocompletion).
|
||||||
|
VG_SUPPRESS_WARNINGS ?=
|
||||||
|
VG_GENERATE_SUPPRESSION ?=
|
||||||
|
USE_VALGRIND ?=
|
Loading…
Reference in New Issue