OpenFPGA/vpr7_x2p/libarchfpga/Makefile

79 lines
2.2 KiB
Makefile
Raw Normal View History

2018-07-26 12:28:21 -05:00
################################ MAKEFILE OPTIONS ####################################
# By default, libarchfpga's build type (debug/release) is inherited from VPR's makefile.
# However, by uncommenting out the line BUILD_TYPE = debug, you can override this
# and set libarchfpga's build type independently.
# BUILD_TYPE = release
# (can be debug or release)
#############################################################################################
CC = g++
AR = ar
2019-05-03 12:48:41 -05:00
OBJ_DIR = OBJ
SRC_DIR = SRC
LIB_DIR = -L.
LIB = -lm -lpcre -larchfpga
2018-07-26 12:28:21 -05:00
WARN_FLAGS = -Wall -Wpointer-arith -Wcast-qual -D__USE_FIXED_PROTOTYPES__ -pedantic -Wshadow -Wcast-align -D_POSIX_SOURCE -Wno-write-strings
DEBUG_FLAGS = -g
OPT_FLAGS = -O3
2019-05-03 12:48:41 -05:00
INC_FLAGS = -I$(SRC_DIR)/include -I$(SRC_DIR)/fpga_spice_include -I../libprinthandler/SRC/TIO_InputOutputHandlers
2018-07-26 12:28:21 -05:00
LIB_FLAGS = rcs
FLAGS = $(INC_FLAGS) $(WARN_FLAGS) -MD -MP
ifneq (,$(findstring release, $(BUILD_TYPE)))
FLAGS := $(FLAGS) $(OPT_FLAGS)
else # DEBUG build
FLAGS := $(FLAGS) $(DEBUG_FLAGS)
endif
2019-05-03 12:48:41 -05:00
OBJ = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o,$(wildcard $(SRC_DIR)/*.c))
OBJ_DIRS=$(sort $(dir $(OBJ)))
DEPS = $(OBJ:.o=.d)
2018-07-26 12:28:21 -05:00
2019-05-03 12:48:41 -05:00
EXE = read_arch
2018-07-26 12:28:21 -05:00
# Standalone executable to test architecture reader
2019-05-03 12:48:41 -05:00
$(EXE): $(OBJ) Makefile libarchfpga.a
$(CC) $(INC_FLAGS) OBJ/main.o -o $(EXE) $(LIB_DIR) $(LIB)
2018-07-26 12:28:21 -05:00
2019-05-03 12:48:41 -05:00
libarchfpga.a: $(OBJ) ../libpcre/libpcre.a ../libprinthandler/libprinthandler.a
cp ../libprinthandler/libprinthandler.a $@
ar rcs $@ $(OBJ)
2018-07-26 12:28:21 -05:00
../pcre/libpcre.a:
2019-05-03 12:48:41 -05:00
@ cd ../libpcre && make
2018-07-26 12:28:21 -05:00
../printhandler/libprinthandler.a:
2019-05-03 12:48:41 -05:00
@ cd ../libprinthandler && make
# Enable a second round of expansion so that we may include
# the target directory as a prerequisite of the object file.
.SECONDEXPANSION:
# The directory follows a "|" to use an existence check instead of the usual
# timestamp check. Every write to the directory updates the timestamp thus
# without this, all but the last file written to a directory would appear
# to be out of date.
$(OBJ): OBJ/%.o:$(SRC_DIR)/%.c | $$(dir $$@D)
$(CC) $(FLAGS) $(INC_FLAGS) -c $< -o $@
# Silently create target directories as need
$(OBJ_DIRS):
@ mkdir -p $@
2018-07-26 12:28:21 -05:00
-include $(DEPS)
clean :
2019-05-03 12:48:41 -05:00
rm -f $(EXE) $(OBJ) $(DEP)
2018-07-26 12:28:21 -05:00
@ rm -f libarchfpga.a
@ rm -f read_arch
@ rm -f main.o main.d