tomcrypt/makefile.shared
Steffen Jaeckel 09c4d4c93b proper use of $(DESTDIR)
@rofl0r @ [1]

"...still it's unusual/unexpected to embed DESTDIR in LIBPATH
etc. where this could hickup is when for example hardcoded paths need
to be embedded into the resulting binary. for example, in the
netbsd-curses makefile i linked earlier, such a case would be reference
to the terminfo DB location, which is derived from PREFIX.
other possible cases might be stuff that dlopen()s its own libs using an
absolute path, or uses other data files. for such a case a contributor
would typically re-use DATAPATH oslt and put it into CPPFLAGS or write
it into a header, to find the required files. when now these paths have
DESTDIR in them too, this will not work. thus it is good practice to use
$(DESTDIR) only in install targets, and keep it out of other vars."


[1] 8e29a6061f (commitcomment-22678488)

This closes #232
2017-06-22 14:21:14 +02:00

75 lines
2.2 KiB
Plaintext

# MAKEFILE for linux GCC
#
# This makefile produces a shared object and requires libtool to be installed.
#
# Thanks to Zed Shaw for helping debug this on BSD/OSX.
# Tom St Denis
#
# (GNU make only)
### USAGE:
#
# CFLAGS="-DUSE_LTM -DLTM_DESC -I/path/to/libtommath" make -f makefile.shared all EXTRALIBS=/path/to/libtommath/libtommath.a
# ./test
# make -f makefile.shared PREFIX=/opt/libtom install
#
PLATFORM := $(shell uname | sed -e 's/_.*//')
ifndef LT
ifeq ($(PLATFORM), Darwin)
LT:=glibtool
else
LT:=libtool
endif
endif
LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC)
INSTALL_CMD = $(LT) --mode=install install
#Output filenames for various targets.
ifndef LIBNAME
LIBNAME=libtomcrypt.la
endif
include makefile_include.mk
#ciphers come in two flavours... enc+dec and enc
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
$(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
.c.o:
$(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -c $<
$(LIBNAME): $(OBJECTS)
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./src -type f -name "*.lo" | LC_ALL=C sort` $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT)
install: .common_install
sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > libtomcrypt.pc
install -d $(DESTDIR)/$(LIBPATH)/pkgconfig
install -m 644 libtomcrypt.pc $(DESTDIR)/$(LIBPATH)/pkgconfig/
install_bins: .common_install_bins
test: $(LIBNAME) $(TOBJECTS)
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
timing: $(TIMINGS) $(LIBNAME)
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $^ $(EXTRALIBS)
# build the demos from a template
define DEMO_template
$(1): demos/$(1).o $$(LIBNAME)
ifneq ($V,1)
@echo " * $${CC} $$@"
endif
$$(LT) --mode=link --tag=CC $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
endef
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
# ref: $Format:%D$
# git commit: $Format:%H$
# commit time: $Format:%ai$