Skip to content

Commit 34540ac

Browse files
committed
fix building demos from makefile.shared
1 parent 9fa7400 commit 34540ac

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

makefile.shared

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,24 @@ uninstall:
7474
rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
7575
rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtommath.pc
7676

77-
test mtest_opponent: demo/shared.o $(LIBNAME) | demo/test.o demo/mtest_opponent.o
78-
$(LTLINK) $(LTM_LDFLAGS) -DLTM_TEST_DYNAMIC demo/$@.o $^ -o $@
77+
DEMOS=mtest_opponent test timing
78+
test: LTM_LDFLAGS+=-DLTM_TEST_DYNAMIC
79+
80+
# build the demos from a template
81+
define DEMO_template
82+
$(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demo/$(1).o demo/shared.o $$(LIBNAME)
83+
ifneq ($V,1)
84+
@echo " * $${CC} $$@" ${silent_echo}
85+
endif
86+
$(LTLINK) $(LTM_CFLAGS) $(LTM_LDFLAGS) $$^ -o $(1)
87+
endef
88+
89+
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
7990

8091
.PHONY: mtest
8192
mtest:
8293
cd mtest ; $(CC) $(LTM_CFLAGS) -O0 mtest.c $(LTM_LDFLAGS) -o mtest
8394

84-
timing: $(LIBNAME) demo/timing.c
85-
$(LTLINK) $(LTM_CFLAGS) $(LTM_LDFLAGS) -DTIMER demo/timing.c $(LIBNAME) -o timing
86-
8795
tune: $(LIBNAME)
8896
$(LTCOMPILE) $(LTM_CFLAGS) -c etc/tune.c -o etc/tune.o
8997
$(LTLINK) $(LTM_LDFLAGS) -o etc/tune etc/tune.o $(LIBNAME)

makefile_include.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ endif
8787

8888
ifdef COMPILE_LTO
8989
LTM_CFLAGS += -flto
90+
LTM_LDFLAGS += -flto
9091
AR = $(subst clang,llvm-ar,$(subst gcc,gcc-ar,$(CC)))
9192
endif
9293

0 commit comments

Comments
 (0)