aboutsummaryrefslogtreecommitdiff
path: root/test/postinstall/c_app/makefile.mak
blob: 01d1c259b6d747abde620256d87a64eebc33ecfd (plain)
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
PROGRAM = c_app
OBJECTS = $(addsuffix .o,$(PROGRAM))
TESTS = \
  test_libpath.sh \
  test_transform.sh \
  test_searchpath.sh \
  test_version.sh

override CFLAGS += -g -Wall -Werror $(shell ${PKG_CONFIG} proj --cflags)

ifeq ($(BUILD_MODE),static)
  UNAME_S := $(shell uname -s)
  _ldflags := $(shell ${PKG_CONFIG} proj --libs --static)
  ifeq ($(UNAME_S),Linux)
    # force static linking to libproj
    _ldflags := $(shell echo $(_ldflags) | sed 's/-lproj/-Wl,-Bstatic -lproj -Wl,-Bdynamic/')
  endif
  override LDFLAGS += $(_ldflags)
else  # default is shared
  override LDFLAGS += $(shell ${PKG_CONFIG} proj --libs)
endif

all: $(PROGRAM)

$(PROGRAM): $(OBJECTS)
	$(CC) -o $@ $< $(LDFLAGS)

test: $(PROGRAM)
	set -e; for t in $(TESTS); do ./$$t; done

clean:
	$(RM) $(PROGRAM) $(OBJECTS)

.PHONY: test clean