2004-10-30 03:00:26 +00:00
|
|
|
# MAKEFILE for linux GCC
|
|
|
|
|
#
|
2022-07-16 08:20:49 -07:00
|
|
|
# This makefile produces a shared object.
|
2004-12-30 23:55:53 +00:00
|
|
|
#
|
2013-09-03 14:27:32 +02:00
|
|
|
# Thanks to Zed Shaw for helping debug this on BSD/OSX.
|
2004-10-30 03:00:26 +00:00
|
|
|
# Tom St Denis
|
2017-05-10 11:56:52 +02:00
|
|
|
#
|
|
|
|
|
# (GNU make only)
|
2004-10-30 03:00:26 +00:00
|
|
|
|
2017-06-13 14:57:07 +02:00
|
|
|
### USAGE:
|
|
|
|
|
#
|
|
|
|
|
# CFLAGS="-DUSE_LTM -DLTM_DESC -I/path/to/libtommath" make -f makefile.shared all EXTRALIBS=/path/to/libtommath/libtommath.a
|
|
|
|
|
# ./test
|
2017-06-19 12:20:37 +02:00
|
|
|
# make -f makefile.shared PREFIX=/opt/libtom install
|
2017-06-13 14:57:07 +02:00
|
|
|
#
|
|
|
|
|
|
2017-06-13 12:25:25 +02:00
|
|
|
PLATFORM := $(shell uname | sed -e 's/_.*//')
|
2021-04-09 12:32:05 +02:00
|
|
|
### Observed uname outputs:
|
|
|
|
|
# MINGW32_NT-6.2 (on MSYS/MINGW old)
|
|
|
|
|
# MINGW64_NT-10.0-14393 (on MSYS new)
|
|
|
|
|
# MSYS_NT-10.0-19042 (on MSYS2)
|
|
|
|
|
# CYGWIN_NT-10.0 (on Cygwin 64bit)
|
|
|
|
|
# CYGWIN_NT-6.2-WOW64 (on Cygwin 32bit)
|
|
|
|
|
# Linux (on all Linux distros)
|
|
|
|
|
# Darwin (on macOS, OS X)
|
2017-06-13 12:25:25 +02:00
|
|
|
|
2022-07-16 08:20:49 -07:00
|
|
|
INSTALL_CMD := install
|
|
|
|
|
UNINSTALL_CMD := rm -f
|
|
|
|
|
|
|
|
|
|
NAME := libtomcrypt
|
|
|
|
|
PIC := -fPIC
|
|
|
|
|
SHARED := $(PIC)
|
|
|
|
|
|
|
|
|
|
ifeq ($(UNAME), Darwin)
|
|
|
|
|
NO_UNDEFINED := -Wl,-undefined,error
|
|
|
|
|
SHARED += -dynamiclib
|
2019-06-03 09:32:06 +02:00
|
|
|
else
|
2022-07-16 08:20:49 -07:00
|
|
|
NO_UNDEFIED := -Wl,--no-undefined
|
|
|
|
|
SHARED += -shared
|
2017-05-02 10:34:16 +02:00
|
|
|
endif
|
2019-06-03 09:32:06 +02:00
|
|
|
|
2022-07-16 08:20:49 -07:00
|
|
|
ifeq ($(PLATFORM), Darwin)
|
|
|
|
|
TARGET := $(NAME).dylib
|
|
|
|
|
else ifeq ($(OS), Windows_NT)
|
|
|
|
|
TARGET := $(NAME).dll
|
|
|
|
|
else
|
|
|
|
|
TARGET := $(NAME).so
|
2017-09-26 20:06:32 +02:00
|
|
|
endif
|
2019-06-03 09:32:06 +02:00
|
|
|
|
2004-10-30 03:00:26 +00:00
|
|
|
#Output filenames for various targets.
|
2005-08-01 16:36:47 +00:00
|
|
|
ifndef LIBNAME
|
2022-07-16 08:20:49 -07:00
|
|
|
LIBNAME = $(TARGET).$(VERSION_LT)
|
2005-08-01 16:36:47 +00:00
|
|
|
endif
|
|
|
|
|
|
2017-05-10 11:56:52 +02:00
|
|
|
include makefile_include.mk
|
|
|
|
|
|
2023-01-18 16:41:36 +01:00
|
|
|
ifneq ($(findstring -DLTM_DESC,$(LTC_CFLAGS)),)
|
2024-10-21 17:07:02 +02:00
|
|
|
LTC_PKG_CONFIG_CFLAGS += -DLTM_DESC
|
|
|
|
|
LTC_PKG_CONFIG_LIBS += -ltommath
|
2023-01-18 16:41:36 +01:00
|
|
|
endif
|
|
|
|
|
ifneq ($(findstring -DTFM_DESC,$(LTC_CFLAGS)),)
|
2024-10-21 17:07:02 +02:00
|
|
|
LTC_PKG_CONFIG_CFLAGS += -DTFM_DESC
|
|
|
|
|
LTC_PKG_CONFIG_LIBS += -ltfm
|
2023-01-18 16:41:36 +01:00
|
|
|
endif
|
|
|
|
|
ifneq ($(findstring -DGMP_DESC,$(LTC_CFLAGS)),)
|
2024-10-21 17:07:02 +02:00
|
|
|
LTC_PKG_CONFIG_CFLAGS += -DGMP_DESC
|
|
|
|
|
LTC_PKG_CONFIG_LIBS += -lgmp
|
2023-01-18 16:41:36 +01:00
|
|
|
endif
|
2024-10-21 17:07:02 +02:00
|
|
|
ifneq ($(findstring -DLTC_PTHREAD,$(LTC_CFLAGS)),)
|
|
|
|
|
LTC_PKG_CONFIG_CFLAGS += -DLTC_PTHREAD
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# set PKG_CONFIG_CFLAGS and PKG_CONFIG_LIBS to what your environment requires
|
|
|
|
|
LTC_PKG_CONFIG_CFLAGS += $(PKG_CONFIG_CFLAGS)
|
|
|
|
|
LTC_PKG_CONFIG_LIBS += $(PKG_CONFIG_LIBS)
|
2017-05-10 11:56:52 +02:00
|
|
|
|
2022-07-16 08:20:49 -07:00
|
|
|
.PHONY: check install install_bins uninstall
|
|
|
|
|
|
|
|
|
|
.bin/.tag: bin.in
|
|
|
|
|
mkdir -p .bin
|
|
|
|
|
touch $@
|
|
|
|
|
|
2013-09-03 14:27:32 +02:00
|
|
|
#ciphers come in two flavours... enc+dec and enc
|
2004-12-30 23:55:53 +00:00
|
|
|
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
|
2022-07-16 08:20:49 -07:00
|
|
|
$(CC) $(LTC_CFLAGS) $(PIC) $(CPPFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
|
2021-09-30 14:49:26 +02:00
|
|
|
src/ciphers/aes/aes_enc_desc.o: src/ciphers/aes/aes_desc.c
|
2022-07-16 08:20:49 -07:00
|
|
|
$(CC) $(LTC_CFLAGS) $(PIC) $(CPPFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes_desc.c -o src/ciphers/aes/aes_enc_desc.o
|
2004-10-30 03:00:26 +00:00
|
|
|
|
2014-07-14 14:26:41 +02:00
|
|
|
.c.o:
|
2022-07-16 08:20:49 -07:00
|
|
|
$(CC) $(LTC_CFLAGS) $(PIC) $(CPPFLAGS) -o $@ -c $<
|
2017-07-10 10:20:36 +02:00
|
|
|
|
2014-07-14 14:26:41 +02:00
|
|
|
$(LIBNAME): $(OBJECTS)
|
2022-07-16 08:20:49 -07:00
|
|
|
$(CC) $(LTC_LDFLAGS) $(OBJECTS) $(EXTRALIBS) $(SHARED) -Wl,-soname,$(TARGET).$(VERSION_MAJOR) $(NO_UNDEFINED) -o $@
|
|
|
|
|
|
|
|
|
|
$(TARGET).$(VERSION_MAJOR) $(TARGET): $(LIBNAME)
|
|
|
|
|
ln -sf $< $@
|
2017-05-02 20:47:00 +02:00
|
|
|
|
2022-07-16 08:20:49 -07:00
|
|
|
.bin/$(TEST): $(TARGET).$(VERSION_MAJOR) $(TARGET) $(TOBJECTS) .bin/.tag
|
|
|
|
|
$(CC) $(LTC_LDFLAGS) $(TOBJECTS) -L. -ltomcrypt $(EXTRALIBS) $(NO_UNDEFINED) -o $@
|
|
|
|
|
|
|
|
|
|
test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) .bin/$(TEST)
|
|
|
|
|
$(INSTALL_CMD) -m 755 bin.in $@
|
2005-04-17 11:37:13 +00:00
|
|
|
|
2017-03-23 01:13:43 +01:00
|
|
|
# build the demos from a template
|
|
|
|
|
define DEMO_template
|
2022-07-16 08:20:49 -07:00
|
|
|
.bin/$(1): demos/$(1).o $$(TARGET).$$(VERSION_MAJOR) $$(TARGET) .bin/.tag
|
|
|
|
|
$$(CC) $$(LTC_LDFLAGS) $$< -L. -ltomcrypt $$(EXTRALIBS) $(NO_UNDEFINED) -o $$@
|
|
|
|
|
|
|
|
|
|
$(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) .bin/$(1)
|
|
|
|
|
$$(INSTALL_CMD) -m 755 bin.in $(1)
|
2017-03-23 01:13:43 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
|
|
|
|
|
|
2017-08-31 05:15:49 -04:00
|
|
|
install: $(call print-help,install,Installs the library + headers + pkg-config file) .common_install
|
2022-07-16 08:20:49 -07:00
|
|
|
ln -sf $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(TARGET).$(VERSION_MAJOR)
|
|
|
|
|
ln -sf $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(TARGET)
|
2023-07-25 10:03:00 +02:00
|
|
|
sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' -e 's,^libdir=.*,libdir=$(LIBPATH),' \
|
|
|
|
|
-e 's,^includedir=.*,includedir=$(INCPATH),' \
|
2024-10-21 17:07:02 +02:00
|
|
|
-e 's,@PKG_CONFIG_LIBS@,$(LTC_PKG_CONFIG_LIBS),' \
|
|
|
|
|
-e 's,@PKG_CONFIG_CFLAGS@,$(LTC_PKG_CONFIG_CFLAGS),' libtomcrypt.pc.in > libtomcrypt.pc
|
2022-07-16 08:20:49 -07:00
|
|
|
$(INSTALL_CMD) -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
|
|
|
|
|
$(INSTALL_CMD) -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
|
2017-07-14 12:18:51 +02:00
|
|
|
|
2022-07-16 08:20:49 -07:00
|
|
|
install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) $(USEFUL_DEMOS) $(DESTDIR)$(BINPATH)
|
|
|
|
|
$(INSTALL_CMD) -p -m 775 $(foreach demo, $(strip $(USEFUL_DEMOS)),.bin/$(demo)) $(DESTDIR)$(BINPATH)
|
2017-07-14 12:18:51 +02:00
|
|
|
|
2017-08-31 05:15:49 -04:00
|
|
|
uninstall: $(call print-help,uninstall,Uninstalls the library + headers + pkg-config file) .common_uninstall
|
2022-07-16 08:20:49 -07:00
|
|
|
$(UNINSTALL_CMD) $(DESTDIR)/$(LIBPATH)/$(TARGET).$(VERSION_MAJOR)
|
|
|
|
|
$(UNINSTALL_CMD) $(DESTDIR)/$(LIBPATH)/$(TARGET)
|
|
|
|
|
$(UNINSTALL_CMD) $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
|