Ruby-generated makefile doesn't run - ruby

Maybe this is a really obvious answer, but I'm trying to extend Ruby using C in a Windows environment and I can't make the extension when I run mingw32-make it gets as far as generating a file called "forktest-i386-mingw32.def" and then says "No rule to make target 'ruby.h', needed by 'forktest.o'".
Forktest is the name of the extension that I'm trying to make.
The makefile was generated by ruby's own create_makefile command and it's really convoluted so I can't make heads or tales of it, but here it is anyway:
SHELL = /bin/sh
# V=0 quiet, V=1 verbose. other values don't work.
V = 0
Q1 = $(V:1=)
Q = $(Q1:0=#)
n=$(NULLCMD)
ECHO1 = $(V:1=#$n)
ECHO = $(ECHO1:0=#echo)
#### Start of system configuration section. ####
srcdir = .
topdir = /D/Programs/Ruby193/include/ruby-1.9.1
hdrdir = /D/Programs/Ruby193/include/ruby-1.9.1
arch_hdrdir = D:/Programs/Ruby193/include/ruby-1.9.1/$(arch)
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
DESTDIR = D:
prefix = $(DESTDIR)/Programs/Ruby193
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
exec_prefix = $(prefix)
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
sitehdrdir = $(rubyhdrdir)/site_ruby
rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
vendordir = $(rubylibprefix)/vendor_ruby
sitedir = $(rubylibprefix)/site_ruby
ridir = $(datarootdir)/$(RI_BASE_NAME)
mandir = $(datarootdir)/man
localedir = $(datarootdir)/locale
libdir = $(exec_prefix)/lib
psdir = $(docdir)
pdfdir = $(docdir)
dvidir = $(docdir)
htmldir = $(docdir)
infodir = $(datarootdir)/info
docdir = $(datarootdir)/doc/$(PACKAGE)
oldincludedir = $(DESTDIR)/usr/include
includedir = $(prefix)/include
localstatedir = $(prefix)/var
sharedstatedir = $(prefix)/com
sysconfdir = $(prefix)/etc
datadir = $(datarootdir)
datarootdir = $(prefix)/share
libexecdir = $(exec_prefix)/libexec
sbindir = $(exec_prefix)/sbin
bindir = $(exec_prefix)/bin
rubylibdir = $(rubylibprefix)/$(ruby_version)
archdir = $(rubylibdir)/$(arch)
sitelibdir = $(sitedir)/$(ruby_version)
sitearchdir = $(sitelibdir)/$(sitearch)
vendorlibdir = $(vendordir)/$(ruby_version)
vendorarchdir = $(vendorlibdir)/$(sitearch)
NULLCMD = :
CC = gcc
CXX = g++
LIBRUBY = lib$(RUBY_SO_NAME).dll.a
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
OUTFLAG = -o
COUTFLAG = -o
RUBY_EXTCONF_H =
cflags = $(optflags) $(debugflags) $(warnflags)
optflags = -O3
debugflags = -g
warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
CFLAGS = $(cflags)
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
DEFS =
CPPFLAGS = $(DEFS) $(cppflags)
CXXFLAGS = $(CFLAGS) $(cxxflags)
ldflags = -L.
dldflags = -Wl,--enable-auto-image-base,--enable-auto-import $(DEFFILE)
ARCH_FLAG =
DLDFLAGS = $(ldflags) $(dldflags)
LDSHARED = $(CC) -shared $(if $(filter-out -g -g0,$(debugflags)),,-s)
LDSHAREDXX = $(CXX) -shared $(if $(filter-out -g -g0,$(debugflags)),,-s)
AR = ar
EXEEXT = .exe
RUBY_BASE_NAME = ruby
RUBY_INSTALL_NAME = ruby
RUBY_SO_NAME = msvcrt-ruby191
arch = i386-mingw32
sitearch = i386-msvcrt
ruby_version = 1.9.1
ruby = D:/Programs/Ruby193/bin/ruby
RUBY = $(ruby)
RM = rm -f
RM_RF = $(RUBY) -run -e rm -- -rf
RMDIRS = rmdir --ignore-fail-on-non-empty -p
MAKEDIRS = /usr/bin/mkdir -p
INSTALL = /usr/bin/install -c
INSTALL_PROG = $(INSTALL) -m 0755
INSTALL_DATA = $(INSTALL) -m 644
COPY = cp
#### End of system configuration section. ####
preload =
libpath = . $(libdir)
LIBPATH = -L. -L$(libdir)
DEFFILE = $(TARGET)-$(arch).def
CLEANFILES = mkmf.log $(DEFFILE)
DISTCLEANFILES =
DISTCLEANDIRS =
extout =
extout_prefix =
target_prefix =
LOCAL_LIBS =
LIBS = $(LIBRUBYARG_SHARED) -lshell32 -lws2_32 -limagehlp
SRCS = forktest.c ruby.c
OBJS = forktest.o ruby.o
TARGET = forktest
DLLIB = $(TARGET).so
EXTSTATIC =
STATIC_LIB =
BINDIR = $(bindir)
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
TARGET_SO = $(DLLIB)
CLEANLIBS = $(TARGET).so
CLEANOBJS = *.o *.bak
all: $(DLLIB)
static: $(STATIC_LIB)
.PHONY: all install static install-so install-rb
.PHONY: clean clean-so clean-rb
clean-rb-default::
clean-rb::
clean-so::
clean: clean-so clean-rb-default clean-rb
#-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
distclean-rb-default::
distclean-rb::
distclean-so::
distclean: clean distclean-so distclean-rb-default distclean-rb
#-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
#-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
#-$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
realclean: distclean
install: install-so install-rb
install-so: $(RUBYARCHDIR)
install-so: $(RUBYARCHDIR)/$(DLLIB)
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
#-$(MAKEDIRS) $(#D)
$(INSTALL_PROG) $(DLLIB) $(#D)
install-rb: pre-install-rb install-rb-default
install-rb-default: pre-install-rb-default
pre-install-rb: Makefile
pre-install-rb-default: Makefile
pre-install-rb-default:
$(ECHO) installing default forktest libraries
$(RUBYARCHDIR):
$(Q) $(MAKEDIRS) $#
site-install: site-install-so site-install-rb
site-install-so: install-so
site-install-rb: install-rb
.SUFFIXES: .c .m .cc .mm .cxx .cpp .o
.cc.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$# -c $<
.mm.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$# -c $<
.cxx.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$# -c $<
.cpp.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$# -c $<
.c.o:
$(ECHO) compiling $(<)
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$# -c $<
.m.o:
$(ECHO) compiling $(<)
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$# -c $<
$(DLLIB): $(DEFFILE) $(OBJS) Makefile
$(ECHO) linking shared-object $(DLLIB)
#-$(RM) $(#)
$(Q) $(LDSHARED) -o $# $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
$(DEFFILE):
$(ECHO) generating $(#)
$(Q) $(RUBY) -e "puts 'EXPORTS', '' + 'Init_$(TARGET)'.sub(/\..*\z/,'')" > $#
$(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h

I had the same issue and found that I accidentally had the MinGW Make on my path. This meant Ruby DevKit found that version before it's own msys version.
The mingw version doesn't handle the /D/Programs/Ruby193/ style of paths and produced the "No rule to make target 'ruby.h'..." error.
My solution was to remove MinGW make from my PATH so that Ruby DevKit found the msys version of Make when it runs (when it prints "Temporarily enhancing PATH to include DevKit...").
I checked my version of Make from the msys.bat environment (just run C:\devkit\msys.bat):
$ which make
# Should print a location like: C:\devkit\bin\make.exe
And check the version like this:
$ make --version
The correct msys version included this in the last line:
This program built for i686-pc-msys
The incorrect MinGW version output this:
GNU Make 4.1
Built for i686-w64-mingw32
I'm using ruby 2.2.3p173 and DevKit-mingw64-32-4.7.2-20130224-1151-sfx but this seems to be a PATH issue, not a ruby issue.

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.

Porting old make file to Windows

I'm attempting to convert this make file to a Windows make file. I haven't done anything like this before, and need some help. I've done research but don't really understand the plethora of errors that I'm running into. Is there an easy way to port this? Is it possible? Could this be made cross platform for cmake? This is all new to me.
#FLAGS = -lm -L/usr/pub/lib -lefence -o
#CC = cc -O2 -fullwarn -TENV:large_GOT
#CC = cc -g -Wall
CC = gcc -O2 # at least for SunOS
#CC = cc -g
#CC = cc -O2 -fullwarn
#CC = cc -O2
FLAGS = -lm -o
SOURCE = stride.c splitstr.c rdpdb.c initchn.c geometry.c thr2one.c one2thr.c filename.c tolostr.c strutil.c place_h.c hbenergy.c memory.c helix.c sheet.c rdmap.c phipsi.c command.c molscr.c die.c hydrbond.c mergepat.c fillasn.c escape.c p_jrnl.c p_rem.c p_atom.c p_helix.c p_sheet.c p_turn.c p_ssbond.c p_expdta.c p_model.c p_compnd.c report.c nsc.c area.c ssbond.c chk_res.c chk_atom.c turn.c pdbasn.c dssp.c outseq.c chkchain.c elem.c measure.c asngener.c p_endmdl.c stred.c contact_order.c contact_map.c
OBJECT = ${SOURCE:.c=.o}
BINDIR = .
.c.o:
$(CC) -c $< -o $#
stride : $(OBJECT)
$(CC) $(OBJECT) $(FLAGS) $(BINDIR)/stride${ARCH}
$(OBJECT) : stride.h protot.h
clean:
rm -f $(OBJECT)
show:
echo $(SOURCE)

How to compile free-form and fixed-form Fortran codes with ifort in linux

I try to compile free-form Fortran code (param0.f90, param1.f90, and param2.f90), in which contains alot of parameters for tsunami modelling. There is only single main program in fixed-form (tunami.for) in this model package. I am struggling to compile and link the code by using the makefile. Here the makefile that I used.
#-----------BEGIN MAKEFILE-------------------------------------------------
DEF_FLAGS = -P -traditional
EXEC = TUNAMI
#==========================================================================
#--------------------------------------------------------------------------
# PRECISION DEFAULT PRECISION: SINGLE
# UNCOMMENT TO SELECT DOUBLE PRECISION
#--------------------------------------------------------------------------
# FLAG_1 = -DDOUBLE_PRECISION
# FLAG_2 = -DPARALLEL
# FLAG_3 = -DLANDSLIDE
# FLAG_4 = -DSALINITY
# FLAG_5 = -DTEMPERATURE
# FLAG_6 = -DBUBBLE
# FLAG_7 = -DSEDIMENT
# FLAG_8 = -DVEGETATION
FLAG_9 = -DINTEL
# FLAG_10 = -DBALANCE2D
# FLAG_12 = -DTWOLAYERSLIDE
# FLAG_13 = -DCORALREEF
#--------------------------------------------------------------------------
# mpi defs
#--------------------------------------------------------------------------
CPP = /usr/bin/cpp
CPPFLAGS = $(DEF_FLAGS)
# FC = ifort
FC = ifort
DEBFLGS =
OPT = #-g
CLIB =
#==========================================================================
FFLAGS = $(DEBFLGS) $(OPT)
MDEPFLAGS = --cpp --fext=f90 --file=-
RANLIB = ranlib
#--------------------------------------------------------------------------
# CAT Preprocessing Flags
#--------------------------------------------------------------------------
CPPARGS = $(CPPFLAGS) $(DEF_FLAGS) $(FLAG_1) $(FLAG_2) $(FLAG_3) \
$(FLAG_4) $(FLAG_5) $(FLAG_6) $(FLAG_7) $(FLAG_8) $(FLAG_9) \
$(FLAG_10) $(FLAG_11) $(FLAG_12) $(FLAG_13)
#--------------------------------------------------------------------------
# Libraries
#--------------------------------------------------------------------------
LIBS = -L/home/gugum/Downloads/hypre/src/hypre/lib -lHYPRE
INCS = -L/home/gugum/Downloads/hypre/src/hypre/include
#--------------------------------------------------------------------------
# Preprocessing and Compilation Directives
#--------------------------------------------------------------------------
.SUFFIXES: .o .f90 .F .F90
.c.o:
$(CC) -c $(CFLAGS) $(INCS) $*.c
.F.o:
$(CPP) $(CPPARGS) $(PETSC_FC_INCLUDES) $*.F > $*.f90
$(FC) -c $(FFLAGS) $(INCS) $*.f90
\rm $*.f90
.F90.o:
$(CPP) $(CPPFLAGS) $(CPPDEFS) $(INCLDIR) $< > $*.f
$(FC) -c $(FFLAGS) $(FIXEDFLAGS) $(INCS) $(INCLDIR) $*.f
\rm $*.f90
# \rm $*.f90
#--------------------------------------------------------------------------
# NHWAVE Source Code.
#--------------------------------------------------------------------------
MODS = param0.f90 param1.f90 param2.f90
MAIN = TUNAMI.for
SRCS = $(MODS) $(MAIN)
#OBJS = $(SRCS:.F=.o) param0.o param1.o param2.o
OBJS = $(patsubst %.for,%.o,$(patsubst %.f90,%.o,$(SRCS)))
#--------------------------------------------------------------------------
# Linking Directives
#--------------------------------------------------------------------------
$(EXEC): $(OBJS)
$(FC) $(FFLAGS) $(LDFLAGS) -o $(EXEC) $(OBJS) $(LIBS)
#--------------------------------------------------------------------------
# Cleaning targets.
#--------------------------------------------------------------------------
clean:
/bin/rm -f *.o *.mod
clobber: clean
/bin/rm -f *.f90 *.o tunami
However, it produces an error.
make: *** No rule to make target 'param0.o', needed by 'TUNAMI'. Stop.

Makefile - How to target all matching files?

CC = g++49
#General Flags
CFLAGS =
#debug flags
CFLAGS +=
#Target Liker Flags
CFLAGS +=
TARGET = ../game
INCDIR += -I
LIBDIR += -L
LIBS += -l
##############################################
INCDIR += -I
LIBDIR += -L
LIBS += -l
##############################################
CPP_FILE =
OBJDIR =../../Object's
CPPOBJS = $(CPP_FILE:%.cpp=$(OBJDIR)/%.o)
default: $(TARGET)
$(OBJDIR)/%.o: %.cpp
#echo compile $<
#$(CC) $(CFLAGS) $(INCDIR) -c $< -o $#
$(TARGET): $(CPPOBJS)
#echo linking....
#$(CC) $(CFLAGS) $(LIBDIR) $(CPPOBJS) $(LIBS) -o $(TARGET)
Soo this si my makefile .
I want to find all .cpp files and compile.
Without their full name specified in CPP_FILE
Example :
CPP_FILE : test.cpp main.cpp slow.cpp scan.cpp
I want something like CPP_FILE = *.cpp
It is this possible?
Make provides a wildcard function for this very purpose.
CPP_FILE = $(wildcard my_dir/*.cpp)

ruby extconf.rb example

I am following instructions to http://people.apache.org/~rooneg/talks/ruby-extensions/ruby-extensions.html (page 6) and my make command is only returning make: Nothing to be done for 'all'.
Does anyone have any ideas?
I am using ruby 1.9.2 and I'm on OSX 10.6.8
SHELL = /bin/sh
#### Start of system configuration section. ####
srcdir = .
topdir = /Users/pcoder/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1
hdrdir = /Users/pcoder/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1
arch_hdrdir = /Users/pcoder/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/$(arch)
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
prefix = $(DESTDIR)/Users/pcoder/.rvm/rubies/ruby-1.9.2-p290
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
exec_prefix = $(prefix)
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
sitehdrdir = $(rubyhdrdir)/site_ruby
rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
vendordir = $(rubylibprefix)/vendor_ruby
sitedir = $(rubylibprefix)/site_ruby
ridir = $(datarootdir)/$(RI_BASE_NAME)
mandir = $(datarootdir)/man
localedir = $(datarootdir)/locale
libdir = $(exec_prefix)/lib
psdir = $(docdir)
pdfdir = $(docdir)
dvidir = $(docdir)
htmldir = $(docdir)
infodir = $(datarootdir)/info
docdir = $(datarootdir)/doc/$(PACKAGE)
oldincludedir = $(DESTDIR)/usr/include
includedir = $(prefix)/include
localstatedir = $(prefix)/var
sharedstatedir = $(prefix)/com
sysconfdir = $(prefix)/etc
datadir = $(datarootdir)
datarootdir = $(prefix)/share
libexecdir = $(exec_prefix)/libexec
sbindir = $(exec_prefix)/sbin
bindir = $(exec_prefix)/bin
rubylibdir = $(rubylibprefix)/$(ruby_version)
archdir = $(rubylibdir)/$(arch)
sitelibdir = $(sitedir)/$(ruby_version)
sitearchdir = $(sitelibdir)/$(sitearch)
vendorlibdir = $(vendordir)/$(ruby_version)
vendorarchdir = $(vendorlibdir)/$(sitearch)
CC = gcc
CXX = g++
LIBRUBY = $(LIBRUBY_SO)
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
OUTFLAG = -o
COUTFLAG = -o
RUBY_EXTCONF_H =
cflags = $(optflags) $(debugflags) $(warnflags)
optflags = -O3
debugflags = -ggdb
warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long
CFLAGS = -fno-common -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64 -fno-common -pipe
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
DEFS =
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
CXXFLAGS = $(CFLAGS) $(cxxflags)
ldflags = -L. -Wl,-syslibroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64
dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
ARCH_FLAG =
DLDFLAGS = $(ldflags) $(dldflags)
LDSHARED = $(CC) -dynamic -bundle
LDSHAREDXX = $(CXX) -dynamic -bundle
AR = ar
EXEEXT =
RUBY_BASE_NAME = ruby
RUBY_INSTALL_NAME = ruby
RUBY_SO_NAME = ruby.1.9.1
arch = x86_64-darwin10.7.0
sitearch = $(arch)
ruby_version = 1.9.1
ruby = /Users/pcoder/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
RUBY = $(ruby)
RM = rm -f
RM_RF = $(RUBY) -run -e rm -- -rf
RMDIRS = $(RUBY) -run -e rmdir -- -p
MAKEDIRS = mkdir -p
INSTALL = /usr/bin/install -c
INSTALL_PROG = $(INSTALL) -m 0755
INSTALL_DATA = $(INSTALL) -m 644
COPY = cp
#### End of system configuration section. ####
preload =
libpath = . $(libdir)
LIBPATH = -L. -L$(libdir)
DEFFILE =
CLEANFILES = mkmf.log
DISTCLEANFILES =
DISTCLEANDIRS =
extout =
extout_prefix =
target_prefix =
LOCAL_LIBS =
LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lobjc
SRCS =
OBJS =
TARGET =
DLLIB =
EXTSTATIC =
STATIC_LIB =
BINDIR = $(bindir)
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
TARGET_SO = $(DLLIB)
CLEANLIBS = $(TARGET).bundle
CLEANOBJS = *.o *.bak
all: Makefile
static: $(STATIC_LIB)
.PHONY: all install static install-so install-rb
.PHONY: clean clean-so clean-rb
clean-rb-default::
clean-rb::
clean-so::
clean: clean-so clean-rb-default clean-rb
#-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
distclean-rb-default::
distclean-rb::
distclean-so::
distclean: clean distclean-so distclean-rb-default distclean-rb
#-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
#-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
#-$(RMDIRS) $(DISTCLEANDIRS)
realclean: distclean
install: install-so install-rb
install-so: Makefile
install-rb: pre-install-rb install-rb-default
install-rb-default: pre-install-rb-default
pre-install-rb: Makefile
pre-install-rb-default: Makefile
site-install: site-install-so site-install-rb
site-install-so: install-so
site-install-rb: install-rb
all: Makefile
this string is wrong, all target should make your extension, and not a Makefile itself.
here is a part of Makefile generated from a random extconf.rb on my system:
all: $(DLLIB)
yours should be the same. a possible error is in extconf.rb.
my extconf.rb:
require 'mkmf'
have_header('ruby.h') or missing('ruby.h')
create_makefile('ext')
files ext.c & ext.h are presend and contain actual extension C code

Resources