-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
37 lines (30 loc) · 1.36 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
WARNINGS_AND_ERRORS?=-Wall -Werror=format-overflow -Werror=format-truncation -Werror=format-extra-args -Werror=format -Werror=maybe-uninitialized -Werror=array-bounds -Werror=narrowing -Werror=multichar
WARNINGS_AND_ERRORS_CC?=-Werror=implicit-function-declaration -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=discarded-qualifiers
WARNINGS_AND_ERRORS_CXX?=
BASE_CFLAGS=-lcurl -lconfig -fopenmp -I . -Wall -O2 $(WARNINGS_AND_ERRORS) $(WARNINGS_AND_ERRORS_CC)
USER_CFLAGS:=$(CFLAGS)
CFLAGS=$(BASE_CFLAGS) $(USER_CFLAGS)
FINAL_TARGET_CFLAGS?=-Wl,--gc-sections
TARGET=recipesAtHome
DEPS=start.h inventory.h recipes.h config.h FTPManagement.h cJSON.h node_print.h calculator.h logger.h shutdown.h base.h pcg_basic.h $(wildcard absl/base/*.h )
OBJ=start.o inventory.o recipes.o config.o FTPManagement.o cJSON.o node_print.o calculator.o logger.o shutdown.o pcg_basic.o
UNAME:=$(shell uname)
ifeq ($(UNAME), Linux)
CC=gcc
endif
ifeq ($(UNAME), Darwin)
MACPREFIX:=$(shell brew --prefix)
CC:=$(MACPREFIX)/opt/llvm/bin/clang
CFLAGS:=-I$(MACPREFIX)/include -L$(MACPREFIX)/lib $(CFLAGS)
FINAL_TARGET_CFLAGS:=$(subst --gc-sections,-dead_strip,$(FINAL_TARGET_CFLAGS))
endif
default: $(TARGET)
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
$(TARGET): $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(FINAL_TARGET_CFLAGS)
all: $(TARGET)
.PHONY: all clean
clean:
$(RM) ./*.o
$(RM) ./$(TARGET)