forked from Foundation-Devices/passport-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
87 lines (66 loc) · 1.78 KB
/
Makefile
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# SPDX-FileCopyrightText: 2020 Foundation Devices, Inc. <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
TOP = ../..
SOURCES = cosign.c
SOURCES += sha256.c
SOURCES += hash.c
SOURCES += uECC.c
VPATH = $(TOP)/common
VPATH += $(TOP)/common/micro-ecc
ARCH ?= x86
CFLAGS = -Wall -fno-strict-aliasing
CFLAGS += -fno-omit-frame-pointer
CFLAGS += -I$(TOP)/include
CFLAGS += -I/usr/local/include
CFLAGS += -I$(TOP)/common/micro-ecc -DuECC_PLATFORM=uECC_x86
CFLAGS += -DPASSPORT_COSIGN_TOOL
CFLAGS += -L/usr/local/lib
LDFLAGS = -Wl,-Map,$(MAP)
LIBS = -lcrypto
CROSS_COMPILE ?=
CC = $(CROSS_COMPILE)gcc
EXECUTABLE = cosign
TARGETDIR = x86
ifeq ($(findstring debug,$(MAKECMDGOALS)),debug)
OBJDIR = $(TARGETDIR)/debug
CFLAGS += -g -DDEBUG
LDFLAGS += -g
STRIP =
else
OBJDIR = $(TARGETDIR)/release
CFLAGS += -O2
STRIP = $(CROSS_COMPILE)strip
endif
PROGRAMDIR = $(OBJDIR)
INSTALL_DIR = $(HOME)/bin
PROGRAM = $(PROGRAMDIR)/$(EXECUTABLE)
MAP = $(PROGRAMDIR)/$(EXECUTABLE).map
OBJECTS = $(addprefix $(OBJDIR)/,$(SOURCES:.c=.o))
RM := rm -rf
all: $(PROGRAM)
debug: $(PROGRAM)
# Tool invocations
$(PROGRAM): $(OBJECTS) FORCE
@echo 'Building target: $@'
@echo 'Invoking: GCC C Linker'
@[ -d $(dir $@) ] || mkdir -p $(dir $@)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean: FORCE
@$(RM) $(TARGETDIR)
$(OBJDIR)/%.o: %.c
@rm -f $@
@[ -d $(dir $@) ] || mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c -MMD -MP -o $@ $<
ifneq ($(MAKECMDGOALS),clean)
-include $(OBJECTS:.o=.d)
endif
install: $(PROGRAM)
@echo 'Installing $(PROGRAM)...'
@cp -f $(PROGRAM) $(INSTALL_DIR)
@[ -z $(STRIP) ] || $(STRIP) $(INSTALL_DIR)/$(EXECUTABLE)
@echo 'Installation complete'
.PHONY: all clean install FORCE
.SECONDARY: