prefix=#prefix#
exec_prefix=#exec_prefix#
bindir=#bindir#
CFLAGS = -pipe -O2 -g `freetype-config --cflags` -c -Wall -Wno-multichar `cat #top_srcdir#/madlax.specs`
CPPFLAGS= $(CFLAGS) -Woverloaded-virtual -Wnon-virtual-dtor
CC = #CC#
EXE = jpegtranslator
MLXLIBDIR = #top_srcdir#/src/kits/objs
SUBDIR = libjpeg
SRC := $(SUBDIR)/jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jcdiffct.c \
jchuff.c jcinit.c jclhuff.c jclossls.c jclossy.c jcmainct.c jcmarker.c jcmaster.c jcodec.c \
jcomapi.c jcparam.c jcphuff.c jcpred.c jcprepct.c jcsample.c jcscale.c jcshuff.c jctrans.c \
jdapimin.c jdapistd.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jddiffct.c jdhuff.c \
jdinput.c jdlhuff.c jdlossls.c jdlossy.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \
jdpostct.c jdpred.c jdsample.c jdscale.c jdshuff.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \
jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jmemmgr.c jmemnobs.c jquant1.c jquant2.c \
jutils.c
OBJS = be_jdatadst.o be_jdatasrc.o be_jerror.o JPEGTranslator.o $(SRC)
OBJDIR := objs
include #top_srcdir#/makefile.rules
all : $(OBJDIR) $(OBJDIR)/$(EXE)
$(OBJDIR):
mkdir $(OBJDIR) -C $(SUBDIR)
The main part of concern is the $(OBJDIR) -C $(SUBDIR), because I don't really know if I also need the -I$(SUBDIR) or the -L$(SUBDIR), or if I just use -ljpeg
First of all the -l option (lower-case L) is for linking with a library, and -L is for adding a path to the linkers library-search-path-list.
And yes you need -L if you want to link with a library in a non-standard location using -l.
You can also skip both the -L and -l options, and provide the full path to the library instead.
Related
There are quite some posts about this error, but I was not able to solve it, I hope you can come up with the solution. I am on a Ubuntu machine.
~/graphmap2$
In this folder, I downloaded zlib. You can see the picture
After some Googling, I also noticed that there is no -lz parameter, so I also added that manually as you can see below
However, I still get the same error as when none of the above were done.
Might it be that the path to zlib is not clear for the compiler? However, I installed it in this same folder.
The make file looks like the below:
BIN = ./bin/graphmap2
BIN_DEBUG = ./bin/graphmap-debug
BIN_LINUX = ./bin/Linux-x64/graphmap2
BIN_MAC = ./bin/Mac/graphmap
OBJ_TESTING = ./obj_test
OBJ_TESTING_EXT = ./obj_testext
OBJ_DEBUG = ./obj_debug
OBJ_LINUX = ./obj_linux
OBJ_EXTCIGAR = ./obj_extcigar
OBJ_MAC = ./obj_mac
SOURCE = src
CODEBASE = codebase
# This finds all 'src' folders at maximum depth 2 (level one inside each submodule's folder).
CODEBASE_SRC_FOLDERS = $(shell find $(CODEBASE) -maxdepth 2 -type d -name "src" -exec echo "-I"{} \;)
# $(shell find $(CODEBASE) -maxdepth 3 -type d -name "libs" -exec echo "-I"{} \;)
# $(shell find $(CODEBASE) -maxdepth 2 -type d -name "src" -exec echo "-I"{}"/*/" \;)
# ? allows override by user using env var
GCC ?= g++
# define variables for GCC version check here
GCC_MAJOR_VERSION_GE_4 := $(shell expr `$(GCC) -dumpversion | cut -f1 -d.` \>= 4)
GCC_MINOR_VERSION_GE_7 := $(shell expr `$(GCC) -dumpversion | cut -f2 -d.` \>= 7)
GCC_MAC ?= g++
# CPP_FILES := $(wildcard $(SOURCE)/*/*.cpp) $(wildcard $(SOURCE)/*.cpp) $(wildcard $(SOURCE)/libs/*/*.cpp)
# CC_FILES := $(wildcard $(SOURCE)/*/*.cc) $(wildcard $(SOURCE)/*.cc) $(wildcard $(SOURCE)/libs/*/*.cc)
# H_FILES := $(wildcard $(SOURCE)/*/*.h) $(wildcard $(SOURCE)/*.h) $(wildcard $(SOURCE)/libs/*/*.h)
CPP_FILES := $(wildcard $(CODEBASE)/*/src/*.cpp) $(wildcard $(CODEBASE)/*/src/libs/*/*.cpp) $(wildcard $(CODEBASE)/*/src/*/*.cpp) $(wildcard $(SOURCE)/*/*.cpp) $(wildcard $(SOURCE)/*.cpp) $(wildcard $(SOURCE)/libs/*/*.cpp)
CC_FILES := $(wildcard $(CODEBASE)/*/src/*.cc) $(wildcard $(CODEBASE)/*/src/libs/*/*.cc) $(wildcard $(CODEBASE)/*/src/*/*.cc) $(wildcard $(SOURCE)/*/*.cc) $(wildcard $(SOURCE)/*.cc) $(wildcard $(SOURCE)/libs/*/*.cc)
H_FILES := $(wildcard $(CODEBASE)/*/src/*.h) $(wildcard $(CODEBASE)/*/src/libs/*/*.h) $(wildcard $(CODEBASE)/*/src/*/*.h) $(wildcard $(SOURCE)/*/*.h) $(wildcard $(SOURCE)/*.h) $(wildcard $(CODEBASE)/*/src/*.hpp) $(wildcard $(CODEBASE)/*$
OBJ_FILES := $(CPP_FILES:.cpp=.o) $(CC_FILES:.cc=.o)
OBJ_FILES_FOLDER_TESTING := $(addprefix $(OBJ_TESTING)/,$(OBJ_FILES))
OBJ_FILES_FOLDER_TESTING_EXT := $(addprefix $(OBJ_TESTING_EXT)/,$(OBJ_FILES))
OBJ_FILES_FOLDER_DEBUG := $(addprefix $(OBJ_DEBUG)/,$(OBJ_FILES))
OBJ_FILES_FOLDER_LINUX := $(addprefix $(OBJ_LINUX)/,$(OBJ_FILES))
OBJ_FILES_FOLDER_EXTCIGAR := $(addprefix $(OBJ_EXTCIGAR)/,$(OBJ_FILES))
OBJ_FILES_FOLDER_MAC := $(addprefix $(OBJ_MAC)/,$(OBJ_FILES))
LIB_DIRS = -L"/usr/local/lib"
CC_LIBS = -static-libgcc -static-libstdc++ -D__cplusplus=201103L
# INCLUDE = -I"./src/" -I"/usr/include/" -I"libs/libdivsufsort-2.0.1/build/include" -I"libs/seqan-library-1.4.2/include"
# INCLUDE = -I"./src/" -I"/usr/include/" -I"src/libs/seqan-library-1.4.2/include"
INCLUDE = -I"./src/" -I"/usr/include/" -I"$(CODEBASE)/seqlib/src/libs/seqan-library-2.0.1/include" -I"$(CODEBASE)/seqlib/src/libs/libdivsufsort-2.0.1-64bit/" $(CODEBASE_SRC_FOLDERS)
CC_FLAGS_DEBUG = -O3 -g -rdynamic -c -fmessage-length=0 -ffreestanding -fopenmp -m64 -std=c++11 -Werror=return-type -pthread -march=native -lz
CC_FLAGS_RELEASE = -DRELEASE_VERSION -g -O3 -fdata-sections -ffunction-sections -c -fmessage-length=0 -ffreestanding -fopenmp -m64 -std=c++11 -Werror=return-type -pthread -lz # -march=native
CC_FLAGS_EXTCIGAR = -DRELEASE_VERSION -DUSE_EXTENDED_CIGAR_FORMAT -g -O3 -fdata-sections -ffunction-sections -c -fmessage-length=0 -ffreestanding -fopenmp -m64 -std=c++11 -Werror=return-type -pthread -march=native -lz
CC_FLAGS_NOT_RELEASE = -g -O3 -fdata-sections -ffunction-sections -c -fmessage-length=0 -ffreestanding -fopenmp -m64 -std=c++11 -Werror=return-type -Wuninitialized -pthread -march=native -lz
CC_FLAGS_NOT_RELEASE_EXT = -g -O3 -DUSE_EXTENDED_CIGAR_FORMAT -fdata-sections -ffunction-sections -c -fmessage-length=0 -ffreestanding -fopenmp -m64 -std=c++11 -Werror=return-type -Wuninitialized -pthread -march=native -lz LD_FLAGS = -static-libgcc -static-libstdc++ -m64 -ffreestanding -lz
# LD_LIBS = -lpthread -lgomp -lm -lz -ldivsufsort64
LD_LIBS = -lpthread -lgomp -lm -lz
all: gcc_version_check linux
install: /usr/bin/graphmap
/usr/bin/graphmap: bin/Linux-x64/graphmap
cp bin/Linux-x64/graphmap /usr/bin/graphmap
modules:
git submodule update --init --recursive
# git submodule foreach git pull origin master
testing: $(OBJ_FILES_FOLDER_TESTING)
mkdir -p $(dir $(BIN))
$(GCC) $(LD_FLAGS) $(LIB_DIRS) -o $(BIN) $(OBJ_FILES_FOLDER_TESTING) $(LD_LIBS)
obj_test/%.o: %.cc $(H_FILES)
mkdir -p $(dir $#)
$(GCC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_NOT_RELEASE) -o $# $<
obj_test/%.o: %.cpp $(H_FILES)
mkdir -p $(dir $#)
$(GCC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_NOT_RELEASE) -o $# $<
testingext: $(OBJ_FILES_FOLDER_TESTING_EXT)
mkdir -p $(dir $(BIN)) $(GCC) $(LD_FLAGS) $(LIB_DIRS) -o $(BIN) $(OBJ_FILES_FOLDER_TESTING_EXT) $(LD_LIBS)
obj_testext/%.o: %.cc $(H_FILES)
mkdir -p $(dir $#)
$(GCC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_NOT_RELEASE_EXT) -o $# $<
obj_testext/%.o: %.cpp $(H_FILES)
mkdir -p $(dir $#)
$(GCC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_NOT_RELEASE_EXT) -o $# $<
gcc_version_check:
ifneq ($(GCC_MAJOR_VERSION_GE_4), 1)
$(warning "*** WARNING $(GCC) major version <4 ***")
endif
ifneq ($(GCC_MINOR_VERSION_GE_7), 1)
$(warning "*** WARNING $(GCC) minor version <7 ***")
endif
Any ideas?
Seems compiler is not able to find the file in the includes path you mentioned.
First check if zconf.h file is available on your machine and get that location. If the file is available then just give the path of the file to the compiler using -I option.
INCLUDE = -I"<YourPath>" -I"./src/" -I"/usr/include/" -I"$(CODEBASE)/seqlib/src/libs/seqan-library-2.0.1/include" -I"$(CODEBASE)/seqlib/src/libs/libdivsufsort-2.0.1-64bit/" $(CODEBASE_SRC_FOLDERS)
If the file itself is missing, then you would need to install it
sudo apt-get install libz-dev
Based on information shared by #Knud Larsen :
The Ubuntu package name is zlib1g-dev from where you can get the missing file. /usr/include/zconf.h
https://packages.ubuntu.com/focal-updates/amd64/zlib1g-dev/filelist
Just for future reference, what Altaf mentioned is correct. More than that, you can continue adding things that are not in the appropriate place exactly like this. Locate them and then add them manually.
If the makefile is not very big this will eventually be ok. It doesn't scale on the general case however, and maybe changing the makefile in a more radical way should be done.
This is how my makefile looks like, I have seperata cudaex.cu cudaaex.h plotter.c plotter.h and mainfn.cpp files. I compiled and created .o files separately. But I cant link them and make an executable file. If further informations needed I can post other codes also.
CUDA ?= /usr/local/cuda
CUDA_LIB :=-L $(CUDA)/lib64 -L $(CUDA)/lib -L /usr/lib64/nvidia -L /usr/lib/nvidia
CUDA_INC += -I $(CUDA)/include
program_INCLUDE_DIRS := ./src
program_LIBRARY_DIRS :=
LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
LDFLAGS += $(CUDA_LIB) -L $(CUDA)/lib64
LIBS += -lcudart -lcuda -lpthread -ldl
CC = gcc
NCC = nvcc
CPP = g++
CFLAGS = -O3 -I./src
RM = rm -f
program_OBJS:= gnuplot_i.o cudaex.o plotter.o mainfn.o
default: gnuplot_i.o cudaex.o plotter.o mainfn.o all
gnuplot_i.o: src/gnuplot_i.c src/gnuplot_i.h
$(CC) $(CFLAGS) -c -o gnuplot_i.o src/gnuplot_i.c
cudaex.o:
$(NCC) -c -o cudaex.o cudaex.cu
plotter.o: plotter.c gnuplot_i.o plotter.h
$(CC) $(CFLAGS) -c -o plotter.o plotter.c
mainfn.o: mainfn.cpp cudaex.h plotter.h plotter.o gnuplot_i.o
$(CPP) -c -o mainfn.o mainfn.cpp
all: mainfn
mainfn: $(program_OBJS)
g++ $(program_OBJS) -o mainfn $(LDFLAGS) $(LIBS)
clean:
$(RM) gnuplot_i.o cudaex.o plotter.o mainfn.o mainfn
this is the output of the make command
I am coding to the NRF51822 bluetooth chip, in Eclipse with GCC and a makefile that I maintain myself.
My problem is that every time I press build, it will compile everything, which is beginning to take quite some time. I am not that experienced in creating and maintaining make-files, so I have no idea where to start in order to get it to build incremtal instead?
My makefile is composed like this (I know there's a lot, and I haven't created this myself - found it in a tutorial, so I don't know what's relevant and what's not :-) ):
PROJECT_NAME := my_project
export OUTPUT_FILENAME
#MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
MAKEFILE_NAME := $(MAKEFILE_LIST)
MAKEFILE_DIR := $(dir $(MAKEFILE_NAME) )
TEMPLATE_PATH = nrf51_sdk/toolchain/gcc
ifeq ($(OS),Windows_NT)
include $(TEMPLATE_PATH)/Makefile.windows
else
include $(TEMPLATE_PATH)/Makefile.posix
endif
MK := mkdir
RM := rm -rf
#echo suspend
ifeq ("$(VERBOSE)","1")
NO_ECHO :=
else
NO_ECHO := #
endif
# Toolchain commands
CC := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-gcc"
AS := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-as"
AR := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ar" -r
LD := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ld"
NM := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-nm"
OBJDUMP := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objdump"
OBJCOPY := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objcopy"
SIZE := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-size"
#function for removing duplicates in a list
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
#source common to all targets
C_SOURCE_FILES += \
main.c \
file1.c \
file2.c \
file3.c \
file4.c \
#assembly files common to all targets
ASM_SOURCE_FILES = nrf51_sdk/toolchain/gcc/gcc_startup_nrf51.s
#includes common to all targets
INC_PATHS = -I Dir1/
INC_PATHS = -I Dir2
INC_PATHS += -I Dir3
INC_PATHS += -I Dir4
OBJECT_DIRECTORY = _build
LISTING_DIRECTORY =$(OBJECT_DIRECTORY)
OUTPUT_BINARY_DIRECTORY =$(OBJECT_DIRECTORY)
# Sorting removes duplicates
BUILD_DIRECTORIES := $(sort $(OBJECT_DIRECTORY) $(OUTPUT_BINARY_DIRECTORY) $(LISTING_DIRECTORY) )
#flags common to all targets
CFLAGS = -DSOFTDEVICE_PRESENT
CFLAGS += -DNRF51
CFLAGS += -DS110
CFLAGS += -DBOARD_PCA10028
CFLAGS += -DBLE_STACK_SUPPORT_REQD
CFLAGS += -mcpu=cortex-m0
CFLAGS += -mthumb -mabi=aapcs --std=gnu99
CFLAGS += -Wall -O0 -g3
CFLAGS += -mfloat-abi=soft
# keep every function in separate section. This will allow linker to dump unused functions
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
#CFLAGS += -flto -fno-builtin
# keep every function in separate section. This will allow linker to dump unused functions
LDFLAGS += -Xlinker -Map=$(LISTING_DIRECTORY)/$(OUTPUT_FILENAME).map
LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
LDFLAGS += -mcpu=cortex-m0
# let linker to dump unused sections
LDFLAGS += -Wl,--gc-sections
# use newlib in nano version
LDFLAGS += --specs=nano.specs -lc -lnosys
# Assembler flags
ASMFLAGS += -x assembler-with-cpp
ASMFLAGS += -DSOFTDEVICE_PRESENT
ASMFLAGS += -DNRF51
ASMFLAGS += -DS110
ASMFLAGS += -DBOARD_PCA10028
ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
#default target - first one defined
default: clean nrf51422_xxac_s110
#building all targets
all: clean
$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e cleanobj
$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e nrf51422_xxac_s110
#target for printing all targets
help:
#echo following targets are available:
#echo nrf51422_xxac_s110
#echo flash_softdevice
C_SOURCE_FILE_NAMES = $(notdir $(C_SOURCE_FILES))
C_PATHS = $(call remduplicates, $(dir $(C_SOURCE_FILES) ) )
C_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(C_SOURCE_FILE_NAMES:.c=.o) )
ASM_SOURCE_FILE_NAMES = $(notdir $(ASM_SOURCE_FILES))
ASM_PATHS = $(call remduplicates, $(dir $(ASM_SOURCE_FILES) ))
ASM_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(ASM_SOURCE_FILE_NAMES:.s=.o) )
vpath %.c $(C_PATHS)
vpath %.s $(ASM_PATHS)
OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
nrf51422_xxac_s110: OUTPUT_FILENAME := nrf51422_xxac_s110
nrf51422_xxac_s110: LINKER_SCRIPT=ble_app_hrs_gcc_nrf51.ld
nrf51422_xxac_s110: $(BUILD_DIRECTORIES) $(OBJECTS)
#echo Linking target: $(OUTPUT_FILENAME).out
$(NO_ECHO)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e finalize
## Create build directories
$(BUILD_DIRECTORIES):
echo $(MAKEFILE_NAME)
$(MK) $#
# Create objects from C SRC files
$(OBJECT_DIRECTORY)/%.o: %.c
#echo Compiling file: $(notdir $<)
#echo arm-none-eabi-gcc $(CFLAGS) $(INC_PATHS) -c -o $# $<
$(NO_ECHO)$(CC) $(CFLAGS) $(INC_PATHS) -c -o $# $<
# Assemble files
$(OBJECT_DIRECTORY)/%.o: %.s
#echo Compiling file: $(notdir $<)
$(NO_ECHO)$(CC) $(ASMFLAGS) $(INC_PATHS) -c -o $# $<
# Link
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out: $(BUILD_DIRECTORIES) $(OBJECTS)
#echo Linking target: $(OUTPUT_FILENAME).out
$(NO_ECHO)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
## Create binary .bin file from the .out file
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
#echo Preparing: $(OUTPUT_FILENAME).bin
$(NO_ECHO)$(OBJCOPY) -O binary $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin
## Create binary .hex file from the .out file
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
#echo Preparing: $(OUTPUT_FILENAME).hex
$(NO_ECHO)$(OBJCOPY) -O ihex $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex
finalize: genbin genhex echosize
genbin:
#echo Preparing: $(OUTPUT_FILENAME).bin
$(NO_ECHO)$(OBJCOPY) -O binary $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin
## Create binary .hex file from the .out file
genhex:
#echo Preparing: $(OUTPUT_FILENAME).hex
$(NO_ECHO)$(OBJCOPY) -O ihex $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex
echosize:
-#echo ""
$(NO_ECHO)$(SIZE) $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
-#echo ""
clean:
$(RM) $(BUILD_DIRECTORIES)
cleanobj:
$(RM) $(BUILD_DIRECTORIES)/*.o
flash: $(MAKECMDGOALS)
#echo Flashing: $(OUTPUT_BINARY_DIRECTORY)/$<.hex
nrfjprog --reset --program $(OUTPUT_BINARY_DIRECTORY)/$<.hex)
## Flash softdevice
flash_softdevice:
#echo Flashing: s110_softdevice.hex
nrfjprog --reset --program nrf51_sdk/softdevice/s110/hex/s110_softdevice.hex
all: clean
check this line. The default (first) Target of your Makefile depends on clean, so before any build is started, the clean target is executed that likely will remove all built files, to rebuild them.
Drop the clean and you should get the incremental behaviour make was designed for.
I am new to using CMake and am attempting to transfer our previous Makefiles into CMakeLists. I have one file, *dsplink_defines.txt* that has the following compile-time defines.
*-DOS_LINUX -DMAX_DSPS=1 -DMAX_PROCESSORS=2 -DID_GPP=1 -DOMAPL1XX -DPROC_COMPONENT -DPOOL_COMPONENT -DNOTIFY_COMPONENT -DMPCS_COMPONENT -DRINGIO_COMPONENT -DMPLIST_COMPONENT -DMSGQ_COMPONENT -DMSGQ_ZCPY_LINK -DCHNL_COMPONENT -DCHNL_ZCPY_LINK -DZCPY_LINK -DKFILE_DEFAULT -DDA8XXGEM -DDA8XXGEM_PHYINTERFACE=SHMEM_INTERFACE -DGPP_SWI_MODE -D_REENTRANT -DVERIFY_DATA -DDDSP_DEBUG*
Our previous Makefile took care of this in the following manner and took care of this by using shell cat starting on line 8:
BIN = ../../build/bin
TMP = build
BUILD_DEF = -DBUILD=$(BUILD_VERSION) -DBUILD_DATE=$(BUILD_DATE)
# these files are captured from the DSPLink Sample build directory (and the named changed)
# they contain the appropriate includes and flags to build a dsplink application.
DSPLINK_INCLUDES = $(shell cat ../dsplink_config/dsplink_includes.txt)
DSPLINK_FLAGS = $(shell cat ../dsplink_config/dsplink_flags.txt)
DSPLINK_DEFINES = $(shell cat ../dsplink_config/dsplink_defines.txt)
DSPLINK_LIBS = $(DSPLINK_PACKAGE_DIR)/dsplink/gpp/export/BIN/Linux/OMAPL1XX/RELEASE/dsplink.lib
#Our project variables
INCLUDE = -I../framework -I../io_master -I../logging -I../../dsp/include - I../flagDictionary
#TOOLCHAIN = ${FACTORY_DIR}/build_armv5l-timesys-linux-uclibcgnueabi/toolchain/bin
TOOLCHAIN = /OMAP-L137/timesys/SDK/omapl137_evm/toolchain/bin
PLATFORM=armv5l-timesys-linux-uclibcgnueabi
#Compile Options
CC=$(TOOLCHAIN)/$(PLATFORM)-g++
LINKER=$(TOOLCHAIN)/$(PLATFORM)-g++
CFLAGS+= $(BUILD_DEF) $(INCLUDE) $(DSPLINK_DEFINES) $(DSPLINK_FLAGS) $(DSPLINK_INCLUDES)
DEBUG = -O
#list of things to compile.
FW_BUILD_DIR=../framework/build
LOG_BUILD_DIR=../logging/build
FLAG_DICT_BUILD_DIR=../flagDictionary/build
FRAMEWORK_OBJECTS= $(FW_BUILD_DIR)/com.o \
$(FW_BUILD_DIR)/application.o \
$(FW_BUILD_DIR)/memoryManagerBase.o \
$(FW_BUILD_DIR)/memoryManager.o \
$(FW_BUILD_DIR)/arguments.o \
$(FW_BUILD_DIR)/lockManager.o \
$(FW_BUILD_DIR)/controlCom.o \
$(FW_BUILD_DIR)/paths.o \
$(LOG_BUILD_DIR)/subsystemLogMasks.o \
$(LOG_BUILD_DIR)/logger.o
FLAG_DICT_OBJECTS= $(FLAG_DICT_BUILD_DIR)/flagEntry.o \
$(FLAG_DICT_BUILD_DIR)/flagDictionary.o
OBJECTS = spidev_test.o sysMon.o
EXES = sysMon
all: $(OBJECTS) $(EXES)
.c.o:
mkdir -p build
$(CC) -c $(CFLAGS) $(DEBUG) -o $(TMP)/$# $<
.cpp.o:
mkdir -p build
$(CC) -c $(CFLAGS) $(DEBUG) -o $(TMP)/$# $<
spidev_test: $(FRAMEWORK_OBJECTS) spidev_test.o
$(LINKER) -lpthread -lc -o $(BIN)/$# $(DSPLINK_LIBS) build/spidev_test.o $(FRAMEWORK_OBJECTS)
sysMon: $(FRAMEWORK_OBJECTS) sysMon.o
$(LINKER) -lpthread -lc -o $(BIN)/$# $(DSPLINK_LIBS) build/sysMon.o $(FLAG_DICT_OBJECTS) $(FRAMEWORK_OBJECTS)
deploy:
../../build/deploy
How do I pass these in using a CMakeList
This should work:
file(READ path/to/dsplink_defines.txt defines) #read file into variable 'defines'
string(REPLACE " " ";" defines "${defines}") #turn space separation into CMake list
add_definitions(${defines})
Of course, if you have full control of the file and can change its format to use semicolons for separation instead of spaces, you can do that and skip the string() line (probably speeding up your CMake processing a little bit by this).
I am trying to implement the non-recursive make solution outlined in the paper "Recursive Make Considered Harmful". I'm currently stuck on getting the *.d dependency files to generate. I've provided the makefile, sample module.mk and error below. Any ideas how I can fix this?
MODULES := \
module1 \
module2
# define compiler
CC = /opt/local/bin/clang++-mp-3.1
# exclude the following warnings for clang
CLANG_NO_WARN = \
-Wno-c++98-compat \
-Wno-weak-vtables \
-Wno-padded \
-Wno-global-constructors \
-Wno-exit-time-destructors
# look for include files in each of the modules
CFLAGS += \
-g -Weverything -Wall -std=c++11 -stdlib=libc++ $(CLANG_NO_WARN) \
-I../ -I/usr/local/include $(patsubst %, -I%, $(MODULES))
# linker flags
LDFLAGS := \
-stdlib=libc++ \
-L/usr/local/boost_1_50_0/stage/lib -L/usr/local/lib
# extra libraries if required (each module will add to this)
LIBS := \
-lboost_program_options \
-lboost_system \
-lglog \
-lpugixml
# source files to be compiled (each module will add to this)
SRCS := \
Main.cpp
# include the descriptions for each module
include $(patsubst %, %/module.mk, $(MODULES))
# determine the object files
OBJS := \
$(patsubst %.cpp, %.o, $(filter %.cpp, $(SRCS)))
# link the program
prog: $(OBJS)
$(CC) -o $# $(OBJS) $(LDFLAGS) $(LIBS)
# include the C include dependencies
include $(OBJS:.o=.d)
# calculate C include dependencies
%.d: %.cpp
depend.sh `dirname $*.cpp` $(CFLAGS) $*.cpp > $#
----------
#!/bin/sh
# Evaluate dependencies for use by the makefile
echo "Called"
DIR="$1"
shift 1
case "$DIR" in
"" | ".")
$CC -MM -MG "$#" | sed -e 's#ˆ\(.*\)\.o:#\1.d \1.o:#' ;;
*)
$CC -MM -MG "$#" | sed -e "s#ˆ\(.*\)\.o:#$DIR/\1.d \ $DIR/\1.o:#" ;;
esac
------------
# module.mk
SRCS += \
Algo.cpp \
CommandHandler.cpp \
Exchange.cpp \
TCPSocket.cpp \
TradingEngine.cpp
----------
$ make
makefile:68: Main.d: No such file or directory
makefile:68: view_string.d: No such file or directory
makefile:68: Algo.d: No such file or directory
makefile:68: CommandHandler.d: No such file or directory
makefile:68: Exchange.d: No such file or directory
makefile:68: TCPSocket.d: No such file or directory
makefile:68: TradingEngine.d: No such file or directory
makefile:68: Exchange.d: No such file or directory
makefile:68: Requests.d: No such file or directory
makefile:68: TickCapture.d: No such file or directory
makefile:68: types.d: No such file or directory
make: *** No rule to make target `types.d'. Stop.
UPDATE
Finished makefile and sample module.mk
$cat makefile
# executable name
BINARY := my_prog
# clang config
CLANG := /opt/local/bin/clang++-mp-3.1
CLANG_WARNINGS := \
-Wno-c++98-compat \
-Wno-weak-vtables \
-Wno-padded \
-Wno-global-constructors \
-Wno-exit-time-destructors
CLANG_CFLAGS := \
-g -Weverything -Wall -std=c++11 -stdlib=libc++
CLANG_LDFLAGS := \
-stdlib=libc++
# generic compiler config
CC := $(CLANG)
CFLAGS := $(CLANG_WARNINGS) $(CLANG_CFLAGS)
LDFLAGS := $(CLANG_LDFLAGS)
INCS := \
-I../ \
-I/usr/local/include \
$(patsubst %, -I%, $(SUBDIRS))
LIBS := \
-L/usr/local/boost_1_50_0/stage/lib \
-L/usr/local/lib \
-lboost_program_options \
-lboost_system \
-lglog \
-lpugixml
# list subdirectories in which to look for dependencies
# must define SRCS first as subdirs will append to this
# their src files
SRCS := Main.cpp
SUBDIRS := \
module1 \
module2
include $(patsubst %, %/module.mk, $(SUBDIRS))
# derive object files from srcs
OBJS := $(patsubst %.cpp, %.o, $(filter %.cpp, $(SRCS)))
# link the program
$(BINARY): $(OBJS)
$(CC) -o $# $(OBJS) $(LDFLAGS) $(LIBS)
# include generated dependency files
DEPS := $(OBJS:.o=.d)
-include $(DEPS)
# generate include dependencies
%.d: %.cpp
./depend.sh `dirname $*.cpp` $(INCS) $*.cpp > $#
# compile
.cpp.o:
$(CC) $(CFLAGS) $(INCS) $< -c -o $#
# clean, obviously
clean:
rm -f $(BINARY)
rm -f $(OBJS)
rm -f $(DEPS)
# et voila!
-----
$cat module1/module.mk
SRCS_PATH := module1
SRCS += \
$(SRCS_PATH)/Algo.cpp \
$(SRCS_PATH)/CommandHandler.cpp \
$(SRCS_PATH)/Exchange.cpp \
$(SRCS_PATH)/TCPSocket.cpp \
$(SRCS_PATH)/TradingEngine.cpp
It looks as if some module adds types.cpp to SRCS, even though no such source file exists.
As for the warnings, the first time you run this makefile, the dependency files (foo.d) do not yet exist, so Make complains that it can't include them. It's not a problem, and the warnings won't appear in subsequent runs when those files do exist beforehand. To supress the warnings entirely, change include to -include.