Created
July 12, 2016 01:48
-
-
Save Higgs1/67892140dc7f6cf30c5a0e2f7c20dd3f to your computer and use it in GitHub Desktop.
Some Weird Derpy Telegram-CLI Makefile I Made
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SRC_DIR=src | |
TGL_DIR=${SRC_DIR}/tgl | |
# SOURCE FILES | |
TG_FILES = main loop interface json-tg lua-tg python-tg python-types | |
MTP_FILES = common client key utils | |
TGL_FILES = binlog queries structures tgl tgl-net tgl-timers tg-mime-types tools updates $(addprefix mtproto-, ${MTP_FILES}) | |
CRYPT_FILES = aes bn err md5 rand rsa_pem sha | |
AUTO_FILES = autocomplete fetch skip store types fetch-ds free-ds print-ds store-ds | |
# COMPILE OPTIONS | |
LDLIBS = $(shell pkg-config --libs libcrypto zlib libconfig lua5.2 jansson libevent) -lreadline -lpython3.5m | |
LDFLAGS = -Wl,--build-id=none,--gc-sections,--hash-style=gnu,-z,norelro | |
CPATH = -I. -I${SRC_DIR} -I${TGL_DIR} -I/usr/include/python3.5m -I/usr/include/lua5.2 | |
CFLAGS = -D__EVENT_OLD_H__ -DHAVE_CONFIG_H -Os -s -pipe -march=native -fdata-sections -ffunction-sections -fmerge-all-constants -fno-asynchronous-unwind-tables -fno-ident -fno-math-errno -fno-stack-protector -fno-unroll-loops -fno-unwind-tables -Wall -Wno-strict-aliasing | |
# ALIASES | |
GENERATE = ./generate -g $(subst auto-,,$(basename $(notdir $@))) | |
COMPRESS = upx --ultra-brute -9 -q $@ | |
STRIP = strip -S --strip-unneeded -R .comment -R .note* $@ | |
COMPILE = ${CC} ${CFLAGS} ${LDFLAGS} ${LDLIBS} ${CPATH} $^ -o $@ | |
# MISC | |
_CRYPT_FILES = $(addprefix crypto/, $(addsuffix _openssl, ${CRYPT_FILES}) $(addsuffix _altern, ${CRYPT_FILES})) | |
telegram-cli: $(addsuffix .c, $(addprefix ${SRC_DIR}/, ${TG_FILES}) $(addprefix ${TGL_DIR}/, ${TGL_FILES} ${_CRYPT_FILES}) $(addprefix auto/auto-, ${AUTO_FILES})) auto/constants.h | ${TGL_DIR}/mime-types.c ${TGL_DIR}/config.h | |
${COMPILE} | |
${STRIP} | |
${COMPRESS} | |
generate: $(addsuffix .c, $(addprefix ${TGL_DIR}/, generate tools ${_CRYPT_FILES})) | ${TGL_DIR}/config.h | |
${COMPILE} | |
${COMPRESS} | |
tl-parser: ${TGL_DIR}/tl-parser/*.c | ${TGL_DIR}/config.h | |
${COMPILE} | |
${COMPRESS} | |
.SECONDARY: | |
auto/auto-%.h: scheme.tlo generate | auto | |
${GENERATE}-header $< > $@ | |
.SECONDEXPANSION: | |
auto/auto-%.c: scheme.tlo generate $$(basename $$@).h | |
${GENERATE} $< > $@ | |
auto/constants.h: ${TGL_DIR}/gen_constants_h.awk scheme.tl tl-parser | auto | |
./tl-parser -E scheme.tl 2>&1 | awk -f $< > $@ | |
scheme.tlo: scheme.tl tl-parser | |
./tl-parser -e $@ $< | |
scheme.tl: $(addsuffix .tl, $(addprefix ${TGL_DIR}/, scheme encrypted_scheme binlog append mtproto)) | |
cat > $@ $^ | |
auto: | |
mkdir -p $@ | |
clean: | |
rm -rf auto generate scheme.tl scheme.tlo telegram-cli tl-parser mime.types ${TGL_DIR}/mime-types.c | |
MIME_TYPES_URL = http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=co | |
${TGL_DIR}/mime.types: | |
curl ${MIME_TYPES_URL} > $@ | |
mime.types: ${TGL_DIR}/mime.types | ${TGL_DIR} | |
awk '!/^#/' $< > $@ | |
${TGL_DIR}/mime-types.c: mime.types | |
xxd -i $< > $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment