76 lines
1.8 KiB
Makefile
76 lines
1.8 KiB
Makefile
# ---------------------------------------------------------------------------
|
|
# Options
|
|
# ---------------------------------------------------------------------------
|
|
|
|
DEBUG ?= 0
|
|
MARCH ?= native
|
|
MTUNE ?= native
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# FLags
|
|
# ---------------------------------------------------------------------------
|
|
|
|
CFLAGS = -IlibMCrypt/include -march=$(MARCH) -mtune=$(MTUNE)
|
|
|
|
ifeq ($(DEBUG),1)
|
|
CFLAGS += -Og -g
|
|
undefine LDFLGS
|
|
else
|
|
CFLAGS += -O3 -static -DNDEBUG
|
|
LDFLGS += -static -s
|
|
endif
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
CFLAGS += -municode -mconsole
|
|
endif
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# File names
|
|
# ---------------------------------------------------------------------------
|
|
|
|
undefine SUFFIX
|
|
ifeq ($(OS),Windows_NT)
|
|
SUFFIX := .exe
|
|
else
|
|
undefine SUFFIX
|
|
endif
|
|
|
|
ifeq ($(DEBUG),1)
|
|
NAMEX := _g
|
|
else
|
|
undefine NAMEX
|
|
endif
|
|
|
|
TARGET_APP := bin/mcrypt$(NAMEX)$(SUFFIX)
|
|
TARGET_LIB := lib/libmcrypt$(NAMEX)-1.a
|
|
|
|
SOURCES_APP := $(wildcard frontend/src/*.c)
|
|
OBJECTS_APP := $(patsubst %.c,%$(NAMEX).o,$(SOURCES_APP))
|
|
|
|
SOURCES_LIB := $(wildcard libMCrypt/src/*.c)
|
|
OBJECTS_LIB := $(patsubst %.c,%$(NAMEX).o,$(SOURCES_LIB))
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Targets
|
|
# ---------------------------------------------------------------------------
|
|
|
|
.PHONY: all clean
|
|
|
|
all: $(TARGET_APP)
|
|
|
|
$(TARGET_APP): $(OBJECTS_APP) $(TARGET_LIB)
|
|
@mkdir -p $(@D)
|
|
$(CC) $(CFLAGS) $^ -o $@ $(LDFLGS)
|
|
|
|
$(TARGET_LIB): $(OBJECTS_LIB)
|
|
@mkdir -p $(@D)
|
|
$(AR) rcs $@ $^
|
|
|
|
%$(NAMEX).o: %.c
|
|
@mkdir -p $(@D)
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
clean:
|
|
$(RM) $(addsuffix *crypt*,$(dir $(TARGET_APP)) $(dir $(TARGET_LIB)))
|
|
$(RM) $(addsuffix *.o,$(dir $(OBJECTS_APP)) $(dir $(OBJECTS_LIB)))
|