Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/DanTheMan827/decodepng.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel <790119+DanTheMan827@users.noreply.github.com>2017-12-01 06:32:39 +0300
committerDaniel <790119+DanTheMan827@users.noreply.github.com>2017-12-01 06:34:02 +0300
commit058ce88e55db765f715b41b902b980c78df42fc7 (patch)
tree1dd7990a4ee379dcc674a28b30d802d92c7e6beb /Makefile
parent39924ba0ab4a0c3fabdf562bb695ca247b13fb2a (diff)
Convert to C and optimize (thanks madmonkey)HEADmaster
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile59
1 files changed, 51 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 229e12a..1941c85 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,55 @@
-BUILD_FLAGS := -DBUILD_COMMIT="\"`git rev-parse --short HEAD``git diff --shortstat --quiet || echo ' (dirty)'`\"" -DBUILD_DATE="\"`date -u +'%Y-%m-%d %H:%M:%S %Z'`\""
+TARGET := $(shell basename "$(shell pwd)")
-all:
- mkdir -p bin
- g++ -o bin/decodepng decodepng.cpp lodepng/lodepng.cpp $(BUILD_FLAGS)
+SOURCES := .
+INCLUDES := $(SOURCES)
-armhf:
- mkdir -p bin
- arm-linux-gnueabihf-g++ -o bin/decodepng-armhf decodepng.cpp lodepng/lodepng.cpp $(BUILD_FLAGS)
+CFLAGS :=
+CFLAGS := $(CFLAGS) -Wall -Wextra -Os -std=gnu99
+#CFLAGS := $(CFLAGS) -flto=3 -fwhole-program -fuse-linker-plugin
+CFLAGS := $(CFLAGS) -flto=4 -fuse-linker-plugin
+CFLAGS := $(CFLAGS) -fno-stack-protector -fno-ident -fomit-frame-pointer -falign-functions=1 -falign-jumps=1 -falign-loops=1 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops -fmerge-all-constants -fno-math-errno
+CFLAGS := $(CFLAGS) -Wl,--as-needed
+CFLAGS := $(CFLAGS) -DBUILD_COMMIT="\"`git rev-parse --short HEAD``git diff --shortstat --quiet || echo ' (dirty)'`\"" -DBUILD_DATE="\"`date -u +'%Y-%m-%d %H:%M:%S %Z'`\""
+
+LIBDIR :=
+LDFLAGS := -lm -lc
+
+INCLUDE += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir))
+CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
+CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
+
+OBJS := $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
+DEPENDS := $(OBJS:.o=.d)
+
+OUTPUT := $(CURDIR)/bin
+ELF := $(OUTPUT)/$(TARGET)
+
+export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
+
+GCC ?= $(CROSS_COMPILE)gcc
+STRIP ?= $(CROSS_COMPILE)strip
+
+.PHONY: all elf dir
+all: elf
+elf: $(ELF)
+
+%.o:%.c Makefile
+ @$(GCC) -MMD $(CFLAGS) $(INCLUDE) -c $< -o $@
+
+%.o:%.cpp Makefile
+ @$(GCC) -MMD $(CFLAGS) $(INCLUDE) -c $< -o $@
+
+-include $(DEPENDS)
+
+dir:
+ @mkdir -p "$(OUTPUT)"
+
+$(ELF).elf: $(OBJS) dir
+ @$(GCC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@ && $(STRIP) --strip-all $@
+
+$(ELF): $(ELF).elf
+ @upx -qq --ultra-brute $^ -o $@ -f
clean:
- rm -r bin \ No newline at end of file
+ @rm -f *.o *.d
+ @rm -f lodepng/*.o lodepng/*.d