2020-10-14 19:59:12 +02:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# Options
|
|
|
|
# ---------------------------------------------------------------------------
|
2020-10-13 23:36:58 +02:00
|
|
|
|
2020-10-21 21:58:46 +02:00
|
|
|
DEBUG ?= 0
|
2020-10-29 18:12:21 +01:00
|
|
|
ASAN ?= 0
|
2020-10-21 21:58:46 +02:00
|
|
|
STATIC ?= 0
|
2020-11-01 22:46:25 +01:00
|
|
|
FLTO ?= 0
|
2020-10-29 18:12:21 +01:00
|
|
|
FPGO ?= 0
|
2020-10-31 16:33:53 +01:00
|
|
|
STRIP ?= 0
|
2020-10-29 18:12:21 +01:00
|
|
|
MARCH ?= native
|
|
|
|
MTUNE ?= native
|
2020-10-14 19:59:12 +02:00
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
2020-10-19 21:56:12 +02:00
|
|
|
# Directories
|
2020-10-14 19:59:12 +02:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
2020-10-19 21:56:12 +02:00
|
|
|
SUBDIR_APP := frontend
|
|
|
|
SUBDIR_LIB := libslunkcrypt
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# Flags
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
2020-11-04 23:46:43 +01:00
|
|
|
CFLAGS = -I$(SUBDIR_LIB)/include -std=gnu99 -Wall -march=$(MARCH) -mtune=$(MTUNE)
|
2020-10-31 16:33:53 +01:00
|
|
|
LDFLGS =
|
2020-10-14 19:59:12 +02:00
|
|
|
|
|
|
|
ifeq ($(DEBUG),1)
|
2020-10-20 17:46:18 +02:00
|
|
|
CONFIG := _g
|
2020-10-21 17:07:03 +02:00
|
|
|
CFLAGS += -Og -g
|
2020-10-29 18:12:21 +01:00
|
|
|
else ifeq ($(ASAN),1)
|
|
|
|
CONFIG := _a
|
|
|
|
CFLAGS += -O1 -g -fsanitize=address -fno-omit-frame-pointer
|
2020-10-14 19:59:12 +02:00
|
|
|
else
|
2020-10-21 17:07:03 +02:00
|
|
|
CONFIG :=
|
2020-10-14 21:55:39 +02:00
|
|
|
CFLAGS += -O3 -DNDEBUG
|
2020-11-01 22:46:25 +01:00
|
|
|
ifneq ($(FLTO),0)
|
|
|
|
CFLAGS += -flto -fuse-linker-plugin
|
2020-10-14 19:59:12 +02:00
|
|
|
endif
|
2020-10-29 18:12:21 +01:00
|
|
|
ifneq ($(FPGO),0)
|
|
|
|
CFLAGS += -fprofile-$(FPGO)
|
|
|
|
endif
|
2020-11-01 22:46:25 +01:00
|
|
|
endif
|
2020-10-29 18:12:21 +01:00
|
|
|
|
2020-10-21 17:07:03 +02:00
|
|
|
MACHINE := $(shell $(CC) -dumpmachine)
|
2020-10-14 19:59:12 +02:00
|
|
|
|
2020-10-28 16:21:01 +01:00
|
|
|
ifneq ($(filter %mingw32 %-windows-gnu %-cygwin %-cygnus,$(MACHINE)),)
|
2020-10-14 19:59:12 +02:00
|
|
|
SUFFIX := .exe
|
2020-10-13 23:36:58 +02:00
|
|
|
else
|
2020-10-21 17:07:03 +02:00
|
|
|
SUFFIX :=
|
2020-10-13 23:36:58 +02:00
|
|
|
endif
|
|
|
|
|
2020-10-28 16:21:01 +01:00
|
|
|
ifeq ($(filter %mingw32 %-windows-gnu,$(MACHINE)),)
|
2020-10-28 14:40:13 +01:00
|
|
|
LDFLGS += -lpthread
|
|
|
|
endif
|
|
|
|
|
2020-10-31 16:33:53 +01:00
|
|
|
ifneq ($(STRIP),0)
|
|
|
|
LDFLGS += -s
|
|
|
|
endif
|
|
|
|
|
2020-10-21 21:58:46 +02:00
|
|
|
ifeq ($(STATIC),1)
|
|
|
|
LDFLGS += -static
|
|
|
|
endif
|
|
|
|
|
2020-10-22 18:01:59 +02:00
|
|
|
ifneq ($(filter %-w64-mingw32 %w64-windows-gnu,$(MACHINE)),)
|
2020-10-21 17:07:03 +02:00
|
|
|
LDFLGS += -mconsole -municode
|
2020-10-14 19:59:12 +02:00
|
|
|
endif
|
|
|
|
|
2020-10-19 21:56:12 +02:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# File names
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
OUTNAME_APP := slunkcrypt$(CONFIG)$(SUFFIX)
|
|
|
|
OUTNAME_LIB := libslunkcrypt$(CONFIG)-1.a
|
|
|
|
|
|
|
|
OUTPATH_APP := $(SUBDIR_APP)/bin/$(OUTNAME_APP)
|
|
|
|
OUTPATH_LIB := $(SUBDIR_LIB)/lib/$(OUTNAME_LIB)
|
2020-10-14 19:59:12 +02:00
|
|
|
|
2020-10-19 21:56:12 +02:00
|
|
|
SOURCES_APP := $(wildcard $(SUBDIR_APP)/src/*.c)
|
|
|
|
OBJECTS_APP := $(patsubst $(SUBDIR_APP)/src/%.c,$(SUBDIR_APP)/obj/%$(CONFIG).o,$(SOURCES_APP))
|
2020-10-14 19:59:12 +02:00
|
|
|
|
2020-10-19 21:56:12 +02:00
|
|
|
SOURCES_LIB := $(wildcard $(SUBDIR_LIB)/src/*.c)
|
|
|
|
OBJECTS_LIB := $(patsubst $(SUBDIR_LIB)/src/%.c,$(SUBDIR_LIB)/obj/%$(CONFIG).o,$(SOURCES_LIB))
|
2020-10-14 19:59:12 +02:00
|
|
|
|
2020-10-21 17:07:03 +02:00
|
|
|
ifneq ($(filter %-mingw32 %-windows-gnu %-cygwin %-cygnus,$(MACHINE)),)
|
2020-10-20 17:46:18 +02:00
|
|
|
RCFILES_APP := $(wildcard $(SUBDIR_APP)/res/*.rc)
|
|
|
|
OBJECTS_APP += $(patsubst $(SUBDIR_APP)/res/%.rc,$(SUBDIR_APP)/obj/%.rsrc.o,$(RCFILES_APP))
|
|
|
|
endif
|
|
|
|
|
2020-10-14 19:59:12 +02:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# Targets
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
2020-10-13 23:36:58 +02:00
|
|
|
.PHONY: all clean
|
|
|
|
|
2020-10-19 21:56:12 +02:00
|
|
|
all: $(OUTPATH_APP)
|
2020-10-14 19:59:12 +02:00
|
|
|
|
2020-10-19 21:56:12 +02:00
|
|
|
$(OUTPATH_APP): $(OBJECTS_APP) $(OUTPATH_LIB)
|
2020-10-14 19:59:12 +02:00
|
|
|
@mkdir -p $(@D)
|
|
|
|
$(CC) $(CFLAGS) $^ -o $@ $(LDFLGS)
|
|
|
|
|
2020-10-19 21:56:12 +02:00
|
|
|
$(OUTPATH_LIB): $(OBJECTS_LIB)
|
2020-10-14 19:59:12 +02:00
|
|
|
@mkdir -p $(@D)
|
|
|
|
$(AR) rcs $@ $^
|
2020-10-13 23:36:58 +02:00
|
|
|
|
2020-10-19 21:56:12 +02:00
|
|
|
$(SUBDIR_APP)/obj/%$(CONFIG).o: $(SUBDIR_APP)/src/%.c
|
2020-10-14 19:59:12 +02:00
|
|
|
@mkdir -p $(@D)
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
2020-10-19 21:56:12 +02:00
|
|
|
|
2020-10-20 17:46:18 +02:00
|
|
|
$(SUBDIR_APP)/obj/%.rsrc.o: $(SUBDIR_APP)/res/%.rc
|
|
|
|
@mkdir -p $(@D)
|
|
|
|
windres -o $@ $<
|
|
|
|
|
2020-10-19 21:56:12 +02:00
|
|
|
$(SUBDIR_LIB)/obj/%$(CONFIG).o: $(SUBDIR_LIB)/src/%.c
|
|
|
|
@mkdir -p $(@D)
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
2020-10-13 23:36:58 +02:00
|
|
|
clean:
|
2020-10-29 18:12:21 +01:00
|
|
|
$(RM) $(SUBDIR_APP)/obj/*.o $(SUBDIR_APP)/obj/*.gcda $(SUBDIR_APP)/lib/*.a $(SUBDIR_APP)/bin/*$(SUFFIX)
|
|
|
|
$(RM) $(SUBDIR_LIB)/obj/*.o $(SUBDIR_LIB)/obj/*.gcda $(SUBDIR_LIB)/lib/*.a $(SUBDIR_LIB)/bin/*$(SUFFIX)
|
|
|
|
|