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
|
# Shared stuff among various make invocations
# Library naming and versioning
.include "${_DIRSRC}/../Makefile.inc"
# Basic cc flags (turn on lots of seatbelts)
C_WARNS = -Wall -Wstrict-prototypes -Wredundant-decls \
-Wmissing-prototypes -Wpointer-arith -Winline \
-Wcast-align -Wcast-qual -Wchar-subscripts \
-Winline -Wnested-externs -Wmissing-declarations \
-Wsign-compare \
-pedantic \
#-Werror
_CFLAGS := -g -O2 -pipe ${C_WARNS} -I../include -Iinclude ${C_FLAGS}
.ifdef NO_OPTIMIZE
_CFLAGS += -O0
.endif
# We generally want to use C[89]9. However, some things (like strdup())
# aren't in the standard, though they're essentially universal, and I
# can't be arsed implementing them manually. Also, some systems get very
# strict about limiting with C99 (Fedora Core, for instance, doesn't
# expose getopt() in unistd.h with -std=c[89]9). As a stopgap, set
# -std=c99, but override it by requesting X/Open and SUS extensions
# (which includes POSIX 200112). We could use -std=gnu99 here too, as
# the GNU extensions include what we care about, but that probably drifts
# us too far in the direction of gcc-centricism.
_CFLAGS += -std=c99 -D_XOPEN_SOURCE=600
# Roll 'em all up in a place easy to override
CFLAGS += ${_CFLAGS}
O_FILES = ${C_FILES:%.c=%.o}
SO_FILES = ${C_FILES:%.c=%.So}
CC ?= cc
LD ?= ld
MV ?= mv
LN ?= ln
RM ?= rm
LORDER ?= ../tools/lorder
TSORT ?= tsort
def: all
${SHLIB_NAME}: ${SO_FILES}
@echo Linking ${SHLIB_NAME}...
${CC} -shared -Wl,-x -o ${@} -Wl,-soname,${SHLIB_NAME} \
`${LORDER} ${SO_FILES} | ${TSORT}`
${LN} -sf ${SHLIB_NAME} ${SHLIB_LINK}
clean allclean:
${RM} -f ${CLEAN_FILES}
# bmake needs this to recognize the transform rule
.SUFFIXES: ${.SUFFIXES} .So
.c.o:
${CC} -c ${CFLAGS} ${CPPFLAGS} -o ${@} ${<}
.c.So:
@echo CPPFLAGS ${CPPFLAGS}
${CC} -fpic -DPIC -c ${CFLAGS} ${CPPFLAGS} -o ${@} ${<}
@${LD} ${LDFLAGS} -o ${@}.tmp -r ${@}
@${MV} -f ${@}.tmp ${@}
# This is used for test/examples
.ifdef PROGNAME
# These paths wind up relative to src/{test,examples}/*
CFLAGS += -I../../../include
L_FLAGS += -g -pipe -L../..
L_FLAGS += ${LDFLAGS}
LCIDR = ../../libcidr.so
CLEAN_FILES = ${O_FILES} ${PROGNAME} *core .depend
all build: ${PROGNAME}
${PROGNAME}: ${O_FILES} ${LCIDR}
${CC} ${L_FLAGS} -o ${@} ${O_FILES} -lcidr
${LCIDR}:
(cd ../.. && make)
.endif
|