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

Makefile - github.com/DanTheMan827/decodepng.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1941c85eb59d5e0b17cc8e038342c4d5ba2a6c47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
TARGET   := $(shell basename "$(shell pwd)")

SOURCES  := .
INCLUDES := $(SOURCES)

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 -f *.o *.d
	@rm -f lodepng/*.o lodepng/*.d