Now builds without glib

This commit is contained in:
Dan Hirsch 2012-10-10 16:45:10 +02:00
parent 158b2b3ba6
commit 8eececcac8
5 changed files with 40 additions and 13 deletions

View file

@ -5,6 +5,10 @@
SUBDIRS = src examples SUBDIRS = src examples
include config.mk
CONFIG_VARS= INCLUDE_TESTS
.DEFAULT_GOAL := all .DEFAULT_GOAL := all
%: %:
@ -25,3 +29,6 @@ $(foreach dir,$(SUBDIRS),$(eval $(call SUBDIR_TEMPLATE,$(dir))))
TAGS: $(shell find * -name "*.c") TAGS: $(shell find * -name "*.c")
etags $^ etags $^
config:
@printf "%30s %s\n" $(foreach var,$(CONFIG_VARS),$(var) $($(var)) )

View file

@ -1,17 +1,29 @@
CFLAGS := $(shell pkg-config --cflags glib-2.0) -std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes
LDFLAGS := $(shell pkg-config --libs glib-2.0)
CC ?= gcc
$(info CC=$(CC))
# Set V=1 for verbose mode...
V ?= 0
CFLAGS += -DINCLUDE_TESTS $(EXTRA_CFLAGS)
HUSH = $(TOPLEVEL)/lib/hush
# Check to make sure variables are properly set # Check to make sure variables are properly set
ifeq ($(TOPLEVEL),) ifeq ($(TOPLEVEL),)
$(error $$TOPLEVEL is unset) $(error $$TOPLEVEL is unset)
endif endif
include $(TOPLEVEL)/config.mk
TEST_CFLAGS := $(shell pkg-config --cflags glib-2.0) -DINCLUDE_TESTS
TEST_LDFLAGS := $(shell pkg-config --libs glib-2.0)
CFLAGS := -std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes
LDFLAGS :=
ifneq ($(INCLUDE_TESTS),0)
CFLAGS += $(TEST_CFLAGS)
LDFLAGS += $(TEST_LDFLAGS)
endif
CC ?= gcc
$(info CC=$(CC))
# Set V=1 for verbose mode...
V ?= 0
CFLAGS += $(EXTRA_CFLAGS)
HUSH = $(TOPLEVEL)/lib/hush
ifsilent = $(if $(findstring 0, $(V)),$(1),) ifsilent = $(if $(findstring 0, $(V)),$(1),)
hush = $(call ifsilent,$(HUSH) $(1)) hush = $(call ifsilent,$(HUSH) $(1))
#.SUFFIXES: #.SUFFIXES:

1
config.mk Normal file
View file

@ -0,0 +1 @@
INCLUDE_TESTS = 1

View file

@ -7,6 +7,9 @@ OUTPUTS := dns.o \
TOPLEVEL := ../ TOPLEVEL := ../
include ../common.mk include ../common.mk
CFLAGS += $(pkg-config --cflags glib-2.0)
LDFLAGS += $(pkg-config --libs glib-2.0)
all: dns base64 all: dns base64

View file

@ -42,10 +42,7 @@ TOPLEVEL := ../
include ../common.mk include ../common.mk
all: libhammer.a test_suite all: libhammer.a
test_suite: test_suite.o libhammer.a
$(call hush, "Linking $@") $(CC) -o $@ $^ $(LDFLAGS)
libhammer.a: bitreader.o hammer.o pprint.o allocator.o datastructures.o bitwriter.o system_allocator.o \ libhammer.a: bitreader.o hammer.o pprint.o allocator.o datastructures.o bitwriter.o system_allocator.o \
$(PARSERS:%=parsers/%.o) $(PARSERS:%=parsers/%.o)
@ -53,5 +50,12 @@ libhammer.a: bitreader.o hammer.o pprint.o allocator.o datastructures.o bitwrite
bitreader.o: test_suite.h bitreader.o: test_suite.h
hammer.o: hammer.h hammer.o: hammer.h
ifneq ($(INCLUDE_TESTS),0)
all: test_suite
test: test_suite test: test_suite
./test_suite -v ./test_suite -v
test_suite: test_suite.o libhammer.a
$(call hush, "Linking $@") $(CC) -o $@ $^ $(LDFLAGS)
endif