2012-11-03 01:16:01 +00:00
|
|
|
DEFINES=
|
2020-06-17 21:31:31 +00:00
|
|
|
PREFIX?=
|
|
|
|
EXE_EXT?=
|
|
|
|
CC=$(PREFIX)gcc
|
|
|
|
CXX=$(PREFIX)g++
|
|
|
|
LD=$(PREFIX)g++
|
|
|
|
PKGCONFIG:=$(CROSS)pkg-config
|
|
|
|
|
|
|
|
TARGET_TRIPLE:=$(shell $(CC) -dumpmachine)
|
|
|
|
ifneq ($(findstring -w64-,$(TARGET_TRIPLE)),)
|
|
|
|
TARGET_OS := Windows
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(TARGET_OS), Windows)
|
|
|
|
# -static allows to statically include libwinpthread-1.dll if possible
|
|
|
|
CFLAGS+=-gstabs
|
|
|
|
CXXFLAGS+=-gstabs
|
|
|
|
LDFLAGS+=-static-libgcc -static
|
|
|
|
else
|
2019-01-24 12:31:07 +00:00
|
|
|
# Distros could use different names for the crypto library. We try a list
|
|
|
|
# of candidate names, only one of them should be the valid one.
|
|
|
|
LIBCRYPTO_NAMES = libcryptopp libcrypto++ cryptopp crypto++
|
|
|
|
|
|
|
|
$(foreach l,$(LIBCRYPTO_NAMES),\
|
2020-06-17 21:31:31 +00:00
|
|
|
$(eval LDLIBS += $(shell $(PKGCONFIG) --silence-errors --libs $(l))))
|
2019-01-24 12:31:07 +00:00
|
|
|
$(foreach l,$(LIBCRYPTO_NAMES),\
|
|
|
|
$(eval CFLAGS += $(shell $(PKGCONFIG) --silence-errors --cflags $(l))))
|
|
|
|
$(foreach l,$(LIBCRYPTO_NAMES),\
|
|
|
|
$(eval CXXFLAGS += $(shell $(PKGCONFIG) --silence-errors --cflags $(l))))
|
2020-06-17 21:31:31 +00:00
|
|
|
endif
|
2019-01-24 12:31:07 +00:00
|
|
|
|
2020-06-17 21:31:31 +00:00
|
|
|
CXXFLAGS+=-g -Wall $(DEFINES)
|
|
|
|
CFLAGS+=-g -Wall -std=c99 $(DEFINES)
|
2020-07-21 13:15:10 +00:00
|
|
|
LDLIBS+=-lpthread -lz
|
2019-01-24 12:31:07 +00:00
|
|
|
|
2020-06-17 21:31:31 +00:00
|
|
|
BINS=upgtool$(EXE_EXT)
|
2012-11-03 01:16:01 +00:00
|
|
|
|
|
|
|
all: $(BINS)
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
|
|
|
|
%.o: %.cpp
|
|
|
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
|
|
|
|
2020-06-17 21:31:31 +00:00
|
|
|
upgtool$(EXE_EXT): upgtool.o upg.o misc.o mg.o keysig_search.o
|
|
|
|
$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
|
2012-11-03 01:16:01 +00:00
|
|
|
|
|
|
|
clean:
|
2020-06-17 21:31:31 +00:00
|
|
|
rm -rf *.o
|
2012-11-03 01:16:01 +00:00
|
|
|
|
|
|
|
veryclean:
|
|
|
|
rm -rf $(BINS)
|