|
nsz |
63c044 |
CFLAGS+=-pipe -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wno-unused-function -Wno-missing-braces
|
|
nsz |
63c044 |
LDFLAGS+=
|
|
Szabolcs Nagy |
054f47 |
LDLIBS+=
|
|
Szabolcs Nagy |
b775d1 |
BUILD?=.
|
|
nsz |
63c044 |
|
|
nsz |
63c044 |
SRC=$(sort $(wildcard *.c))
|
|
Szabolcs Nagy |
b775d1 |
OBJ=$(SRC:%.c=$(BUILD)/%.o)
|
|
nsz |
63c044 |
DSOOBJ=$(filter %_dso.o,$(OBJ))
|
|
nsz |
63c044 |
BINOBJ=$(filter-out %_dso.o,$(OBJ))
|
|
Szabolcs Nagy |
054f47 |
NO_DL_OBJ=$(filter-out %dlopen.o,$(BINOBJ))
|
|
nsz |
63c044 |
DSO=$(DSOOBJ:.o=.so)
|
|
nsz |
63c044 |
BIN=$(BINOBJ:.o=)
|
|
Szabolcs Nagy |
054f47 |
BIN_STATIC=$(NO_DL_OBJ:.o=-static)
|
|
Szabolcs Nagy |
054f47 |
ALL=$(BIN) $(BIN_STATIC) $(DSO)
|
|
nsz |
63c044 |
|
|
nsz |
63c044 |
-include ../../config.mak
|
|
nsz |
63c044 |
|
|
Szabolcs Nagy |
054f47 |
all: $(ALL)
|
|
nsz |
63c044 |
run: all
|
|
Szabolcs Nagy |
054f47 |
@N=0; A=0; for i in $(BIN) $(BIN_STATIC);do \
|
|
Szabolcs Nagy |
054f47 |
A=$$((A+1)); ./$$i || { N=$$((N+1)); echo FAIL $$i; } \
|
|
Szabolcs Nagy |
054f47 |
done; \
|
|
Szabolcs Nagy |
054f47 |
[ "$$N" = 0 ] && echo PASS || echo FAILS: $$N/$$A
|
|
nsz |
63c044 |
clean:
|
|
Szabolcs Nagy |
054f47 |
rm -f $(OBJ) $(ALL)
|
|
nsz |
63c044 |
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD):
|
|
Szabolcs Nagy |
b775d1 |
mkdir -p $@
|
|
Szabolcs Nagy |
b775d1 |
$(OBJ): test.h | $(BUILD)
|
|
Szabolcs Nagy |
054f47 |
$(DSOOBJ): CFLAGS+=-fPIC
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/%.o: %.c
|
|
Szabolcs Nagy |
054f47 |
$(CC) $(CFLAGS) -c -o $@ $< || echo BUILDERROR $@
|
|
nsz |
63c044 |
%.so: %.o
|
|
Szabolcs Nagy |
054f47 |
$(CC) -shared $(LDFLAGS) -o $@ $< $(LDLIBS) || echo BUILDERROR $@
|
|
Szabolcs Nagy |
054f47 |
%-static: %.o
|
|
Szabolcs Nagy |
054f47 |
$(CC) -static $(LDFLAGS) -o $@ $< $(LDLIBS) || echo BUILDERROR $@
|
|
nsz |
63c044 |
%: %.o
|
|
Szabolcs Nagy |
054f47 |
$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS) || echo BUILDERROR $@
|
|
nsz |
49b23c |
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/dlopen: LDLIBS+=-ldl -rdynamic
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/pthread%: LDLIBS+=-lpthread
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/sem $(BUILD)/sem-static: LDLIBS+=-lpthread -lrt
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/strtod_simple $(BUILD)/strtod_simple-static: LDLIBS+=-lm
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/tgmath tgmath-static: LDLIBS+=-lm
|
|
Szabolcs Nagy |
4a4a5c |
# adding ./lib.so through LDLIBS instead of $^ in the implicit rule because make removes the leading ./ from dependencies
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/tls_align: LDLIBS+=$(BUILD)/tls_align_dso.so
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/tls_align: $(BUILD)/tls_align_dso.so
|
|
Szabolcs Nagy |
054f47 |
# make bug: tls_align target specific flags are also set for tls_align_dso.so when both target is built
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/tls_align_dso.so: LDLIBS=
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/tls_align-static: LDLIBS+=$(BUILD)/tls_align_dso.o
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/tls_align-static: $(BUILD)/tls_align_dso.o
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/tls_align_dlopen: LDLIBS+=-ldl
|
|
Szabolcs Nagy |
b775d1 |
$(BUILD)/tls_init tls_init-static: LDLIBS+=-lpthread
|
|
Szabolcs Nagy |
054f47 |
|