parent
f03c8bd7dd
commit
2aaea5390a
3 changed files with 41 additions and 12 deletions
@ -0,0 +1 @@ |
|||||||
|
*.s?? |
@ -1,27 +1,38 @@ |
|||||||
|
|
||||||
|
# Function to expand a wildcard pattern recursively.
|
||||||
|
rwildcard=$(strip $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)$(filter $(subst *,%,$2),$d)))
|
||||||
|
|
||||||
.PHONY: all clean |
.PHONY: all clean |
||||||
CC=gcc
|
CC=gcc
|
||||||
CXX=g++
|
CXX=g++
|
||||||
CFLAGS=-std=c99
|
CFLAGS=-std=c99
|
||||||
INCLUDE=-Idescriptor -Isrc -Itests -I.
|
INCLUDE=-Idescriptor -Isrc -Itests -I.
|
||||||
CPPFLAGS=-O3 -fomit-frame-pointer -Wall -Wextra -g -DNDEBUG $(INCLUDE)
|
CPPFLAGS=-O3 -fomit-frame-pointer -Wall -Wextra -g -DNDEBUG $(INCLUDE)
|
||||||
OBJ=src/upb_parse.o src/upb_table.o src/upb_msg.o src/upb_enum.o src/upb_context.o \
|
|
||||||
src/upb_string.o src/upb_text.o src/upb_serialize.o descriptor/descriptor.o
|
ALL=deps $(OBJ) src/libupb.a tests/test_table tests/tests tools/upbc
|
||||||
SRC=src/*.c src/*.h descriptor/*.c descriptor/*.h tests/*.c tests/*.h tools/*.c
|
|
||||||
ALL=$(OBJ) src/libupb.a tests/test_table tests/tests tools/upbc benchmark/benchmark
|
|
||||||
all: $(ALL) |
all: $(ALL) |
||||||
clean: |
clean: |
||||||
rm -f $(ALL) benchmark/google_messages.proto.pb benchmark/google_messages.pb.*
|
rm -f $(call rwildcard,,*.o) $(ALL) benchmark/google_messages.proto.pb benchmark/google_messages.pb.* benchmark/b_*
|
||||||
|
|
||||||
test: tests/tests |
|
||||||
./tests/tests
|
|
||||||
|
|
||||||
|
# The core library (src/libupb.a)
|
||||||
|
OBJ=src/upb_parse.o src/upb_table.o src/upb_msg.o src/upb_enum.o src/upb_context.o \
|
||||||
|
src/upb_string.o src/upb_text.o src/upb_serialize.o descriptor/descriptor.o
|
||||||
|
SRC=$(call rwildcard,,*.c)
|
||||||
|
HEADERS=$(call rwildcard,,*.h)
|
||||||
src/libupb.a: $(OBJ) |
src/libupb.a: $(OBJ) |
||||||
ar rcs src/libupb.a $(OBJ)
|
ar rcs src/libupb.a $(OBJ)
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
test: tests/tests |
||||||
|
./tests/tests
|
||||||
tests/test_table: src/libupb.a |
tests/test_table: src/libupb.a |
||||||
tests/tests: src/libupb.a |
tests/tests: src/libupb.a |
||||||
|
|
||||||
|
# Tools
|
||||||
tools/upbc: src/libupb.a |
tools/upbc: src/libupb.a |
||||||
benchmark/benchmark: src/libupb.a benchmark/google_messages.pb.h benchmark/google_messages.pb.o benchmark/benchmark.o |
|
||||||
$(CXX) $(CPPFLAGS) -o benchmark/benchmark benchmark/google_messages.pb.o benchmark/benchmark.cc src/libupb.a -lm -lprotobuf -lpthread
|
# Benchmarks
|
||||||
benchmark/google_messages.pb.cc benchmark/google_messages.pb.h benchmark/google_messages.pb: benchmark/google_messages.proto |
|
||||||
protoc benchmark/google_messages.proto --cpp_out=. -obenchmark/google_messages.proto.pb
|
-include deps |
||||||
|
deps: $(SRC) $(HEADERS) gen-deps.sh Makefile |
||||||
|
./gen-deps.sh $(SRC)
|
||||||
|
@ -0,0 +1,17 @@ |
|||||||
|
#!/bin/sh |
||||||
|
# This script wraps gcc -MM, which unhelpfully strips the directory |
||||||
|
# off of the input filename. In other words, if you run: |
||||||
|
# |
||||||
|
# $ gcc -MM src/upb_parse.c |
||||||
|
# |
||||||
|
# ...the emitted dependency information looks like: |
||||||
|
# |
||||||
|
# upb_parse.o: src/upb_parse.h [...] |
||||||
|
# |
||||||
|
# Since upb_parse.o is actually in src, the dependency information is |
||||||
|
# not used. To remedy this, we use the -MT flag (see gcc docs). |
||||||
|
|
||||||
|
rm -f deps |
||||||
|
for file in $@; do |
||||||
|
gcc -MM $file -MT ${file%.*}.o -Idescriptor -Isrc -I. >> deps |
||||||
|
done |
Loading…
Reference in new issue