SlunkCrypt/Makefile

90 lines
2.3 KiB
Makefile
Raw Normal View History

2020-10-14 19:59:12 +02:00
# ---------------------------------------------------------------------------
# Options
# ---------------------------------------------------------------------------
2020-10-13 23:36:58 +02:00
2020-10-14 19:59:12 +02:00
DEBUG ?= 0
MARCH ?= native
MTUNE ?= native
# ---------------------------------------------------------------------------
# Directories
2020-10-14 19:59:12 +02:00
# ---------------------------------------------------------------------------
SUBDIR_APP := frontend
SUBDIR_LIB := libslunkcrypt
# ---------------------------------------------------------------------------
# Flags
# ---------------------------------------------------------------------------
CFLAGS = -I$(SUBDIR_LIB)/include -Wall -Wno-trigraphs -march=$(MARCH) -mtune=$(MTUNE)
2020-10-14 19:59:12 +02:00
ifeq ($(DEBUG),1)
CFLAGS += -Og -g
undefine LDFLGS
else
2020-10-14 21:55:39 +02:00
CFLAGS += -O3 -DNDEBUG
2020-10-14 19:59:12 +02:00
LDFLGS += -static -s
endif
ifeq ($(OS),Windows_NT)
2020-10-14 21:55:39 +02:00
LDFLGS += -municode -mconsole
2020-10-14 19:59:12 +02:00
endif
undefine SUFFIX
2020-10-13 23:36:58 +02:00
ifeq ($(OS),Windows_NT)
2020-10-14 19:59:12 +02:00
SUFFIX := .exe
2020-10-13 23:36:58 +02:00
else
2020-10-14 19:59:12 +02:00
undefine SUFFIX
2020-10-13 23:36:58 +02:00
endif
2020-10-14 19:59:12 +02:00
ifeq ($(DEBUG),1)
CONFIG := _g
2020-10-14 19:59:12 +02:00
else
undefine CONFIG
2020-10-14 19:59:12 +02:00
endif
# ---------------------------------------------------------------------------
# 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
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
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
# ---------------------------------------------------------------------------
# Targets
# ---------------------------------------------------------------------------
2020-10-13 23:36:58 +02:00
.PHONY: all clean
all: $(OUTPATH_APP)
2020-10-14 19:59:12 +02:00
$(OUTPATH_APP): $(OBJECTS_APP) $(OUTPATH_LIB)
2020-10-14 19:59:12 +02:00
@mkdir -p $(@D)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLGS)
$(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
$(SUBDIR_APP)/obj/%$(CONFIG).o: $(SUBDIR_APP)/src/%.c
2020-10-14 19:59:12 +02:00
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
$(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-14 19:59:12 +02:00
$(RM) $(addsuffix *crypt*,$(dir $(TARGET_APP)) $(dir $(TARGET_LIB)))
$(RM) $(addsuffix *.o,$(dir $(OBJECTS_APP)) $(dir $(OBJECTS_LIB)))