67 lines
2.1 KiB
Makefile
67 lines
2.1 KiB
Makefile
|
# ---------------------------------------------------------------------------
|
||
|
# FLAGS
|
||
|
# ---------------------------------------------------------------------------
|
||
|
|
||
|
MACHINE := $(shell gcc -dumpmachine)
|
||
|
ifeq ($(MACHINE),$(filter x86_64-%,$(MACHINE)))
|
||
|
MYCPU := x64
|
||
|
MARCH := x86-64
|
||
|
MTUNE := corei7
|
||
|
else
|
||
|
MYCPU := x86
|
||
|
MARCH := i486
|
||
|
MTUNE := intel
|
||
|
endif
|
||
|
|
||
|
CFLAGS = -municode -march=$(MARCH) -mtune=$(MTUNE) -Os -DNDEBUG -Wall -flto -Ideps/$(MYCPU)/include
|
||
|
LDFLAGS = -static -Ldeps/$(MYCPU)/lib -Wl,--strip-all
|
||
|
LIBS = -lcrypto
|
||
|
|
||
|
ifneq ($(XCFLAGS),)
|
||
|
CFLAGS += $(XCFLAGS)
|
||
|
endif
|
||
|
ifneq ($(XLDFLAGS),)
|
||
|
LDFLAGS += $(XLDFLAGS)
|
||
|
endif
|
||
|
ifneq ($(XLIBS),)
|
||
|
LIBS += $(XLIBS)
|
||
|
endif
|
||
|
|
||
|
# ---------------------------------------------------------------------------
|
||
|
# RULES
|
||
|
# ---------------------------------------------------------------------------
|
||
|
|
||
|
.PHONY: all keygen sign verify subdirs clean
|
||
|
|
||
|
all: keygen sign verify
|
||
|
|
||
|
keygen: subdirs src/.magic.h
|
||
|
windres -DAPP="Key Generator ($(MYCPU))" -DNAME=keygen -o obj/version_keygen.o res/version.rc
|
||
|
gcc $(CFLAGS) $(LDFLAGS) -o bin/codesign_keygen.exe src/codesign_keygen.c src/common.c obj/version_keygen.o $(LIBS)
|
||
|
|
||
|
sign: subdirs src/.magic.h
|
||
|
windres -DAPP="Signer ($(MYCPU))" -DNAME=sign -o obj/version_sign.o res/version.rc
|
||
|
gcc $(CFLAGS) $(LDFLAGS) -o bin/codesign_sign.exe src/codesign_sign.c src/common.c obj/version_sign.o $(LIBS)
|
||
|
|
||
|
verify: subdirs src/.magic.h
|
||
|
windres -DAPP="Verifier ($(MYCPU))" -DNAME=verify -o obj/version_verify.o res/version.rc
|
||
|
windres -DAPP="Verifier ($(MYCPU))" -DNAME=verifz -o obj/version_verifz.o res/version.rc
|
||
|
gcc $(CFLAGS) -UEMBED_PUBKEY $(LDFLAGS) -o bin/codesign_verify.exe src/codesign_verify.c src/common.c obj/version_verify.o $(LIBS)
|
||
|
gcc $(CFLAGS) -DEMBED_PUBKEY $(LDFLAGS) -o bin/codesign_verifz.exe src/codesign_verify.c src/common.c obj/version_verifz.o $(LIBS)
|
||
|
|
||
|
src/.magic.h:
|
||
|
str=$$(tr -dc '0-9A-F' < /dev/urandom | head -c 26); \
|
||
|
printf 'static const unsigned char MAGIC_NMBR[] = { ' > $@; \
|
||
|
for i in {0..12}; do \
|
||
|
[ $$i -gt 0 ] && printf ', '; \
|
||
|
printf '0x%s' $${str:((2*i)):2}; \
|
||
|
done >> $@; \
|
||
|
printf ' };\n' >> $@
|
||
|
|
||
|
subdirs:
|
||
|
@mkdir -p bin obj
|
||
|
|
||
|
clean:
|
||
|
rm -rf bin obj
|
||
|
rm -f src/.magic.h
|