Makefile improvements.
This commit is contained in:
parent
985dcfd6ee
commit
53dcefacbb
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,6 @@
|
||||
*.o
|
||||
*.user
|
||||
/.vs
|
||||
/bin
|
||||
/lib
|
||||
/obj
|
||||
|
78
Makefile
78
Makefile
@ -1,19 +1,75 @@
|
||||
CFLAGS = -O3 -static -DNDEBUG -IlibMCrypt/include
|
||||
# ---------------------------------------------------------------------------
|
||||
# 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)
|
||||
SUFFIX := exe
|
||||
CFLAGS += -municode
|
||||
else
|
||||
SUFFIX := out
|
||||
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:
|
||||
@mkdir -p bin
|
||||
$(CC) $(CFLAGS) -o bin/mcrypt.$(SUFFIX) $(wildcard frontend/src/*.c) $(wildcard libMCrypt/src/*.c)
|
||||
strip bin/mcrypt.$(SUFFIX)
|
||||
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:
|
||||
@mkdir -p bin
|
||||
rm -f bin/*.$(SUFFIX)
|
||||
$(RM) $(addsuffix *crypt*,$(dir $(TARGET_APP)) $(dir $(TARGET_LIB)))
|
||||
$(RM) $(addsuffix *.o,$(dir $(OBJECTS_APP)) $(dir $(OBJECTS_LIB)))
|
||||
|
Loading…
Reference in New Issue
Block a user