Makefile - samtools installation failed - makefile

I'm trying to install samtools on openSUSE, I did this:
cd htslib-1.2.1
./configure
make install
Worked fine.
bcftools-1.2
./configure
make install
Worked fine.
And for samtools:
cd samtools-1.2
make install
Produces this output:
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libcurses.so when searching for -lcurses
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lcurses
collect2: error: ld returned 1 exit status
Makefile:125: recipe for target 'samtools' failed
make: *** [samtools] Error 1
I can't figure out why this won't work. I know how make tool work, but I'm newbie in linuxOS.
# Makefile for samtools, utilities for the Sequence Alignment/Map format.
#
# Copyright (C) 2008-2014 Genome Research Ltd.
# Portions copyright (C) 2010-2012 Broad Institute.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
CC = gcc
CPPFLAGS = $(DFLAGS) $(INCLUDES)
CFLAGS = -g -Wall -O2
LDFLAGS =
LDLIBS =
DFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_CURSES_LIB=1
LOBJS= bam_aux.o bam.o bam_import.o sam.o \
sam_header.o bam_plbuf.o
AOBJS= bam_index.o bam_plcmd.o sam_view.o \
bam_cat.o bam_md.o bam_reheader.o bam_sort.o bedidx.o kprobaln.o \
bam_rmdup.o bam_rmdupse.o bam_mate.o bam_stat.o bam_color.o \
bamtk.o bam2bcf.o bam2bcf_indel.o errmod.o sample.o \
cut_target.o phase.o bam2depth.o padding.o bedcov.o bamshuf.o \
faidx.o stats.o stats_isize.o bam_flags.o bam_split.o \
bam_tview.o bam_tview_curses.o bam_tview_html.o bam_lpileup.o
INCLUDES= -I. -I$(HTSDIR)
LIBCURSES= -lcurses # -lXCurses
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
mandir = $(prefix)/share/man
man1dir = $(mandir)/man1
MKDIR_P = mkdir -p
INSTALL = install -p
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644
INSTALL_DIR = $(MKDIR_P) -m 755
PROGRAMS = samtools
BUILT_MISC_PROGRAMS = \
misc/ace2sam misc/maq2sam-long misc/maq2sam-short \
misc/md5fa misc/md5sum-lite misc/wgsim
MISC_PROGRAMS = \
$(BUILT_MISC_PROGRAMS) \
misc/blast2sam.pl misc/bowtie2sam.pl misc/export2sam.pl \
misc/interpolate_sam.pl misc/novo2sam.pl \
misc/plot-bamstats misc/psl2sam.pl \
misc/sam2vcf.pl misc/samtools.pl misc/seq_cache_populate.pl \
misc/soap2sam.pl \
misc/varfilter.py misc/wgsim_eval.pl misc/zoom2sam.pl
BUILT_TEST_PROGRAMS = \
test/merge/test_bam_translate \
test/merge/test_pretty_header \
test/merge/test_rtrans_build \
test/merge/test_trans_tbl_init \
test/split/test_count_rg \
test/split/test_expand_format_string \
test/split/test_filter_header_rg \
test/split/test_parse_args \
test/vcf-miniview
all: $(PROGRAMS) $(BUILT_MISC_PROGRAMS) $(BUILT_TEST_PROGRAMS)
# Adjust $(HTSDIR) to point to your top-level htslib directory
HTSDIR = htslib-1.2.1
include $(HTSDIR)/htslib.mk
HTSLIB = $(HTSDIR)/libhts.a
BGZIP = $(HTSDIR)/bgzip
PACKAGE_VERSION = 1.2
# If building from a Git repository, replace $(PACKAGE_VERSION) with the Git
# description of the working tree: either a release tag with the same value
# as $(PACKAGE_VERSION) above, or an exact description likely based on a tag.
# $(shell), :=, etc are GNU Make-specific. If you don't have GNU Make,
# comment out this conditional.
ifneq "$(wildcard .git)" ""
PACKAGE_VERSION := $(shell git describe --always --dirty)
# Force version.h to be remade if $(PACKAGE_VERSION) has changed.
version.h: $(if $(wildcard version.h),$(if $(findstring "$(PACKAGE_VERSION)",$(shell cat version.h)),,force))
endif
# If you don't have GNU Make but are building from a Git repository, you may
# wish to replace this with a rule that always rebuilds version.h:
# version.h: force
# echo '#define SAMTOOLS_VERSION "`git describe --always --dirty`"' > $#
version.h:
echo '#define SAMTOOLS_VERSION "$(PACKAGE_VERSION)"' > $#
.SUFFIXES: .c .o
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $# $<
lib:libbam.a
libbam.a:$(LOBJS)
$(AR) -csru $# $(LOBJS)
samtools: $(AOBJS) libbam.a $(HTSLIB)
$(CC) -pthread $(LDFLAGS) -o $# $(AOBJS) libbam.a $(HTSLIB) $(LDLIBS) $(LIBCURSES) -lm -lz
bam_h = bam.h $(htslib_bgzf_h) $(htslib_sam_h)
bam2bcf_h = bam2bcf.h $(htslib_vcf_h) errmod.h
bam_lpileup_h = bam_lpileup.h $(htslib_sam_h)
bam_plbuf_h = bam_plbuf.h $(htslib_sam_h)
bam_tview_h = bam_tview.h $(htslib_hts_h) $(htslib_sam_h) $(htslib_faidx_h) $(bam2bcf_h) $(HTSDIR)/htslib/khash.h $(bam_lpileup_h)
sam_h = sam.h $(htslib_sam_h) $(bam_h)
sample_h = sample.h $(HTSDIR)/htslib/kstring.h
bam.o: bam.c $(bam_h) sam_header.h
bam2bcf.o: bam2bcf.c $(htslib_sam_h) $(HTSDIR)/htslib/kstring.h $(HTSDIR)/htslib/kfunc.h $(bam2bcf_h) errmod.h
bam2bcf_indel.o: bam2bcf_indel.c $(htslib_sam_h) $(bam2bcf_h) kprobaln.h $(HTSDIR)/htslib/khash.h $(HTSDIR)/htslib/ksort.h
bam2depth.o: bam2depth.c $(htslib_sam_h) samtools.h
bam_aux.o: bam_aux.c
bam_cat.o: bam_cat.c $(htslib_bgzf_h) $(bam_h)
bam_color.o: bam_color.c $(bam_h)
bam_import.o: bam_import.c $(HTSDIR)/htslib/kstring.h $(bam_h) $(HTSDIR)/htslib/kseq.h
bam_index.o: bam_index.c $(htslib_hts_h) $(htslib_sam_h) $(HTSDIR)/htslib/khash.h
bam_lpileup.o: bam_lpileup.c $(bam_plbuf_h) $(bam_lpileup_h) $(HTSDIR)/htslib/ksort.h
bam_mate.o: bam_mate.c $(bam_h)
bam_md.o: bam_md.c $(htslib_faidx_h) $(sam_h) kprobaln.h
bam_pileup.o: bam_pileup.c $(sam_h)
bam_plbuf.o: bam_plbuf.c $(htslib_hts_h) $(htslib_sam_h) $(bam_plbuf_h)
bam_plcmd.o: bam_plcmd.c $(htslib_sam_h) $(htslib_faidx_h) $(HTSDIR)/htslib/kstring.h $(HTSDIR)/htslib/khash_str2int.h sam_header.h samtools.h $(bam2bcf_h) $(sample_h)
bam_reheader.o: bam_reheader.c $(htslib_bgzf_h) $(bam_h)
bam_rmdup.o: bam_rmdup.c $(sam_h) $(HTSDIR)/htslib/khash.h
bam_rmdupse.o: bam_rmdupse.c $(sam_h) $(HTSDIR)/htslib/khash.h $(HTSDIR)/htslib/klist.h
bam_sort.o: bam_sort.c $(HTSDIR)/htslib/ksort.h $(HTSDIR)/htslib/khash.h $(HTSDIR)/htslib/klist.h $(HTSDIR)/htslib/kstring.h $(htslib_sam_h)
bam_stat.o: bam_stat.c $(bam_h) samtools.h
bam_tview.o: bam_tview.c $(bam_tview_h) $(htslib_faidx_h) $(htslib_sam_h) $(htslib_bgzf_h)
bam_tview_curses.o: bam_tview_curses.c $(bam_tview_h)
bam_tview_html.o: bam_tview_html.c $(bam_tview_h)
bam_flags.o: bam_flags.c $(sam_h)
bamshuf.o: bamshuf.c $(htslib_sam_h) $(HTSDIR)/htslib/ksort.h samtools.h
bamtk.o: bamtk.c $(htslib_hts_h) version.h samtools.h
bedcov.o: bedcov.c $(HTSDIR)/htslib/kstring.h $(htslib_sam_h) $(HTSDIR)/htslib/kseq.h
bedidx.o: bedidx.c $(HTSDIR)/htslib/ksort.h $(HTSDIR)/htslib/kseq.h $(HTSDIR)/htslib/khash.h
cut_target.o: cut_target.c $(bam_h) errmod.h $(htslib_faidx_h)
errmod.o: errmod.c errmod.h $(HTSDIR)/htslib/ksort.h
kprobaln.o: kprobaln.c kprobaln.h
padding.o: padding.c sam_header.h $(sam_h) $(bam_h) $(htslib_faidx_h)
phase.o: phase.c $(htslib_sam_h) errmod.h $(HTSDIR)/htslib/kseq.h $(HTSDIR)/htslib/khash.h $(HTSDIR)/htslib/ksort.h
sam.o: sam.c $(htslib_faidx_h) $(sam_h)
sam_header.o: sam_header.c sam_header.h $(HTSDIR)/htslib/khash.h
sam_view.o: sam_view.c $(htslib_sam_h) $(htslib_faidx_h) $(HTSDIR)/htslib/kstring.h $(HTSDIR)/htslib/khash.h samtools.h
sample.o: sample.c $(sample_h) $(HTSDIR)/htslib/khash.h
stats_isize.o: stats_isize.c stats_isize.h $(HTSDIR)/htslib/khash.h
stats.o: stats.c $(sam_h) sam_header.h samtools.h stats_isize.h $(HTSDIR)/htslib/khash.h $(HTSDIR)/htslib/khash_str2int.h $(htslib_faidx_h)
# test programs
# For tests that might use it, set $REF_PATH explicitly to use only reference
# areas within the test suite (or set it to ':' to use no reference areas).
# (regression.sh sets $REF_PATH to a subdirectory itself.)
check test: samtools $(BGZIP) $(BUILT_TEST_PROGRAMS)
REF_PATH=: test/test.pl --exec bgzip=$(BGZIP)
test/merge/test_bam_translate test/merge/test_bam_translate.tmp
test/merge/test_pretty_header
test/merge/test_rtrans_build
test/merge/test_trans_tbl_init
cd test/mpileup && ./regression.sh
test/split/test_count_rg
test/split/test_expand_format_string
test/split/test_filter_header_rg
test/split/test_parse_args
test/merge/test_bam_translate: test/merge/test_bam_translate.o test/test.o $(HTSLIB)
$(CC) -pthread $(LDFLAGS) -o $# test/merge/test_bam_translate.o test/test.o $(HTSLIB) $(LDLIBS) -lz
test/merge/test_pretty_header: test/merge/test_pretty_header.o $(HTSLIB)
$(CC) -pthread $(LDFLAGS) -o $# test/merge/test_pretty_header.o $(HTSLIB) $(LDLIBS) -lz
test/merge/test_rtrans_build: test/merge/test_rtrans_build.o $(HTSLIB)
$(CC) -pthread $(LDFLAGS) -o $# test/merge/test_rtrans_build.o $(HTSLIB) $(LDLIBS) -lz
test/merge/test_trans_tbl_init: test/merge/test_trans_tbl_init.o $(HTSLIB)
$(CC) -pthread $(LDFLAGS) -o $# test/merge/test_trans_tbl_init.o $(HTSLIB) $(LDLIBS) -lz
test/split/test_count_rg: test/split/test_count_rg.o test/test.o $(HTSLIB)
$(CC) -pthread $(LDFLAGS) -o $# test/split/test_count_rg.o test/test.o $(HTSLIB) $(LDLIBS) -lz
test/split/test_expand_format_string: test/split/test_expand_format_string.o test/test.o $(HTSLIB)
$(CC) -pthread $(LDFLAGS) -o $# test/split/test_expand_format_string.o test/test.o $(HTSLIB) $(LDLIBS) -lz
test/split/test_filter_header_rg: test/split/test_filter_header_rg.o test/test.o $(HTSLIB)
$(CC) -pthread $(LDFLAGS) -o $# test/split/test_filter_header_rg.o test/test.o $(HTSLIB) $(LDLIBS) -lz
test/split/test_parse_args: test/split/test_parse_args.o test/test.o $(HTSLIB)
$(CC) -pthread $(LDFLAGS) -o $# test/split/test_parse_args.o test/test.o $(HTSLIB) $(LDLIBS) -lz
test/vcf-miniview: test/vcf-miniview.o $(HTSLIB)
$(CC) -pthread $(LDFLAGS) -o $# test/vcf-miniview.o $(HTSLIB) $(LDLIBS) -lz
test_test_h = test/test.h $(htslib_sam_h)
test/merge/test_bam_translate.o: test/merge/test_bam_translate.c $(test_test_h) bam_sort.o
test/merge/test_pretty_header.o: test/merge/test_pretty_header.c bam_sort.o
test/merge/test_rtrans_build.o: test/merge/test_rtrans_build.c bam_sort.o
test/merge/test_trans_tbl_init.o: test/merge/test_trans_tbl_init.c bam_sort.o
test/split/test_count_rg.o: test/split/test_count_rg.c bam_split.o $(test_test_h)
test/split/test_expand_format_string.o: test/split/test_expand_format_string.c bam_split.o $(test_test_h)
test/split/test_filter_header_rg.o: test/split/test_filter_header_rg.c bam_split.o $(test_test_h)
test/split/test_parse_args.o: test/split/test_parse_args.c bam_split.o $(test_test_h)
test/test.o: test/test.c $(htslib_sam_h) $(test_test_h)
test/vcf-miniview.o: test/vcf-miniview.c $(htslib_vcf_h)
# misc programs
misc/ace2sam: misc/ace2sam.o
$(CC) $(LDFLAGS) -o $# misc/ace2sam.o $(LDLIBS) -lz
misc/maq2sam-short: misc/maq2sam-short.o
$(CC) $(LDFLAGS) -o $# misc/maq2sam-short.o $(LDLIBS) -lz
misc/maq2sam-long: misc/maq2sam-long.o
$(CC) $(LDFLAGS) -o $# misc/maq2sam-long.o $(LDLIBS) -lz
misc/md5fa: misc/md5fa.o misc/md5.o
$(CC) $(LDFLAGS) -o $# misc/md5fa.o misc/md5.o $(LDLIBS) -lz
misc/md5sum-lite: misc/md5sum-lite.o
$(CC) $(LDFLAGS) -o $# misc/md5sum-lite.o $(LDLIBS)
misc/wgsim: misc/wgsim.o
$(CC) $(LDFLAGS) -o $# misc/wgsim.o $(LDLIBS) -lm -lz
misc/ace2sam.o: misc/ace2sam.c $(HTSDIR)/htslib/kstring.h $(HTSDIR)/htslib/kseq.h
misc/md5.o: misc/md5.c misc/md5.h
misc/md5fa.o: misc/md5fa.c misc/md5.h $(HTSDIR)/htslib/kseq.h
misc/wgsim.o: misc/wgsim.c $(HTSDIR)/htslib/kseq.h
misc/maq2sam-short.o: misc/maq2sam.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $# misc/maq2sam.c
misc/maq2sam-long.o: misc/maq2sam.c
$(CC) $(CFLAGS) $(CPPFLAGS) -DMAQ_LONGREADS -c -o $# misc/maq2sam.c
misc/md5sum-lite.o: misc/md5.c misc/md5.h
$(CC) $(CFLAGS) $(CPPFLAGS) -DMD5SUM_MAIN -c -o $# misc/md5.c
install: $(PROGRAMS) $(BUILT_MISC_PROGRAMS)
$(INSTALL_DIR) $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir)
$(INSTALL_PROGRAM) $(PROGRAMS) $(MISC_PROGRAMS) $(DESTDIR)$(bindir)
$(INSTALL_DATA) samtools.1 $(DESTDIR)$(man1dir)
testclean:
-rm -f test/*.new test/*.tmp test/*/*.new test/*/*.tmp
-cd test/mpileup && rm -f FAIL-*.out* PASS-*.out* anomalous.[bc]*am indels.[bc]*am mpileup.*.[cs]*am mpileup.*.crai overlap50.[bc]*am expected/1.out
mostlyclean: testclean
-rm -f *.o misc/*.o test/*.o test/*/*.o version.h
clean: mostlyclean
-rm -f $(PROGRAMS) libbam.a $(BUILT_MISC_PROGRAMS) $(BUILT_TEST_PROGRAMS)
distclean: clean
-rm -f TAGS
clean-all: clean clean-htslib
tags:
ctags -f TAGS *.[ch] misc/*.[ch]
force:
.PHONY: all check clean clean-all distclean force install
.PHONY: lib mostlyclean tags test testclean

On SUSE, you may need to link with -lncurses rather than -lcurses. See for example this answer to What's the difference between -lcurses and -lncurses….
So try make LIBCURSES=-lncurses.
Samtools may soon acquire a configure script which will detect what curses you have on your machine and use -lcurses/-lncurses/etc as appropriate.

Related

clang: error: linker command failed with exit code 1 when running fishchips on macOS

I run macOS Big Sur (v. 11.4) and I am trying to do Fisher analysis by using fishchips (https://github.com/xzackli/fishchips-public.git). In order to do so, I need to use CLASS (https://github.com/lesgourg/class_public.git). Following the instructions here, Class requires using make to allow us to use classy. When I initially run make, I get the error: clang: error: unsupported option '-fopenmp'. After reading here, I changed the OMPFLAG in my makefile from OMPFLAG = -fopenmp to OMPFLAG = -Xpreprocessor -fopenmp and now I get the error:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make: *** [class] Error 1.
I am confused about how to solve this. Here is a copy of my current makefile if it helps:
#Some Makefile for CLASS.
#Julien Lesgourgues, 28.11.2011
#Nils Schöneberg, Matteo Lucca, 27.02.2019
MDIR := $(shell pwd)
WRKDIR = $(MDIR)/build
.base:
if ! [ -e $(WRKDIR) ]; then mkdir $(WRKDIR) ; mkdir $(WRKDIR)/lib; fi;
touch build/.base
vpath %.c source:tools:main:test
vpath %.o build
vpath .base build
########################################################
###### LINES TO ADAPT TO YOUR PLATEFORM ################
########################################################
# your C compiler:
CC = gcc
#CC = icc
#CC = pgcc
# your tool for creating static libraries:
AR = ar rv
# Your python interpreter.
# In order to use Python 3, you can manually
# substitute python3 to python in the line below, or you can simply
# add a compilation option on the terminal command line:
# "PYTHON=python3 make all" (Thanks to Marius Millea for python3 compatibility)
PYTHON ?= python
# your optimization flag
OPTFLAG = -O3
#OPTFLAG = -Ofast -ffast-math #-march=native
#OPTFLAG = -fast
# your openmp flag (comment for compiling without openmp)
OMPFLAG = -Xpreprocessor -fopenmp
#OMPFLAG = -mp -mp=nonuma -mp=allcores -g
#OMPFLAG = -openmp
# all other compilation flags
CCFLAG = -g -fPIC
LDFLAG = -g -fPIC
# leave blank to compile without HyRec, or put path to HyRec directory
# (with no slash at the end: e.g. "external/RecfastCLASS")
HYREC = external/HyRec2020
RECFAST = external/RecfastCLASS
HEATING = external/heating
########################################################
###### IN PRINCIPLE THE REST SHOULD BE LEFT UNCHANGED ##
########################################################
# pass current working directory to the code
CCFLAG += -D__CLASSDIR__='"$(MDIR)"'
# where to find include files *.h
INCLUDES = -I../include
HEADERFILES = $(wildcard ./include/*.h)
# automatically add external programs if needed. First, initialize to blank.
EXTERNAL =
vpath %.c $(RECFAST)
#CCFLAG += -DRECFAST
INCLUDES += -I../$(RECFAST)
EXTERNAL += wrap_recfast.o
HEADERFILES += $(wildcard ./$(RECFAST)/*.h)
vpath %.c $(HEATING)
#CCFLAG += -DHEATING
INCLUDES += -I../$(HEATING)
EXTERNAL += injection.o noninjection.o
HEADERFILES += $(wildcard ./$(HEATING)/*.h)
# update flags for including HyRec
ifneq ($(HYREC),)
vpath %.c $(HYREC)
CCFLAG += -DHYREC
#LDFLAGS += -DHYREC
INCLUDES += -I../$(HYREC)
EXTERNAL += hyrectools.o helium.o hydrogen.o history.o wrap_hyrec.o energy_injection.o
HEADERFILES += $(wildcard ./$(HYREC)/*.h)
endif
%.o: %.c .base $(HEADERFILES)
cd $(WRKDIR);$(CC) $(OPTFLAG) $(OMPFLAG) $(CCFLAG) $(INCLUDES) -c ../$< -o $*.o
TOOLS = growTable.o dei_rkck.o sparse.o evolver_rkck.o evolver_ndf15.o arrays.o parser.o quadrature.o hyperspherical.o common.o trigonometric_integrals.o
SOURCE = input.o background.o thermodynamics.o perturbations.o primordial.o fourier.o transfer.o harmonic.o lensing.o distortions.o
INPUT = input.o
PRECISION = precision.o
BACKGROUND = background.o
THERMO = thermodynamics.o
PERTURBATIONS = perturbations.o
TRANSFER = transfer.o
PRIMORDIAL = primordial.o
HARMONIC = harmonic.o
FOURIER = fourier.o
LENSING = lensing.o
DISTORTIONS = distortions.o
OUTPUT = output.o
CLASS = class.o
TEST_LOOPS = test_loops.o
TEST_LOOPS_OMP = test_loops_omp.o
TEST_HARMONIC = test_harmonic.o
TEST_TRANSFER = test_transfer.o
TEST_FOURIER = test_fourier.o
TEST_PERTURBATIONS = test_perturbations.o
TEST_THERMODYNAMICS = test_thermodynamics.o
TEST_BACKGROUND = test_background.o
TEST_HYPERSPHERICAL = test_hyperspherical.o
C_TOOLS = $(addprefix tools/, $(addsuffix .c,$(basename $(TOOLS))))
C_SOURCE = $(addprefix source/, $(addsuffix .c,$(basename $(SOURCE) $(OUTPUT))))
C_TEST = $(addprefix test/, $(addsuffix .c,$(basename $(TEST_DEGENERACY) $(TEST_LOOPS) $(TEST_TRANSFER) $(TEST_FOURIER) $(TEST_PERTURBATIONS) $(TEST_THERMODYNAMICS))))
C_MAIN = $(addprefix main/, $(addsuffix .c,$(basename $(CLASS))))
C_ALL = $(C_MAIN) $(C_TOOLS) $(C_SOURCE)
H_ALL = $(addprefix include/, common.h svnversion.h $(addsuffix .h, $(basename $(notdir $(C_ALL)))))
PRE_ALL = cl_ref.pre clt_permille.pre
INI_ALL = explanatory.ini lcdm.ini
MISC_FILES = Makefile CPU psd_FD_single.dat myselection.dat myevolution.dat README bbn/sBBN.dat external_Pk/* cpp
PYTHON_FILES = python/classy.pyx python/setup.py python/cclassy.pxd python/test_class.py
all: class libclass.a classy
libclass.a: $(TOOLS) $(SOURCE) $(EXTERNAL)
$(AR) $# $(addprefix build/, $(TOOLS) $(SOURCE) $(EXTERNAL))
class: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(CLASS)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o class $(addprefix build/,$(notdir $^)) -lm
test_loops: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(TEST_LOOPS)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $# $(addprefix build/,$(notdir $^)) -lm
test_loops_omp: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(TEST_LOOPS_OMP)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $# $(addprefix build/,$(notdir $^)) -lm
test_harmonic: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_HARMONIC)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $# $(addprefix build/,$(notdir $^)) -lm
test_transfer: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_TRANSFER)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $# $(addprefix build/,$(notdir $^)) -lm
test_fourier: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_FOURIER)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $# $(addprefix build/,$(notdir $^)) -lm
test_perturbations: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_PERTURBATIONS)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $# $(addprefix build/,$(notdir $^)) -lm
test_thermodynamics: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_THERMODYNAMICS)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $# $(addprefix build/,$(notdir $^)) -lm
test_background: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_BACKGROUND)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $# $(addprefix build/,$(notdir $^)) -lm
test_hyperspherical: $(TOOLS) $(TEST_HYPERSPHERICAL)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o test_hyperspherical $(addprefix build/,$(notdir $^)) -lm
tar: $(C_ALL) $(C_TEST) $(H_ALL) $(PRE_ALL) $(INI_ALL) $(MISC_FILES) $(HYREC) $(PYTHON_FILES)
tar czvf class.tar.gz $(C_ALL) $(H_ALL) $(PRE_ALL) $(INI_ALL) $(MISC_FILES) $(HYREC) $(PYTHON_FILES)
classy: libclass.a python/classy.pyx python/cclassy.pxd
ifdef OMPFLAG
cp python/setup.py python/autosetup.py
else
grep -v "lgomp" python/setup.py > python/autosetup.py
endif
cd python; export CC=$(CC); $(PYTHON) autosetup.py install || $(PYTHON) autosetup.py install --user
rm python/autosetup.py
clean: .base
rm -rf $(WRKDIR);
rm -f libclass.a
rm -f $(MDIR)/python/classy.c
rm -rf $(MDIR)/python/build
rm -f python/autosetup.py
I believe I found the solution fix. It seems as if deleting OMPFLAG was all that was needed to run.

RELEASE and DEBUG build in makefile

I am developing an application for STM32 in stm32cubeIDE
I am using the below custom makefile. Now i want to have a release and a debug build, but they both build the debug build.
I´ve tried
RELDIR = bin/release
DEBUGDIR = bin/debug
ifdef DEBUG
BIN=$(DEBUGDIR)
COMPILERFLAGS += -g3 -O0 -D_DEBUG
else
BIN=$(RELDIR)
COMPILERFLAGS += -O3
endif
and
debug : rebuild
BIN=$(DEBUGDIR)
COMPILERFLAGS += -g3 -O0 -D_DEBUG
release : rebuild
BIN=$(RELDIR)
COMPILERFLAGS += -O3
Can someone tell me how to achieve a release and a debug build :)
Full script:
RED = [31m
GREEN = [32m
YELLOW = [33m
BLUE = [34m
NC = [0m
BIN = bin
SRC = src
INC = inc
SOURCE = $(wildcard $(SRC)/*.c)
OBJECT = $(patsubst %,$(BIN)/%, $(notdir $(SOURCE:.c=.o)))
COMPILER=arm-none-eabi-gcc
ARCHITECTURE=cortex-m4
COMPILERFLAGS= -c -mcpu=$(ARCHITECTURE) -mthumb -mfloat-abi=soft -std=gnu11 -Wall -I $(INC)
LINKERFLAGS= -mcpu=$(ARCHITECTURE) -mthumb -mfloat-abi=soft --specs=nano.specs --specs=rdimon.specs -lc -lrdimon --specs=nosys.specs -T stm32_linker_script.ld -Wl,-Map=out.map
COMPILE= $(COMPILER) $(COMPILERFLAGS) -o $# $<
LINK= $(COMPILER) $(LINKERFLAGS) -o $# $^
RELDIR = bin/release
DEBUGDIR = bin/debug
ifdef DEBUG
BIN=$(DEBUGDIR)
COMPILERFLAGS += -g3 -O0 -D_DEBUG
else
BIN=$(RELDIR)
COMPILERFLAGS += -O3
endif
debug : rebuild
#BIN=$(DEBUGDIR)
#COMPILERFLAGS += -g3 -O0 -D_DEBUG
#
release : rebuild
#BIN=$(RELDIR)
#COMPILERFLAGS += -O3
.PHONY: rebuild
rebuild:
$(MAKE) clean
$(MAKE) all
all : out.elf
#echo "$(GREEN)Done!$(NC)"
out.elf : $(OBJECT)
#echo "$(YELLOW)Linking...$(NC)"
$(LINK)
$(BIN)/%.o : $(SRC)/%.c
$(COMPILE)
.PHONY: all clean debug prep release remake
clean:
#echo "$(GREEN)Cleaning...$(NC)"
rm -rf $(BIN)/*.o $(BIN)/*.elf
I ended up creating two makefiles, one for debug and one for release. It is kind of anoying to have duplicated code, but at least it is obvious what is going on in each script. The scripts are then called from the IDE via "make -f Makefile.DEBUG.mk rebuild" and "make -f Makefile.REBUILD.mk rebuild"
#RED = [31m
#GREEN = [32m
#YELLOW = [33m
BLUE = [34m
NC = [0m
BIN = bin/release
SRC = src
INC = inc
MAKE = make -f Makefile.RELEASE.mk
COMPILER=arm-none-eabi-gcc
ARCHITECTURE=cortex-m4
COMPILERFLAGS= -c -mcpu=$(ARCHITECTURE) \
-mthumb -mfloat-abi=soft -std=gnu11 -Wall -O3 -I $(INC)
LINKERFLAGS= -mcpu=$(ARCHITECTURE) \
-mthumb -mfloat-abi=soft \
--specs=nano.specs \
-T stm32_linker_script.ld \
-Wl,-Map=$(BIN)/out.map
COMPILE= $(COMPILER) $(COMPILERFLAGS) -o $# $<
LINK= $(COMPILER) $(LINKERFLAGS) -o $(BIN)/$# $^
SOURCE = $(wildcard $(SRC)/*.c)
OBJECT = $(patsubst %,$(BIN)/%, $(notdir $(SOURCE:.c=.o)))
.PHONY: rebuild
rebuild:
$(MAKE) clean
$(MAKE) all
all : out.elf
#echo "$(BLUE)Done!$(NC)"
out.elf : $(OBJECT)
#echo "$(BLUE)Linking...$(NC)"
$(LINK)
$(BIN)/%.o : $(SRC)/%.c
$(COMPILE)
.PHONY: all clean
clean:
#echo "$(BLUE)Cleaning...$(NC)"
rm -rf $(BIN)/*.o $(BIN)/*.elf $(BIN)/*.map
and
#RED = [31m
#GREEN = [32m
#YELLOW = [33m
BLUE = [34m
NC = [0m
BIN = bin/debug
SRC = src
INC = inc
MAKE = make -f Makefile.DEBUG.mk
COMPILER=arm-none-eabi-gcc
ARCHITECTURE=cortex-m4
COMPILERFLAGS= -c -mcpu=$(ARCHITECTURE) \
-mthumb -mfloat-abi=soft -std=gnu11 -Wall -g -I $(INC)
LINKERFLAGS= -mcpu=$(ARCHITECTURE) \
-mthumb -mfloat-abi=soft \
--specs=nano.specs \
--specs=rdimon.specs -lc -lrdimon \
--specs=nosys.specs \
-T stm32_linker_script.ld \
-Wl,-Map=$(BIN)/out.map
COMPILE= $(COMPILER) $(COMPILERFLAGS) -o $# $<
LINK= $(COMPILER) $(LINKERFLAGS) -o $(BIN)/$# $^
SOURCE = $(wildcard $(SRC)/*.c)
OBJECT = $(patsubst %,$(BIN)/%, $(notdir $(SOURCE:.c=.o)))
.PHONY: rebuild
rebuild:
$(MAKE) clean
$(MAKE) all
all : out.elf
#echo "$(BLUE)Done!$(NC)"
out.elf : $(OBJECT)
#echo "$(BLUE)Linking...$(NC)"
$(LINK)
$(BIN)/%.o : $(SRC)/%.c
$(COMPILE)
.PHONY: all clean
clean :
#echo "$(BLUE)Cleaning...$(NC)"
rm -rf $(BIN)/*.o $(BIN)/*.elf $(BIN)/*.map

modifying Makefile for silverfrost FTN95 ( Windows)

Compiling error
I am quite new to Fortran coding.
Currently, I have a makefile which has been previously used by original authors to compile the Fortran codes in Linux. However, I cannot understand what needs to be changed in the previous makefile to run it in Windows-based compiler Silverfrost FTN95.
While trying to compile in FTN95 I encountered the following error:
C:\Users\Geo-TGS\Documents\landslidemodel\src\TRIGRS>MAKE TPX
mpif90 -w -O3 -w -O3 -c ssizgrd.f95
process_begin: CreateProcess(NULL, mpif90 -w -O3 -w -O3 -c ssizgrd.f95, ...) failed.
make (e=2): The system cannot find the file specified.
makefile:59: recipe for target `ssizgrd.o' failed
MAKE: *** [ssizgrd.o] Error 2
C:\Users\Geo-TGS\Documents\landslidemodel\src\TRIGRS>make trg
mpif90 -w -O3 -w -O3 -c grids.f95
process_begin: CreateProcess(NULL, mpif90 -w -O3 -w -O3 -c grids.f95, ...) failed.
make (e=2): The system cannot find the file specified.
makefile:59: recipe for target `grids.o' failed
make: *** [grids.o] Error 2
Below is the Makefile code:
TRG = trg
PRG = prg
TPX = tpx
OBJT90 = trigrs.o flux.o prpijz.o svxmdv.o svijz.o dzero_brac.o
OBJT95 = grids.o input_vars.o model_vars.o dsimps.o input_file_defs.o iverson.o pstpi.o satfin.o savage.o steady.o trini.o unsinf.o ivestp.o pstpf.o rnoff.o satinf.o smallt.o svgstp.o unsfin.o unsth.o ssizgrd.o svlist.o
OBJT77 = calerf.o dbsct.o derfc.o irdgrd.o irdswm.o isvgrd.o roots.o srdgrd.o srdswm.o ssvgrd.o
OBJP90 = trigrs_p.o partial_p.o flux.o flux_p.o prpijz.o svxmdv.o svijz.o dzero_brac.o srdgrd_p.o irdgrd_p.o
OBJP95 = modules_p.o grids.o input_vars.o model_vars.o dsimps.o input_file_defs.o iverson.o pstpi.o pstpi_p.o satfin.o satfin_p.o savage.o steady.o trini.o trini_p.o unsinf.o unsinf_p.o ivestp.o ivestp_p.o pstpf.o pstpf_p.o rnoff.o satinf.o satinf_p.o smallt.o svgstp.o svgstp_p.o unsfin.o unsfin_p.o unsth.o unsth_p.o ssizgrd.o ssizgrd_p.o svlist.o rnoff_p.o steady_p.o
OBJP77 = calerf.o dbsct.o derfc.o irdgrd.o irdswm.o irdswm_p.o isvgrd.o roots.o srdgrd.o srdswm.o srdswm_p.o ssvgrd.o
OBJX90 = tpindx.o nxtcel.o
OBJX95 = ssizgrd.o
OBJX77 = isvgrd.o mpfldr.o rdflodir.o sindex.o slofac.o srdgrd1.o
LIBS =
CC = gcc -O3
CCFLAGS = -lgsl -lgslcblas -lm
FC = ftn95 -w -O3
FFLAGS =
F90 = f95 -w -O3
MPIF90 = mpif90 -w -O3
F90FLAGS = -w -O3
LDFLAGS = -w -O3
all: $(TRG) $(PRG)
#-----------------------------------------------------------------
$(TRG): $(OBJT95) $(OBJT90) $(OBJT77)
$(F90) $(CCLIBS) $(LDFLAGS) -o $# $(OBJT95) $(OBJT90) $(OBJT77) $(CCFLAGS) $(LIBS)
$(PRG): $(OBJP95) $(OBJP90) $(OBJP77)
$(MPIF90) $(CCLIBS) $(LDFLAGS) -o $# $(OBJP95) $(OBJP90) $(OBJP77)
$(CCFLAGS) $(LIBS)
$(TPX): $(OBJX95) $(OBJX90) $(OBJX77)
$(F90) $(CCLIBS) $(LDFLAGS) -o $# $(OBJX95) $(OBJX90) $(OBJX77) $(CCFLAGS) $(LIBS)
#-----------------------------------------------------------------
clean:
rm -f $(TRG) $(TPX) $(PRG)
rm -rf $(OBJT95) $(OBJT90) $(OBJT77) $(OBJP95) $(OBJP90) $(OBJP77)
rm -rf $(OBJX95) $(OBJX90) $(OBJX77)
rm -rf *.mod *.exe *.stackdump
.SUFFIXES: $(SUFFIXES) .f90 .f .c .f95
.f90.o:
$(MPIF90) $(F90FLAGS) -c $<
.f.o:
$(MPIF90) $(F90FLAGS) -c $<
.c.o:
$(CC) $(CCINCLUDE) -c -w $<
.f95.o:
$(MPIF90) $(F90FLAGS) -c $<
What changes need to be made for the code to compile?

Makefile: object file not found

I have the following Makefile. Whenever I run make, I get the following error.
ifort: error #10236: File not found: 'mkl_matrix_multiply.o'
I have been trying to figure this out for a while now with no luck.
C = icc
FC = ifort
LD = ifort
OPT = -Ofast -vec_report6 -simd -xhost -debug -traceback -ftrapuv
OP = -Ofast -vec_report6 -simd -xhost
LINK = -L$(MKLROOT)/lib/intel64 $(MKLROOT)/lib/intel64/libmkl_blas95_ilp64.a -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -lpthread -lm
INCLUDE = -openmp -i8 -I$(MKLROOT)/include/intel64/ilp64 -I$(MKLROOT)/include
mkl_matrix_multiply.exe: mkl_matrix_multiply.o timing.o
$(LD) -o mkl_matrix_multiply.exe mkl_matrix_multiply.o timing.o
mkl_matrix_multiply.o: mkl_matrix_multiply.f90
$(FC) $(INCLUDE) $(LINK) mkl_matrix_multiply.f90
timing.o: timing.c
$(CC) $(OP) -c timing.c
dummy.o: dummy.c
$(CC) $(OP) -c dummy.c
clean:
rm -f *.o matrix_multiply.exe
Any help would be greatly appreciated.
Seems like you are missing -c in mkl_matrix_multiply.o rule.
Modify your makefile as
C = icc
FC = ifort
LD = ifort
OPT = -Ofast -vec_report6 -simd -xhost -debug -traceback -ftrapuv
OP = -Ofast -vec_report6 -simd -xhost
LINK = -L$(MKLROOT)/lib/intel64 $(MKLROOT)/lib/intel64/libmkl_blas95_ilp64.a -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -lpthread -lm
INCLUDE = -openmp -i8 -I$(MKLROOT)/include/intel64/ilp64 -I$(MKLROOT)/include
mkl_matrix_multiply.exe: mkl_matrix_multiply.o timing.o
$(LD) -o mkl_matrix_multiply.exe mkl_matrix_multiply.o timing.o
mkl_matrix_multiply.o: mkl_matrix_multiply.f90
$(FC) -c $(INCLUDE) $(LINK) mkl_matrix_multiply.f90
timing.o: timing.c
$(CC) $(OP) -c timing.c
dummy.o: dummy.c
$(CC) $(OP) -c dummy.c
clean:
rm -f *.o matrix_multiply.exe

gcc makefile error: “No rule to make target …”

i'm trying to use GCC (linux) with a makefile to compile my project.
I get the following error :
% make map
make: *** No rule to make target `map'. Stop.
Does any one have any idea what could that be ?
This is the makefile:
CC = gcc
DEBUG_FLAG = -g
COMP_FLAG = -std=c99 -Wall -Werror -pedantic-errors -DNDEBUG
LIB = -L. -lmtm
MAP_OBJS = map.o
USER_OBJS = user.o
NETWORK_OBJS = network.o
ISOCIAL_OBJS = network.o user.o Isocial.o
PARSING_OBJS = user.o network.o map.o Isocial.o mtm_isocial.o
PARSING = parsing
MAP_TEST = map_example_test
ISOCIAL_TEST = Isocial_test
NETWORK_TEST = network_test
USER_TEST = user_test
TEST_PATH = ./tests/
$(PARSING) : $(PARSING_OBJS)
$(CC) $(DEBUG_FLAG) $(PARSING_OBJS) $(LIB) -o $#
$(MAP_TEST) : $(MAP_OBJS)
$(CC) $(DEBUG_FLAG) $(MAP_OBJS) $(LIB) -o $#
$(ISOCIAL_TEST) : $(ISOCIAL_OBJS)
$(CC) $(DEBUG_FLAG) $(ISOCIAL_OBJS) $(LIB) -o $#
$(USER_TEST) : &(USER_OBJS)
$(CC) $(DEBUG_FLAG) $(USER_OBJS) $(LIB) -o $#
$(NETWORK_TEST) : $(NETWORK_OBJS)
$(CC) $(DEBUG_FLAG) $(MAP_OBJS) $(LIB) -o $#
map.o: map.c map.h mtm_ex2.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
isocial.o: Isocial.c user.h mtm_ex2.h set.h network.h list.h Isocial.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
parsing.o: parsing.c Isocial.h parsing.h mtm_ex2.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
network.o: network.c network.h set.h mtm_ex2.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
user.o:user.c user.h set.h mtm_ex2.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c
user_test.o: user_test.c ../test_utilities.h ../user.h ../mtm_ex2.h \
../set.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $(TEST_PATH)$*.c
Isocial_test.o: Isocial_test.c ../test_utilities.h ../Isocial.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c $(TEST_PATH)$*.c
map_example_test.o: map_example_test.c ../test_utilities.h ../map.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c $(TEST_PATH)$*.c
network_test.o: network_test.c ../test_utilities.h ../network.h ../set.h \
../mtm_ex2.h
$(CC) -c $(DEBUG_FLAG) $(COMP_FLAG) $*.c $(TEST_PATH)$*.c
EXEC = $(PARSING) $(MAP_TEST) $(ISOCIAL_TEST $(USER_TEST) $(NETWORK_TEST)
tests : $(MAP_TEST) $(ISOCIAL_TEST) $(USER_TEST) $(NETWORK_TEST)
isocial : $(PARSING)
clean:
rm -f $(PARSING_OBJS) $(EXEC)
The error message is correct: I see a target for map.o, but there's no target for map, which would look like
map: map.o
something something something
There are targets for programs named parsing, map_example_test, network_test, and Isocial_test; perhaps you want to build one of those?
If you just typed make, it would build the program parsing, as that's the first target in the file.

Resources