diff options
author | Daniel <790119+DanTheMan827@users.noreply.github.com> | 2017-12-01 06:32:39 +0300 |
---|---|---|
committer | Daniel <790119+DanTheMan827@users.noreply.github.com> | 2017-12-01 06:34:02 +0300 |
commit | 058ce88e55db765f715b41b902b980c78df42fc7 (patch) | |
tree | 1dd7990a4ee379dcc674a28b30d802d92c7e6beb /Makefile | |
parent | 39924ba0ab4a0c3fabdf562bb695ca247b13fb2a (diff) |
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 59 |
1 files changed, 51 insertions, 8 deletions
@@ -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 |